+//==================================================================================================
+bool ConstructionPlugin_ValidatorPlaneThreePoints::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+
+ AttributeSelectionPtr aPointAttribute1 = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ AttributeSelectionPtr aPointAttribute2 = aFeature->selection(theArguments.front());
+ AttributeSelectionPtr aPointAttribute3 = aFeature->selection(theArguments.back());
+
+ GeomShapePtr aPointShape1 = aPointAttribute1->value();
+ ResultPtr aContext1 = aPointAttribute1->context();
+ if(!aContext1.get()) {
+ theError = "One of the attribute not initialized.";
+ return false;
+ }
+ if(!aPointShape1.get()) {
+ aPointShape1 = aContext1->shape();
+ }
+ if(!aPointShape1->isVertex()) {
+ theError = "One of the selected shapes not a vertex.";
+ return false;
+ }
+
+ GeomShapePtr aPointShape2 = aPointAttribute2->value();
+ ResultPtr aContext2 = aPointAttribute2->context();
+ if(!aContext2.get()) {
+ return true;
+ }
+ if(!aPointShape2.get()) {
+ aPointShape2 = aContext2->shape();
+ }
+ if(!aPointShape2->isVertex()) {
+ theError = "One of the selected shapes not a vertex.";
+ return false;
+ }
+
+ GeomShapePtr aPointShape3 = aPointAttribute3->value();
+ ResultPtr aContext3 = aPointAttribute3->context();
+ if(!aContext3.get()) {
+ return true;
+ }
+ if(!aPointShape3.get()) {
+ aPointShape3 = aContext3->shape();
+ }
+ if(!aPointShape3->isVertex()) {
+ theError = "One of the selected shapes not a vertex.";
+ return false;
+ }
+
+ std::shared_ptr<GeomAPI_Vertex> aVertex1(new GeomAPI_Vertex(aPointShape1));
+ std::shared_ptr<GeomAPI_Vertex> aVertex2(new GeomAPI_Vertex(aPointShape2));
+ std::shared_ptr<GeomAPI_Vertex> aVertex3(new GeomAPI_Vertex(aPointShape3));
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt1 = aVertex1->point();
+ std::shared_ptr<GeomAPI_Pnt> aPnt2 = aVertex2->point();
+ std::shared_ptr<GeomAPI_Pnt> aPnt3 = aVertex3->point();
+
+ std::shared_ptr<GeomAPI_Lin> aLin(new GeomAPI_Lin(aPnt1, aPnt2));
+
+ if(aLin->contains(aPnt3)) {
+ theError = "Selected points lie on a line.";
+ return false;
+ }
+
+ return true;
+}
+
+//==================================================================================================
+bool ConstructionPlugin_ValidatorPlaneLinePoint::isValid(
+ const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+
+ AttributeSelectionPtr anAttribute1 = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ AttributeSelectionPtr anAttribute2 = aFeature->selection(theArguments.front());
+
+ std::shared_ptr<GeomAPI_Lin> aLin;
+ std::shared_ptr<GeomAPI_Pnt> aPnt;
+
+ GeomShapePtr aShape1 = anAttribute1->value();
+ ResultPtr aContext1 = anAttribute1->context();
+ if(!aContext1.get()) {
+ theError = "One of the attribute not initialized.";
+ return false;
+ }
+ if(!aShape1.get()) {
+ aShape1 = aContext1->shape();
+ }
+
+ GeomShapePtr aShape2 = anAttribute2->value();
+ ResultPtr aContext2 = anAttribute2->context();
+ if(!aContext2.get()) {
+ return true;
+ }
+ if(!aShape2.get()) {
+ aShape2 = aContext2->shape();
+ }
+
+ aLin = getLin(aShape1);
+ aPnt = getPnt(aShape2);
+ if(!aLin.get() || !aPnt.get()) {
+ aLin = getLin(aShape2);
+ aPnt = getPnt(aShape1);
+ }
+
+ if(!aLin.get() || !aPnt.get()) {
+ theError = "Wrong shape types selected.";
+ return false;
+ }
+
+ if(aLin->contains(aPnt)) {
+ theError = "Point lies on the line.";
+ return false;
+ }
+
+ return true;
+}
+
+std::shared_ptr<GeomAPI_Lin> getLin(const GeomShapePtr theShape)