예제 #1
0
        /// <summary>
        /// Read a history record and extract the references for the antecedent objects.
        /// </summary>
        private bool ReadHistory(ReplayHistoryData replay, ref ObjRef railObjRef, ref ObjRef shapeObjRef, ref double tolerance)
        {
            if (HISTORY_VERSION != replay.HistoryVersion)
            {
                return(false);
            }

            railObjRef = replay.GetRhinoObjRef(0);
            if (null == railObjRef)
            {
                return(false);
            }

            shapeObjRef = replay.GetRhinoObjRef(1);
            if (null == shapeObjRef)
            {
                return(false);
            }

            if (!replay.TryGetDouble(2, out tolerance))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Rhino calls the virtual ReplayHistory functions to to remake an objects when inputs have changed.
        /// </summary>
        protected override bool ReplayHistory(ReplayHistoryData replay)
        {
            ObjRef rail_objref  = null;
            ObjRef shape_objref = null;
            double tolerance    = RhinoMath.UnsetValue;

            if (!ReadHistory(replay, ref rail_objref, ref shape_objref, ref tolerance))
            {
                return(false);
            }

            Rhino.Geometry.Curve rail_curve = rail_objref.Curve();
            if (null == rail_curve)
            {
                return(false);
            }

            Rhino.Geometry.Curve shape_curve = shape_objref.Curve();
            if (null == shape_curve)
            {
                return(false);
            }

            if (!Rhino.RhinoMath.IsValidDouble(tolerance))
            {
                tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
            }

            Brep[] brep = Brep.CreateFromSweep(rail_curve, shape_curve, false, tolerance);
            if (null == brep || 0 == brep.Length)
            {
                return(false);
            }

            for (int i = 0; i < brep.Length; i++)
            {
                if (null != replay.Results[i])
                {
                    replay.Results[i].UpdateToBrep(brep[i], null);
                }
                else
                {
                    break;
                }
            }

            return(true);
        }