]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix unit test problems on Debian 6
authorazv <azv@opencascade.com>
Mon, 10 Oct 2016 10:21:41 +0000 (13:21 +0300)
committerazv <azv@opencascade.com>
Mon, 10 Oct 2016 10:21:41 +0000 (13:21 +0300)
src/SketchAPI/SketchAPI_Constraint.cpp
src/SketchPlugin/Test/TestConstraintMirror.py

index 617a0bfa62485d90f16239ea548cbce261122ba0..6ed3e193fac98bdd0e4560a4b8cb0cf517050231 100644 (file)
@@ -24,6 +24,7 @@
 #include <SketchPlugin_ConstraintRigid.h>
 #include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_ConstraintVertical.h>
+#include <SketchPlugin_SketchEntity.h>
 
 #include <SketcherPrs_Tools.h>
 
@@ -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<SketchPlugin_Constraint>(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<SketchPlugin_Feature> aSketchFeature =
-        std::dynamic_pointer_cast<SketchPlugin_Feature>(
-        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;
index 25b7eeecb6c7cf97def16038767e34f3df2827c7..16ab8201cce8de8c6021862fb9fedbe0997d93fe 100644 (file)
@@ -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)