示例#1
0
        /// <summary>
        /// add new trimloop to datamodel
        /// </summary>
        public static void AddNewTrimCurve(TrimLoopSO curveSO)
        {
            curveSO.AssignSOMaterial(OrthogenMaterials.TrimLoopMaterial);
            curveSO.ConnectToTarget(OG.Leg, OG.Leg.SO, true);
            curveSO.Name = "TrimLine";
            curveSO.RootGameObject.SetLayer(OrthogenMaterials.CurvesLayer);
            OG.Model.InitializeTrimline(curveSO);

            // if we delete this SO, we need to update some things
            OG.Model.RegisterDeleteSOAction(curveSO, OnTrimLineDeleted);
        }
示例#2
0
        /// <summary>
        /// this is set as result action in draw-surface-loop tool, converts curve preview into a TrimLoopSO
        /// </summary>
        public static void EmitTrimCurveFromPreview(CurvePreview preview)
        {
            TrimLoopSO curveSO = TrimLoopSO.CreateFromPreview(preview, OrthogenMaterials.TrimLoopMaterial, OG.Scene);

            AddNewTrimCurve(curveSO);

            // next frame, transition, and select the curve
            OG.Context.RegisterNextFrameAction(() => {
                OG.Transition(OGWorkflow.DrawTrimlineExitT);
                OG.Scene.Select(curveSO, true);
            });
        }
示例#3
0
        public void RemoveTrimLine()
        {
            trimline = null;

            if (socket != null)
            {
                socket.EnableUpdate = false;
                socket.RemoveTrimLine();
                socket.HideSocket();
            }

            OnDataModelModified?.Invoke(this, EventArgs.Empty);
        }
示例#4
0
        public void InitializeTrimline(TrimLoopSO so)
        {
            trimline = so;

            if (socket != null)
            {
                socket.SetNewTrimLine(trimline);
                socket.EnableUpdate = true;
                socket.ShowSocket();
            }

            OnDataModelModified?.Invoke(this, EventArgs.Empty);
        }
示例#5
0
        /// <summary>
        /// initial trimline from plane-cut
        /// </summary>
        public static void EmitTrimCurveFromPlane(SceneObject targetLegSO, Frame3f planeFrameS)
        {
            TrimLoopSO curveSO = TrimLoopSO.CreateFromPlane(
                targetLegSO as DMeshSO, planeFrameS, OrthogenMaterials.PlaneCurveMaterial,
                targetLegSO.GetScene(), OrthogenUI.CurveOnSurfaceOffsetTol);

            curveSO.ConnectToTarget(OG.Leg, OG.Leg.SO, true);
            curveSO.Name = "TrimLine";
            curveSO.RootGameObject.SetLayer(OrthogenMaterials.CurvesLayer);
            OG.Model.InitializeTrimline(curveSO);

            // if we delete this SO, we need to update some things
            OG.Model.RegisterDeleteSOAction(curveSO, OnTrimLineDeleted);

            // next frame, transition, and select the curve
            OG.Context.RegisterNextFrameAction(() => {
                OG.Scene.Select(curveSO, true);
            });
        }
示例#6
0
        /// <summary>
        /// parse the DataModel section of the save file, and restore the scene/datamodel as necessary
        /// </summary>
        /// <param name="xml"></param>
        protected virtual void RestoreDataModel(XmlDocument xml)
        {
            // look up root datamodel (should only be one)
            XmlNodeList datamodels = xml.SelectNodes("//DataModel");
            XmlNode     datamodel  = datamodels[0];


            // find scan
            ScanSO scanSO = OG.Scene.FindSceneObjectsOfType <ScanSO>().FirstOrDefault();

            if (scanSO == null)
            {
                throw new Exception("OGSerializer.RestoreDataModel: no ScanSO?");
            }

            // [TODO] we have scanIn and scanOut, don't we?!?
            // start in scan state, restore the scan
            OGActions.RestoreSocketDesignFromScan(OG.Context, scanSO);


            // [TODO] should only do this transition if user has accepted scan
            //    (probably should have some current-state field in datamodel)
            OG.TransitionToState(RectifyState.Identifier);


            // restore LegModel deformation ops
            XmlNodeList deformationOps = datamodel.SelectNodes("LegDeformOp");

            foreach (XmlNode opNode in deformationOps)
            {
                string type    = opNode.Attributes["OpType"].InnerText;
                string so_uuid = opNode.Attributes["SceneObjectUUID"].InnerText;

                if (type == typeof(EnclosedRegionOffsetOp).ToString())
                {
                    EnclosedPatchSO patchSO = OG.Scene.FindByUUID(so_uuid) as EnclosedPatchSO;
                    var             newOp   = OGActions.AddNewRegionDeformation(patchSO, LegModel.LegDeformationTypes.Offset);
                    double          offset  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as EnclosedRegionOffsetOp).PushPullDistance = offset;
                    }
                }
                else if (type == typeof(EnclosedRegionSmoothOp).ToString())
                {
                    EnclosedPatchSO patchSO = OG.Scene.FindByUUID(so_uuid) as EnclosedPatchSO;
                    var             newOp   = OGActions.AddNewRegionDeformation(patchSO, LegModel.LegDeformationTypes.Smooth);
                    double          smooth  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Smooth"].InnerText, out smooth))
                    {
                        (newOp as EnclosedRegionSmoothOp).SmoothAlpha = smooth;
                    }
                    double offset = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as EnclosedRegionSmoothOp).OffsetDistance = offset;
                    }
                }
                else if (type == typeof(PlaneBandExpansionOp).ToString())
                {
                    PlaneIntersectionCurveSO curveSO = OG.Scene.FindByUUID(so_uuid) as PlaneIntersectionCurveSO;
                    var    newOp  = OGActions.AddNewPlaneBandExpansion(curveSO);
                    double extent = 0.0f;
                    if (double.TryParse(opNode.Attributes["Extent"].InnerText, out extent))
                    {
                        (newOp as PlaneBandExpansionOp).BandDistance = extent;
                    }
                    double offset = 0.0f;
                    if (double.TryParse(opNode.Attributes["Offset"].InnerText, out offset))
                    {
                        (newOp as PlaneBandExpansionOp).PushPullDistance = offset;
                    }
                    Vector3d origin = TryParseVector3(opNode.Attributes["Origin"].InnerText);
                    (newOp as PlaneBandExpansionOp).Origin = origin;
                    Vector3d normal = TryParseVector3(opNode.Attributes["Normal"].InnerText);
                    (newOp as PlaneBandExpansionOp).Normal = normal;
                }
                else if (type == typeof(LengthenOp).ToString())
                {
                    LengthenPivotSO pivotSO = OG.Scene.FindByUUID(so_uuid) as LengthenPivotSO;
                    LengthenOp      newOp   = OGActions.AddNewLengthenOp(pivotSO);
                    double          offset  = 0.0f;
                    if (double.TryParse(opNode.Attributes["Distance"].InnerText, out offset))
                    {
                        newOp.LengthenDistance = offset;
                    }
                }
            }


            // if we have a trimloop, restore it
            TrimLoopSO trimSO = OG.Scene.FindSceneObjectsOfType <TrimLoopSO>().FirstOrDefault();

            if (trimSO != null)
            {
                OG.TransitionToState(SocketDesignState.Identifier);
                OGActions.AddNewTrimCurve(trimSO);
            }

            // [TODO] restore socket enabled, parameters, etc
        }