Esempio n. 1
0
 public SelBoxCasePalletSolution(Document document, BoxCasePalletAnalysis analysis, BoxCasePalletSolution sol)
     : base(document)
 {
     _analysis = analysis;
     _solution = sol;
     Name = sol.Title;
 }
Esempio n. 2
0
 public TruckProperties(Document document, double length, double width, double height)
     : base(document)
 {
     _length = length;
     _width = width;
     _height = height;
 }
 public PalletProperties(Document document, string typeName, double length, double width, double height)
     : base(document)
 {
     _typeName = typeName;
     _length = length;
     _width = width;
     _height = height;
 }
Esempio n. 4
0
 /// <summary>
 /// Default constructor used for creating analysis
 /// </summary>
 public FormNewAnalysisHCylinder(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
 }
 /// <summary>
 /// Default constructor used for creating analysis 
 /// </summary>
 public FormNewAnalysisHCylinder(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
 }
 /// <summary>
 /// Constructor 2
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="length">Outer length</param>
 /// <param name="width">Outer width</param>
 /// <param name="height">Outer height</param>
 public BoxProperties(Document document, double length, double width, double height)
     : base(document)
 {
     _length     = length;
     _width      = width;
     _height     = height;
     _hasInsideDimensions = false;
     _showTape = false;
 }
Esempio n. 7
0
        public SelBoxCaseSolution(Document document, BoxCaseAnalysis analysis, BoxCaseSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name = sol.Title;
        }
Esempio n. 8
0
 public CylinderProperties(Document document, string name, string description
     , double radius, double height, double weight, Color colorTop, Color colorWall)
     : base(document, name, description)
 {
     _radius = radius;
     _height = height;
     _weight = weight;
     _colorTop = colorTop;
     _colorWall = colorWall;
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="document">Parent document</param>
 public FormNewBoxCaseAnalysis(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     // name
     tbName.Text        = _document.GetValidNewAnalysisName(Resources.ID_ANALYSIS);
     tbDescription.Text = tbName.Text;
 }
Esempio n. 10
0
 /// <summary>
 /// Default constructor used for creating analysis
 /// </summary>
 public FormNewAnalysisCylinder(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     // update interlayer UI
     onInterlayerChecked(this, null);
     onInterlayerAntiSlipChecked(this, null);
 }
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Analysis</param>
 public FormNewBoxCaseAnalysis(Document document, BoxCaseAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
 }
Esempio n. 12
0
 /// <summary>
 /// Constructor 3
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="length">Outer length</param>
 /// <param name="width">Outer width</param>
 /// <param name="height">Outer height</param>
 /// <param name="insideLength">Inner length</param>
 /// <param name="insideWidth">Inner width</param>
 /// <param name="insideHeight">Inner height</param>
 public BoxProperties(Document document, double length, double width, double height, double insideLength, double insideWidth, double insideHeight)
     : base(document)
 {
     _length     = length;
     _width      = width;
     _height     = height;
     _insideLength = insideLength;
     _insideWidth = insideWidth;
     _insideHeight = insideHeight;
     _hasInsideDimensions = true;
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="document">Parent document</param>
 public FormNewBoxCaseAnalysis(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     // name
     tbName.Text = _document.GetValidNewAnalysisName(Resources.ID_ANALYSIS);
     tbDescription.Text = tbName.Text;
 }
 /// <summary>
 /// Default constructor used for creating analysis 
 /// </summary>
 public FormNewAnalysisCylinder(Document document)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     // update interlayer UI
     onInterlayerChecked(this, null);
     onInterlayerAntiSlipChecked(this, null);
 }
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 public FormNewAnalysisHCylinder(Document document, HCylinderPalletAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
 }
 /// <summary>
 /// Instantiate a new case from a box, a case definition and a case optimization constraintset
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="bProperties">Box properties</param>
 /// <param name="constraintSet">Case optimization constraint set</param>
 public CaseOfBoxesProperties(Document document
     , BoxProperties boxProperties
     , CaseDefinition caseDefinition
     , CaseOptimConstraintSet constraintSet)
     : base(document)
 {
     _boxProperties = boxProperties;
     _boxProperties.AddDependancie(this);
     _caseDefinition = caseDefinition;
     _constraintSet = constraintSet;
     OnAttributeModified(boxProperties);
 }
 /// <summary>
 /// Constructor 2
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="width">Width</param>
 /// <param name="color">Color</param>
 public PalletCornerProperties(Document document,
     string name, string description,
     double length, double width, double thickness,
     double weight,
     Color color)
     : base(document, name, description)
 {
     _length = length;
     _width = width;
     _thickness = thickness;
     _weight = weight;
     _color = color;
 }
 public CylinderProperties(Document document, string name, string description
     , double radiusOuter, double radiusInner, double height, double weight
     , Color colorTop, Color colorWallOuter, Color colorWallInner)
     : base(document, name, description)
 {
     _radiusOuter = radiusOuter;
     _radiusInner = radiusInner;
     _height = height;
     _weight = weight;
     _colorTop = colorTop;
     _colorWallOuter = colorWallOuter;
     _colorWallInner = colorWallInner;
 }
Esempio n. 19
0
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 public FormNewAnalysisCylinder(Document document, CylinderPalletAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
     // update interlayer UI
     onInterlayerChecked(this, null);
     onInterlayerAntiSlipChecked(this, null);
 }
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 public FormNewAnalysisCylinder(Document document, CylinderPalletAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
     // update interlayer UI
     onInterlayerChecked(this, null);
     onInterlayerAntiSlipChecked(this, null);
 }
Esempio n. 21
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="doc">Reference of parent <see cref="Document"/></param>
        /// <param name="box">Reference </param>
        public PackProperties(Document doc
            , BoxProperties box
            , PackArrangement arrangement
            , HalfAxis.HAxis orientation
            , PackWrapper wrapper)
            : base(doc)
        {
            _boxProperties = box;
            _boxProperties.AddDependancy(this);

            _arrangement = arrangement;
            _orientation = orientation;
            _wrapper = wrapper;
        }
Esempio n. 22
0
 /// <summary>
 /// Truck analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Parent pallet analysis</param>
 /// <param name="selSolution">Parent selected solution</param>
 /// <param name="truckProperties">TruckProperties item</param>
 /// <param name="constraintSet">Constraint set</param>
 public TruckAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution
     , TruckProperties truckProperties
     , TruckConstraintSet constraintSet)
     : base(document)
 {
     Name = truckProperties.Name;
     _analysis = analysis;
     _selSolution = selSolution;
     this.TruckProperties = truckProperties;
     _constraintSet = constraintSet;
 }
