コード例 #1
0
        void ungroupSelectedBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string makingCopyLabel     = LocalizedString.Get("Ungrouping");
            string makingCopyLabelFull = string.Format("{0}:", makingCopyLabel);

            processingProgressControl.ProcessType = makingCopyLabelFull;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            BackgroundWorker backgroundWorker = (BackgroundWorker)sender;

            PushMeshGroupDataToAsynchLists(TraceInfoOpperation.DO_COPY);

            int indexBeingReplaced = SelectedMeshGroupIndex;

            asynchMeshGroups[indexBeingReplaced].Transform(asynchMeshGroupTransforms[indexBeingReplaced].TotalTransform);
            List <Mesh> discreetMeshes = CreateDiscreteMeshes.SplitConnectedIntoMeshes(asynchMeshGroups[indexBeingReplaced], (double progress0To1, string processingState, out bool continueProcessing) =>
            {
                BackgroundWorker_ProgressChanged(progress0To1 * .5, processingState, out continueProcessing);
            });

            asynchMeshGroups.RemoveAt(indexBeingReplaced);
            asynchPlatingDatas.RemoveAt(indexBeingReplaced);
            asynchMeshGroupTransforms.RemoveAt(indexBeingReplaced);
            double ratioPerDiscreetMesh = 1.0 / discreetMeshes.Count;
            double currentRatioDone     = 0;

            for (int discreetMeshIndex = 0; discreetMeshIndex < discreetMeshes.Count; discreetMeshIndex++)
            {
                PlatingMeshGroupData newInfo = new PlatingMeshGroupData();
                asynchPlatingDatas.Add(newInfo);
                asynchMeshGroups.Add(new MeshGroup(discreetMeshes[discreetMeshIndex]));
                int       addedMeshIndex = asynchMeshGroups.Count - 1;
                MeshGroup addedMeshGroup = asynchMeshGroups[addedMeshIndex];

                ScaleRotateTranslate transform = ScaleRotateTranslate.Identity();
                transform.SetCenteringForMeshGroup(addedMeshGroup);
                asynchMeshGroupTransforms.Add(transform);

                //PlatingHelper.PlaceMeshGroupOnBed(asynchMeshGroups, asynchMeshGroupTransforms, addedMeshIndex, false);

                // and create selection info
                PlatingHelper.CreateITraceableForMeshGroup(asynchPlatingDatas, asynchMeshGroups, addedMeshIndex, (double progress0To1, string processingState, out bool continueProcessing) =>
                {
                    BackgroundWorker_ProgressChanged(progress0To1 * .5 + .5, processingState, out continueProcessing);
                });
                currentRatioDone += ratioPerDiscreetMesh;
            }
        }
コード例 #2
0
        public static void FindPositionForGroupAndAddToPlate(MeshGroup meshGroupToAdd, ScaleRotateTranslate meshTransform, List <PlatingMeshGroupData> perMeshInfo, List <MeshGroup> meshesGroupsToAvoid, List <ScaleRotateTranslate> meshTransforms)
        {
            if (meshGroupToAdd == null || meshGroupToAdd.Meshes.Count < 1)
            {
                return;
            }

            meshesGroupsToAvoid.Add(meshGroupToAdd);

            PlatingMeshGroupData newMeshInfo = new PlatingMeshGroupData();

            perMeshInfo.Add(newMeshInfo);
            meshTransform.SetCenteringForMeshGroup(meshGroupToAdd);
            meshTransforms.Add(meshTransform);

            int meshGroupIndex = meshesGroupsToAvoid.Count - 1;

            MoveMeshGroupToOpenPosition(meshGroupIndex, perMeshInfo, meshesGroupsToAvoid, meshTransforms);

            PlaceMeshGroupOnBed(meshesGroupsToAvoid, meshTransforms, meshGroupIndex, false);
        }
コード例 #3
0
        public static void FindPositionForGroupAndAddToPlate(MeshGroup meshGroupToAdd, ScaleRotateTranslate meshTransform, List <PlatingMeshGroupData> perMeshInfo, List <MeshGroup> meshesGroupsToAvoid, List <ScaleRotateTranslate> meshTransforms)
        {
            if (meshGroupToAdd == null || meshGroupToAdd.Meshes.Count < 1)
            {
                return;
            }

            // first find the bounds of what is already here.
            AxisAlignedBoundingBox allPlacedMeshBounds = GetAxisAlignedBoundingBox(meshesGroupsToAvoid[0], meshTransforms[0].TotalTransform);

            for (int i = 1; i < meshesGroupsToAvoid.Count; i++)
            {
                AxisAlignedBoundingBox nextMeshBounds = GetAxisAlignedBoundingBox(meshesGroupsToAvoid[i], meshTransforms[i].TotalTransform);
                allPlacedMeshBounds = AxisAlignedBoundingBox.Union(allPlacedMeshBounds, nextMeshBounds);
            }

            meshesGroupsToAvoid.Add(meshGroupToAdd);

            PlatingMeshGroupData newMeshInfo = new PlatingMeshGroupData();

            perMeshInfo.Add(newMeshInfo);
            meshTransform.SetCenteringForMeshGroup(meshGroupToAdd);
            meshTransforms.Add(meshTransform);

            int meshGroupIndex = meshesGroupsToAvoid.Count - 1;

            // move the part to the total bounds lower left side
            MeshGroup            meshGroup     = meshesGroupsToAvoid[meshGroupIndex];
            Vector3              meshLowerLeft = GetAxisAlignedBoundingBox(meshGroup, meshTransforms[meshGroupIndex].TotalTransform).minXYZ;
            ScaleRotateTranslate atLowerLeft   = meshTransforms[meshGroupIndex];

            atLowerLeft.translation       *= Matrix4X4.CreateTranslation(-meshLowerLeft + allPlacedMeshBounds.minXYZ);
            meshTransforms[meshGroupIndex] = atLowerLeft;

            MoveMeshGroupToOpenPosition(meshGroupIndex, perMeshInfo, meshesGroupsToAvoid, meshTransforms);

            PlaceMeshGroupOnBed(meshesGroupsToAvoid, meshTransforms, meshGroupIndex);
        }
コード例 #4
0
        private void UngroupSelected()
        {
            if (SelectedMeshGroupIndex == -1)
            {
                SelectedMeshGroupIndex = 0;
            }
            string makingCopyLabel     = LocalizedString.Get("Ungrouping");
            string makingCopyLabelFull = string.Format("{0}:", makingCopyLabel);

            processingProgressControl.ProcessType = makingCopyLabelFull;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            PushMeshGroupDataToAsynchLists(TraceInfoOpperation.DO_COPY);

            int         indexBeingReplaced = SelectedMeshGroupIndex;
            List <Mesh> discreetMeshes     = new List <Mesh>();

            asynchMeshGroups[indexBeingReplaced].Transform(asynchMeshGroupTransforms[indexBeingReplaced].TotalTransform);
            // if there are multiple meshes than just make them separate groups
            if (asynchMeshGroups[indexBeingReplaced].Meshes.Count > 1)
            {
                foreach (Mesh mesh in asynchMeshGroups[indexBeingReplaced].Meshes)
                {
                    discreetMeshes.Add(mesh);
                }
            }
            else             // actually try and cut up the mesh into separate parts
            {
                discreetMeshes = CreateDiscreteMeshes.SplitConnectedIntoMeshes(asynchMeshGroups[indexBeingReplaced], (double progress0To1, string processingState, out bool continueProcessing) =>
                {
                    ReportProgressChanged(progress0To1 * .5, processingState, out continueProcessing);
                });
            }

            asynchMeshGroups.RemoveAt(indexBeingReplaced);
            asynchPlatingDatas.RemoveAt(indexBeingReplaced);
            asynchMeshGroupTransforms.RemoveAt(indexBeingReplaced);
            double ratioPerDiscreetMesh = 1.0 / discreetMeshes.Count;
            double currentRatioDone     = 0;

            for (int discreetMeshIndex = 0; discreetMeshIndex < discreetMeshes.Count; discreetMeshIndex++)
            {
                PlatingMeshGroupData newInfo = new PlatingMeshGroupData();
                asynchPlatingDatas.Add(newInfo);
                asynchMeshGroups.Add(new MeshGroup(discreetMeshes[discreetMeshIndex]));
                int       addedMeshIndex = asynchMeshGroups.Count - 1;
                MeshGroup addedMeshGroup = asynchMeshGroups[addedMeshIndex];

                ScaleRotateTranslate transform = ScaleRotateTranslate.Identity();
                transform.SetCenteringForMeshGroup(addedMeshGroup);
                asynchMeshGroupTransforms.Add(transform);

                //PlatingHelper.PlaceMeshGroupOnBed(asynchMeshGroups, asynchMeshGroupTransforms, addedMeshIndex, false);

                // and create selection info
                PlatingHelper.CreateITraceableForMeshGroup(asynchPlatingDatas, asynchMeshGroups, addedMeshIndex, (double progress0To1, string processingState, out bool continueProcessing) =>
                {
                    ReportProgressChanged(.5 + progress0To1 * .5 * currentRatioDone, processingState, out continueProcessing);
                });
                currentRatioDone += ratioPerDiscreetMesh;
            }
        }