if (aCenter.IsEqual(aPoint, Precision::Confusion()))
return NULL;
- gp_Dir2d aDir(theCenterX - thePointX, theCenterY - thePointY);
+ gp_Dir2d aDir(thePointX - theCenterX, thePointY - theCenterY);
return newCirc2d(theCenterX, theCenterY, aDir, aRadius);
}
#include <ios>
#include <cmath>
-#define PRECISION 7
+#define PRECISION 6
#define TOLERANCE (1.e-7)
ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(FeaturePtr theFeature) {
return "";
}
-static void dumpArray(std::ostringstream& theOutput, const double theArray[], int theSize)
+static void dumpArray(std::ostringstream& theOutput, const double theArray[], int theSize, int thePrecision = PRECISION)
{
for (int i = 0; i < theSize; ++i) {
if (i > 0)
theOutput << " ";
- theOutput << std::fixed << setprecision(PRECISION)
+ theOutput << std::fixed << setprecision(thePrecision)
<< (fabs(theArray[i]) < TOLERANCE ? 0.0 : theArray[i]);
}
}
aResult<<anAttr->text();
} else if (aType == ModelAPI_AttributeDouble::typeId()) {
AttributeDoublePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttr);
+ int aPrecision = PRECISION;
+ // Special case - precision for the arc angle. It is calculated with tolerance 1e-4,
+ // so the value has only 4 correct digits
+ if (anAttr->id() == "ArcAngle")
+ aPrecision = 1;
if (anAttr->text().empty()) {
double aVal = anAttr->value();
- dumpArray(aResult, &aVal, 1);
+ dumpArray(aResult, &aVal, 1, aPrecision);
} else
aResult<<anAttr->text();
} else if (aType == ModelAPI_AttributeBoolean::typeId()) {
// output the main characteristics
aResult<<"Volume: "<<setprecision(2)<<GeomAlgoAPI_ShapeTools::volume(theShape)<<std::endl;
std::shared_ptr<GeomAPI_Pnt> aCenter = GeomAlgoAPI_ShapeTools::centreOfMass(theShape);
- aResult<<"Center of mass: "<<std::fixed<<setprecision(PRECISION)
- <<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
+ aResult<<"Center of mass: ";
+ double aCenterVals[3] = {aCenter->x(), aCenter->y(), aCenter->z()};
+ dumpArray(aResult, aCenterVals, 3);
+ aResult<<std::endl;
return aResult.str();
}
#=========================================================================
aSession.startOperation()
aStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
-aStartPoint.setValue(0., 30.)
+aStartPoint.setValue(0., -30.)
aConstraint.execute()
aSession.finishOperation()
assert (angle(aSketchLineA, aSketchLineB) == ANGLE_DEGREE)
# End of test
#=========================================================================
+
+# make second line fixed
+aSession.startOperation()
+aFixed = aSketchFeature.addFeature("SketchConstraintRigid")
+aRefObjectA = aFixed.refattr("ConstraintEntityA")
+anObjectA = modelAPI_ResultConstruction(aSketchLine2.lastResult())
+assert (anObjectA is not None)
+aRefObjectA.setObject(anObjectA)
+aFixed.execute()
+aSession.finishOperation()
+# set mirror for first line to check dumping
+aSession.startOperation()
+aRefListInitial.clear()
+assert (aRefListB.size() == 0)
+assert (aRefListC.size() == 0)
+aRefListInitial.append(aSketchLine1.lastResult())
+aSession.finishOperation()
+assert (aRefListB.size() == 1)
+assert (aRefListC.size() == 1)
+checkMirror(aRefListB, aRefListC, aMirrorLine)
+
import model
assert(model.checkPythonDump())
aStartPoint1 = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
aEndPoint1 = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
aStartPoint1.setValue(10., 10.)
- aEndPoint1.setValue(30., 5.)
+ aEndPoint1.setValue(30., 15.)
allFeatures.append(aSketchLine)
# Arc
aSketchArc = theSketch.addFeature("SketchArc")
# Change Fillet radius
#=========================================================================
aRadius.setValue(FILLET_RADIUS2)
+aFillet.execute()
aSession.finishOperation()
checkFillet(aResObjects, FILLET_RADIUS2)
# Change Fillet radius
#=========================================================================
aRadius.setValue(FILLET_RADIUS2)
+aFillet.execute()
aSession.finishOperation()
checkFillet(aResObjects, FILLET_RADIUS2)
#=========================================================================
aLineEnd.setValue(50., 0.)
aSession.finishOperation()
aSession.startOperation()
+aFixed = aSketchFeature.addFeature("SketchConstraintRigid")
+aRefObjectA = aFixed.refattr("ConstraintEntityA")
+aRefObjectA.setObject(modelAPI_ResultConstruction(aSketchLine.lastResult()))
+aFixed.execute()
+aSession.finishOperation()
+aSession.startOperation()
aSketchArcTangent = aSketchFeature.addFeature("SketchArc")
aSketchArcTangent.string("ArcType").setValue("Tangent")
anArcEndPoint = geomDataAPI_Point2D(aSketchArcTangent.attribute("ArcEndPoint"))
anArcEndPoint2 = geomDataAPI_Point2D(aSketchArcTangent2.attribute("ArcEndPoint"))
aTangent = aSketchArcTangent2.refattr("ArcTangentPoint")
aTangent.setAttr(anArcEndPoint)
-anArcEndPoint2.setValue(anArcEndPoint.x() + 1, anArcEndPoint.y() + 1)
-aSession.finishOperation()
-aSession.startOperation()
-anArcEndPoint2.setValue(50., 50.)
+anArcEndPoint2.setValue(50., 150.)
aSession.finishOperation()
#=========================================================================
# End of test
aConstrList.push_back(GCSConstraintPtr(new GCS::ConstraintPointOnLine(*aPoint, *aLine)));
double aDist = lineLength(*aLine);
std::shared_ptr<PlaneGCSSolver_ParameterWrapper> aDistance =
- std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(createParameter(theGroupID, aDist));
+ std::dynamic_pointer_cast<PlaneGCSSolver_ParameterWrapper>(createParameter(theGroupID, aDist * 0.5));
aConstrList.push_back(GCSConstraintPtr(
new GCS::ConstraintP2PDistance(*aPoint, aLine->p1, aDistance->parameter())));
aConstrList.push_back(GCSConstraintPtr(