Esempio n. 23
0
 public BundleProperties(Document document, string name, string description,
     double length, double width
     , double unitThickness
     , double unitWeight
     , int noFlats
     , Color color)
     : base(document, name, description)
 {
     _length = length;
     _width = width;
     _unitThickness = unitThickness;
     _unitWeight = unitWeight;
     _noFlats = noFlats;
     _color = color;
 }
 public PalletFilmProperties(Document doc,
     string name, string description,
     bool useTransparency,
     bool useHatching
     , double hatchSpacing
     , double hatchAngle,
     Color color)
     : base(doc, name, description)
 {
     _useTransparency = useTransparency;
     _useHatching = useHatching;
     _hatchSpacing = hatchSpacing;
     _hatchAngle = hatchAngle;
     _color = color;
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));
            XmlConfigurator.Configure();

            try
            {
                // check arguments
                if (args.Length != 1)
                {
                    log.Info("No command argument. Exiting...");
                    return;
                }
                if (!File.Exists(args[0]))
                {
                    log.Info(string.Format("File {0} could not be found. Exiting...", args[0]));
                    return;
                }

                string filePath = args[0];
                // load document
                Document doc = new Document(filePath,  new DocumentListenerLog());
                // get first analysis
                List<CasePalletAnalysis> analyses = doc.Analyses;
                if (analyses.Count == 0)
                {
                    log.Info("Document has no analysis -> Exiting...");
                    return;
                }
                // build output file path
                string outputFilePath = Path.ChangeExtension(Path.GetTempFileName(), "doc");
                string templatePath = @"..\..\..\TreeDim.StackBuilder.Reporting\ReportTemplates\";
                ReporterMSWord reporter = new ReporterMSWord(
                    new ReportData(analyses[0], analyses[0].GetSelSolutionBySolutionIndex(0))
                    , templatePath, outputFilePath, new Margins());
                Console.WriteLine("Saved report to: {0}", outputFilePath);

                // Display resulting report in Word
                Process.Start(new ProcessStartInfo(outputFilePath));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Esempio n. 26
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ECTAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution)
     : base(document)
 {
     _analysis = analysis;
     _selSolution = selSolution;
     // get a cardboard quality
     foreach (string skey in McKeeFormula.CardboardQualityDictionary.Keys)
     {
         _qualityData = McKeeFormula.CardboardQualityDictionary[skey];
         break;
     }
     // get a _printSurface value
     foreach (string skey in McKeeFormula.PrintCoefDictionary.Keys)
     {
         _printSurface = skey;
         break;
     }
 }
