1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SketchPlugin_Validators.h"
22 #include "SketchPlugin_Arc.h"
23 #include "SketchPlugin_BSpline.h"
24 #include "SketchPlugin_BSplinePeriodic.h"
25 #include "SketchPlugin_Circle.h"
26 #include "SketchPlugin_ConstraintCoincidence.h"
27 #include "SketchPlugin_ConstraintDistance.h"
28 #include "SketchPlugin_ConstraintRigid.h"
29 #include "SketchPlugin_ConstraintTangent.h"
30 #include "SketchPlugin_Ellipse.h"
31 #include "SketchPlugin_EllipticArc.h"
32 #include "SketchPlugin_Fillet.h"
33 #include "SketchPlugin_Line.h"
34 #include "SketchPlugin_MacroArc.h"
35 #include "SketchPlugin_MacroCircle.h"
36 #include "SketchPlugin_MultiRotation.h"
37 #include "SketchPlugin_Point.h"
38 #include "SketchPlugin_Sketch.h"
39 #include "SketchPlugin_Trim.h"
40 #include "SketchPlugin_Tools.h"
42 #include "SketcherPrs_Tools.h"
44 #include <Events_InfoMessage.h>
46 #include <ModelAPI_Data.h>
47 #include <ModelAPI_Validator.h>
48 #include <ModelAPI_AttributeDouble.h>
49 #include <ModelAPI_AttributeInteger.h>
50 #include <ModelAPI_AttributeRefAttr.h>
51 #include <ModelAPI_AttributeRefList.h>
52 #include <ModelAPI_AttributeSelectionList.h>
53 #include <ModelAPI_AttributeString.h>
54 #include <ModelAPI_Session.h>
55 #include <ModelAPI_Tools.h>
56 #include <ModelAPI_ResultConstruction.h>
58 #include <ModelGeomAlgo_Point2D.h>
59 #include <ModelGeomAlgo_Shape.h>
61 #include <GeomAlgoAPI_EdgeBuilder.h>
62 #include <GeomAlgoAPI_ShapeTools.h>
64 #include <GeomAPI_Circ.h>
65 #include <GeomAPI_Dir2d.h>
66 #include <GeomAPI_Ellipse.h>
67 #include <GeomAPI_Lin.h>
68 #include <GeomAPI_Edge.h>
69 #include <GeomAPI_Vertex.h>
71 #include <GeomDataAPI_Point2D.h>
72 #include <GeomDataAPI_Point2DArray.h>
77 const double tolerance = 1.e-7;
79 static bool isSpline(FeaturePtr theFeature)
81 return theFeature && (theFeature->getKind() == SketchPlugin_BSpline::ID() ||
82 theFeature->getKind() == SketchPlugin_BSplinePeriodic::ID());
86 bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribute,
87 const std::list<std::string>& theArguments,
88 Events_InfoMessage& theError) const
90 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
91 theError = "The attribute with the %1 type is not processed";
92 theError.arg(theAttribute->attributeType());
96 // there is a check whether the feature contains a point and a linear edge or two point values
97 std::string aParamA = theArguments.front();
98 SessionPtr aMgr = ModelAPI_Session::get();
99 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
101 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
103 bool isObject = aRefAttr->isObject();
105 // an attribute is a point. A point value is valid always for the distance
108 // 1. check whether the references object is a linear
109 ObjectPtr anObject = aRefAttr->object();
111 const ModelAPI_AttributeValidator* aShapeValidator =
112 dynamic_cast<const ModelAPI_AttributeValidator*>(
113 aFactory->validator("GeomValidators_ShapeType"));
114 std::list<std::string> anArguments;
115 anArguments.push_back("circle");
116 Events_InfoMessage aCircleError;
117 bool aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aCircleError);
118 // the circle line is not a valid case
120 theError = "Circle can not be used in distance constraint";
125 anArguments.push_back("line");
126 Events_InfoMessage aLineError;
127 aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aLineError);
128 // if the attribute value is not a line, that means it is a vertex. A vertex is always valid
130 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
131 // If it is a line then we have to check that first attribute id not a line
132 std::shared_ptr<SketchPlugin_Feature> aSFeature =
133 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
134 SketchPlugin_Sketch* aSketch = aSFeature->sketch();
135 std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(aSketch);
136 std::shared_ptr<GeomDataAPI_Point2D> aPoint = SketcherPrs_Tools::getFeaturePoint(
137 aFeature->data(), aParamA, aPlane);
139 theError = "One of parameters of distance constraint should be a point";
147 bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute,
148 const std::list<std::string>& theArguments,
149 Events_InfoMessage& theError) const
151 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
152 theError = "The attribute with the %1 type is not processed";
153 theError.arg(theAttribute->attributeType());
157 // there is a check whether the feature contains a point and a linear edge or two point values
158 std::string aParamA = theArguments.front();
159 SessionPtr aMgr = ModelAPI_Session::get();
160 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
162 FeaturePtr anAttributeFeature =
163 std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
164 AttributeRefAttrPtr aRefAttr =
165 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
167 bool isObject = aRefAttr->isObject();
168 ObjectPtr anObject = aRefAttr->object();
169 if (isObject && anObject.get()) {
170 FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
172 AttributeRefAttrPtr aOtherAttr = anAttributeFeature->data()->refattr(aParamA);
173 ObjectPtr aOtherObject = aOtherAttr->object();
174 FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
178 if (aRefFea->getKind() == SketchPlugin_Line::ID() &&
179 aOtherFea->getKind() == SketchPlugin_Line::ID()) {
180 theError = "Two segments cannot be tangent";
183 else if (isSpline(aRefFea) && isSpline(aOtherFea)) {
184 theError = "Two B-splines cannot be tangent";
190 theError = "It uses an empty object";
197 bool SketchPlugin_PerpendicularAttrValidator::isValid(const AttributePtr& theAttribute,
198 const std::list<std::string>& theArguments,
199 Events_InfoMessage& theError) const
201 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
202 theError = "The attribute with the %1 type is not processed";
203 theError.arg(theAttribute->attributeType());
207 std::string aParamA = theArguments.front();
208 SessionPtr aMgr = ModelAPI_Session::get();
209 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
211 FeaturePtr anOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
212 AttributeRefAttrPtr aRefAttr =
213 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
215 bool isObject = aRefAttr->isObject();
216 ObjectPtr anObject = aRefAttr->object();
217 if (isObject && anObject.get()) {
218 FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
220 AttributeRefAttrPtr aOtherAttr = anOwner->refattr(aParamA);
221 ObjectPtr aOtherObject = aOtherAttr->object();
222 FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
224 // at least one feature should be a line
225 if (aRefFea->getKind() != SketchPlugin_Line::ID() &&
226 aOtherFea && aOtherFea->getKind() != SketchPlugin_Line::ID()) {
227 theError = "At least one feature should be a line";
230 else if (isSpline(aRefFea) || isSpline(aOtherFea)) {
231 theError = "B-spline is not supported";
236 theError = "It uses an empty object";
243 bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute,
244 const std::list<std::string>& theArguments,
245 Events_InfoMessage& theError) const
247 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
248 theError = "The attribute with the %1 type is not processed";
249 theError.arg(theAttribute->attributeType());
253 std::shared_ptr<SketchPlugin_Feature> aFeature =
254 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
258 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
260 SketchPlugin_Sketch* aSketch = aFeature->sketch();
261 int aNbFeatures = aSketch->numberOfSubs();
262 for (int anInd = 0; anInd < aNbFeatures; anInd++) {
263 FeaturePtr aSubFeature = aSketch->subFeature(anInd);
264 if (aSubFeature->getKind() != SketchPlugin_ConstraintRigid::ID() || aSubFeature == aFeature)
266 AttributeRefAttrPtr aRAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
267 aSubFeature->attribute(SketchPlugin_ConstraintRigid::ENTITY_A()));
268 if (aRefAttr->isObject()) {
269 if (aRefAttr->object() == aRAttr->object()) {
270 ObjectPtr anObject = aRefAttr->object();
271 std::string aName = anObject.get() ? anObject->data()->name() : "";
272 theError = "The object %1 has been already fixed.";
277 else if (aRefAttr->attr() == aRAttr->attr()) {
278 AttributePtr anAttribute = aRefAttr->attr();
279 std::string aName = anAttribute.get() ? anAttribute->id() : "";
280 theError = "The attribute %1 has been already fixed.";
288 bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute,
289 const std::list<std::string>& theArguments,
290 Events_InfoMessage& theError) const
292 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
293 theError = "The attribute with the %1 type is not processed";
294 theError.arg(theAttribute->attributeType());
298 std::string aParamA = theArguments.front();
299 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
300 AttributeRefAttrPtr aRefAttr[2];
301 aRefAttr[0] = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
302 aRefAttr[1] = aFeature->data()->refattr(aParamA);
304 if (!aRefAttr[0]->isObject() || !aRefAttr[1]->isObject()) {
305 theError = "Attributes can not be used in equal constraint";
309 std::string aType[2];
310 std::list<std::string> anArguments;
311 for (int i = 0; i < 2; i++) {
312 aFeature = ModelAPI_Feature::feature(aRefAttr[i]->object());
316 aType[i] = aFeature->getKind();
317 if (aFeature->getKind() != SketchPlugin_Line::ID() &&
318 aFeature->getKind() != SketchPlugin_Circle::ID() &&
319 aFeature->getKind() != SketchPlugin_Arc::ID() &&
320 aFeature->getKind() != SketchPlugin_Ellipse::ID() &&
321 aFeature->getKind() != SketchPlugin_EllipticArc::ID()) {
322 theError = "The %1 feature is not supported by the Equal constraint.";
323 theError.arg(aFeature->getKind());
324 // wrong type of attribute
329 bool isOk = aType[0] == aType[1];
331 // circle and arc may be equal
332 isOk = (aType[0] == SketchPlugin_Arc::ID() && aType[1] == SketchPlugin_Circle::ID())
333 || (aType[0] == SketchPlugin_Circle::ID() && aType[1] == SketchPlugin_Arc::ID());
336 // ellipse and elliptic arc may be equal
337 isOk = (aType[0] == SketchPlugin_EllipticArc::ID() && aType[1] == SketchPlugin_Ellipse::ID())
338 || (aType[0] == SketchPlugin_Ellipse::ID() && aType[1] == SketchPlugin_EllipticArc::ID());
341 theError = "Features with kinds %1 and %2 can not be equal.";
342 theError.arg(aType[0]).arg(aType[1]);
348 bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute,
349 const std::list<std::string>& theArguments,
350 Events_InfoMessage& theError) const
352 if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) {
353 theError = "The attribute with the %1 type is not processed";
354 theError.arg(theAttribute->attributeType());
358 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
359 AttributeRefListPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
361 AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
362 aFeature->attribute(SketchPlugin_Constraint::ENTITY_C()));
363 std::list<ObjectPtr> aMirroredObjects = aRefListOfMirrored->list();
365 for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
366 ObjectPtr aSelObject = aSelAttr->object(anInd);
367 std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
368 std::list<ObjectPtr>::iterator aMirIter = aMirroredObjects.begin();
369 for (; aMirIter != aMirroredObjects.end(); aMirIter++)
370 if (aSelObject == *aMirIter) {
371 theError = "The object %1 is a result of mirror";
379 bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttribute,
380 const std::list<std::string>& theArguments,
381 Events_InfoMessage& theError) const
383 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
384 theError = "The attribute with the %1 type is not processed";
385 theError.arg(theAttribute->attributeType());
389 // there is a check whether the feature contains a point and a linear edge or two point values
390 std::string aParamA = theArguments.front();
391 SessionPtr aMgr = ModelAPI_Session::get();
392 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
394 FeaturePtr aConstraint = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
395 AttributeRefAttrPtr aRefAttrA = aConstraint->data()->refattr(aParamA);
397 theError = "The %1 attribute should be %2";
398 theError.arg(aParamA).arg(ModelAPI_AttributeRefAttr::typeId());
402 AttributeRefAttrPtr aRefAttrB =
403 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
405 // first attribute is a point, it may coincide with any object
406 if (!aRefAttrA->isObject())
409 ObjectPtr anObject = aRefAttrA->object();
410 if (!anObject.get()) {
411 theError = "%1 attribute has an empty object";
412 theError.arg(aParamA);
415 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrA->object());
416 if (!aFeature.get()) {
417 theError = "%1 attribute has an empty feature";
418 theError.arg(aParamA);
422 if (aFeature->getKind() == SketchPlugin_Point::ID())
426 // second attribute is a point, it may coincide with any object
427 if (!aRefAttrB->isObject())
430 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrB->object());
432 theError = "%1 attribute has an empty object";
433 theError.arg(theAttribute->id());
436 if (aFeature->getKind() == SketchPlugin_Point::ID())
439 theError = "There is no an attribute filled by a point";
444 bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
445 const std::list<std::string>& theArguments,
446 Events_InfoMessage& theError) const
448 if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) {
449 theError = "The attribute with the %1 type is not processed";
450 theError.arg(theAttribute->attributeType());
454 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
455 AttributeRefListPtr aSelAttr =
456 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
458 AttributeRefListPtr aRefListOfInitial = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
459 aFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
460 AttributeRefListPtr aRefListOfCopied = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
461 aFeature->attribute(SketchPlugin_Constraint::ENTITY_B()));
462 std::list<ObjectPtr> anInitialObjects = aRefListOfInitial->list();
463 std::list<ObjectPtr> aCopiedObjects = aRefListOfCopied->list();
465 std::list<ObjectPtr>::iterator anObjIter;
466 for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
467 ObjectPtr aSelObject = aSelAttr->object(anInd);
468 anObjIter = anInitialObjects.begin();
469 for (; anObjIter != anInitialObjects.end(); anObjIter++)
470 if (aSelObject == *anObjIter)
472 if (anObjIter != anInitialObjects.end())
474 anObjIter = aCopiedObjects.begin();
475 for (; anObjIter != aCopiedObjects.end(); anObjIter++)
476 if (aSelObject == *anObjIter) {
477 std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
478 theError = "The object %1 is a result of copy";
486 bool SketchPlugin_SolverErrorValidator::isValid(
487 const std::shared_ptr<ModelAPI_Feature>& theFeature,
488 const std::list<std::string>& theArguments,
489 Events_InfoMessage& theError) const
491 AttributeStringPtr aAttributeString = theFeature->string(SketchPlugin_Sketch::SOLVER_ERROR());
493 if (!aAttributeString->value().empty()) {
494 theError = aAttributeString->value();
501 bool SketchPlugin_SolverErrorValidator::isNotObligatory(std::string theFeature,
502 std::string theAttribute)
507 static bool hasSameTangentFeature(const std::set<AttributePtr>& theRefsList,
508 const FeaturePtr theFeature)
510 for(std::set<AttributePtr>::const_iterator
511 anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) {
512 std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
513 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
516 if (aFeature->getKind() == SketchPlugin_ConstraintTangent::ID()) {
517 AttributeRefAttrPtr anAttrRefA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
518 aFeature->attribute(SketchPlugin_ConstraintTangent::ENTITY_A()));
519 AttributeRefAttrPtr anAttrRefB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
520 aFeature->attribute(SketchPlugin_ConstraintTangent::ENTITY_B()));
521 if(anAttrRefA.get()) {
522 ResultPtr aResA = std::dynamic_pointer_cast<ModelAPI_Result>(anAttrRefA->object());
524 DocumentPtr aDoc = aResA->document();
526 FeaturePtr aFeatureA = aDoc->feature(aResA);
527 if(aFeatureA.get() && aFeatureA == theFeature) {
533 if(anAttrRefB.get()) {
534 ResultPtr aResB = std::dynamic_pointer_cast<ModelAPI_Result>(anAttrRefB->object());
536 DocumentPtr aDoc = aResB->document();
538 FeaturePtr aFeatureB = aDoc->feature(aResB);
539 if(aFeatureB.get() && aFeatureB == theFeature) {
550 static bool isPointPointCoincidence(const FeaturePtr& theCoincidence)
552 AttributeRefAttrPtr aRefAttr[2] = {
553 theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_A()),
554 theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_B())
557 bool arePoints = true;
558 for (int i = 0; i < 2 && arePoints; ++i) {
559 if (aRefAttr[i]->isObject()) {
560 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr[i]->object());
561 arePoints = aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID();
563 arePoints = aRefAttr[i]->attr().get() != NULL;
568 bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute,
569 const std::list<std::string>& theArguments,
570 Events_InfoMessage& theError) const
572 AttributeRefAttrPtr aPointRefAttr =
573 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
574 if(!aPointRefAttr.get()) {
575 theError = "Error: Point not selected.";
579 AttributePtr aPointAttribute = aPointRefAttr->attr();
580 if (!aPointAttribute.get()) {
581 theError = "Error: Bad point selected.";
584 std::shared_ptr<GeomAPI_Pnt2d> aSelectedPnt =
585 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttribute)->pnt();
587 // Obtain constraint coincidence for the fillet point.
588 const std::set<AttributePtr>& aRefsList = aPointAttribute->owner()->data()->refsToMe();
589 FeaturePtr aConstraintCoincidence;
590 for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin();
591 anIt != aRefsList.cend(); ++anIt) {
592 std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
593 FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
594 if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
595 if (!isPointPointCoincidence(aConstrFeature))
598 AttributeRefAttrPtr anAttrRefA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
599 aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_A()));
600 AttributeRefAttrPtr anAttrRefB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
601 aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_B()));
603 AttributePtr anAttrA = anAttrRefA->attr();
604 if(aPointAttribute == anAttrA) {
605 aConstraintCoincidence = aConstrFeature;
609 AttributePtr anAttrB = anAttrRefB->attr();
610 if(aPointAttribute == anAttrB) {
611 aConstraintCoincidence = aConstrFeature;
617 if(!aConstraintCoincidence.get()) {
618 theError = "Error: one of the selected point does not have coincidence.";
622 // Get coincides from constraint.
623 std::set<FeaturePtr> aCoinsides;
624 SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
625 SketchPlugin_ConstraintCoincidence::ENTITY_A(),
628 SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
629 SketchPlugin_ConstraintCoincidence::ENTITY_B(),
633 // Remove points and external lines from set of coincides.
634 std::set<FeaturePtr> aNewSetOfCoincides;
635 for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
636 anIt != aCoinsides.end(); ++anIt) {
637 std::shared_ptr<SketchPlugin_SketchEntity> aSketchEntity =
638 std::dynamic_pointer_cast<SketchPlugin_SketchEntity>(*anIt);
639 if(aSketchEntity.get() && (aSketchEntity->isCopy() || aSketchEntity->isExternal())) {
642 if((*anIt)->getKind() != SketchPlugin_Line::ID() &&
643 (*anIt)->getKind() != SketchPlugin_Arc::ID()) {
646 if((*anIt)->getKind() == SketchPlugin_Arc::ID()) {
647 AttributePtr anArcCenter = (*anIt)->attribute(SketchPlugin_Arc::CENTER_ID());
648 std::shared_ptr<GeomAPI_Pnt2d> anArcCenterPnt =
649 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anArcCenter)->pnt();
650 double aDistSelectedArcCenter = aSelectedPnt->distance(anArcCenterPnt);
651 if(aDistSelectedArcCenter < tolerance) {
655 aNewSetOfCoincides.insert(*anIt);
657 aCoinsides = aNewSetOfCoincides;
659 // If we still have more than two coincides remove auxilary entities from set of coincides.
660 if(aCoinsides.size() > 2) {
661 aNewSetOfCoincides.clear();
662 for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
663 anIt != aCoinsides.end(); ++anIt) {
664 if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
665 aNewSetOfCoincides.insert(*anIt);
668 aCoinsides = aNewSetOfCoincides;
671 if(aCoinsides.size() != 2) {
672 theError = "Error: One of the selected points does not have two suitable edges for fillet.";
676 // Check that selected edges don't have tangent constraint.
677 std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
678 FeaturePtr aFirstFeature = *anIt++;
679 FeaturePtr aSecondFeature = *anIt;
680 const std::set<AttributePtr>& aFirstFeatureRefsList = aFirstFeature->data()->refsToMe();
681 if(hasSameTangentFeature(aFirstFeatureRefsList, aSecondFeature)) {
682 theError = "Error: Edges in selected point has tangent constraint.";
686 std::list<ResultPtr> aFirstResults = aFirstFeature->results();
687 for(std::list<ResultPtr>::iterator aResIt = aFirstResults.begin();
688 aResIt != aFirstResults.end(); ++aResIt) {
689 ResultPtr aRes = *aResIt;
690 const std::set<AttributePtr>& aResRefsList = aRes->data()->refsToMe();
691 if(hasSameTangentFeature(aResRefsList, aSecondFeature)) {
692 theError = "Error: Edges in selected point has tangent constraint.";
697 // Check the features are not tangent
698 std::shared_ptr<GeomAPI_Shape> aFirstShape = aFirstFeature->lastResult()->shape();
699 std::shared_ptr<GeomAPI_Shape> aSecondShape = aSecondFeature->lastResult()->shape();
700 if (!aFirstShape || !aFirstShape->isEdge() ||
701 !aSecondShape || !aSecondShape->isEdge()) {
702 theError = "Error: At least on of the features is not an edge";
706 std::shared_ptr<GeomAPI_Edge> anEdge1 = std::dynamic_pointer_cast<GeomAPI_Edge>(aFirstShape);
707 std::shared_ptr<GeomAPI_Edge> anEdge2 = std::dynamic_pointer_cast<GeomAPI_Edge>(aSecondShape);
709 static const double TOL = 1.e-7;
710 if (anEdge1->isLine() && anEdge2->isLine()) {
711 // Check that lines not collinear
712 std::shared_ptr<GeomAPI_Dir> aDir1 = anEdge1->line()->direction();
713 std::shared_ptr<GeomAPI_Dir> aDir2 = anEdge2->line()->direction();
714 double aCross = aDir1->cross(aDir2)->squareModulus();
715 if (aCross < TOL * TOL)
717 } else if (anEdge1->isArc() && anEdge2->isArc()) {
718 // check the circles are not tangent
719 std::shared_ptr<GeomAPI_Circ> aCirc1 = anEdge1->circle();
720 std::shared_ptr<GeomAPI_Circ> aCirc2 = anEdge2->circle();
721 double aDistCC = aCirc1->center()->distance(aCirc2->center());
722 double aRadSum = aCirc1->radius() + aCirc2->radius();
723 double aRadDiff = fabs(aCirc1->radius() - aCirc2->radius());
724 if (fabs(aDistCC - aRadSum) < TOL || fabs(aDistCC - aRadDiff) < TOL)
727 // check whether line and arc are tangent
728 std::shared_ptr<GeomAPI_Circ> aCirc;
729 std::shared_ptr<GeomAPI_Lin> aLine;
730 if (anEdge1->isLine()) {
731 aLine = anEdge1->line();
732 aCirc = anEdge2->circle();
734 aCirc = anEdge1->circle();
735 aLine = anEdge2->line();
738 double aDistCL = aLine->distance(aCirc->center());
739 if (fabs(aDistCL - aCirc->radius()) < TOL)
746 bool SketchPlugin_MiddlePointAttrValidator::isValid(const AttributePtr& theAttribute,
747 const std::list<std::string>& theArguments,
748 Events_InfoMessage& theError) const
750 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
751 theError = "The attribute with the %1 type is not processed";
752 theError.arg(theAttribute->attributeType());
756 // there is a check whether the feature contains a point and a linear edge or two point values
757 std::string aParamA = theArguments.front();
758 SessionPtr aMgr = ModelAPI_Session::get();
759 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
761 FeaturePtr anAttributeFeature =
762 std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
763 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
764 AttributeRefAttrPtr anOtherAttr = anAttributeFeature->data()->refattr(aParamA);
766 AttributeRefAttrPtr aRefAttrs[2] = {aRefAttr, anOtherAttr};
769 for (int i = 0; i < 2; ++i) {
770 if (!aRefAttrs[i]->isObject())
773 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrs[i]->object());
775 if (aNbPoints + aNbLines != 0)
780 if (aFeature->getKind() == SketchPlugin_Point::ID())
782 else if (aFeature->getKind() == SketchPlugin_Line::ID() ||
783 aFeature->getKind() == SketchPlugin_Arc::ID() ||
784 aFeature->getKind() == SketchPlugin_EllipticArc::ID())
789 if (aNbPoints != 1 || aNbLines != 1) {
790 theError = "Middle point constraint allows points and lines only";
796 bool SketchPlugin_ArcTangentPointValidator::isValid(const AttributePtr& theAttribute,
797 const std::list<std::string>& /*theArguments*/,
798 Events_InfoMessage& theError) const
800 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
801 theError = "The attribute with the %1 type is not processed";
802 theError.arg(theAttribute->attributeType());
805 FeaturePtr anOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
806 AttributeStringPtr anArcTypeAttr = anOwner->string(SketchPlugin_MacroArc::ARC_TYPE());
807 if (anArcTypeAttr && anArcTypeAttr->value() != SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE())
808 return true; // not applicable for non-tangent arcs
810 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
811 AttributePtr anAttr = aRefAttr->attr();
813 theError = "The attribute %1 should be a point";
814 theError.arg(theAttribute->id());
818 FeaturePtr anAttrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->owner());
819 const std::string& aFeatureType = anAttrFeature->getKind();
820 if (aFeatureType == SketchPlugin_Arc::ID()) {
821 // selected point should not be a center of arc
822 const std::string& aPntId = anAttr->id();
823 if (aPntId != SketchPlugin_Arc::START_ID() && aPntId != SketchPlugin_Arc::END_ID()) {
824 theError = "The attribute %1 is not supported";
825 theError.arg(aPntId);
829 else if (aFeatureType == SketchPlugin_Line::ID()) {
830 // selected point should be bound point of line
831 const std::string& aPntId = anAttr->id();
832 if (aPntId != SketchPlugin_Line::START_ID() && aPntId != SketchPlugin_Line::END_ID()) {
833 theError = "The attribute %1 is not supported";
834 theError.arg(aPntId);
839 theError = "Unable to build tangent arc on %1";
840 theError.arg(anAttrFeature->getKind());
847 bool SketchPlugin_ArcTransversalPointValidator::isValid(
848 const AttributePtr& theAttribute,
849 const std::list<std::string>& /*theArguments*/,
850 Events_InfoMessage& theError) const
852 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
853 theError = "The attribute with the %1 type is not processed";
854 theError.arg(theAttribute->attributeType());
857 FeaturePtr anOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
858 AttributeStringPtr anArcTypeAttr = anOwner->string(SketchPlugin_MacroArc::ARC_TYPE());
860 anArcTypeAttr->value() != SketchPlugin_MacroArc::ARC_TYPE_BY_TRANSVERSAL_LINE())
861 return true; // not applicable for non-transversal arcs
863 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
864 AttributePtr anAttr = aRefAttr->attr();
866 theError = "The attribute %1 should be a point";
867 theError.arg(theAttribute->id());
871 FeaturePtr anAttrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->owner());
872 const std::string& aFeatureType = anAttrFeature->getKind();
873 if (aFeatureType == SketchPlugin_Line::ID()) {
874 // selected point should be bound point of line
875 const std::string& aPntId = anAttr->id();
876 if (aPntId != SketchPlugin_Line::START_ID() && aPntId != SketchPlugin_Line::END_ID()) {
877 theError = "The attribute %1 is not supported";
878 theError.arg(aPntId);
883 theError = "Unable to build perpendicular arc on %1";
884 theError.arg(anAttrFeature->getKind());
891 bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribute,
892 const std::list<std::string>& theArguments,
893 Events_InfoMessage& theError) const
895 if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) {
896 theError = "The attribute with the %1 type is not processed";
897 theError.arg(theAttribute->attributeType());
900 AttributeSelectionPtr anExternalAttr =
901 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
902 std::shared_ptr<GeomAPI_Edge> anEdge;
903 if (anExternalAttr && anExternalAttr->value() && anExternalAttr->value()->isEdge()) {
904 anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anExternalAttr->value()));
905 } else if(anExternalAttr->context() && anExternalAttr->context()->shape() &&
906 anExternalAttr->context()->shape()->isEdge()) {
907 anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anExternalAttr->context()->shape()));
911 theError = "The attribute %1 should be an edge";
912 theError.arg(theAttribute->id());
917 std::shared_ptr<SketchPlugin_Sketch> aSketch;
918 std::set<AttributePtr> aRefs = anExternalAttr->owner()->data()->refsToMe();
919 std::set<AttributePtr>::const_iterator anIt = aRefs.begin();
920 for (; anIt != aRefs.end(); ++anIt) {
921 CompositeFeaturePtr aComp =
922 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*anIt)->owner());
923 if (aComp && aComp->getKind() == SketchPlugin_Sketch::ID()) {
924 aSketch = std::dynamic_pointer_cast<SketchPlugin_Sketch>(aComp);
929 theError = "There is no sketch referring to the current feature";
933 // check the edge is intersected with sketch plane
934 std::shared_ptr<GeomAPI_Pln> aPlane = aSketch->plane();
936 std::list<GeomPointPtr> anIntersectionsPoints;
937 anEdge->intersectWithPlane(aPlane, anIntersectionsPoints);
938 if (anIntersectionsPoints.empty()) {
939 theError = "The edge is not intersected with sketch plane";
945 bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute,
946 const std::list<std::string>& theArguments,
947 Events_InfoMessage& theError) const
951 if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
952 theError = "The attribute with the %1 type is not processed";
953 theError.arg(theAttribute->attributeType());
956 AttributeReferencePtr aFeatureAttr =
957 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
958 std::shared_ptr<SketchPlugin_Feature> aSplitFeature =
959 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
961 ObjectPtr anAttrObject = aFeatureAttr->value();
963 AttributePtr aPreviewAttr = aSplitFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
964 aFeatureAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
965 anAttrObject = aFeatureAttr->value();
968 FeaturePtr anAttrFeature = ModelAPI_Feature::feature(anAttrObject);
972 std::set<ResultPtr> anEdgeShapes;
973 ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
974 if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
977 // coincidences to the feature
978 std::set<std::shared_ptr<GeomDataAPI_Point2D> > aRefAttributes;
979 ModelGeomAlgo_Point2D::getPointsOfReference(anAttrFeature,
980 SketchPlugin_ConstraintCoincidence::ID(),
981 aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
983 GeomShapePtr anAttrShape = (*anEdgeShapes.begin())->shape();
984 std::shared_ptr<SketchPlugin_Feature> aSFeature =
985 std::dynamic_pointer_cast<SketchPlugin_Feature>(anAttrFeature);
986 if (!aSFeature || aSFeature->isCopy())
988 SketchPlugin_Sketch* aSketch = aSFeature->sketch();
990 std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
991 std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
992 aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
993 std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
994 aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
995 std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
996 aData->attribute(SketchPlugin_Sketch::NORM_ID()));
997 std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
999 typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
1000 std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
1001 std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
1002 PointToRefsMap aPointsInfo;
1004 ModelGeomAlgo_Point2D::getPointsInsideShape(anAttrShape, aRefAttributes, aC->pnt(),
1005 aX->dir(), aDirY, aPointsInfo);
1006 int aCoincidentToFeature = (int)aPointsInfo.size();
1007 if (anAttrFeature->getKind() == SketchPlugin_Circle::ID() ||
1008 anAttrFeature->getKind() == SketchPlugin_Ellipse::ID())
1009 aValid = aCoincidentToFeature >= 2;
1011 aValid = aCoincidentToFeature >= 1;
1016 bool SketchPlugin_TrimValidator::isValid(const AttributePtr& theAttribute,
1017 const std::list<std::string>& theArguments,
1018 Events_InfoMessage& theError) const
1020 bool aValid = false;
1022 if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
1023 theError = "The attribute with the %1 type is not processed";
1024 theError.arg(theAttribute->attributeType());
1027 AttributeReferencePtr aBaseObjectAttr =
1028 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
1030 std::shared_ptr<SketchPlugin_Feature> aTrimFeature =
1031 std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
1033 ObjectPtr aBaseObject = aBaseObjectAttr->value();
1035 AttributePtr aPreviewAttr = aTrimFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
1036 aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
1037 aBaseObject = aBaseObjectAttr->value();
1040 FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObject);
1044 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
1045 std::dynamic_pointer_cast<SketchPlugin_Feature>(aBaseFeature);
1046 if (!aSketchFeature.get() || aSketchFeature->isCopy())
1050 AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
1051 aTrimFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
1053 SketchPlugin_Sketch* aSketch = aTrimFeature->sketch();
1055 std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
1056 std::shared_ptr<GeomAPI_Pnt> anAttributePnt = aSketch->to3D(anAttributePnt2d->x(),
1057 anAttributePnt2d->y());
1059 std::map<ObjectPtr, std::set<GeomShapePtr> > aCashedShapes;
1060 std::map<ObjectPtr, std::map<std::shared_ptr<GeomAPI_Pnt>,
1061 std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
1062 std::list<std::shared_ptr<ModelAPI_Object> > > > > anObjectToPoints;
1063 SketchPlugin_SegmentationTools::fillObjectShapes(
1064 aTrimFeature.get(), aBaseObject, aCashedShapes, anObjectToPoints);
1065 const std::set<GeomShapePtr>& aShapes = aCashedShapes[aBaseObject];
1067 return aShapes.size() > 1;
1070 bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
1071 const std::list<std::string>& theArguments,
1072 Events_InfoMessage& theError) const
1074 if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) {
1075 theError = "The attribute with the %1 type is not processed";
1076 theError.arg(theAttribute->attributeType());
1080 AttributeSelectionPtr aFeatureAttr =
1081 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
1082 std::shared_ptr<GeomAPI_Edge> anEdge;
1083 std::shared_ptr<SketchPlugin_Feature> aSketchFeature;
1084 if (aFeatureAttr.get()) {
1085 GeomShapePtr aVal = aFeatureAttr->value();
1086 ResultPtr aRes = aFeatureAttr->context();
1087 if (aVal && aVal->isVertex())
1088 return true; // vertex is always could be projected
1089 if (aVal && aVal->isEdge()) {
1090 anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aFeatureAttr->value()));
1091 } else if(aRes && aRes->shape()) {
1092 if (aRes->shape()->isVertex())
1093 return true; // vertex is always could be projected
1094 else if (aRes->shape()->isEdge())
1095 anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aFeatureAttr->context()->shape()));
1098 // try to convert result to sketch feature
1101 std::dynamic_pointer_cast<SketchPlugin_Feature>(ModelAPI_Feature::feature(aRes));
1105 theError = "The attribute %1 should be an edge or vertex";
1106 theError.arg(theAttribute->id());
1111 std::shared_ptr<SketchPlugin_Sketch> aSketch;
1112 std::set<AttributePtr> aRefs = theAttribute->owner()->data()->refsToMe();
1113 std::set<AttributePtr>::const_iterator anIt = aRefs.begin();
1114 for (; anIt != aRefs.end(); ++anIt) {
1115 CompositeFeaturePtr aComp =
1116 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*anIt)->owner());
1117 if (aComp && aComp->getKind() == SketchPlugin_Sketch::ID()) {
1118 aSketch = std::dynamic_pointer_cast<SketchPlugin_Sketch>(aComp);
1123 theError = "There is no sketch referring to the current feature";
1126 if (aSketchFeature && aSketch.get() == aSketchFeature->sketch()) {
1127 theError = "Unable to project feature from the same sketch";
1131 std::shared_ptr<GeomAPI_Pln> aPlane = aSketch->plane();
1132 std::shared_ptr<GeomAPI_Dir> aNormal = aPlane->direction();
1133 std::shared_ptr<GeomAPI_Pnt> anOrigin = aPlane->location();
1136 if (anEdge->isLine()) {
1137 std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
1138 std::shared_ptr<GeomAPI_Dir> aLineDir = aLine->direction();
1139 double aDot = fabs(aNormal->dot(aLineDir));
1140 aValid = fabs(aDot - 1.0) >= tolerance * tolerance;
1142 theError = "Error: Line is orthogonal to the sketch plane.";
1144 else if (anEdge->isCircle() || anEdge->isArc()) {
1145 std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
1146 std::shared_ptr<GeomAPI_Dir> aCircNormal = aCircle->normal();
1147 double aDot = fabs(aNormal->dot(aCircNormal));
1148 aValid = aDot >= tolerance * tolerance;
1150 theError.arg(anEdge->isCircle() ? "Error: Circle is orthogonal to the sketch plane."
1151 : "Error: Arc is orthogonal to the sketch plane.");
1153 else if (anEdge->isEllipse()) {
1154 std::shared_ptr<GeomAPI_Ellipse> anEllipse = anEdge->ellipse();
1155 std::shared_ptr<GeomAPI_Dir> anEllipseNormal = anEllipse->normal();
1156 double aDot = fabs(aNormal->dot(anEllipseNormal));
1157 aValid = fabs(aDot - 1.0) <= tolerance * tolerance;
1159 theError.arg(anEdge->isClosed() ? "Error: Ellipse is orthogonal to the sketch plane."
1160 : "Error: Elliptic Arc is orthogonal to the sketch plane.");
1167 static std::set<FeaturePtr> common(const std::set<FeaturePtr>& theSet1,
1168 const std::set<FeaturePtr>& theSet2)
1170 std::set<FeaturePtr> aCommon;
1171 if (theSet1.empty() || theSet2.empty())
1174 std::set<FeaturePtr>::const_iterator anIt2 = theSet2.begin();
1175 for (; anIt2 != theSet2.end(); ++anIt2)
1176 if (theSet1.find(*anIt2) != theSet1.end())
1177 aCommon.insert(*anIt2);
1181 bool SketchPlugin_DifferentReferenceValidator::isValid(
1182 const AttributePtr& theAttribute,
1183 const std::list<std::string>& theArguments,
1184 Events_InfoMessage& theError) const
1186 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
1188 int aNbFeaturesReferred = 0;
1189 int aNbAttributesReferred = 0;
1190 std::set<FeaturePtr> aCommonReferredFeatures;
1192 // find all features referred by attributes listed in theArguments
1193 std::list<std::string>::const_iterator anArgIt = theArguments.begin();
1194 for (; anArgIt != theArguments.end(); ++anArgIt) {
1195 AttributeRefAttrPtr aRefAttr = anOwner->refattr(*anArgIt);
1199 std::set<FeaturePtr> aCoincidentFeatures;
1200 if (aRefAttr->isObject()) {
1201 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
1203 aCoincidentFeatures.insert(aFeature);
1204 aNbFeaturesReferred += 1;
1207 AttributePoint2DPtr aPoint =
1208 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
1210 aCoincidentFeatures = SketchPlugin_Tools::findFeaturesCoincidentToPoint(aPoint);
1211 aNbAttributesReferred += 1;
1215 if (aCommonReferredFeatures.empty())
1216 aCommonReferredFeatures = aCoincidentFeatures;
1218 aCommonReferredFeatures = common(aCommonReferredFeatures, aCoincidentFeatures);
1220 if (aCommonReferredFeatures.empty())
1224 bool isOk = aNbFeaturesReferred < 1;
1225 if (aNbFeaturesReferred == 1) {
1226 if (aCommonReferredFeatures.size() == 1) {
1227 FeaturePtr aFeature = *aCommonReferredFeatures.begin();
1228 isOk = aNbAttributesReferred <= 1 ||
1229 aFeature->getKind() == SketchPlugin_Circle::ID() ||
1230 aFeature->getKind() == SketchPlugin_Arc::ID();
1236 theError = "Attributes are referred to the same feature";
1240 bool SketchPlugin_DifferentPointReferenceValidator::isValid(
1241 const AttributePtr& theAttribute,
1242 const std::list<std::string>& theArguments,
1243 Events_InfoMessage& theError) const
1245 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
1246 std::set<AttributePoint2DPtr> aReferredCoincidentPoints;
1248 // find all points referred by attributes listed in theArguments
1249 bool hasRefsToPoints = false;
1250 std::list<std::string>::const_iterator anArgIt = theArguments.begin();
1251 for (; anArgIt != theArguments.end(); ++anArgIt) {
1252 AttributeRefAttrPtr aRefAttr = anOwner->refattr(*anArgIt);
1256 if (!aRefAttr->isObject()) {
1257 AttributePoint2DPtr aPoint =
1258 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
1259 if (aReferredCoincidentPoints.empty())
1260 aReferredCoincidentPoints = SketchPlugin_Tools::findPointsCoincidentToPoint(aPoint);
1261 else if (aReferredCoincidentPoints.find(aPoint) == aReferredCoincidentPoints.end())
1262 return true; // non-coincident point has been found
1264 hasRefsToPoints = true;
1268 if (hasRefsToPoints)
1269 theError = "Attributes are referred to the same point";
1270 return !hasRefsToPoints;
1273 bool SketchPlugin_CirclePassedPointValidator::isValid(
1274 const AttributePtr& theAttribute,
1275 const std::list<std::string>&,
1276 Events_InfoMessage& theError) const
1278 static const std::string aErrorMessage(
1279 "Passed point refers to the same feature as a center point");
1281 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
1283 AttributeRefAttrPtr aCenterRef =
1284 anOwner->refattr(SketchPlugin_MacroCircle::CENTER_POINT_REF_ID());
1285 AttributeRefAttrPtr aPassedRef =
1286 anOwner->refattr(SketchPlugin_MacroCircle::PASSED_POINT_REF_ID());
1288 if (!aPassedRef->isObject())
1291 FeaturePtr aPassedFeature = ModelAPI_Feature::feature(aPassedRef->object());
1292 if (!aPassedFeature)
1295 if (aCenterRef->isObject()) {
1296 if (aCenterRef->object() == aPassedRef->object()) {
1297 theError = aErrorMessage;
1301 AttributePoint2DPtr aCenterPoint =
1302 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aCenterRef->attr());
1304 std::set<FeaturePtr> aCoincidentFeatures =
1305 SketchPlugin_Tools::findFeaturesCoincidentToPoint(aCenterPoint);
1306 // check one of coincident features is a feature referred by passed point
1307 std::set<FeaturePtr>::const_iterator anIt = aCoincidentFeatures.begin();
1308 for(; anIt != aCoincidentFeatures.end(); ++anIt)
1309 if (*anIt == aPassedFeature) {
1310 theError = aErrorMessage;
1318 bool SketchPlugin_ThirdPointValidator::isValid(
1319 const AttributePtr& theAttribute,
1320 const std::list<std::string>& theArguments,
1321 Events_InfoMessage& theError) const
1323 FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
1324 return arePointsNotOnLine(anOwner, theError) &&
1325 arePointsNotSeparated(anOwner, theArguments, theError);
1328 static std::shared_ptr<GeomAPI_Pnt2d> toPoint(const FeaturePtr& theMacroCircle,
1329 const std::string& thePointAttrName,
1330 const std::string& theRefPointAttrName)
1332 AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
1333 theMacroCircle->attribute(thePointAttrName));
1334 AttributeRefAttrPtr aRefAttr = theMacroCircle->refattr(theRefPointAttrName);
1336 std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
1338 if (aRefAttr->isObject()) {
1339 // project a point onto selected feature
1340 std::shared_ptr<SketchPlugin_Feature> aFeature =
1341 std::dynamic_pointer_cast<SketchPlugin_Feature>(
1342 ModelAPI_Feature::feature(aRefAttr->object()));
1344 SketchPlugin_Sketch* aSketch = aFeature->sketch();
1345 std::shared_ptr<GeomAPI_Edge> anEdge =
1346 std::dynamic_pointer_cast<GeomAPI_Edge>(aFeature->lastResult()->shape());
1348 std::shared_ptr<GeomAPI_Pnt> aPoint3D = aSketch->to3D(aPoint->x(), aPoint->y());
1349 if (anEdge->isLine())
1350 aPoint3D = anEdge->line()->project(aPoint3D);
1351 else if (anEdge->isCircle())
1352 aPoint3D = anEdge->circle()->project(aPoint3D);
1354 aPoint = aSketch->to2D(aPoint3D);
1358 AttributePoint2DPtr anOtherPoint =
1359 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
1361 aPoint = anOtherPoint->pnt(); // the reference point is much more precise, use it
1368 static void threePointsOfFeature(const FeaturePtr& theMacroFeature,
1369 std::shared_ptr<GeomAPI_Pnt2d> thePoints[3])
1371 if (theMacroFeature->getKind() == SketchPlugin_MacroCircle::ID()) {
1372 thePoints[0] = toPoint(theMacroFeature,
1373 SketchPlugin_MacroCircle::FIRST_POINT_ID(),
1374 SketchPlugin_MacroCircle::FIRST_POINT_REF_ID());
1375 thePoints[1] = toPoint(theMacroFeature,
1376 SketchPlugin_MacroCircle::SECOND_POINT_ID(),
1377 SketchPlugin_MacroCircle::SECOND_POINT_REF_ID());
1378 thePoints[2] = toPoint(theMacroFeature,
1379 SketchPlugin_MacroCircle::THIRD_POINT_ID(),
1380 SketchPlugin_MacroCircle::THIRD_POINT_REF_ID());
1381 } else if (theMacroFeature->getKind() == SketchPlugin_MacroArc::ID()) {
1382 thePoints[0] = toPoint(theMacroFeature,
1383 SketchPlugin_MacroArc::START_POINT_2_ID(),
1384 SketchPlugin_MacroArc::START_POINT_REF_ID());
1385 thePoints[1] = toPoint(theMacroFeature,
1386 SketchPlugin_MacroArc::END_POINT_2_ID(),
1387 SketchPlugin_MacroArc::END_POINT_REF_ID());
1388 thePoints[2] = toPoint(theMacroFeature,
1389 SketchPlugin_MacroArc::PASSED_POINT_ID(),
1390 SketchPlugin_MacroArc::PASSED_POINT_REF_ID());
1394 static bool isPointsOnLine(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
1395 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
1396 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
1398 static const double aTolerance = 1.e-7;
1399 if (thePoint1->distance(thePoint2) < aTolerance ||
1400 thePoint1->distance(thePoint3) < aTolerance)
1403 std::shared_ptr<GeomAPI_Dir2d> aDirP1P2(new GeomAPI_Dir2d(thePoint2->x() - thePoint1->x(),
1404 thePoint2->y() - thePoint1->y()));
1405 std::shared_ptr<GeomAPI_Dir2d> aDirP1P3(new GeomAPI_Dir2d(thePoint3->x() - thePoint1->x(),
1406 thePoint3->y() - thePoint1->y()));
1407 return fabs(aDirP1P2->cross(aDirP1P3)) < aTolerance;
1410 static bool isOnSameSide(const std::shared_ptr<GeomAPI_Lin>& theLine,
1411 const std::shared_ptr<GeomAPI_Pnt>& thePoint1,
1412 const std::shared_ptr<GeomAPI_Pnt>& thePoint2)
1414 static const double aTolerance = 1.e-7;
1415 std::shared_ptr<GeomAPI_Dir> aLineDir = theLine->direction();
1416 std::shared_ptr<GeomAPI_XYZ> aLineLoc = theLine->location()->xyz();
1418 std::shared_ptr<GeomAPI_XYZ> aVec1 = thePoint1->xyz()->decreased(aLineLoc);
1419 // the first point is on the line
1420 if (aVec1->squareModulus() < aTolerance * aTolerance)
1422 std::shared_ptr<GeomAPI_Dir> aDirP1L(new GeomAPI_Dir(aVec1));
1423 std::shared_ptr<GeomAPI_XYZ> aVec2 = thePoint2->xyz()->decreased(aLineLoc);
1424 // the second point is on the line
1425 if (aVec2->squareModulus() < aTolerance * aTolerance)
1427 std::shared_ptr<GeomAPI_Dir> aDirP2L(new GeomAPI_Dir(aVec2));
1429 return aLineDir->cross(aDirP1L)->dot(aLineDir->cross(aDirP2L)) > -aTolerance;
1432 static bool isOnSameSide(const std::shared_ptr<GeomAPI_Circ>& theCircle,
1433 const std::shared_ptr<GeomAPI_Pnt>& thePoint1,
1434 const std::shared_ptr<GeomAPI_Pnt>& thePoint2)
1436 static const double aTolerance = 1.e-7;
1437 std::shared_ptr<GeomAPI_Pnt> aCenter = theCircle->center();
1438 double aDistP1C = thePoint1->distance(aCenter);
1439 double aDistP2C = thePoint2->distance(aCenter);
1440 return (aDistP1C - theCircle->radius()) * (aDistP2C - theCircle->radius()) > -aTolerance;
1443 bool SketchPlugin_ThirdPointValidator::arePointsNotOnLine(
1444 const FeaturePtr& theMacroFeature,
1445 Events_InfoMessage& theError) const
1447 static const std::string aErrorPointsOnLine(
1448 "Selected points are on the same line");
1450 std::shared_ptr<GeomAPI_Pnt2d> aPoints[3];
1451 threePointsOfFeature(theMacroFeature, aPoints);
1453 if (isPointsOnLine(aPoints[0], aPoints[1], aPoints[2])) {
1454 theError = aErrorPointsOnLine;
1460 bool SketchPlugin_ThirdPointValidator::arePointsNotSeparated(
1461 const FeaturePtr& theMacroFeature,
1462 const std::list<std::string>& theArguments,
1463 Events_InfoMessage& theError) const
1465 static const std::string aErrorPointsApart(
1466 "Selected entity is lying between first two points");
1468 AttributeRefAttrPtr aThirdPointRef = theMacroFeature->refattr(theArguments.front());
1469 FeaturePtr aRefByThird;
1470 if (aThirdPointRef->isObject())
1471 aRefByThird = ModelAPI_Feature::feature(aThirdPointRef->object());
1475 std::shared_ptr<GeomAPI_Pnt2d> aPoints[3];
1476 threePointsOfFeature(theMacroFeature, aPoints);
1478 std::shared_ptr<GeomAPI_Edge> aThirdShape =
1479 std::dynamic_pointer_cast<GeomAPI_Edge>(aRefByThird->lastResult()->shape());
1483 SketchPlugin_Sketch* aSketch =
1484 std::dynamic_pointer_cast<SketchPlugin_Feature>(theMacroFeature)->sketch();
1485 std::shared_ptr<GeomAPI_Pnt> aFirstPnt3D = aSketch->to3D(aPoints[0]->x(), aPoints[0]->y());
1486 std::shared_ptr<GeomAPI_Pnt> aSecondPnt3D = aSketch->to3D(aPoints[1]->x(), aPoints[1]->y());
1489 if (aThirdShape->isLine())
1490 isOk = isOnSameSide(aThirdShape->line(), aFirstPnt3D, aSecondPnt3D);
1491 else if (aThirdShape->isCircle() || aThirdShape->isArc())
1492 isOk = isOnSameSide(aThirdShape->circle(), aFirstPnt3D, aSecondPnt3D);
1495 theError = aErrorPointsApart;
1499 bool SketchPlugin_ArcEndPointValidator::isValid(
1500 const AttributePtr& theAttribute,
1501 const std::list<std::string>& theArguments,
1502 Events_InfoMessage& theError) const
1504 FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
1505 AttributeRefAttrPtr anEndPointRef = aFeature->refattr(theArguments.front());
1507 if(!anEndPointRef.get()) {
1511 ObjectPtr anObject = anEndPointRef->object();
1512 AttributePtr anAttr = anEndPointRef->attr();
1513 if(!anObject.get() && !anAttr.get()) {
1517 if(anEndPointRef->attr().get()) {
1521 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
1523 GeomShapePtr aShape = aResult->shape();
1524 if(aShape.get() && aShape->isVertex()) {
1529 aFeature = ModelAPI_Feature::feature(anObject);
1530 if(aFeature.get()) {
1531 if(aFeature->getKind() == SketchPlugin_Point::ID()) {
1539 static GeomShapePtr toInfiniteEdge(const GeomShapePtr theShape)
1541 if(!theShape.get()) {
1545 if(!theShape->isEdge()) {
1549 std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
1555 if(anEdge->isLine()) {
1556 std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
1557 GeomShapePtr aShape = GeomAlgoAPI_EdgeBuilder::line(aLine);
1561 if(anEdge->isCircle() || anEdge->isArc()) {
1562 std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
1563 GeomShapePtr aShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCircle);
1570 bool SketchPlugin_ArcEndPointIntersectionValidator::isValid(
1571 const AttributePtr& theAttribute,
1572 const std::list<std::string>& theArguments,
1573 Events_InfoMessage& theError) const
1575 std::shared_ptr<SketchPlugin_MacroArc> anArcFeature =
1576 std::dynamic_pointer_cast<SketchPlugin_MacroArc>(theAttribute->owner());
1577 AttributeRefAttrPtr anEndPointRef = anArcFeature->refattr(theArguments.front());
1579 if(!anEndPointRef.get()) {
1583 GeomShapePtr anArcShape = toInfiniteEdge(anArcFeature->getArcShape(false));
1585 if(!anArcShape.get() || anArcShape->isNull()) {
1589 ObjectPtr anObject = anEndPointRef->object();
1590 AttributePtr anAttr = anEndPointRef->attr();
1591 if(!anObject.get() && !anAttr.get()) {
1595 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
1597 GeomShapePtr aShape = aResult->shape();
1598 if (!aShape->isEdge())
1600 aShape = toInfiniteEdge(aShape);
1601 if(aShape.get() && !aShape->isNull()) {
1602 if(anArcShape->isIntersect(aShape)) {
1608 FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(anObject);
1609 if(aSelectedFeature.get()) {
1610 std::list<ResultPtr> aResults = aSelectedFeature->results();
1611 for(std::list<ResultPtr>::const_iterator anIt = aResults.cbegin();
1612 anIt != aResults.cend();
1615 GeomShapePtr aShape = (*anIt)->shape();
1616 if (!aShape->isEdge())
1618 aShape = toInfiniteEdge(aShape);
1619 if(aShape.get() && !aShape->isNull()) {
1620 if(anArcShape->isIntersect(aShape)) {
1630 bool SketchPlugin_HasNoConstraint::isValid(const AttributePtr& theAttribute,
1631 const std::list<std::string>& theArguments,
1632 Events_InfoMessage& theError) const
1634 std::set<std::string> aFeatureKinds;
1635 for (std::list<std::string>::const_iterator anArgIt = theArguments.begin();
1636 anArgIt != theArguments.end(); anArgIt++) {
1637 aFeatureKinds.insert(*anArgIt);
1640 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
1641 theError = "The attribute with the %1 type is not processed";
1642 theError.arg(theAttribute->attributeType());
1646 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
1648 bool isObject = aRefAttr->isObject();
1650 theError = "It uses an empty object";
1653 ObjectPtr anObject = aRefAttr->object();
1654 FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
1655 if (!aFeature.get()) {
1656 theError = "The feature of the checked attribute is empty";
1660 FeaturePtr aCurrentFeature = ModelAPI_Feature::feature(aRefAttr->owner());
1662 std::set<AttributePtr> aRefsList = anObject->data()->refsToMe();
1663 std::set<AttributePtr>::const_iterator anIt = aRefsList.begin();
1664 for (; anIt != aRefsList.end(); anIt++) {
1665 FeaturePtr aRefFeature = ModelAPI_Feature::feature((*anIt)->owner());
1666 if (aRefFeature.get() && aCurrentFeature != aRefFeature &&
1667 aFeatureKinds.find(aRefFeature->getKind()) != aFeatureKinds.end())
1668 return false; // constraint is found, that means that the check is not valid
1673 bool SketchPlugin_ReplicationReferenceValidator::isValid(
1674 const AttributePtr& theAttribute,
1675 const std::list<std::string>& theArguments,
1676 Events_InfoMessage& theError) const
1678 AttributeRefAttrPtr aRefAttr =
1679 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
1682 theError = "Incorrect attribute";
1687 if (aRefAttr->isObject())
1688 anOwner = aRefAttr->object();
1691 AttributePtr anAttr = aRefAttr->attr();
1692 anOwner = anAttr->owner();
1694 FeaturePtr anAttrOwnerFeature = ModelAPI_Feature::feature(anOwner);
1695 if (!anAttrOwnerFeature)
1697 AttributeBooleanPtr aCopyAttr = anAttrOwnerFeature->boolean(SketchPlugin_SketchEntity::COPY_ID());
1698 if (!aCopyAttr || !aCopyAttr->value())
1699 return true; // feature is not a copy, thus valid
1701 // check the copy feature is already referred by the "Multi" feature
1702 FeaturePtr aMultiFeature = ModelAPI_Feature::feature(theAttribute->owner());
1703 AttributeRefListPtr aRefList = aMultiFeature->reflist(theArguments.front());
1704 for (int i = 0; i < aRefList->size(); ++i)
1706 FeaturePtr aRefOwner = ModelAPI_Feature::feature(aRefList->object(i));
1707 if (aRefOwner == anAttrOwnerFeature)
1709 theError = "Attribute refers to the object generated by this feature";
1717 bool SketchPlugin_SketchFeatureValidator::isValid(const AttributePtr& theAttribute,
1718 const std::list<std::string>& theArguments,
1719 Events_InfoMessage& theError) const
1721 if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
1722 theError = "The attribute with the %1 type is not processed";
1723 theError.arg(theAttribute->attributeType());
1727 // check the attribute refers to a sketch feature
1728 AttributeRefAttrPtr aRefAttr =
1729 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
1730 bool isSketchFeature = aRefAttr->isObject();
1731 if (isSketchFeature) {
1732 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
1733 isSketchFeature = aFeature.get() != NULL;
1734 if (isSketchFeature) {
1735 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
1736 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
1737 isSketchFeature = aSketchFeature.get() != NULL;
1741 if (isSketchFeature)
1744 theError = "The object selected is not a sketch feature";
1748 bool SketchPlugin_MultiRotationAngleValidator::isValid(const AttributePtr& theAttribute,
1749 const std::list<std::string>& theArguments,
1750 Events_InfoMessage& theError) const
1752 if (theAttribute->attributeType() != ModelAPI_AttributeDouble::typeId()) {
1753 theError = "The attribute with the %1 type is not processed";
1754 theError.arg(theAttribute->attributeType());
1758 AttributeDoublePtr anAngleAttr =
1759 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
1761 FeaturePtr aMultiRotation = ModelAPI_Feature::feature(theAttribute->owner());
1762 AttributeStringPtr anAngleType =
1763 aMultiRotation->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
1764 AttributeIntegerPtr aNbCopies =
1765 aMultiRotation->integer(SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID());
1767 if (anAngleType->value() != "FullAngle")
1769 double aFullAngleValue = anAngleAttr->value() * (aNbCopies->value() - 1);
1770 if (aFullAngleValue < -1.e-7 || aFullAngleValue > 359.9999999)
1772 theError = "Rotation single angle should produce full angle less than 360 degree";
1778 double aFullAngleValue = anAngleAttr->value();
1779 if (aFullAngleValue < -1.e-7 || aFullAngleValue > 360.0000001)
1781 theError = "Rotation full angle should be in range [0, 360]";
1789 bool SketchPlugin_BSplineValidator::isValid(const AttributePtr& theAttribute,
1790 const std::list<std::string>& theArguments,
1791 Events_InfoMessage& theError) const
1793 AttributePoint2DArrayPtr aPolesArray =
1794 std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(theAttribute);
1798 if (aPolesArray->size() < 2) {
1799 theError = "Number of B-spline poles should be 2 or more";