From: azv Date: Mon, 10 Oct 2016 10:21:41 +0000 (+0300) Subject: Fix unit test problems on Debian 6 X-Git-Tag: V_2.5.1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a34635e0dae5664d9438f6424a1ee1179f94edf4;p=modules%2Fshaper.git Fix unit test problems on Debian 6 --- diff --git a/src/SketchAPI/SketchAPI_Constraint.cpp b/src/SketchAPI/SketchAPI_Constraint.cpp index 617a0bfa6..6ed3e193f 100644 --- a/src/SketchAPI/SketchAPI_Constraint.cpp +++ b/src/SketchAPI/SketchAPI_Constraint.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -128,42 +129,40 @@ static std::string angleTypeToString(int theAngleType) void SketchAPI_Constraint::dump(ModelHighAPI_Dumper& theDumper) const { FeaturePtr aBase = feature(); - ConstraintPtr aConstraint = std::dynamic_pointer_cast(aBase); - if (!aConstraint) - return; // dump constraints only + const std::string& aSetter = constraintTypeToSetter(aBase->getKind()); + if (aSetter.empty()) + return; // incorrect constraint type // do not need to dump "Fixed" constraint for external object - if (aConstraint->getKind() == SketchPlugin_ConstraintRigid::ID()) { - AttributeRefAttrPtr aRefAttr = aConstraint->refattr(SketchPlugin_Constraint::ENTITY_A()); - std::shared_ptr aSketchFeature = - std::dynamic_pointer_cast( - ModelAPI_Feature::feature(aRefAttr->object())); - if (!aSketchFeature || aSketchFeature->isExternal()) + if (aBase->getKind() == SketchPlugin_ConstraintRigid::ID()) { + AttributeRefAttrPtr aRefAttr = aBase->refattr(SketchPlugin_Constraint::ENTITY_A()); + FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object()); + if (!aFeature) + return; + AttributeSelectionPtr aAttr = aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()); + if (aAttr && aAttr->context().get() != NULL && !aAttr->isInvalid()) return; } - const std::string& aSetter = constraintTypeToSetter(aConstraint->getKind()); - if (aSetter.empty()) - return; // incorrect constraint type - bool isAngle = aConstraint->getKind() == SketchPlugin_ConstraintAngle::ID(); + bool isAngle = aBase->getKind() == SketchPlugin_ConstraintAngle::ID(); std::string aSetterSuffix; if (isAngle) - aSetterSuffix = angleTypeToString(aConstraint->integer( + aSetterSuffix = angleTypeToString(aBase->integer( SketchPlugin_ConstraintAngle::TYPE_ID())->value()); - const std::string& aSketchName = theDumper.parentName(aConstraint); + const std::string& aSketchName = theDumper.parentName(aBase); theDumper << aBase << " = " << aSketchName << "." << aSetter << aSetterSuffix << "("; bool isFirstAttr = true; for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) { - AttributeRefAttrPtr aRefAttr = aConstraint->refattr(SketchPlugin_Constraint::ATTRIBUTE(i)); + AttributeRefAttrPtr aRefAttr = aBase->refattr(SketchPlugin_Constraint::ATTRIBUTE(i)); if (aRefAttr && aRefAttr->isInitialized()) { theDumper << (isFirstAttr ? "" : ", ") << aRefAttr; isFirstAttr = false; } } - AttributeDoublePtr aValueAttr = aConstraint->real( + AttributeDoublePtr aValueAttr = aBase->real( isAngle ? SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID() :SketchPlugin_Constraint::VALUE()); if (aValueAttr && aValueAttr->isInitialized()) theDumper << ", " << aValueAttr; diff --git a/src/SketchPlugin/Test/TestConstraintMirror.py b/src/SketchPlugin/Test/TestConstraintMirror.py index 25b7eeecb..16ab8201c 100644 --- a/src/SketchPlugin/Test/TestConstraintMirror.py +++ b/src/SketchPlugin/Test/TestConstraintMirror.py @@ -56,9 +56,9 @@ def checkMirror(theListInit, theListMirr, theMirrorLine): aDir = normalize(aDir) aDot = aLineDir[0] * aDir[0] + aLineDir[1] * aDir[1] assert math.fabs(aDot) < TOL, "aDot = {0}".format(aDot) - aDirX = aLineEndPoint.x() - 0.5 * (aPointB.x() + aPointC.x()) - aDirY = aLineEndPoint.y() - 0.5 * (aPointB.y() + aPointC.y()) - aCross = aLineDir[0] * aDir[0] - aLineDir[1] * aDir[1] + aDir[0] = aLineEndPoint.x() - 0.5 * (aPointB.x() + aPointC.x()) + aDir[1] = aLineEndPoint.y() - 0.5 * (aPointB.y() + aPointC.y()) + aCross = aLineDir[0] * aDir[1] - aLineDir[1] * aDir[0] assert math.fabs(aCross) < TOL, "aCross = {0}".format(aCross) @@ -136,7 +136,7 @@ aTangency = aSketchFeature.addFeature("SketchConstraintTangent") aRefObjectA = aTangency.refattr("ConstraintEntityA") aRefObjectB = aTangency.refattr("ConstraintEntityB") anObjectA = modelAPI_ResultConstruction(aSketchArc1.lastResult()) -anObjectB = modelAPI_ResultConstruction(aSketchLine1.firstResult()) +anObjectB = modelAPI_ResultConstruction(aSketchLine1.lastResult()) assert (anObjectA is not None) assert (anObjectB is not None) aRefObjectA.setObject(anObjectA)