Esempio n. 27
0
 public TruckProperties(Document document)
     : base(document)
 { 
 }
 public PalletFilmProperties(Document doc)
     : base(doc)
 {
 }
Esempio n. 29
0
        private CasePalletAnalysis LoadPalletAnalysis(Document doc, string sid)
        {
            CasePalletAnalysis analysis = null;

            palletAnalysis xmlAnalysis = _root.data.analyses.palletAnalysis.Find(delegate(palletAnalysis pa) { return pa.id == sid; });
            if (null == xmlAnalysis)
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));

            BoxProperties caseProperties = LoadCaseById(doc, _root.data.items.library_cases, xmlAnalysis.caseId);
            BundleProperties bundleProperties = LoadBundleById(doc, _root.data.items.library_bundles, xmlAnalysis.bundleId);

            BProperties bProperties;
            PalletConstraintSet constraintSet;

            if (null != caseProperties)
            {
                CasePalletConstraintSet caseConstraintSet = new CasePalletConstraintSet();
                // interlayer
                caseConstraintSet.HasInterlayer = xmlAnalysis.interlayerPeriodSpecified;
                caseConstraintSet.HasInterlayerAntiSlip = false;

                // allowed ortho axes
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                // interlayer period
                caseConstraintSet.InterlayerPeriod = xmlAnalysis.interlayerPeriodSpecified ? (int)xmlAnalysis.interlayerPeriod : 1;

                bProperties = caseProperties;
                constraintSet = caseConstraintSet;
            }
            else if (null != bundleProperties)
            {
                BundlePalletConstraintSet bundleConstraintSet = new BundlePalletConstraintSet();

                bProperties = bundleProperties;
                constraintSet = bundleConstraintSet;
            }
            else
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));

               // generic constraintSet properties
               // allow aligned / alternate layers
            constraintSet.AllowAlignedLayers = false;
            constraintSet.AllowAlternateLayers = false;
            foreach (layerArrangement layerArr in xmlAnalysis.allowedLayerArrangements)
            {
                if (layerArr == layerArrangement.ALIGNED)
                    constraintSet.AllowAlignedLayers = true;
                if (layerArr == layerArrangement.ROTATED180 | layerArr == layerArrangement.ROTATED90)
                    constraintSet.AllowAlternateLayers = true;
            }
            // allowed patterns
            foreach (patternName pName in xmlAnalysis.allowedLayerPatterns)
            {
                switch (pName)
                {
                    case patternName.COLUMN: constraintSet.SetAllowedPattern("Column"); break;
                    case patternName.DIAGONAL: constraintSet.SetAllowedPattern("Diagonal"); break;
                    case patternName.INTERLOCK: constraintSet.SetAllowedPattern("Interlock"); break;
                    case patternName.TRILOCK: constraintSet.SetAllowedPattern("Trilock"); break;
                    case patternName.SPIRAL: constraintSet.SetAllowedPattern("Spiral"); break;
                    case patternName.ENLARGED_SPIRAL: constraintSet.SetAllowedPattern("Enlarged spiral"); break;
                    default: break;
                }
            }
            // overhang
            constraintSet.OverhangX = xmlAnalysis.overhang[0];
            constraintSet.OverhangY = xmlAnalysis.overhang[1];

            // stop criterions
            // max height
            if (xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeightSpecified)
            {
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight = xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeight;
            }
            else
                constraintSet.UseMaximumHeight = false;
            // max weight
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeightSpecified)
            {
                constraintSet.UseMaximumPalletWeight = true;
                constraintSet.MaximumPalletWeight = xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeight;
            }
            else
                constraintSet.UseMaximumPalletWeight = false;
            // max number of box/bundle
            if (xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumberSpecified)
            {
                constraintSet.UseMaximumNumberOfCases = true;
                constraintSet.MaximumNumberOfItems = (int)xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumber;
            }
            else
                constraintSet.UseMaximumNumberOfCases = false;
            // max weight on case
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCaseSpecified)
            {
                constraintSet.UseMaximumWeightOnBox = true;
                constraintSet.MaximumWeightOnBox = xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCase;
            }
            else
                constraintSet.UseMaximumWeightOnBox = false;

            if (null != doc)
            {
                analysis = doc.CreateNewCasePalletAnalysis(xmlAnalysis.name, xmlAnalysis.description
                    , bProperties
                    , LoadPalletById(doc, _root.data.items.library_pallets, xmlAnalysis.palletId)
                    , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                    , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerAntiSlipId)
                    , null
                    , null
                    , null
                    , constraintSet
                    , new TreeDim.StackBuilder.Engine.CasePalletSolver());
            }
            else
            {
                // instantiate pallet analysis
                analysis = new CasePalletAnalysis(
                    bProperties
                    , LoadPalletById(null, _root.data.items.library_pallets, xmlAnalysis.palletId)
                    , LoadInterlayerById(null, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                    , null
                    , null
                    , null
                    , null
                    , constraintSet);
                // name
                analysis.Name = xmlAnalysis.name;
                // description
                analysis.Description = xmlAnalysis.description;
            }
            return analysis;
        }
