* Dump auxiliary objects as features produces by the ellipse.
* Unit tests for ellipse creation and movement.
%include "std_pair.i"
%include "std_shared_ptr.i"
+// function with named parameters
+%feature("kwargs") SketchAPI_Ellipse::construction;
+
// shared pointers
%shared_ptr(SketchAPI_Arc)
%shared_ptr(SketchAPI_MacroArc)
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+#include <SketchPlugin_ConstraintCoincidenceInternal.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Point.h>
+
+static const std::string AUXILIARY_VALUE = "aux";
+static const std::string MAJOR_AXIS_ID = "majorAxis";
+static const std::string MINOR_AXIS_ID = "minorAxis";
+
SketchAPI_Ellipse::SketchAPI_Ellipse(const std::shared_ptr<ModelAPI_Feature> & theFeature)
: SketchAPI_SketchEntity(theFeature)
{
return ModelHighAPI_Selection();
}
+static CompositeFeaturePtr sketchForFeature(FeaturePtr theFeature)
+{
+ const std::set<AttributePtr>& aRefs = theFeature->data()->refsToMe();
+ for (std::set<AttributePtr>::const_iterator anIt = aRefs.begin(); anIt != aRefs.end(); ++anIt)
+ if ((*anIt)->id() == SketchPlugin_Sketch::FEATURES_ID())
+ return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>((*anIt)->owner());
+ return CompositeFeaturePtr();
+}
+
+static void createInternalConstraint(const CompositeFeaturePtr& theSketch,
+ const AttributePoint2DPtr& thePoint1,
+ const AttributePoint2DPtr& thePoint2)
+{
+ FeaturePtr aConstraint = theSketch->addFeature(SketchPlugin_ConstraintCoincidenceInternal::ID());
+ aConstraint->refattr(SketchPlugin_Constraint::ENTITY_A())->setAttr(thePoint1);
+ aConstraint->refattr(SketchPlugin_Constraint::ENTITY_B())->setAttr(thePoint2);
+ aConstraint->execute();
+}
+
+static FeaturePtr createPoint(const CompositeFeaturePtr& theSketch,
+ const AttributePtr& theCoincident,
+ const std::string& theAuxOrName)
+{
+ AttributePoint2DPtr anElPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theCoincident);
+
+ FeaturePtr aPointFeature = theSketch->addFeature(SketchPlugin_Point::ID());
+ AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aPointFeature->attribute(SketchPlugin_Point::COORD_ID()));
+ aCoord->setValue(anElPoint->x(), anElPoint->y());
+ aPointFeature->execute();
+
+ if (theAuxOrName == AUXILIARY_VALUE)
+ aPointFeature->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true);
+ else if (!theAuxOrName.empty()) {
+ aPointFeature->data()->setName(theAuxOrName);
+ aPointFeature->lastResult()->data()->setName(theAuxOrName);
+ }
+
+ createInternalConstraint(theSketch, anElPoint, aCoord);
+
+ return aPointFeature;
+}
+
+static FeaturePtr createAxis(const CompositeFeaturePtr& theSketch,
+ const AttributePtr& theCoincidentStart,
+ const AttributePtr& theCoincidentEnd,
+ const std::string& theAuxOrName)
+{
+ AttributePoint2DPtr aStartPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theCoincidentStart);
+ AttributePoint2DPtr aEndPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theCoincidentEnd);
+
+ FeaturePtr aLineFeature = theSketch->addFeature(SketchPlugin_Line::ID());
+ AttributePoint2DPtr aLineStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aLineFeature->attribute(SketchPlugin_Line::START_ID()));
+ aLineStart->setValue(aStartPoint->x(), aStartPoint->y());
+ AttributePoint2DPtr aLineEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aLineFeature->attribute(SketchPlugin_Line::END_ID()));
+ aLineEnd->setValue(aEndPoint->x(), aEndPoint->y());
+ aLineFeature->execute();
+
+ if (theAuxOrName == AUXILIARY_VALUE)
+ aLineFeature->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true);
+ else if (!theAuxOrName.empty()) {
+ aLineFeature->data()->setName(theAuxOrName);
+ aLineFeature->lastResult()->data()->setName(theAuxOrName);
+ }
+
+ createInternalConstraint(theSketch, aStartPoint, aLineStart);
+ createInternalConstraint(theSketch, aEndPoint, aLineEnd);
+
+ return aLineFeature;
+}
+
+std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Ellipse::construction(
+ const std::string& center,
+ const std::string& firstFocus,
+ const std::string& secondFocus,
+ const std::string& majorAxisStart,
+ const std::string& majorAxisEnd,
+ const std::string& minorAxisStart,
+ const std::string& minorAxisEnd,
+ const std::string& majorAxis,
+ const std::string& minorAxis) const
+{
+ FeaturePtr anEllipse = feature();
+ CompositeFeaturePtr aSketch = sketchForFeature(anEllipse);
+
+ std::list<FeaturePtr> anEntities;
+ if (!center.empty()) {
+ AttributePtr aCenterAttr = anEllipse->attribute(SketchPlugin_Ellipse::CENTER_ID());
+ anEntities.push_back(createPoint(aSketch, aCenterAttr, center));
+ }
+ if (!firstFocus.empty()) {
+ AttributePtr aFocusAttr = anEllipse->attribute(SketchPlugin_Ellipse::FIRST_FOCUS_ID());
+ anEntities.push_back(createPoint(aSketch, aFocusAttr, firstFocus));
+ }
+ if (!secondFocus.empty()) {
+ AttributePtr aFocusAttr = anEllipse->attribute(SketchPlugin_Ellipse::SECOND_FOCUS_ID());
+ anEntities.push_back(createPoint(aSketch, aFocusAttr, secondFocus));
+ }
+ if (!majorAxisStart.empty()) {
+ AttributePtr aStartAttr = anEllipse->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_START_ID());
+ anEntities.push_back(createPoint(aSketch, aStartAttr, majorAxisStart));
+ }
+ if (!majorAxisEnd.empty()) {
+ AttributePtr aEndAttr = anEllipse->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID());
+ anEntities.push_back(createPoint(aSketch, aEndAttr, majorAxisEnd));
+ }
+ if (!minorAxisStart.empty()) {
+ AttributePtr aStartAttr = anEllipse->attribute(SketchPlugin_Ellipse::MINOR_AXIS_START_ID());
+ anEntities.push_back(createPoint(aSketch, aStartAttr, minorAxisStart));
+ }
+ if (!minorAxisEnd.empty()) {
+ AttributePtr aEndAttr = anEllipse->attribute(SketchPlugin_Ellipse::MINOR_AXIS_END_ID());
+ anEntities.push_back(createPoint(aSketch, aEndAttr, minorAxisEnd));
+ }
+ if (!majorAxis.empty()) {
+ AttributePtr aStartAttr = anEllipse->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_START_ID());
+ AttributePtr aEndAttr = anEllipse->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID());
+ anEntities.push_back(createAxis(aSketch, aStartAttr, aEndAttr, majorAxis));
+ }
+ if (!minorAxis.empty()) {
+ AttributePtr aStartAttr = anEllipse->attribute(SketchPlugin_Ellipse::MINOR_AXIS_START_ID());
+ AttributePtr aEndAttr = anEllipse->attribute(SketchPlugin_Ellipse::MINOR_AXIS_END_ID());
+ anEntities.push_back(createAxis(aSketch, aStartAttr, aEndAttr, minorAxis));
+ }
+
+ return SketchAPI_SketchEntity::wrap(anEntities);
+}
+
+static void ellipseAttributeAndAuxiliaryFeature(
+ const FeaturePtr& theInternalConstraint,
+ std::map<std::string, FeaturePtr>& theAttrToFeature)
+{
+ AttributeRefAttrPtr aRefAttrA =
+ theInternalConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
+ AttributeRefAttrPtr aRefAttrB =
+ theInternalConstraint->refattr(SketchPlugin_Constraint::ENTITY_B());
+ // the first point is usually an ellipse attribute
+ // and the second point is an attribute of the auxiliary feature
+ ObjectPtr anAuxObject;
+ if (aRefAttrB->isObject())
+ anAuxObject = aRefAttrB->object();
+ else
+ anAuxObject = aRefAttrB->attr()->owner();
+
+ FeaturePtr anAuxFeature = ModelAPI_Feature::feature(anAuxObject);
+ if (anAuxFeature->getKind() == SketchPlugin_Point::ID())
+ theAttrToFeature[aRefAttrA->attr()->id()] = anAuxFeature;
+ else {
+ const std::string& anAttrID = aRefAttrA->attr()->id();
+ if (anAttrID == SketchPlugin_Ellipse::MAJOR_AXIS_START_ID() ||
+ anAttrID == SketchPlugin_Ellipse::MAJOR_AXIS_END_ID())
+ theAttrToFeature[MAJOR_AXIS_ID] = anAuxFeature;
+ else if (anAttrID == SketchPlugin_Ellipse::MINOR_AXIS_START_ID() ||
+ anAttrID == SketchPlugin_Ellipse::MINOR_AXIS_END_ID())
+ theAttrToFeature[MINOR_AXIS_ID] = anAuxFeature;
+ }
+}
+
void SketchAPI_Ellipse::dump(ModelHighAPI_Dumper& theDumper) const
{
if (isCopy())
}
// dump "auxiliary" flag if necessary
SketchAPI_SketchEntity::dump(theDumper);
+
+ // dump auxiliary features produced by ellipse
+ std::map<std::string, FeaturePtr> anAuxFeatures;
+ const std::set<AttributePtr>& aRefs = aBase->data()->refsToMe();
+ for (std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
+ aRefIt != aRefs.end(); ++aRefIt) {
+ FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner());
+ if (anOwner->getKind() != SketchPlugin_ConstraintCoincidenceInternal::ID())
+ continue; // process internal constraints only
+ ellipseAttributeAndAuxiliaryFeature(anOwner, anAuxFeatures);
+ }
+ if (!anAuxFeatures.empty()) {
+ typedef std::pair<std::string, std::string> PairOfStrings;
+ static PairOfStrings anAttributes[] = {
+ PairOfStrings(SketchPlugin_Ellipse::CENTER_ID(), "center"),
+ PairOfStrings(SketchPlugin_Ellipse::FIRST_FOCUS_ID(), "firstFocus"),
+ PairOfStrings(SketchPlugin_Ellipse::SECOND_FOCUS_ID(), "secondFocus"),
+ PairOfStrings(SketchPlugin_Ellipse::MAJOR_AXIS_START_ID(), "majorAxisStart"),
+ PairOfStrings(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID(), "majorAxisEnd"),
+ PairOfStrings(SketchPlugin_Ellipse::MINOR_AXIS_START_ID(), "minorAxisStart"),
+ PairOfStrings(SketchPlugin_Ellipse::MINOR_AXIS_END_ID(), "minorAxisEnd"),
+ PairOfStrings(MAJOR_AXIS_ID, MAJOR_AXIS_ID),
+ PairOfStrings(MINOR_AXIS_ID, MINOR_AXIS_ID)
+ };
+
+ theDumper << "[";
+ bool isFirst = true;
+ for (PairOfStrings* anIt = std::begin(anAttributes);
+ anIt != std::end(anAttributes); ++anIt) {
+ std::map<std::string, FeaturePtr>::iterator aFound = anAuxFeatures.find(anIt->first);
+ if (aFound == anAuxFeatures.end())
+ continue;
+ if (!isFirst)
+ theDumper << ", ";
+ theDumper << theDumper.name(aFound->second, false);
+ theDumper.doNotDumpFeature(aFound->second);
+ isFirst = false;
+ }
+ theDumper << "] = " << theDumper.name(aBase) << ".construction(";
+ isFirst = true;
+ for (PairOfStrings* anIt = std::begin(anAttributes);
+ anIt != std::end(anAttributes); ++anIt) {
+ std::map<std::string, FeaturePtr>::iterator aFound = anAuxFeatures.find(anIt->first);
+ if (aFound == anAuxFeatures.end())
+ continue;
+ if (!isFirst)
+ theDumper << ", ";
+ isFirst = false;
+ theDumper << anIt->second << " = \"";
+ if (aFound->second->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value())
+ theDumper << AUXILIARY_VALUE;
+ else
+ theDumper << aFound->second->name();
+ theDumper << "\"";
+ }
+ theDumper << ")" << std::endl;
+ }
}
SKETCHAPI_EXPORT
ModelHighAPI_Selection minorAxis() const;
+ /// Create construction elements (focuses, axes etc.).
+ /// Empty value for each parameter shows that the corresponding feature has been removed.
+ /// Value "aux" marks this feature as auxiliary.
+ /// And the name of the feature shows that it is a regular feature.
+ SKETCHAPI_EXPORT
+ std::list<std::shared_ptr<SketchAPI_SketchEntity> > construction(
+ const std::string& center = std::string(),
+ const std::string& firstFocus = std::string(),
+ const std::string& secondFocus = std::string(),
+ const std::string& majorAxisStart = std::string(),
+ const std::string& majorAxisEnd = std::string(),
+ const std::string& minorAxisStart = std::string(),
+ const std::string& minorAxisEnd = std::string(),
+ const std::string& majorAxis = std::string(),
+ const std::string& minorAxis = std::string()) const;
+
/// Dump wrapped feature
SKETCHAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_MacroEllipse::ID());
return MacroEllipsePtr(new SketchAPI_MacroEllipse(aFeature,
- thePoint1X, thePoint1Y, thePoint2X, thePoint1Y, thePassedX, thePassedY, isPoint1Center));
+ thePoint1X, thePoint1Y, thePoint2X, thePoint2Y, thePassedX, thePassedY, isPoint1Center));
}
std::shared_ptr<SketchAPI_MacroEllipse> SketchAPI_Sketch::addEllipse(
return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y));
}
+static std::shared_ptr<GeomAPI_Pnt2d> pointOnEllipse(const FeaturePtr& theFeature)
+{
+ AttributePoint2DPtr aMajorAxisEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theFeature->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID()));
+ return aMajorAxisEnd ? aMajorAxisEnd->pnt() : std::shared_ptr<GeomAPI_Pnt2d>();
+}
+
static std::shared_ptr<GeomAPI_Pnt2d> middlePoint(const ObjectPtr& theObject)
{
std::shared_ptr<GeomAPI_Pnt2d> aMiddlePoint;
aMiddlePoint = pointOnCircle(aFeature);
else if (aFeatureKind == SketchPlugin_Arc::ID())
aMiddlePoint = middlePointOnArc(aFeature);
+ else if (aFeatureKind == SketchPlugin_Ellipse::ID())
+ aMiddlePoint = pointOnEllipse(aFeature);
}
return aMiddlePoint;
}
TestCreateCircleByCenterAndPassed.py
TestCreateCircleByThreePoints.py
TestCreateCircleChangeType.py
+ TestCreateEllipseByCenterSemiaxisAndPassed.py
+ TestCreateEllipseByMajorAxisAndPassed.py
+ TestCreateEllipseByExternal.py
TestDegeneratedGeometry.py
TestDistanceDump.py
TestDistanceSignedVsUnsigned01.py
ADD_UNIT_TESTS(
TestMoveArc.py
TestMoveCircle.py
+ TestMoveEllipse.py
TestMoveLine.py
TestMovementComplex.py
TestMovePoint.py
// Calculate all characteristics of the ellipse.
fillCharacteristicPoints();
- // Make a visible center of the ellipse.
- int aResultIndex = 0;
- SketchPlugin_Sketch::createPoint2DResult(this, aSketch, CENTER_ID(), aResultIndex++);
// Make a visible ellipse.
- createEllipse(aSketch, aResultIndex);
+ createEllipse(aSketch, 0);
}
bool SketchPlugin_Ellipse::isFixed() {
this, SECOND_POINT_REF_ID(),
theEllipseFeature->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID()),
ObjectPtr(), isTangencyApplicable);
- SketchPlugin_Tools::createCoincidenceOrTangency(
- this, PASSED_POINT_REF_ID(), AttributePtr(),
- theEllipseFeature->lastResult(), isTangencyApplicable);
+ // make coincidence only if PASSED_POINT_REF_ID() refers a point but not an object
+ if (!refattr(PASSED_POINT_REF_ID())->isObject()) {
+ SketchPlugin_Tools::createCoincidenceOrTangency(
+ this, PASSED_POINT_REF_ID(), AttributePtr(),
+ theEllipseFeature->lastResult(), isTangencyApplicable);
+ }
}
void SketchPlugin_MacroEllipse::constraintsForEllipseByMajoxAxisAndPassed(
this, SECOND_POINT_REF_ID(),
theEllipseFeature->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_END_ID()),
ObjectPtr(), isTangencyApplicable);
- SketchPlugin_Tools::createCoincidenceOrTangency(
- this, PASSED_POINT_REF_ID(), AttributePtr(),
- theEllipseFeature->lastResult(), isTangencyApplicable);
+ // make coincidence only if PASSED_POINT_REF_ID() refers a point but not an object
+ if (!refattr(PASSED_POINT_REF_ID())->isObject()) {
+ SketchPlugin_Tools::createCoincidenceOrTangency(
+ this, PASSED_POINT_REF_ID(), AttributePtr(),
+ theEllipseFeature->lastResult(), isTangencyApplicable);
+ }
}
FeaturePtr SketchPlugin_MacroEllipse::createEllipseFeature()
aEllipseFeature->execute();
// create auxiliary points
+ createAuxiliaryPoint(aEllipseFeature->attribute(SketchPlugin_Ellipse::CENTER_ID()));
createAuxiliaryPoint(aEllipseFeature->attribute(SketchPlugin_Ellipse::FIRST_FOCUS_ID()));
createAuxiliaryPoint(aEllipseFeature->attribute(SketchPlugin_Ellipse::SECOND_FOCUS_ID()));
createAuxiliaryPoint(aEllipseFeature->attribute(SketchPlugin_Ellipse::MAJOR_AXIS_START_ID()));
--- /dev/null
+# Copyright (C) 2019 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+ Test creation of ellipse by center, semi-axis and passed point
+"""
+
+import unittest
+from salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+__updated__ = "2019-09-09"
+
+class TestEllipse(unittest.TestCase):
+ def setUp(self):
+ model.begin()
+ self.myDocument = model.moduleDocument()
+ self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
+ self.myCenter = GeomAPI_Pnt2d(50., 50.)
+ self.myFocus = GeomAPI_Pnt2d(70., 50.)
+ self.myPassedPoint = GeomAPI_Pnt2d(60., 60.)
+ self.myMinorRadius = 20.
+ self.myDOF = 0
+
+ def tearDown(self):
+ self.checkDOF()
+ model.end()
+
+
+ def checkDOF(self):
+ self.assertEqual(model.dof(self.mySketch), self.myDOF)
+
+ def checkPointsEqual(self, thePoint1, thePoint2):
+ self.assertAlmostEqual(thePoint1.x(), thePoint2.x(), 5)
+ self.assertAlmostEqual(thePoint1.y(), thePoint2.y(), 5)
+
+ def checkPointOnLine(self, theCoordinates, theLine):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ dist = model.distancePointLine(point, theLine)
+ self.assertAlmostEqual(dist, 0, 7)
+
+ def checkPointOnCircle(self, theCoordinates, theCircle):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ dist = model.distancePointPoint(point, theCircle.center())
+ self.assertAlmostEqual(dist , theCircle.radius().value(), 7)
+
+ def checkPointOnEllipse(self, theCoordinates, theEllipse):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ firstFocus2d = GeomAPI_Pnt2d(theEllipse.firstFocus().x(), theEllipse.firstFocus().y())
+ distPF1 = model.distancePointPoint(firstFocus2d, point)
+ secondFocus2d = GeomAPI_Pnt2d(theEllipse.secondFocus().x(), theEllipse.secondFocus().y())
+ distPF2 = model.distancePointPoint(secondFocus2d, point)
+ if issubclass(type(theEllipse), SketchAPI_Ellipse):
+ majorRad = theEllipse.majorRadius().value()
+ else:
+ majorRad = theEllipse.majorRadius()
+ self.assertAlmostEqual(distPF1 + distPF2, 2.0 * majorRad, 7)
+
+
+ def test_ellipse_by_center_and_focus(self):
+ """ Test 1. Create ellipse by coordinates of center, focus and minor radius
+ """
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter.x(), self.myCenter.y(), self.myFocus.x(), self.myFocus.y(), self.myMinorRadius)
+ self.myDOF += 5
+
+ self.myEllipse2 = self.mySketch.addEllipse(self.myCenter, self.myFocus, self.myMinorRadius)
+ self.myDOF += 5
+ model.do()
+
+ # check both ellipses are equal
+ anEllipse1 = self.myEllipse1.defaultResult().shape().edge().ellipse()
+ anEllipse2 = self.myEllipse2.defaultResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse1.center(), anEllipse2.center())
+ self.checkPointsEqual(anEllipse1.firstFocus(), anEllipse2.firstFocus())
+ self.checkPointsEqual(anEllipse1.secondFocus(), anEllipse2.secondFocus())
+ self.assertAlmostEqual(anEllipse1.minorRadius(), anEllipse2.minorRadius())
+ self.assertAlmostEqual(anEllipse1.majorRadius(), anEllipse2.majorRadius())
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 0)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 0)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+
+ def test_ellipse_by_semiaxis_and_passed(self):
+ """ Test 2. Create ellipse by coordinates of center, major semi-axis point and a passed point on ellipse
+ """
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter.x(), self.myCenter.y(), self.myFocus.x(), self.myFocus.y(), self.myPassedPoint.x(), self.myPassedPoint.y(), True)
+ self.myDOF += 5
+ model.do()
+ anEllipseFeature1 = model.lastSubFeature(self.mySketch, "SketchEllipse")
+
+ self.myEllipse2 = self.mySketch.addEllipse(self.myCenter, self.myFocus, self.myPassedPoint, True)
+ self.myDOF += 5
+ model.do()
+ anEllipseFeature2 = model.lastSubFeature(self.mySketch, "SketchEllipse")
+
+ # check both ellipses are equal
+ anEllipse1 = anEllipseFeature1.lastResult().shape().edge().ellipse()
+ anEllipse2 = anEllipseFeature2.lastResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse1.center(), anEllipse2.center())
+ self.checkPointsEqual(anEllipse1.firstFocus(), anEllipse2.firstFocus())
+ self.checkPointsEqual(anEllipse1.secondFocus(), anEllipse2.secondFocus())
+ self.assertAlmostEqual(anEllipse1.minorRadius(), anEllipse2.minorRadius())
+ self.assertAlmostEqual(anEllipse1.majorRadius(), anEllipse2.majorRadius())
+ # check passed point on ellipse
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse1)
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse2)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 14)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 4)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+
+ def test_ellipse_with_fixed_center(self):
+ """ Test 3. Create ellipse which center is coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(aLine.endPoint(), self.myFocus, self.myPassedPoint, True)
+ self.myDOF += 3
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse.center(), aLine.endPoint())
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_center_on_line(self):
+ """ Test 4. Create ellipse which center is coincident with a line
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myCenter, aLine.result()], self.myFocus, self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ # check center on line
+ self.checkPointOnLine(anEllipse.center(), aLine)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_center_on_circle(self):
+ """ Test 5. Create ellipse which center is coincident with a circle
+ """
+ aCircle = self.mySketch.addCircle(10, 10, 20)
+ self.myDOF += 3
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myCenter, aCircle.defaultResult()], self.myFocus, self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ # check center on circle
+ self.checkPointOnCircle(anEllipse.center(), aCircle)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchCircle", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_center_on_ellipse(self):
+ """ Test 6. Create ellipse which center is coincident with another ellipse
+ """
+ anOtherEllipse = self.mySketch.addEllipse(10, 10, 30, 20, 10)
+ self.myDOF += 5
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myCenter, anOtherEllipse.defaultResult()], self.myFocus, self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ # check center on ellipse
+ self.checkPointOnEllipse(anEllipse.center(), anOtherEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_fixed_axis(self):
+ """ Test 7. Create ellipse which point on major semi-axis is coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, aLine.endPoint(), self.myPassedPoint, True)
+ self.myDOF += 3
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ self.checkPointOnEllipse(aLine.endPoint(), anEllipse)
+ # check distance is equal to major semi-axis
+ dist = model.distancePointPoint(GeomAPI_Pnt2d(anEllipse.center().x(), anEllipse.center().y()), aLine.endPoint())
+ self.assertAlmostEqual(dist, anEllipse.majorRadius(), 7)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_on_line(self):
+ """ Test 8. Create ellipse which point on major semi-axis is coincident with a line
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, [self.myFocus, aLine.result()], self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check axis point on line
+ self.checkPointOnLine(anEllipse.majorAxisPositive(), aLine)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_on_circle(self):
+ """ Test 9. Create ellipse which point on major semi-axis is coincident with a circle
+ """
+ aCircle = self.mySketch.addCircle(10, 10, 20)
+ self.myDOF += 3
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, [self.myFocus, aCircle.defaultResult()], self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on circle
+ self.checkPointOnCircle(anEllipse.majorAxisPositive(), aCircle)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchCircle", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_on_ellipse(self):
+ """ Test 10. Create ellipse which point on major semi-axis is coincident with another ellipse
+ """
+ anOtherEllipse = self.mySketch.addEllipse(10, 10, 90, 40, 30)
+ self.myDOF += 5
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, [self.myFocus, anOtherEllipse.defaultResult()], self.myPassedPoint, True)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on ellipse
+ self.checkPointOnEllipse(anEllipse.majorAxisPositive(), anOtherEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_fixed_passed_point(self):
+ """ Test 11. Create ellipse which passed point is coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, self.myFocus, aLine.endPoint(), True)
+ self.myDOF += 4
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(aLine.endPoint(), anEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_passed_point_on_line(self):
+ """ Test 12. Create ellipse which passed point is placed on a line.
+ Check no constraints is applied.
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myCenter, self.myFocus, [self.myPassedPoint, aLine.result()], True)
+ self.myDOF += 5
+ model.do()
+
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ # check neither coincidence nor tangent feature exists
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 0)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintTangent", 0)
+
+
+if __name__ == "__main__":
+ test_program = unittest.main(exit=False)
+ assert test_program.result.wasSuccessful(), "Test failed"
+ assert model.checkPythonDump()
--- /dev/null
+# Copyright (C) 2019 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+ Test creation of ellipse by external feature
+"""
+
+import unittest
+from salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+__updated__ = "2019-09-12"
+
+# reference data
+CENTER_POINT = GeomAPI_Pnt2d(50., 50.)
+FOCUS_POINT = GeomAPI_Pnt2d(70., 60.)
+MINOR_RADIUS = 10.
+
+class TestEllipse(unittest.TestCase):
+ def setUp(self):
+ model.begin()
+ self.myDocument = model.moduleDocument()
+ self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
+ self.myDOF = 0
+
+ def tearDown(self):
+ self.checkDOF()
+ model.end()
+
+
+ def checkDOF(self):
+ self.assertEqual(model.dof(self.mySketch), self.myDOF)
+
+ def checkPointsEqual(self, thePoint1, thePoint2):
+ self.assertAlmostEqual(thePoint1.x(), thePoint2.x(), 5)
+ self.assertAlmostEqual(thePoint1.y(), thePoint2.y(), 5)
+
+
+ def test_ellipse_by_external_name(self):
+ """ Test 1. Create ellipse by name of external edge
+ """
+ self.myEllipse = self.mySketch.addEllipse("Sketch_1/SketchEllipse_1")
+ model.do()
+
+ # check ellipse parameters
+ anEllipse = self.myEllipse.defaultResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse.center(), CENTER_POINT)
+ self.checkPointsEqual(anEllipse.firstFocus(), FOCUS_POINT)
+ self.assertAlmostEqual(anEllipse.minorRadius(), MINOR_RADIUS)
+
+ def test_ellipse_by_external_selection(self):
+ """ Test 2. Create ellipse by selected edge
+ """
+ self.myEllipse = self.mySketch.addEllipse(ELLIPSE.results()[-1])
+ model.do()
+
+ # check ellipse parameters
+ anEllipse = self.myEllipse.defaultResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse.center(), CENTER_POINT)
+ self.checkPointsEqual(anEllipse.firstFocus(), FOCUS_POINT)
+ self.assertAlmostEqual(anEllipse.minorRadius(), MINOR_RADIUS)
+
+
+if __name__ == "__main__":
+ model.begin()
+ aDocument = model.moduleDocument()
+ aSketch = model.addSketch(aDocument, model.defaultPlane("XOY"))
+ ELLIPSE = aSketch.addEllipse(CENTER_POINT, FOCUS_POINT, MINOR_RADIUS)
+ model.end()
+
+ test_program = unittest.main(exit=False)
+ assert test_program.result.wasSuccessful(), "Test failed"
+ assert model.checkPythonDump()
--- /dev/null
+# Copyright (C) 2019 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+ Test creation of ellipse by majoraxis and passed point
+"""
+
+import unittest
+from salome.shaper import model
+
+from GeomAPI import *
+from SketchAPI import *
+
+__updated__ = "2019-09-12"
+
+class TestEllipse(unittest.TestCase):
+ def setUp(self):
+ model.begin()
+ self.myDocument = model.moduleDocument()
+ self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
+ self.myAxisStart = GeomAPI_Pnt2d(30., 60.)
+ self.myAxisEnd = GeomAPI_Pnt2d(80., 50.)
+ self.myPassedPoint = GeomAPI_Pnt2d(60., 60.)
+ self.myDOF = 0
+
+ def tearDown(self):
+ self.checkDOF()
+ model.end()
+
+
+ def checkDOF(self):
+ self.assertEqual(model.dof(self.mySketch), self.myDOF)
+
+ def checkPointsEqual(self, thePoint1, thePoint2):
+ self.assertAlmostEqual(thePoint1.x(), thePoint2.x(), 5)
+ self.assertAlmostEqual(thePoint1.y(), thePoint2.y(), 5)
+
+ def checkPointOnLine(self, theCoordinates, theLine):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ dist = model.distancePointLine(point, theLine)
+ self.assertAlmostEqual(dist, 0, 7)
+
+ def checkPointOnCircle(self, theCoordinates, theCircle):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ dist = model.distancePointPoint(point, theCircle.center())
+ self.assertAlmostEqual(dist , theCircle.radius().value(), 7)
+
+ def checkPointOnEllipse(self, theCoordinates, theEllipse):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ firstFocus2d = GeomAPI_Pnt2d(theEllipse.firstFocus().x(), theEllipse.firstFocus().y())
+ distPF1 = model.distancePointPoint(firstFocus2d, point)
+ secondFocus2d = GeomAPI_Pnt2d(theEllipse.secondFocus().x(), theEllipse.secondFocus().y())
+ distPF2 = model.distancePointPoint(secondFocus2d, point)
+ self.assertAlmostEqual(distPF1 + distPF2, 2.0 * theEllipse.majorRadius(), 7)
+
+
+ def test_ellipse_by_axis_and_passed(self):
+ """ Test 1. Create ellipse by points defining major semi-axis and a passed point on ellipse
+ """
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart.x(), self.myAxisStart.y(), self.myAxisEnd.x(), self.myAxisEnd.y(), self.myPassedPoint.x(), self.myPassedPoint.y(), False)
+ self.myDOF += 5
+ model.do()
+ anEllipseFeature1 = model.lastSubFeature(self.mySketch, "SketchEllipse")
+
+ self.myEllipse2 = self.mySketch.addEllipse(self.myAxisStart, self.myAxisEnd, self.myPassedPoint, False)
+ self.myDOF += 5
+ model.do()
+ anEllipseFeature2 = model.lastSubFeature(self.mySketch, "SketchEllipse")
+
+ # check both ellipses are equal
+ anEllipse1 = anEllipseFeature1.lastResult().shape().edge().ellipse()
+ anEllipse2 = anEllipseFeature2.lastResult().shape().edge().ellipse()
+ self.checkPointsEqual(anEllipse1.center(), anEllipse2.center())
+ self.checkPointsEqual(anEllipse1.firstFocus(), anEllipse2.firstFocus())
+ self.checkPointsEqual(anEllipse1.secondFocus(), anEllipse2.secondFocus())
+ self.assertAlmostEqual(anEllipse1.minorRadius(), anEllipse2.minorRadius())
+ self.assertAlmostEqual(anEllipse1.majorRadius(), anEllipse2.majorRadius())
+ # check passed point on ellipse
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse1)
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse2)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 14)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 4)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+
+ def test_ellipse_with_fixed_axis_start(self):
+ """ Test 2. Create ellipse which negative point on the major axis coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(aLine.startPoint(), self.myAxisEnd, self.myPassedPoint, False)
+ self.myDOF += 3
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ self.checkPointOnEllipse(aLine.startPoint(), anEllipse)
+ # check distance is equal to major semi-axis
+ dist = model.distancePointPoint(GeomAPI_Pnt2d(anEllipse.center().x(), anEllipse.center().y()), aLine.startPoint())
+ self.assertAlmostEqual(dist, anEllipse.majorRadius(), 7)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_start_on_line(self):
+ """ Test 3. Create ellipse which negative point on the major axis coincident with a line
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myAxisStart, aLine.result()], self.myAxisEnd, self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check negative point of major axis on line
+ self.checkPointOnLine(anEllipse.majorAxisNegative(), aLine)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_start_on_circle(self):
+ """ Test 4. Create ellipse which negative point on the major axis coincident with a circle
+ """
+ aCircle = self.mySketch.addCircle(10, 10, 20)
+ self.myDOF += 3
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myAxisStart, aCircle.defaultResult()], self.myAxisEnd, self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on circle
+ self.checkPointOnCircle(anEllipse.majorAxisNegative(), aCircle)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchCircle", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_start_on_ellipse(self):
+ """ Test 5. Create ellipse which negative point on the major axis coincident with another ellipse
+ """
+ anOtherEllipse = self.mySketch.addEllipse(10, 10, 30, 20, 10)
+ self.myDOF += 5
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse([self.myAxisStart, anOtherEllipse.defaultResult()], self.myAxisEnd, self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on ellipse
+ self.checkPointOnEllipse(anEllipse.majorAxisNegative(), anOtherEllipse.defaultResult().shape().edge().ellipse())
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_fixed_axis_end(self):
+ """ Test 6. Create ellipse which positive point on the major axis coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 90, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, aLine.endPoint(), self.myPassedPoint, False)
+ self.myDOF += 3
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ self.checkPointOnEllipse(aLine.endPoint(), anEllipse)
+ # check distance is equal to major semi-axis
+ dist = model.distancePointPoint(GeomAPI_Pnt2d(anEllipse.center().x(), anEllipse.center().y()), aLine.endPoint())
+ self.assertAlmostEqual(dist, anEllipse.majorRadius(), 7)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_end_on_line(self):
+ """ Test 7. Create ellipse which negative point on the major axis coincident with a line
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, [self.myAxisEnd, aLine.result()], self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check axis point on line
+ self.checkPointOnLine(anEllipse.majorAxisPositive(), aLine)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_end_on_circle(self):
+ """ Test 8. Create ellipse which negative point on the major axis coincident with a circle
+ """
+ aCircle = self.mySketch.addCircle(10, 10, 20)
+ self.myDOF += 3
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, [self.myAxisEnd, aCircle.defaultResult()], self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on circle
+ self.checkPointOnCircle(anEllipse.majorAxisPositive(), aCircle)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchCircle", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_axis_end_on_ellipse(self):
+ """ Test 9. Create ellipse which negative point on the major axis coincident with another ellipse
+ """
+ anOtherEllipse = self.mySketch.addEllipse(10, 10, 90, 40, 30)
+ self.myDOF += 5
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, [self.myAxisEnd, anOtherEllipse.defaultResult()], self.myPassedPoint, False)
+ self.myDOF += 4
+ model.do()
+
+ anEllipse = SketchAPI_Ellipse(model.lastSubFeature(self.mySketch, "SketchEllipse"))
+ # check center on ellipse
+ self.checkPointOnEllipse(anEllipse.majorAxisPositive(), anOtherEllipse.defaultResult().shape().edge().ellipse())
+ # check coincidence feature exists
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 2)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_fixed_passed_point(self):
+ """ Test 10. Create ellipse which passed point is coincident with another point
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, self.myAxisEnd, aLine.endPoint(), False)
+ self.myDOF += 4
+ model.do()
+ # check ellipse
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(aLine.endPoint(), anEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1)
+
+ def test_ellipse_with_passed_point_on_line(self):
+ """ Test 11. Create ellipse which passed point is placed on a line.
+ Check no constraints is applied.
+ """
+ aLine = self.mySketch.addLine(10, 10, 30, 40)
+ self.myDOF += 4
+ model.do()
+
+ self.myEllipse1 = self.mySketch.addEllipse(self.myAxisStart, self.myAxisEnd, [self.myPassedPoint, aLine.result()], False)
+ self.myDOF += 5
+ model.do()
+
+ anEllipseFeature = model.lastSubFeature(self.mySketch, "SketchEllipse")
+ anEllipse = anEllipseFeature.lastResult().shape().edge().ellipse()
+ self.checkPointOnEllipse(self.myPassedPoint, anEllipse)
+ # check number of features
+ model.testNbSubFeatures(self.mySketch, "SketchPoint", 7)
+ model.testNbSubFeatures(self.mySketch, "SketchLine", 3)
+ model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1)
+ # check neither coincidence nor tangent feature exists
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 0)
+ model.testNbSubFeatures(self.mySketch, "SketchConstraintTangent", 0)
+
+
+if __name__ == "__main__":
+ test_program = unittest.main(exit=False)
+ assert test_program.result.wasSuccessful(), "Test failed"
+ assert model.checkPythonDump()
--- /dev/null
+# Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+ Test movement of the sketch ellipse
+"""
+
+import unittest
+import math
+from GeomAPI import GeomAPI_Pnt2d
+from GeomDataAPI import geomDataAPI_Point2D
+from salome.shaper import model
+
+__updated__ = "2019-09-12"
+
+class TestMoveEllipse(unittest.TestCase):
+ def setUp(self):
+ model.begin()
+ self.myDocument = model.moduleDocument()
+ self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
+ self.myCenter = [70., 50.]
+ self.myFocus = [100., 70.]
+ self.myMinorRadius = 20.
+ self.myEllipse = self.mySketch.addEllipse(self.myCenter[0], self.myCenter[1], self.myFocus[0], self.myFocus[1], self.myMinorRadius)
+ self.myDOF = 5
+ model.do()
+ self.checkDOF()
+ self.myMajorRadius = self.myEllipse.majorRadius().value()
+
+ def tearDown(self):
+ self.checkDOF()
+ model.end()
+
+ def checkDOF(self):
+ self.assertEqual(model.dof(self.mySketch), self.myDOF)
+
+ def checkPointCoordinates(self, thePoint, theCoordinates):
+ aCoord = []
+ if issubclass(type(theCoordinates), GeomAPI_Pnt2d):
+ aCoord = [theCoordinates.x(), theCoordinates.y()]
+ else:
+ aCoord = theCoordinates
+ DIGITS = 7 - math.floor(math.log10(math.hypot(aCoord[0], aCoord[1])))
+ self.assertAlmostEqual(thePoint.x(), aCoord[0], DIGITS)
+ self.assertAlmostEqual(thePoint.y(), aCoord[1], DIGITS)
+
+ def checkPointOnEllipse(self, theCoordinates, theEllipse):
+ point = GeomAPI_Pnt2d(theCoordinates.x(), theCoordinates.y())
+ firstFocus2d = GeomAPI_Pnt2d(theEllipse.firstFocus().x(), theEllipse.firstFocus().y())
+ distPF1 = model.distancePointPoint(firstFocus2d, point)
+ secondFocus2d = GeomAPI_Pnt2d(theEllipse.secondFocus().x(), theEllipse.secondFocus().y())
+ distPF2 = model.distancePointPoint(secondFocus2d, point)
+ self.assertAlmostEqual(distPF1 + distPF2, 2.0 * theEllipse.majorRadius().value(), 7 - math.floor(math.log10(theEllipse.majorRadius().value())))
+
+ def fixMajorRadius(self):
+ self.mySketch.setDistance(self.myEllipse.center(), self.myEllipse.majorAxisPositive(), self.myMajorRadius)
+ self.myDOF -= 1
+ model.do()
+ self.checkDOF()
+
+ def fixMinorRadius(self):
+ self.mySketch.setDistance(self.myEllipse.center(), self.myEllipse.minorAxisPositive(), self.myMinorRadius)
+ self.myDOF -= 1
+ model.do()
+ self.checkDOF()
+
+ def fixPoint(self, thePoint):
+ self.mySketch.setFixed(thePoint)
+ self.myDOF -= 2
+ model.do()
+ self.checkDOF()
+
+
+ def test_move_center_free_ellipse(self):
+ """ Test 1. Movement of central point of a free ellipse
+ """
+ newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
+ self.mySketch.move(self.myEllipse.center(), newPosition[0], newPosition[1])
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), newPosition)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_free_ellipse(self):
+ """ Test 2. Movement of a free ellipse dragging the edge
+ """
+ newPosition = GeomAPI_Pnt2d(120., 90.)
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), self.myCenter)
+ self.checkPointOnEllipse(newPosition, self.myEllipse)
+ self.assertNotEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertNotEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_center_ellipse_fixed_major_radius(self):
+ """ Test 3. Movement of central point of ellipse with fixed major radius
+ """
+ self.fixMajorRadius()
+
+ newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
+ self.mySketch.move(self.myEllipse.center(), newPosition[0], newPosition[1])
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), newPosition)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_ellipse_fixed_major_radius(self):
+ """ Test 4. Movement of ellipse with fixed major radius
+ """
+ self.fixMajorRadius()
+
+ newPosition = GeomAPI_Pnt2d(80., 80.)
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointOnEllipse(newPosition, self.myEllipse)
+ self.assertNotEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_center_ellipse_fixed_minor_radius(self):
+ """ Test 5. Movement of central point of ellipse with fixed minor radius
+ """
+ self.fixMinorRadius()
+
+ newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
+ self.mySketch.move(self.myEllipse.center(), newPosition[0], newPosition[1])
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), newPosition)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_ellipse_fixed_minor_radius(self):
+ """ Test 6. Movement of ellipse with fixed minor radius
+ """
+ self.fixMinorRadius()
+
+ newPosition = GeomAPI_Pnt2d(120., 90.)
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointOnEllipse(newPosition, self.myEllipse)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertNotEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_center_ellipse_fixed_center(self):
+ """ Test 7. Movement of central point of ellipse with fixed center (nothing should be changed)
+ """
+ self.fixPoint(self.myEllipse.center())
+
+ newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
+ self.mySketch.move(self.myEllipse.center(), newPosition[0], newPosition[1])
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), self.myCenter)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_ellipse_fixed_center(self):
+ """ Test 8. Movement of ellipse with fixed center
+ """
+ self.fixPoint(self.myEllipse.center())
+
+ newPosition = GeomAPI_Pnt2d(120., 90.)
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointOnEllipse(newPosition, self.myEllipse)
+ self.assertNotEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertNotEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_center_ellipse_fixed_focus(self):
+ """ Test 9. Movement of central point of ellipse with fixed focus
+ """
+ self.fixPoint(self.myEllipse.firstFocus())
+
+ newPosition = GeomAPI_Pnt2d(self.myCenter[0] + 20., self.myCenter[1] + 10.)
+ self.mySketch.move(self.myEllipse.center(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), newPosition)
+ self.checkPointCoordinates(self.myEllipse.firstFocus(), self.myFocus)
+ self.assertNotEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertNotEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_focus_ellipse_fixed_focus(self):
+ """ Test 10. Movement of a focus point of ellipse with fixed focus (nothing should be changed)
+ """
+ self.fixPoint(self.myEllipse.firstFocus())
+
+ newPosition = GeomAPI_Pnt2d(self.myFocus[0] + 10., self.myFocus[1] + 10.)
+ self.mySketch.move(self.myEllipse.firstFocus(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.firstFocus(), self.myFocus)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertAlmostEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_ellipse_fixed_focus(self):
+ """ Test 11. Movement of ellipse with fixed focus
+ """
+ self.fixPoint(self.myEllipse.firstFocus())
+
+ newPosition = GeomAPI_Pnt2d(80., 90.)
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition.x(), newPosition.y())
+ model.do()
+ self.checkPointOnEllipse(newPosition, self.myEllipse)
+ self.checkPointCoordinates(self.myEllipse.firstFocus(), self.myFocus)
+ self.assertNotEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+ self.assertNotEqual(self.myEllipse.majorRadius().value(), self.myMajorRadius)
+
+ def test_move_fixed_ellipse(self):
+ """ Test 12. Trying to move fully fixed ellipse
+ """
+ self.mySketch.setFixed(self.myEllipse.results()[-1])
+ self.myDOF -= 5
+ model.do()
+ self.checkDOF()
+
+ newPosition = [120., 90.]
+ self.mySketch.move(self.myEllipse.defaultResult(), newPosition[0], newPosition[1])
+ model.do()
+ self.checkPointCoordinates(self.myEllipse.center(), self.myCenter)
+ self.checkPointCoordinates(self.myEllipse.firstFocus(), self.myFocus)
+ self.assertAlmostEqual(self.myEllipse.minorRadius().value(), self.myMinorRadius)
+
+
+if __name__ == "__main__":
+ test_program = unittest.main(exit=False)
+ assert test_program.result.wasSuccessful(), "Test failed"
+ assert(model.checkPythonDump())
<feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon="icons/Sketch/fixed.png"
helpfile="rigidFeature.html">
<sketch_shape_selector id="ConstraintEntityA" label="Object"
- tooltip="Select point, line end point, line, center of circle or arc."
+ tooltip="Select point, curve or its boundary point."
shape_types="edge vertex">
- <validator id="GeomValidators_ShapeType" parameters="vertex,line,circle"/>
+ <validator id="GeomValidators_ShapeType" parameters="vertex,edge"/>
<validator id="SketchPlugin_NotFixed"/>
</sketch_shape_selector>
<validator id="PartSet_RigidSelection"/>
CONSTRAINT_PT_PT_COINCIDENT,
CONSTRAINT_PT_ON_LINE,
CONSTRAINT_PT_ON_CIRCLE,
+ CONSTRAINT_PT_ON_ELLIPSE,
CONSTRAINT_MIDDLE_POINT,
CONSTRAINT_DISTANCE, // base distance if we don't know the measured objects yet
CONSTRAINT_PT_PT_DISTANCE,
#include <Events_LongOp.h>
// Multiplier to correlate IDs of SketchPlugin constraint and primitive PlaneGCS constraints
-static const int THE_CONSTRAINT_MULT = 10;
+static const int THE_CONSTRAINT_MULT = 100;
PlaneGCSSolver_Solver::PlaneGCSSolver_Solver()
break;
case CONSTRAINT_PT_ON_LINE:
case CONSTRAINT_PT_ON_CIRCLE:
+ case CONSTRAINT_PT_ON_ELLIPSE:
aResult = createConstraintPointOnEntity(theType, aPoint1, GCS_EDGE_WRAPPER(theEntity1));
break;
case CONSTRAINT_MIDDLE_POINT:
myType = CONSTRAINT_PT_ON_LINE;
else if (anEntType == ENTITY_CIRCLE || anEntType == ENTITY_ARC)
myType = CONSTRAINT_PT_ON_CIRCLE;
+ else if (anEntType == ENTITY_ELLIPSE || anEntType == ENTITY_ELLIPTICAL_ARC)
+ myType = CONSTRAINT_PT_ON_ELLIPSE;
else
myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
const std::shared_ptr<GeomAPI_Ax3>& thePlane,
gp_Pnt& thePnt1, gp_Pnt& thePnt2)
{
+ if (!thePlane)
+ return false;
+
DataPtr aData = theConstraint->data();
if (theConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) {
// The constraint is length