示例#1
0
        /// <summary>
        /// Initialize the data model to the new-imported-scan state, with the given mesh (presumably loaded from file?)
        /// </summary>
        public static void InitializeScan(DMesh3 mesh)
        {
            AxisAlignedBox3d bounds    = mesh.CachedBounds;
            Vector3d         translate = -bounds.Center;
            double           dy        = 0.5 * bounds.Height;

            MeshTransforms.Translate(mesh, translate);

            ScanSO scanSO = new ScanSO();

            scanSO.Create(mesh, OrthogenMaterials.ScanMaterial);
            OG.Scene.AddSceneObject(scanSO);

            Frame3f f = scanSO.GetLocalFrame(CoordSpace.SceneCoords);

            f.Translate((float)dy * Vector3f.AxisY);
            scanSO.SetLocalFrame(f, CoordSpace.SceneCoords);

            OG.Model.InitializeScan(scanSO);
            OG.Model.Workflow.SetInitialState(ScanState.Identifier);

            // reposition camera
            Vector3f c = scanSO.GetLocalFrame(CoordSpace.WorldCoords).Origin;

            //OG.Context.ActiveCamera.Animator().PanFocus(c);
            OG.Context.ActiveCamera.Manipulator().ScenePanFocus(
                OG.Context.Scene, OG.Context.ActiveCamera, c, false);

            // [TODO] this should happen via a transition, I think...

            // set up xforms/etc
            OG.Context.TransformManager.SetActiveGizmoType(AxisTransformGizmo.DefaultName);
        }
示例#2
0
        /// <summary>
        /// assuming we restored a ScanSO from save file, restore Scan parts of datamodel
        /// </summary>
        public static void RestoreScan(ScanSO scanSO)
        {
            OG.Model.InitializeScan(scanSO);
            OG.Model.Workflow.SetInitialState(ScanState.Identifier);

            // reposition camera
            Vector3f c = scanSO.GetLocalFrame(CoordSpace.WorldCoords).Origin;

            OG.Context.ActiveCamera.Manipulator().ScenePanFocus(
                OG.Context.Scene, OG.Context.ActiveCamera, c, false);

            // [TODO] this should happen via a transition, I think...

            // set up xforms/etc
            OG.Context.TransformManager.SetActiveGizmoType(AxisTransformGizmo.DefaultName);
        }
示例#3
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
        }
示例#4
0
 public void InitializeScan(ScanSO so)
 {
     scan = new ScanModel(so);
     OnDataModelModified?.Invoke(this, EventArgs.Empty);
 }
示例#5
0
 /// <summary>
 /// Initialize datamodel / workflow / etc for Socket design, based on restored scan SO
 /// </summary>
 public static void RestoreSocketDesignFromScan(FContext context, ScanSO scanSO)
 {
     OG.Reinitialize(context, DesignTypes.StandardLegSocket);
     OGActions.RestoreScan(scanSO);
 }