Esempio n. 30
0
        static int Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));
            XmlConfigurator.Configure();

            try
            {
                bool useSingleColor = false;
                // instantiate document
                Document doc = new Document("Test", "Test", "fga", DateTime.Now, null);

                // define pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150);
                Console.WriteLine("=== Pallet properties ===");
                Console.WriteLine(palletProperties.ToString());

                bool testCylinder = false;
                if (!testCylinder)
                {
                    // define box properties
                    BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250);
                    boxProperties.Name = "Box1";
                    boxProperties.Weight = 3.0;
                    if (!useSingleColor)
                    {
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
                    }
                    else
                        boxProperties.SetColor(Color.Chocolate);

                    Console.WriteLine(boxProperties.ToString());

                    InterlayerProperties interlayerProperties = null;

                    // define constraints
                    CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                    constraintSet.SetAllowedPattern("Trilock");

                    constraintSet.AllowAlignedLayers = true;
                    constraintSet.AllowAlternateLayers = false;

                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.MaximumNumberOfItems = 2000;
                    constraintSet.MaximumHeight = 2000.0;
                    constraintSet.UseMaximumHeight = true;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.UseMaximumWeightOnBox = false;
                    constraintSet.AllowLastLayerOrientationChange = true;
                    Console.WriteLine("=== Constraint set ===");
                    Console.WriteLine(constraintSet.ToString());

                    // initialize analysis
                    CasePalletAnalysis analysis = new CasePalletAnalysis(
                        boxProperties, palletProperties, interlayerProperties,
                        null, null, null, null,
                        constraintSet);

                    // initialize solver
                    CasePalletSolver solver = new CasePalletSolver();
                    solver.ProcessAnalysis(analysis);

                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CasePalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        // save
                        string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
                else
                {
                    // cylinder
                    Console.WriteLine("=== Cylinder properties ===");
                    CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder",
                        90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue);
                    Console.WriteLine(cylProperties.ToString());
                    // constraint set
                    Console.WriteLine("=== Constraint set ===");
                    CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet();
                    constraintSet.UseMaximumPalletHeight = true;
                    constraintSet.MaximumPalletHeight = 1200.0;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.UseMaximumNumberOfItems = true;
                    constraintSet.MaximumNumberOfItems = 2000;
                    Console.WriteLine(constraintSet.ToString());
                    // cylinder analysis
                    CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet);
                    // initialize solver
                    CylinderSolver solver = new CylinderSolver();
                    solver.ProcessAnalysis(analysis);
                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CylinderPalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        string fileName = string.Format("Pallet_{0}.jpg", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return 0;
        }
Esempio n. 31
0
 private static BundleProperties LoadBundleById(Document doc, List<bundle> listBundles, string sid)
 {
     bundle bundleItem = listBundles.Find(delegate(bundle b) { return b.id == sid; });
     if (null == bundleItem)
         return null;
     else
     {
         double[] bundleDim = bundleItem.flatDimensions.ToArray();
         // instantiate bundle
         BundleProperties bundleProperties = new BundleProperties(
             doc, bundleItem.name, bundleItem.description
             , bundleDim[0], bundleDim[1], bundleDim[2]
             , bundleItem.flatWeight, (int)bundleItem.numberFlats
             , System.Drawing.Color.FromArgb((int)bundleItem.color[0], (int)bundleItem.color[1], (int)bundleItem.color[2]));
         // insert in list
         if (null != doc)
             doc.AddType(bundleProperties);
         return bundleProperties;
     }
 }
Esempio n. 32
0
 private void ProcessReportSolution(reportSolution rSol)
 {
     // create document
     Document doc = new Document(rSol.reportParameters.name, rSol.reportParameters.description, rSol.reportParameters.author, DateTime.Now, null);
     // load analysis
     CasePalletAnalysis analysis = LoadPalletAnalysis(doc, rSol.solutionRef.analysisId);
     if (null == analysis)
         return;
     // compute solutions
     TreeDim.StackBuilder.Engine.CasePalletSolver solver = new TreeDim.StackBuilder.Engine.CasePalletSolver();
     solver.ProcessAnalysis(analysis);
     // retrieve wanted solution
     List<Basics.CasePalletSolution> solutions = analysis.Solutions;
     if (rSol.solutionRef.index >= solutions.Count)
         throw new Exception(string.Format("Analysis {0} has no solution with index {1}", analysis.Name, rSol.solutionRef.index));
     Basics.CasePalletSolution sol = solutions[(int)rSol.solutionRef.index];
     // selected solution
     SelCasePalletSolution selSolution = new SelCasePalletSolution(doc, analysis, sol);
     // generate report
     ReporterMSWord reporter = new ReporterMSWord(new ReportData(analysis, selSolution)
         , rSol.reportParameters.templateFilePath, rSol.reportParameters.outputPath, new Margins());
 }
