Salome HOME
Merge branch 'BR_ADVANCED_CURRENT_FEATURE_MANAGEMENT' into Dev_1.5.0
[modules/shaper.git] / src / PartSet / PartSet_Validators.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_Validators.cpp
4 // Created:     09 July 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "PartSet_Validators.h"
8
9 #include "PartSet_Tools.h"
10
11 #include <TopoDS.hxx>
12 #include <TopoDS_Edge.hxx>
13 #include <BRep_Tool.hxx>
14 #include <GeomAdaptor_Curve.hxx>
15 #include <GeomAbs_CurveType.hxx>
16 #include <GeomValidators_Tools.h>
17 #include <ModuleBase_ISelection.h>
18 #include <ModuleBase_WidgetShapeSelector.h>
19
20 #include <ModelAPI_AttributeRefAttr.h>
21 #include <ModelAPI_AttributeSelection.h>
22 #include <ModelAPI_AttributeReference.h>
23 #include <ModelAPI_AttributeSelectionList.h>
24 #include <ModelAPI_AttributeRefList.h>
25 #include <ModelAPI_Object.h>
26 #include <ModelAPI_Session.h>
27 #include <ModelAPI_Tools.h>
28
29 #include <SketchPlugin_Sketch.h>
30 #include <SketchPlugin_ConstraintCoincidence.h>
31 #include <SketchPlugin_Arc.h>
32 #include <GeomAPI_Edge.h>
33
34 #include <list>
35 #ifdef _DEBUG
36 #include <iostream>
37 #endif
38
39 int shapesNbPoints(const ModuleBase_ISelection* theSelection)
40 {
41   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
42   ModuleBase_ISelection::filterPreselectionOnEqualPoints(aList);
43
44   int aCount = 0;
45   foreach (ModuleBase_ViewerPrs aPrs, aList) {
46     const TopoDS_Shape& aShape = aPrs.shape();
47     if (!aShape.IsNull()) {
48       if (aShape.ShapeType() == TopAbs_VERTEX)
49         aCount++;
50     }
51   }
52   return aCount;
53 }
54
55 int shapesNbLines(const ModuleBase_ISelection* theSelection)
56 {
57   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
58   int aCount = 0;
59   foreach(ModuleBase_ViewerPrs aPrs, aList) {
60     const TopoDS_Shape& aShape = aPrs.shape();
61     if (!aShape.IsNull()) {
62       if (aShape.ShapeType() == TopAbs_EDGE) {
63         TopoDS_Edge aEdge = TopoDS::Edge(aShape);
64         Standard_Real aStart, aEnd;
65         Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
66         GeomAdaptor_Curve aAdaptor(aCurve);
67         if (aAdaptor.GetType() == GeomAbs_Line)
68           aCount++;
69       }
70     }
71   }
72   return aCount;
73 }
74
75 bool PartSet_DistanceSelection::isValid(const ModuleBase_ISelection* theSelection) const
76 {
77   int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection);
78   return (aCount > 0) && (aCount < 3);
79 }
80
81 bool PartSet_LengthSelection::isValid(const ModuleBase_ISelection* theSelection) const
82 {
83   int aCount = shapesNbLines(theSelection);
84   return (aCount == 1);
85 }
86
87 bool PartSet_PerpendicularSelection::isValid(const ModuleBase_ISelection* theSelection) const
88 {
89   int aCount = shapesNbLines(theSelection);
90   return (aCount > 0) && (aCount < 3);
91 }
92
93 bool PartSet_ParallelSelection::isValid(const ModuleBase_ISelection* theSelection) const
94 {
95   int aCount = shapesNbLines(theSelection);
96   return (aCount > 0) && (aCount < 3);
97 }
98
99 bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection) const
100 {
101   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
102   ModuleBase_ViewerPrs aPrs;
103   int aCount = 0;
104   foreach (ModuleBase_ViewerPrs aPrs, aList) {
105     const TopoDS_Shape& aShape = aPrs.shape();
106     if (!aShape.IsNull()) {
107       if (aShape.ShapeType() == TopAbs_EDGE) {
108         TopoDS_Edge aEdge = TopoDS::Edge(aShape);
109         Standard_Real aStart, aEnd;
110         Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
111         GeomAdaptor_Curve aAdaptor(aCurve);
112         if (aAdaptor.GetType() == GeomAbs_Circle)
113           aCount++;
114       }
115     }
116   }
117   return (aCount == 1);
118 }
119
120 bool PartSet_RigidSelection::isValid(const ModuleBase_ISelection* theSelection) const
121 {
122   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
123   return (aList.count() == 1);
124 }
125
126
127 bool PartSet_CoincidentSelection::isValid(const ModuleBase_ISelection* theSelection) const
128 {
129   // Coincident can be applied to points and to lines
130   int aCount = shapesNbPoints(theSelection);
131   aCount += shapesNbLines(theSelection);
132   return (aCount > 0) && (aCount < 3);
133 }
134
135 bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection) const
136 {
137   int aCount = shapesNbLines(theSelection);
138   return (aCount == 1);
139 }
140
141 bool PartSet_FilletSelection::isValid(const ModuleBase_ISelection* theSelection) const
142 {
143   int aCount = shapesNbLines(theSelection);
144   return (aCount > 0) && (aCount < 3);
145 }
146
147 bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection) const
148 {
149   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
150   if ((aList.size() == 0) || (aList.size() > 2))
151     return false;
152
153   ModuleBase_ViewerPrs aPrs = aList.first();
154   const TopoDS_Shape& aShape = aPrs.shape();
155   if (aShape.IsNull())
156     return false;
157
158   if (aShape.ShapeType() != TopAbs_EDGE)
159     return false;
160
161   std::shared_ptr<GeomAPI_Shape> aShapePtr(new GeomAPI_Shape);
162   aShapePtr->setImpl(new TopoDS_Shape(aShape));
163   GeomAPI_Edge aEdge1(aShapePtr);
164
165   if (aEdge1.isLine() || aEdge1.isArc()) {
166     if (aList.size() == 2) {
167       // Check second selection
168       aPrs = aList.last();
169       const TopoDS_Shape& aShape2 = aPrs.shape();
170       if (aShape2.IsNull())
171         return false;
172
173       if (aShape2.ShapeType() != TopAbs_EDGE)
174         return false;
175
176       std::shared_ptr<GeomAPI_Shape> aShapePtr2(new GeomAPI_Shape);
177       aShapePtr2->setImpl(new TopoDS_Shape(aShape2));
178       GeomAPI_Edge aEdge2(aShapePtr2);
179       if (aEdge1.isLine() && aEdge2.isArc())
180         return true;
181       else if (aEdge1.isArc() && aEdge2.isLine())
182         return true;
183       else
184         return false;
185     } else
186       return true;
187   }
188   return false;
189 }
190
191 bool PartSet_AngleSelection::isValid(const ModuleBase_ISelection* theSelection) const
192 {
193   int aCount = shapesNbLines(theSelection);
194   return (aCount > 0) && (aCount < 3);
195 }
196
197 std::string PartSet_DifferentObjectsValidator::errorMessage(
198                          const PartSet_DifferentObjectsValidator::ErrorType& theType,
199                          const std::string& thEqualObject, const std::string& theFirstAttribute,
200                          const std::string& theSecondAttribute) const
201 {
202   std::string anError;
203   switch (theType) {
204     case EqualObjects:
205       anError = "The feature uses one " + thEqualObject + " object in " +
206                 theFirstAttribute + " and " + theSecondAttribute + " attributes.";
207       break;
208     case EqualAttributes:
209       anError = "The feature uses reference to one " + thEqualObject + " attribute in " +
210                 theFirstAttribute + " and " + theSecondAttribute + " attributes.";
211       break;
212     case EqualShapes:
213       anError = "The feature uses one shape in " +
214                 theFirstAttribute + " and " + theSecondAttribute + " attributes.";
215       break;
216     case EmptyShapes:
217       anError = "The feature uses empty shapes in " +
218                 theFirstAttribute + " and " + theSecondAttribute + " attributes.";
219       break;
220       break;
221     default:
222       break;
223   }
224   return anError;
225 }
226
227 bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
228                                                 const std::list<std::string>& theArguments,
229                                                 std::string& theError) const
230 {
231   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
232
233   // the type of validated attributes should be equal, attributes with different types are not validated
234   // Check RefAttr attributes
235   std::string anAttrType = theAttribute->attributeType();
236   std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs;
237
238   if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
239     AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
240     bool isObject = anAttr->isObject();
241     ObjectPtr anObject = anAttr->object();
242     AttributePtr anAttributeAttr = anAttr->attr();
243
244     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
245     if (anAttrs.size() > 0) {
246       std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
247       for(; anAttr != anAttrs.end(); anAttr++) {
248       if ((*anAttr).get() && (*anAttr)->id() != theAttribute->id()) {
249           std::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
250                                       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
251           if (aRef->isObject() != isObject)
252             continue;
253           if (isObject) {
254             if (aRef->object() == anObject) {
255               theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
256                                       theAttribute->id(), aRef->id());
257               return false;
258             }
259           }
260           else { // the attribute reference
261             if (aRef->attr() == anAttributeAttr) {
262               theError = errorMessage(EqualAttributes,
263                                       anAttributeAttr.get() ? anAttributeAttr->id() : "",
264                                       theAttribute->id(), aRef->id());
265               return false;
266             }
267           }
268         }
269       }
270     }
271   }
272   else if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
273     AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
274     ResultPtr aContext = anAttr->context();
275     GeomShapePtr aShape = anAttr->value();
276
277     // Check selection attributes
278     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
279     if (anAttrs.size() > 0) {
280       std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
281       for(; anAttr != anAttrs.end(); anAttr++) {
282         if ((*anAttr).get() && (*anAttr)->id() != theAttribute->id()) {
283           std::shared_ptr<ModelAPI_AttributeSelection> aRef =
284                                         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*anAttr);
285           // check the object is already presented
286           if (aRef->context() == aContext) {
287             bool aHasShape = aShape.get() != NULL;
288             if (!aHasShape || aRef->value()->isEqual(aShape)) {
289               theError = errorMessage(EqualShapes, "", theAttribute->id(), aRef->id());
290               return false;
291             }
292           }
293         }
294       }
295     }
296   }
297   else if (anAttrType == ModelAPI_AttributeReference::typeId()) {
298     AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
299     ObjectPtr anObject = anAttr->value();
300     // Check selection attributes
301     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeReference::typeId());
302     if (anAttrs.size() > 0) {
303       std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
304       for(; anAttr != anAttrs.end(); anAttr++) {
305         if ((*anAttr).get() && (*anAttr)->id() != theAttribute->id()) {
306           std::shared_ptr<ModelAPI_AttributeReference> aRef =
307             std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
308           // check the object is already presented
309           if (aRef->value() == anObject) {
310             theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
311                                     theAttribute->id(), aRef->id());
312             return false;
313           }
314         }
315         return true;
316       }
317     }
318   }
319   else if(anAttrType == ModelAPI_AttributeSelectionList::typeId()) {
320     std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList = 
321             std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
322     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
323     if(anAttrs.size() > 0) {
324       std::list<std::shared_ptr<ModelAPI_Attribute>>::iterator anAttrItr = anAttrs.begin();
325       for(; anAttrItr != anAttrs.end(); anAttrItr++){
326         if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){
327           std::shared_ptr<ModelAPI_AttributeSelectionList> aRefSelList = 
328             std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*anAttrItr);
329           for(int i = 0; i < aCurSelList->size(); i++) {
330             std::shared_ptr<ModelAPI_AttributeSelection> aCurSel = aCurSelList->value(i);
331             ResultPtr aCurSelContext = aCurSel->context();
332             ResultCompSolidPtr aCurSelCompSolidPtr = ModelAPI_Tools::compSolidOwner(aCurSelContext);
333             std::shared_ptr<GeomAPI_Shape> aCurSelCompSolid;
334             if(aCurSelCompSolidPtr.get()) {
335               aCurSelCompSolid = aCurSelCompSolidPtr->shape();
336             }
337             for(int j = 0; j < aRefSelList->size(); j++) {
338               std::shared_ptr<ModelAPI_AttributeSelection> aRefSel = aRefSelList->value(j);
339               ResultPtr aRefSelContext = aRefSel->context();
340               ResultCompSolidPtr aRefSelCompSolidPtr = ModelAPI_Tools::compSolidOwner(aRefSelContext);
341               std::shared_ptr<GeomAPI_Shape> aRefSelCompSolid;
342               if(aRefSelCompSolidPtr.get()) {
343                 aRefSelCompSolid = aRefSelCompSolidPtr->shape();
344               }
345               if ((aCurSelCompSolid.get() && aCurSelCompSolid->isEqual(aRefSel->value()))
346                 || (aRefSelCompSolid.get() && aRefSelCompSolid->isEqual(aCurSel->value()))) {
347                   theError = errorMessage(EqualShapes, "", theAttribute->id(),
348                                           aRefSel->id());
349                   return false;
350               }
351               if(aCurSelContext == aRefSelContext) {
352                 if (aCurSel->value().get() == NULL || aRefSel->value().get() == NULL) {
353                   theError = errorMessage(EmptyShapes, "", theAttribute->id(),
354                                           aRefSel->id());
355                   return false;
356                 }
357                 if (aCurSel->value()->isEqual(aRefSel->value())) {
358                   theError = errorMessage(EqualShapes, "", theAttribute->id(),
359                                           aRefSel->id());
360                   return false;
361                 }
362               }
363             }
364           }
365         }
366       }
367     }
368   }
369   else if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
370     std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
371       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
372     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeRefList::typeId());
373     if (anAttrs.size() > 0) {
374       std::list<std::shared_ptr<ModelAPI_Attribute>>::iterator anAttrItr = anAttrs.begin();
375       for (; anAttrItr != anAttrs.end(); anAttrItr++){
376         if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){
377           std::shared_ptr<ModelAPI_AttributeRefList> aRefSelList =
378             std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrItr);
379           for (int i = 0; i < aCurSelList->size(); i++) {
380             ObjectPtr aCurSelObject = aCurSelList->object(i);
381             for (int j = 0; j < aRefSelList->size(); j++) {
382               if (aCurSelObject == aRefSelList->object(j)) {
383                 theError = errorMessage(EqualObjects,
384                               aCurSelObject.get() ? aCurSelObject->data()->name() : "",
385                               theAttribute->id(), aCurSelList->id());
386                 return false;
387               }
388             }
389           }
390         }
391       }
392     }
393   }
394   return true;
395 }
396
397 bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
398                                             const std::list<std::string>& theArguments,
399                                             std::string& theError) const
400 {
401   bool isSketchEntities = true;
402   std::set<std::string> anEntityKinds;
403   std::string anEntityKindsStr;
404   std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
405   for (; anIt != aLast; anIt++) {
406     anEntityKinds.insert(*anIt);
407     if (!anEntityKindsStr.empty())
408       anEntityKindsStr += ", ";
409     anEntityKindsStr += *anIt;
410   }
411
412   std::string anAttributeType = theAttribute->attributeType();
413   if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
414     AttributeSelectionListPtr aSelectionListAttr = 
415                       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
416     // all context objects should be sketch entities
417     for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
418       AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
419       ObjectPtr anObject = aSelectAttr->context();
420       // a context of the selection attribute is a feature result. It can be a case when the result
421       // of the feature is null, e.g. the feature is modified and has not been executed yet.
422       // The validator returns an invalid result here. The case is an extrusion built on a sketch
423       // feature. A new sketch element creation leads to an empty result.
424       if (!anObject.get())
425         isSketchEntities = false;
426       else {
427         FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
428         isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
429       }
430     }
431   }
432   if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
433     AttributeRefListPtr aRefListAttr =
434       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
435     // all context objects should be sketch entities
436     for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
437       ObjectPtr anObject = aRefListAttr->object(i);
438       // a context of the selection attribute is a feature result. It can be a case when the result
439       // of the feature is null, e.g. the feature is modified and has not been executed yet.
440       // The validator returns an invalid result here. The case is an extrusion built on a sketch
441       // feature. A new sketch element creation leads to an empty result.
442       if (!anObject.get())
443         isSketchEntities = false;
444       else {
445         FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
446         isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
447       }
448     }
449   }
450   if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
451     std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
452                      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
453     isSketchEntities = false;
454     if (aRef->isObject()) {
455       ObjectPtr anObject = aRef->object();
456       if (anObject.get() != NULL) {
457         FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
458         if (aFeature.get() != NULL)
459           isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
460       }
461     }
462   }
463   if (!isSketchEntities) {
464     theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
465   }
466
467   return isSketchEntities;
468 }
469
470 bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, 
471                                      const std::list<std::string>& theArguments,
472                                      std::string& theError) const
473 {
474   if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
475     theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
476     return false;
477   }
478
479   // there is a check whether the feature contains a point and a linear edge or two point values
480   std::string aParamA = theArguments.front();
481   SessionPtr aMgr = ModelAPI_Session::get();
482   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
483
484   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
485   AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
486   QList<FeaturePtr> aCoinsideLines;
487
488   bool isObject = aRefAttr->isObject();
489   ObjectPtr anObject = aRefAttr->object();
490   if (isObject && anObject) {
491     FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
492     AttributeRefAttrPtr aOtherAttr = aFeature->data()->refattr(aParamA);
493     ObjectPtr aOtherObject = aOtherAttr->object();
494     // if the other attribute is not filled still, the result is true
495     if (!aOtherObject.get())
496       return true;
497     FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
498
499     // check that both have coincidence
500     FeaturePtr aConstrFeature;
501     std::set<FeaturePtr> aCoinList;
502     const std::set<std::shared_ptr<ModelAPI_Attribute>>& aRefsList = aRefFea->data()->refsToMe();
503     std::set<std::shared_ptr<ModelAPI_Attribute>>::const_iterator aIt;
504     for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
505       std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
506       aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
507       if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
508         AttributeRefAttrPtr aRAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
509         AttributePtr aAR = aRAttr->attr();
510         if (aAR->id() != SketchPlugin_Arc::CENTER_ID()) // ignore constraint to center of arc
511           aCoinList.insert(aConstrFeature);
512           PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
513                                           SketchPlugin_ConstraintCoincidence::ENTITY_A());
514           PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
515                                           SketchPlugin_ConstraintCoincidence::ENTITY_B());
516       }
517     }
518     // if there is no coincidence then it is not valid
519     if (aCoinList.size() > 0) {
520       QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(), aLast = aCoinsideLines.end();
521       bool aValid = false;
522       for (; anIt != aLast && !aValid; anIt++) {
523         aValid = *anIt == aOtherFea;
524       }
525       if (aValid)
526         return true;
527     }
528   }
529   theError = "There is no a common coincident point.";
530   return false;
531 }
532