Sketcher: Responsivity tweaks and AngleViaPoint Constraint

Solver iteration limit independent of system size (reduces hangs when
solver fails to converge).
Repaint() instead of update() to force render for every movePoint.

Sketcher: New Constraint AngleViaPoint

* Adding generic CalculateNormal() method
* Reconfiguration of GCS geometry classes: adding a base class "Curve",
that has a pure virtual function CalculateNormal().
* Initial inplementation of the new function.
* adding Vector2D class (I wanted to reuse the existing, but got wierd
compile errors, so implemented a new one... TODO.)
* Adding redirection support into GCS shapes. Adding a Copy method to
GCS::Curve.
* Automatic point-on-object
* Angle precalculation: when AngleViaPoint is added, angle is properly calculated based on
existing geometry.
* Added tangency-via-point using one.
* Implemented placement of tangency-via-point icon in 3d view. Also
affected is the placement of point-on-object icon (since it is very
similar code, it is now shared with tangency-via-point)
* Placement and moving of angle datum
Functions: calculateAngleViaPoint, isPointOnCurve,
calculateConstraintError exposed to python
* Endpoint tangency: All endpoint-to-endpoint and endpoint-to-curve tangency now works
through AngleViaPoint constraint and obsolete code clean up (most procedures
addConstraintTangentXXX2YYY)
This commit is contained in:
DeepSOIC
2014-11-01 22:17:46 +04:00
committed by wmayer
parent ec03fb541f
commit 9f821e06b5
17 changed files with 1497 additions and 692 deletions

View File

@@ -677,7 +677,56 @@ PyObject* SketchObjectPy::trim(PyObject *args)
}
Py_Return;
}
PyObject* SketchObjectPy::calculateAngleViaPoint(PyObject *args)
{
int GeoId1=0, GeoId2=0;
double px=0, py=0;
if (!PyArg_ParseTuple(args, "iidd", &GeoId1, &GeoId2, &px, &py))
return 0;
SketchObject* obj = this->getSketchObjectPtr();
if (GeoId1 > obj->getHighestCurveIndex() || -GeoId1 > obj->getExternalGeometryCount() ||
GeoId2 > obj->getHighestCurveIndex() || -GeoId2 > obj->getExternalGeometryCount() ) {
PyErr_SetString(PyExc_ValueError, "Invalid geometry Id");
return 0;
}
double ang = obj->calculateAngleViaPoint(GeoId1, GeoId2, px, py);
return Py::new_reference_to(Py::Float(ang));
}
PyObject* SketchObjectPy::isPointOnCurve(PyObject *args)
{
int GeoId=Constraint::GeoUndef;
double px=0, py=0;
if (!PyArg_ParseTuple(args, "idd", &GeoId, &px, &py))
return 0;
SketchObject* obj = this->getSketchObjectPtr();
if (GeoId > obj->getHighestCurveIndex() || -GeoId > obj->getExternalGeometryCount()) {
PyErr_SetString(PyExc_ValueError, "Invalid geometry Id");
return 0;
}
return Py::new_reference_to(Py::Boolean(obj->isPointOnCurve(GeoId, px, py)));
}
PyObject* SketchObjectPy::calculateConstraintError(PyObject *args)
{
int ic=-1;
if (!PyArg_ParseTuple(args, "i", &ic))
return 0;
SketchObject* obj = this->getSketchObjectPtr();
if (ic >= obj->Constraints.getSize() || ic < 0) {
PyErr_SetString(PyExc_ValueError, "Invalid constraint Id");
return 0;
}
double err = obj->calculateConstraintError(ic);
return Py::new_reference_to(Py::Float(err));
}
PyObject* SketchObjectPy::ExposeInternalGeometry(PyObject *args)