Esempio n. 33
0
        private void ProcessDocument(genDocument genDoc)
        {
            // create document
            Document document = new Document(genDoc.name, genDoc.description, genDoc.author, DateTime.Now, null);

            foreach (analysisRef aRef in genDoc.analysisRef)
            {
                // get analysis
                CasePalletAnalysis analysis = LoadPalletAnalysis(document, aRef.analysisId);
                // load case if any
                // load bundle if any
                // load pallet
                // load interlayer if any
                // load pallet analysis
            }
            // attempt to create directory
            string outDir = Path.GetDirectoryName(genDoc.path); ;
            try { Directory.CreateDirectory(outDir); }
            catch (System.UnauthorizedAccessException /*ex*/)
            { throw new UnauthorizedAccessException(string.Format("User not allowed to write under {0}", Directory.GetParent(outDir).FullName)); }
            // save document
            document.Write(genDoc.path);
            // open generated document using TreeDim.StackBuilder.Desktop
            string stackbuilderExePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "TreeDim.StackBuilder.Desktop.exe");
            if (genDoc.open && File.Exists(stackbuilderExePath))
            {
                // build start info
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName = stackbuilderExePath;
                startInfo.Arguments = "\"" + genDoc.path + "\"";
                System.Diagnostics.Process.Start(startInfo);
            }
            else
                _log.Info(string.Format("Executable {0} could not be found!", stackbuilderExePath));
        }
Esempio n. 34
0
        private static InterlayerProperties LoadInterlayerById(Document doc, List<interlayer> listInterlayer, string sid)
        {
            interlayer interlayerItem = listInterlayer.Find(delegate(interlayer i) { return i.id == sid; });
            if (null == interlayerItem)
                return null;
            else
            {
                // dimensions
                double[] dimensions = interlayerItem.dimensions.ToArray();
                // instantiate interlayer properties
                InterlayerProperties interlayerProperties = new InterlayerProperties(
                    doc
                    , interlayerItem.name
                    , interlayerItem.description
                    , dimensions[0], dimensions[1], dimensions[2]
                    , interlayerItem.weight
                    , Color.FromArgb((int)interlayerItem.color[0], (int)interlayerItem.color[1], (int)interlayerItem.color[2], (int)interlayerItem.color[3])
                    );
                // insert in list
                if (null != doc)
                    doc.AddType(interlayerProperties);

                return interlayerProperties;
            }
        }
Esempio n. 35
0
        private static PalletProperties LoadPalletById(Document doc, List<pallet> listPallet, string sid)
        {
            pallet palletItem = listPallet.Find(delegate(pallet p) { return p.id == sid; });
            if (null == palletItem)
                return null;
            else
            {
                // dimensions
                double[] dimensions = palletItem.dimensions.ToArray();
                // type
                string typeName = string.Empty;
                switch (palletItem.type)
                {
                    case palletType.BLOCK: typeName = "BLOCK"; break;
                    case palletType.EUR: typeName = "EUR"; break;
                    case palletType.EUR2: typeName = "EUR2"; break;
                    case palletType.EUR3: typeName = "EUR3"; break;
                    case palletType.EUR6: typeName = "EUR6"; break;
                    case palletType.GMA: typeName = "GMA"; break;
                    case palletType.STANDARD_UK: typeName = "STANDARD_UK"; break;
                    default:
                        throw new Exception("Pallet with id = {0} has an unknown pallet type");
                }
                // instantiate pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, typeName, dimensions[0], dimensions[1], dimensions[2]);
                // name
                palletProperties.Name = palletItem.name;
                // description
                palletProperties.Description = palletItem.description;
                // color
                palletProperties.Color = System.Drawing.Color.FromArgb((int)palletItem.color[0], (int)palletItem.color[1], (int)palletItem.color[2], (int)palletItem.color[3]);
                // weight
                palletProperties.Weight = palletItem.weight;
                // insert in list
                if (null != doc)
                    doc.AddType(palletProperties);

                return palletProperties;
            }
        }