From ef6a0053de177cc664334f6f6245675270ac310d Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 11 Jul 2018 17:20:44 +0300 Subject: [PATCH] Fix for the unit-tests that use not HighAPI pythion interface to create construction points by 3 coordinates --- src/ConstructionPlugin/Test/TestAxisCreation.py | 10 ++-------- src/ConstructionPlugin/Test/TestPointName.py | 6 ++---- src/FeaturesPlugin/Test/TestFillet.py | 5 ++--- src/Model/Model_Expression.cpp | 4 ++-- src/ModelAPI/Test/TestDocument.py | 5 ++--- src/ModelAPI/Test/TestFolder_Create.py | 13 ++++--------- src/ModelAPI/Test/TestFolder_Remove.py | 5 ++--- src/ModelAPI/Test/TestFolder_Stability.py | 5 ++--- src/ModelAPI/Test/TestFolder_Update.py | 5 ++--- src/SketchPlugin/Test/TestConstraintCoincidence.py | 5 +---- src/SketchPlugin/Test/TestConstraintMiddlePoint.py | 5 +---- 11 files changed, 22 insertions(+), 46 deletions(-) diff --git a/src/ConstructionPlugin/Test/TestAxisCreation.py b/src/ConstructionPlugin/Test/TestAxisCreation.py index a645c548e..642d83bde 100644 --- a/src/ConstructionPlugin/Test/TestAxisCreation.py +++ b/src/ConstructionPlugin/Test/TestAxisCreation.py @@ -48,10 +48,7 @@ aSession.startOperation() aPointFeature = aPart.addFeature("Point") aPointFeatureData = aPointFeature.data() assert(aPointFeatureData is not None) -# aPointFeatureData.string("creation_method").setValue("by_xyz") -aPointFeatureData.real("x").setValue(0.) -aPointFeatureData.real("y").setValue(0.) -aPointFeatureData.real("z").setValue(0.) +geomDataAPI_Point(aPointFeatureData.attribute("point3d")).setValue(0., 0., 0.) aPointFeatureData.string("creation_method").setValue("by_xyz") aPointFeature.execute() aSession.finishOperation() @@ -64,10 +61,7 @@ aSession.startOperation() aPointFeature = aPart.addFeature("Point") aPointFeatureData = aPointFeature.data() assert(aPointFeatureData is not None) -# aPointFeatureData.string("creation_method").setValue("by_xyz") -aPointFeatureData.real("x").setValue(0.) -aPointFeatureData.real("y").setValue(0.) -aPointFeatureData.real("z").setValue(100.) +geomDataAPI_Point(aPointFeatureData.attribute("point3d")).setValue(0., 0., 100.) aPointFeatureData.string("creation_method").setValue("by_xyz") aPointFeature.execute() aSession.finishOperation() diff --git a/src/ConstructionPlugin/Test/TestPointName.py b/src/ConstructionPlugin/Test/TestPointName.py index 557970091..3b4fee985 100644 --- a/src/ConstructionPlugin/Test/TestPointName.py +++ b/src/ConstructionPlugin/Test/TestPointName.py @@ -19,6 +19,7 @@ ## from ModelAPI import * +from GeomDataAPI import * aSession = ModelAPI_Session.get() aDoc = aSession.moduleDocument() @@ -27,10 +28,7 @@ aSession.startOperation() aFeature = aDoc.addFeature("Point") aFeatureData = aFeature.data() assert(aFeatureData is not None) -# aFeatureData.string("creation_method").setValue("by_xyz") -aFeatureData.real("x").setValue(0.) -aFeatureData.real("y").setValue(0.) -aFeatureData.real("z").setValue(0.) +geomDataAPI_Point(aFeatureData.attribute("point3d")).setValue(0., 0., 0.) aFeatureData.string("creation_method").setValue("by_xyz") aFeatureName = aFeature.name() aFeature.execute() diff --git a/src/FeaturesPlugin/Test/TestFillet.py b/src/FeaturesPlugin/Test/TestFillet.py index 49831b3f5..a641328bf 100644 --- a/src/FeaturesPlugin/Test/TestFillet.py +++ b/src/FeaturesPlugin/Test/TestFillet.py @@ -24,6 +24,7 @@ """ from ModelAPI import * +from GeomDataAPI import * __updated__ = "2017-11-30" @@ -51,9 +52,7 @@ aSession.finishOperation() aSession.startOperation() aPoint = aPart.addFeature("Point") aPoint.string("creation_method").setValue("by_xyz") -aPoint.real("x").setValue(20) -aPoint.real("y").setValue(5) -aPoint.real("z").setValue(0) +geomDataAPI_Point(aFeature.attribute("point3d")).setValue(20, 5, 0) aSession.finishOperation() aSession.startOperation() diff --git a/src/Model/Model_Expression.cpp b/src/Model/Model_Expression.cpp index 4a129757a..2696e6c2d 100644 --- a/src/Model/Model_Expression.cpp +++ b/src/Model/Model_Expression.cpp @@ -118,7 +118,7 @@ void Model_ExpressionDouble::setValue(const double theValue) double Model_ExpressionDouble::value() { - if (myIsInitialized) + if (myIsInitialized && !myReal.IsNull()) return myReal->Get(); return std::numeric_limits::max(); // error } @@ -166,7 +166,7 @@ void Model_ExpressionInteger::setValue(const int theValue) int Model_ExpressionInteger::value() { - if (myIsInitialized) + if (myIsInitialized && !myInteger.IsNull()) return myInteger->Get(); return std::numeric_limits::max(); // error } diff --git a/src/ModelAPI/Test/TestDocument.py b/src/ModelAPI/Test/TestDocument.py index f197d2606..ee8f7eb1d 100644 --- a/src/ModelAPI/Test/TestDocument.py +++ b/src/ModelAPI/Test/TestDocument.py @@ -27,6 +27,7 @@ # Initialization of the test #========================================================================= from ModelAPI import * +from GeomDataAPI import * __updated__ = "2014-12-26" @@ -71,9 +72,7 @@ aSession.startOperation() aFeature = aPart.addFeature("Point") aFeatureData = aFeature.data() assert(aFeatureData is not None) -aFeatureData.real("x").setValue(15.) -aFeatureData.real("y").setValue(10.) -aFeatureData.real("z").setValue(20.) +geomDataAPI_Point(aFeatureData.attribute("point3d")).setValue(15., 10., 20.) aSession.finishOperation() assert(aPart.size("Features") == 1) # Duplicate the document diff --git a/src/ModelAPI/Test/TestFolder_Create.py b/src/ModelAPI/Test/TestFolder_Create.py index ad9631455..6ef31341d 100644 --- a/src/ModelAPI/Test/TestFolder_Create.py +++ b/src/ModelAPI/Test/TestFolder_Create.py @@ -22,6 +22,7 @@ # Initialization of the test #========================================================================= from ModelAPI import * +from GeomDataAPI import * __updated__ = "2017-11-22" @@ -35,9 +36,7 @@ aSession.startOperation() aPoint0 = aPartSetDoc.addFeature("Point") aPoint0Data = aPoint0.data() assert(aPoint0Data is not None) -aPoint0Data.real("x").setValue(0.) -aPoint0Data.real("y").setValue(0.) -aPoint0Data.real("z").setValue(0.) +geomDataAPI_Point(aPoint0Data.attribute("point3d")).setValue(0., 0., 0.) aPoint0Data.string("creation_method").setValue("by_xyz") aSession.finishOperation() @@ -45,9 +44,7 @@ aSession.startOperation() aPoint1 = aPartSetDoc.addFeature("Point") aPoint1Data = aPoint1.data() assert(aPoint1Data is not None) -aPoint1Data.real("x").setValue(0.) -aPoint1Data.real("y").setValue(0.) -aPoint1Data.real("z").setValue(0.) +geomDataAPI_Point(aPoint1Data.attribute("point3d")).setValue(0., 0., 0.) aPoint1Data.string("creation_method").setValue("by_xyz") aSession.finishOperation() @@ -87,9 +84,7 @@ aSession.startOperation() aPoint2 = aPartDoc.addFeature("Point") aPoint2Data = aPoint2.data() assert(aPoint2Data is not None) -aPoint2Data.real("x").setValue(0.) -aPoint2Data.real("y").setValue(0.) -aPoint2Data.real("z").setValue(0.) +geomDataAPI_Point(aPoint2Data.attribute("point3d")).setValue(0., 0., 0.) aPoint2Data.string("creation_method").setValue("by_xyz") aSession.finishOperation() diff --git a/src/ModelAPI/Test/TestFolder_Remove.py b/src/ModelAPI/Test/TestFolder_Remove.py index 6e78b581f..632c88c6e 100644 --- a/src/ModelAPI/Test/TestFolder_Remove.py +++ b/src/ModelAPI/Test/TestFolder_Remove.py @@ -22,6 +22,7 @@ # Initialization of the test #========================================================================= from ModelAPI import * +from GeomDataAPI import * __updated__ = "2017-11-24" @@ -33,9 +34,7 @@ def newPoint(theDocument, theX, theY, theZ): aPoint = theDocument.addFeature("Point") aPointData = aPoint.data() assert(aPointData is not None) - aPointData.real("x").setValue(theX) - aPointData.real("y").setValue(theY) - aPointData.real("z").setValue(theZ) + geomDataAPI_Point(aPointData.attribute("point3d")).setValue(theX, theY, theZ) aPointData.string("creation_method").setValue("by_xyz") aSession.finishOperation() return aPoint diff --git a/src/ModelAPI/Test/TestFolder_Stability.py b/src/ModelAPI/Test/TestFolder_Stability.py index e6cdbe893..e6a86c297 100644 --- a/src/ModelAPI/Test/TestFolder_Stability.py +++ b/src/ModelAPI/Test/TestFolder_Stability.py @@ -22,6 +22,7 @@ # Test checks stability of the foldering mechanism due to incorrect input parameters #========================================================================= from ModelAPI import * +from GeomDataAPI import * __updated__ = "2017-11-23" @@ -33,9 +34,7 @@ def newPoint(theDocument, theX, theY, theZ): aPoint = theDocument.addFeature("Point") aPointData = aPoint.data() assert(aPointData is not None) - aPointData.real("x").setValue(theX) - aPointData.real("y").setValue(theY) - aPointData.real("z").setValue(theZ) + geomDataAPI_Point(aPointData.attribute("point3d")).setValue(theX, theY, theZ) aPointData.string("creation_method").setValue("by_xyz") aSession.finishOperation() return aPoint diff --git a/src/ModelAPI/Test/TestFolder_Update.py b/src/ModelAPI/Test/TestFolder_Update.py index 39406251d..145be954c 100644 --- a/src/ModelAPI/Test/TestFolder_Update.py +++ b/src/ModelAPI/Test/TestFolder_Update.py @@ -22,6 +22,7 @@ # Initialization of the test #========================================================================= from ModelAPI import * +from GeomDataAPI import * __updated__ = "2017-11-23" @@ -33,9 +34,7 @@ def newPoint(theDocument, theX, theY, theZ): aPoint = theDocument.addFeature("Point") aPointData = aPoint.data() assert(aPointData is not None) - aPointData.real("x").setValue(theX) - aPointData.real("y").setValue(theY) - aPointData.real("z").setValue(theZ) + geomDataAPI_Point(aPointData.attribute("point3d")).setValue(theX, theY, theZ) aPointData.string("creation_method").setValue("by_xyz") aSession.finishOperation() return aPoint diff --git a/src/SketchPlugin/Test/TestConstraintCoincidence.py b/src/SketchPlugin/Test/TestConstraintCoincidence.py index 4ce25cd89..7d6424e87 100644 --- a/src/SketchPlugin/Test/TestConstraintCoincidence.py +++ b/src/SketchPlugin/Test/TestConstraintCoincidence.py @@ -83,10 +83,7 @@ aDocument = aSession.moduleDocument() # add an origin aSession.startOperation() aFeature = aDocument.addFeature("Point") -# aFeature.string("creation_method").setValue("by_xyz") -aFeature.real("x").setValue(0.) -aFeature.real("y").setValue(0.) -aFeature.real("z").setValue(0.) +geomDataAPI_Point(aFeature.attribute("point3d")).setValue(0., 0., 0.) aFeature.string("creation_method").setValue("by_xyz") anOriginName = aFeature.name() aSession.finishOperation() diff --git a/src/SketchPlugin/Test/TestConstraintMiddlePoint.py b/src/SketchPlugin/Test/TestConstraintMiddlePoint.py index c5aaa01a8..53133e6b5 100644 --- a/src/SketchPlugin/Test/TestConstraintMiddlePoint.py +++ b/src/SketchPlugin/Test/TestConstraintMiddlePoint.py @@ -67,10 +67,7 @@ aDocument = aSession.moduleDocument() # add an origin aSession.startOperation() aFeature = aDocument.addFeature("Point") -# aFeature.string("creation_method").setValue("by_xyz") -aFeature.real("x").setValue(0.) -aFeature.real("y").setValue(0.) -aFeature.real("z").setValue(0.) +geomDataAPI_Point(aFeature.attribute("point3d")).setValue(0., 0., 0.) aFeature.string("creation_method").setValue("by_xyz") anOriginName = aFeature.name() aSession.finishOperation() -- 2.39.2