protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            GetObject go = new GetObject();

            go.SetCommandPrompt("Select two curves for planar curve containment test");
            go.GeometryFilter          = ObjectType.Curve;
            go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve;
            go.SubObjectSelect         = false;
            go.GetMultiple(2, 2);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            Rhino.Geometry.Curve curveA = go.Object(0).Curve();
            Rhino.Geometry.Curve curveB = go.Object(1).Curve();
            if (null == curveA || null == curveB)
            {
                return(Result.Failure);
            }

            Plane planeA, planeB;

            if (!curveA.IsPlanar() || !curveA.TryGetPlane(out planeA))
            {
                RhinoApp.WriteLine("Curve A is not planar.");
                return(Result.Success);
            }

            if (!curveB.IsPlanar() || !curveB.TryGetPlane(out planeB))
            {
                RhinoApp.WriteLine("Curve B is not planar.");
                return(Result.Success);
            }

            double            tol = Rhino.RhinoMath.ZeroTolerance;
            RegionContainment rc  = Curve.PlanarClosedCurveRelationship(curveA, curveB, planeA, tol);

            switch (rc)
            {
            case RegionContainment.Disjoint:
                RhinoApp.WriteLine("There is no common area between the two regions.");
                break;

            case RegionContainment.MutualIntersection:
                RhinoApp.WriteLine("The two curves intersect. No full containment relationship exists.");
                break;

            case RegionContainment.AInsideB:
                RhinoApp.WriteLine("Region bounded by curveA (first curve) is inside of curveB (second curve).");
                break;

            case RegionContainment.BInsideA:
                RhinoApp.WriteLine("Region bounded by curveB (second curve) is inside of curveA (first curve).");
                break;
            }

            return(Result.Success);
        }
 public static IfcBoundedCurve ConvertRhinoCommonCurve(DatabaseIfc db, Curve crv)
 {
     double tol = db.Tolerance, angTol = Math.PI / 1800;
     if (crv.IsLinear(tol))
         return new IfcPolyline(new List<IfcCartesianPoint>() { new IfcCartesianPoint(db, crv.PointAtStart), new IfcCartesianPoint(db, crv.PointAtEnd) });
     Plane pln = new Plane();
     if (crv.TryGetPlane(out pln, tol))
     {
         if (Math.Abs(pln.Origin.Z) < tol && pln.ZAxis.IsParallelTo(Vector3d.ZAxis, angTol) != 0)
             return convCurve(db, crv, true);
     }
     return convCurve(db, crv, false);
 }
Example #3
0
 /// <summary>
 /// Find the curve in this collection which encloses the others
 /// </summary>
 /// <param name="curves"></param>
 /// <returns></returns>
 private static RC.Curve outerCurve(IList <RC.Curve> curves)
 {
     if (curves.Count == 0)
     {
         return(null);
     }
     RC.Curve result = curves[0];
     RC.Plane plane;
     if (!result.TryGetPlane(out plane))
     {
         return(null);
     }
     for (int i = 1; i < curves.Count; i++)
     {
         RC.Curve curve       = curves[i];
         var      containment = RC.Curve.PlanarClosedCurveRelationship(result, curve, plane, Tolerance.Distance);
         if (containment == RC.RegionContainment.AInsideB)
         {
             result = curve;
         }
     }
     return(result);
 }