Monday, July 6, 2009

Ellipse drawing, parallelism magic points

Changed the ellipse code so that the first click is the ellipse center. Updated also the descriptors so that the property grid reflects the properties of the new ellipse style.

Worked also at implementing in the geometric solver detection of magic points that make parallel lines. It started detecting some parallelism but it doesn't work well yet, also it needs better integration with the other types of magic points. Probably in a few more hours of work it will work ok.

The current code for parallelism calculation is the following:

// Build a vector with each two points from the magic point list
OCgp_Vec sceneVec = new OCgp_Vec(pointList[i].Point, pointList[j].Point);
// Try to find a parallelism
if (vec.IsParallel(sceneVec, tolerance))
{
// If parallels found, build a line from the two points
OCgp_Lin line = new OCgce_MakeLin(pointList[i].Point, pointList[j].Point).Value();
// Make a parallel line with this line starting from the initial point
OCgp_Lin resultLine = new OCgce_MakeLin(line, initialPosition.Point).Value();
OCGeom_Line geomLine = new OCGeom_Line(resultLine);
// Project the point on the parallel line, with this finding the magic point that
// makes the parallelism
var projectionPoint = new OCGeomAPI_ProjectPointOnCurve(currentPoint.Point, geomLine);
if (projectionPoint.NbPoints() > 0)
{
return new SolverPoint(projectionPoint.NearestPoint(), GeometryType.Parallel);
}
}

No comments: