コード例 #1
0
 public void WriteToSettings(PrintMeshSettings settings)
 {
     settings.ObjectType     = object_type;
     settings.NoVoids        = NoVoids;
     settings.OuterShellOnly = OuterShellOnly;
     settings.OpenMeshMode   = OpenMode;
     settings.Clearance      = Clearance;
     settings.OffsetXY       = OffsetXY;
 }
コード例 #2
0
ファイル: PrintMeshSO.cs プロジェクト: tomleetv/Cotangent
        public static PrintMeshSettings RestorePrintMeshSettings(SOFactory factory, TypedAttribSet attributes)
        {
            PrintMeshSettings settings = new PrintMeshSettings();

            TypedAttribSet attribs = factory.find_struct(attributes, PrintSettingsStruct);

            if (attribs == null)
            {
                throw new Exception("PrintMeshSO.RestorePrintMeshSettings: PrintMeshSettings struct not found!");
            }

            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsVersion))
            {
                settings.Version = (int)attribs[AttrPrintSettingsVersion];
            }

            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsObjectType))
            {
                settings.ObjectType = (PrintMeshSettings.ObjectTypes)(int) attribs[AttrPrintSettingsObjectType];
            }
            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsOpenMode))
            {
                settings.OpenMeshMode = (PrintMeshSettings.OpenMeshModes)(int) attribs[AttrPrintSettingsOpenMode];
            }

            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsNoVoids))
            {
                settings.NoVoids = (bool)attribs[AttrPrintSettingsNoVoids];
            }
            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsShellOnly))
            {
                settings.OuterShellOnly = (bool)attribs[AttrPrintSettingsShellOnly];
            }

            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsClearanceXY))
            {
                settings.Clearance = (float)attribs[AttrPrintSettingsClearanceXY];
            }
            if (factory.check_key_or_debug_print(attribs, AttrPrintSettingsOffsetXY))
            {
                settings.OffsetXY = (float)attribs[AttrPrintSettingsOffsetXY];
            }

            return(settings);
        }
コード例 #3
0
        public void UpdateFromSettings(PrintMeshSO printSO)
        {
            if (printSO == null)
            {
                return;
            }

            ActiveSO = printSO;
            Active   = printSO.Settings;

            // Note!! have to use internal variables here, if we use accessors then we
            // will spawn toolpath invalidations when objects change
            object_type = Active.ObjectType;
            no_voids    = Active.NoVoids;
            shell_only  = Active.OuterShellOnly;
            open_mode   = Active.OpenMeshMode;
            clearance   = Active.Clearance;
            offset_xy   = Active.OffsetXY;

            bValueModified = false;
            OnNewSettings?.Invoke(this);
        }
コード例 #4
0
ファイル: PrintMeshSO.cs プロジェクト: tomleetv/Cotangent
        public static SceneObject Build(SOFactory factory, FScene scene, TypedAttribSet attributes)
        {
            PrintMeshSO so = new PrintMeshSO();

            factory.RestoreDMeshSO(scene, attributes, so);

            if (attributes.ContainsKey(AttrSourceFilePath))
            {
                so.SourceFilePath = attributes[AttrSourceFilePath] as string;
            }

            PrintMeshSettings settings = null;

            try {
                settings = RestorePrintMeshSettings(factory, attributes);
            } catch { }
            if (settings != null)
            {
                so.Settings = settings;
            }

            return(so);
        }
コード例 #5
0
ファイル: PrintMeshSO.cs プロジェクト: tomleetv/Cotangent
        public static void EmitPrintMeshSettings(this SceneSerializer s, IOutputStream o, PrintMeshSettings settings)
        {
            o.BeginStruct(PrintSettingsStruct);
            o.AddAttribute(AttrPrintSettingsVersion, settings.Version);

            o.AddAttribute(AttrPrintSettingsObjectType, (int)settings.ObjectType);
            o.AddAttribute(AttrPrintSettingsOpenMode, (int)settings.OpenMeshMode);

            o.AddAttribute(AttrPrintSettingsNoVoids, settings.NoVoids);
            o.AddAttribute(AttrPrintSettingsShellOnly, settings.OuterShellOnly);

            o.AddAttribute(AttrPrintSettingsClearanceXY, (float)settings.Clearance);
            o.AddAttribute(AttrPrintSettingsOffsetXY, (float)settings.OffsetXY);

            o.EndStruct();
        }
コード例 #6
0
ファイル: GeometrySlicer.cs プロジェクト: tomleetv/Cotangent
            public void Compute()
            {
                int N = meshToScene.Length;

                slicer = new MeshPlanarSlicerPro()
                {
                    LayerHeightMM = CC.Settings.LayerHeightMM,
                    // [RMS] 1.5 here is a hack. If we don't leave a bit of space then often the filament gets squeezed right at
                    //   inside/outside transitions, which is bad. Need a better way to handle.
                    OpenPathDefaultWidthMM = CC.Settings.NozzleDiameterMM * 1.5,
                    SetMinZValue           = 0,
                    SliceFactoryF          = PlanarSlicePro.FactoryF
                };
                if (CC.Settings.OpenMode == PrintSettings.OpenMeshMode.Clipped)
                {
                    slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Clipped;
                }
                else if (CC.Settings.OpenMode == PrintSettings.OpenMeshMode.Embedded)
                {
                    slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Embedded;
                }
                else if (CC.Settings.OpenMode == PrintSettings.OpenMeshMode.Ignored)
                {
                    slicer.DefaultOpenPathMode = PrintMeshOptions.OpenPathsModes.Ignored;
                }

                if (CC.Settings.StartLayers > 0)
                {
                    int    start_layers       = CC.Settings.StartLayers;
                    double std_layer_height   = CC.Settings.LayerHeightMM;
                    double start_layer_height = CC.Settings.StartLayerHeightMM;
                    slicer.LayerHeightF = (layer_i) => {
                        return((layer_i < start_layers) ? start_layer_height : std_layer_height);
                    };
                }

                try {
                    assembly = new PrintMeshAssembly();
                    for (int k = 0; k < N; ++k)
                    {
                        DMesh3            mesh     = meshCopies[k];
                        Frame3f           mapF     = meshToScene[k];
                        PrintMeshSettings settings = meshSettings[k];

                        PrintMeshOptions options = new PrintMeshOptions();
                        options.IsSupport    = (settings.ObjectType == PrintMeshSettings.ObjectTypes.Support);
                        options.IsCavity     = (settings.ObjectType == PrintMeshSettings.ObjectTypes.Cavity);
                        options.IsCropRegion = (settings.ObjectType == PrintMeshSettings.ObjectTypes.CropRegion);
                        options.IsOpen       = false;
                        if (settings.OuterShellOnly)
                        {
                            options.IsOpen = true;
                        }
                        options.OpenPathMode = PrintMeshSettings.Convert(settings.OpenMeshMode);
                        options.Extended     = new ExtendedPrintMeshOptions()
                        {
                            ClearanceXY = settings.Clearance,
                            OffsetXY    = settings.OffsetXY
                        };

                        Vector3f scale = localScale[k];
                        MeshTransforms.Scale(mesh, scale.x, scale.y, scale.z);
                        MeshTransforms.FromFrame(mesh, mapF);
                        MeshTransforms.FlipLeftRightCoordSystems(mesh);
                        MeshTransforms.ConvertYUpToZUp(mesh);

                        MeshAssembly decomposer = new MeshAssembly(mesh);
                        decomposer.HasNoVoids = settings.NoVoids;
                        decomposer.Decompose();

                        assembly.AddMeshes(decomposer.ClosedSolids, options);

                        PrintMeshOptions openOptions = options.Clone();
                        assembly.AddMeshes(decomposer.OpenMeshes, openOptions);
                    }

                    if (slicer.Add(assembly) == false)
                    {
                        throw new Exception("error adding PrintMeshAssembly to Slicer!!");
                    }

                    // set clip box
                    Box2d clip_box = new Box2d(Vector2d.Zero,
                                               new Vector2d(CC.Settings.BedSizeXMM / 2, CC.Settings.BedSizeYMM / 2));
                    slicer.ValidRegions = new List <GeneralPolygon2d>()
                    {
                        new GeneralPolygon2d(new Polygon2d(clip_box.ComputeVertices()))
                    };

                    result  = slicer.Compute();
                    Success = true;
                } catch (Exception e) {
                    DebugUtil.Log("GeometrySlicer.Compute: exception: " + e.Message);
                    Success = false;
                }

                Finished = true;
            }
コード例 #7
0
 public void ClearCurrentSettings()
 {
     Active   = null;
     ActiveSO = null;
 }