예제 #1
0
 public XSecModelParams()
 {
     Material        = new Material();
     RemovalRate     = new RemovalRate();
     CurvatureEffect = new CurvatureEffect();
     DepthInfo       = new DepthInfo();
 }
예제 #2
0
 double feedrateFactor(double feedrate, RemovalRate mrr)
 {
     if (feedrate == 0)
     {
         feedrate = 1;
     }
     return(mrr.NominalSurfaceSpeed / feedrate);
 }
예제 #3
0
 internal AbMachParameters(AbMachOperation op, RunInfo runInfo, RemovalRate removalRate, Material mat, AbMachJet abmachJet, DepthInfo depthInfo, double meshSize)
 {
     Operation   = op;
     RunInfo     = runInfo;
     RemovalRate = removalRate;
     Material    = mat;
     AbMachJet   = abmachJet;
     DepthInfo   = depthInfo;
     _meshSize   = meshSize;
 }
예제 #4
0
 internal AbMachParameters()
 {
     _meshSize   = .005;
     AbMachJet   = new AbMachJet();
     RunInfo     = new RunInfo();
     RemovalRate = new RemovalRate();
     Material    = new Material();
     Operation   = AbMachOperation.OTHER;
     DepthInfo   = new DepthInfo();
 }
예제 #5
0
        public static AbMachParameters Build()
        {
            double          meshSize    = .001;
            AbMachOperation op          = AbMachOperation.OTHER;
            RunInfo         runInfo     = new RunInfo();
            RemovalRate     removalRate = new RemovalRate();
            Material        mat         = new Material();
            AbMachJet       abmachJet   = new AbMachJet();
            DepthInfo       depthInfo   = new DepthInfo();

            return(new AbMachParameters(op, runInfo, removalRate, mat, abmachJet, depthInfo, meshSize));
        }
예제 #6
0
 public AbmachSimModel3D(ISurface <AbmachPoint> initialSurface, ISurface <AbmachPoint> targetSurface, ModelPath path, AbMachParameters parms)
 {
     surface             = initialSurface;
     this.targetSurface  = targetSurface;
     this.initialSurface = initialSurface.Clone();
     this.path           = path;
     abmachParams        = parms;
     runInfo             = parms.RunInfo;
     jetRadius           = abmachParams.AbMachJet.Diameter / 2.0;
     currentRemovalRate  = parms.RemovalRate;
     depthInfo           = abmachParams.DepthInfo;
 }
예제 #7
0
        RemovalRate adjustMRR(double currentDepth, RemovalRate currentMrr, RunInfo runInfo, double targetDepth)
        {
            //TODO calc adjust mrr
            double targetMrr = Math.Abs(targetDepth / runInfo.Runs);
            double actualMrr = Math.Abs(currentDepth / runInfo.CurrentRun);
            var    newMrr    = new RemovalRate(currentMrr.NominalSurfaceSpeed, currentMrr.DepthPerPass);

            if (actualMrr != 0)
            {
                newMrr.DepthPerPass = currentMrr.DepthPerPass * targetMrr / actualMrr;
            }
            return(newMrr);
        }
예제 #8
0
        private RemovalRate newRemovalRate(ModelPath path, RunInfo runInfo, RemovalRate oldRemovalRate, DepthInfo depthInfo)
        {
            var             newRemovalRate           = new RemovalRate();
            ModelPathEntity mpeDepth                 = nearestPathEntity(path, depthInfo.LocationOfDepthMeasure);
            double          currentDepth             = getDepth(mpeDepth, depthInfo);
            double          currentDepthPerRun       = currentDepth / runInfo.CurrentRun;
            double          currentTargetDepthPerRun = depthInfo.TargetDepth / runInfo.CurrentRun;

            depthInfo.CurrentDepth = currentDepth;

            if (currentDepth != 0)
            {
                double newMrr = oldRemovalRate.DepthPerPass * (currentTargetDepthPerRun / currentDepthPerRun);
                return(newRemovalRate);
            }
            else
            {
                return(oldRemovalRate);
            }
        }
예제 #9
0
        public void SubtractSurface2D(CancellationToken ct, IProgress <int> progress)
        {
            int jetR = abmachParams.AbMachJet.JetRadius;

            matRemRate = abmachParams.RemovalRate;
            int prevXIndex = surf.Xindex(path.Entities[0].Position.X);
            int prevYIndex = surf.Xindex(path.Entities[0].Position.Y);

            for (int iteration = 0; iteration < runInfo.Iterations; iteration++)// iterations
            {
                runInfo.CurrentIteration += 1;
                for (int run = 0; run < runInfo.Runs; run++)//runs
                {
                    runInfo.CurrentRun += 1;
                    foreach (ModelPathEntity ent in path.Entities)//path
                    {
                        int    xIndex     = surf.Xindex(ent.Position.X);
                        int    yIndex     = surf.Yindex(ent.Position.Y);
                        double deltaIndex = Math.Sqrt(Math.Pow(xIndex - prevXIndex, 2) + Math.Pow(yIndex - prevYIndex, 2));
                        prevXIndex = xIndex;
                        prevYIndex = yIndex;
                        if (deltaIndex != 0)
                        {
                            double feedFactor = feedrateFactor(ent.Feedrate, deltaIndex, matRemRate);
                            //subtract jet footprint and put into temp surface
                            //temp surface so that slope calc is not affected by depth changes
                            for (int a = xIndex - jetR; a <= xIndex + jetR; a++)
                            {
                                for (int b = yIndex - jetR; b <= yIndex + jetR; b++)
                                {
                                    double depth = feedFactor * slopeFactor(surf.Normal(a, b)) * surf.GetValue(a, b).MachIndex *abmachParams.AbMachJet.FootPrint(a - xIndex + jetR, b - yIndex + jetR);
                                    surf.SetValue(AbmachValType.Temp, depth, a, b);
                                }
                            }
                            //smooth surface and place in temp surface smooth spikes and pits
                            for (int a = xIndex - jetR; a <= xIndex + jetR; a++)
                            {
                                for (int b = yIndex - jetR; b <= yIndex + jetR; b++)
                                {
                                    smoothValue(a, b);
                                }
                            }
                            //replace model surface with smoothed surface
                            for (int a = xIndex - jetR; a <= xIndex + jetR; a++)
                            {
                                for (int b = yIndex - jetR; b <= yIndex + jetR; b++)
                                {
                                    surf.SetValue(AbmachValType.Model, surf.GetValue(a, b).Temp, a, b);
                                }
                            }
                        }
                    }//next toolpath segment
                    //get depth at depth location
                    abmachParams.DepthInfo.DepthAtLocation = getDepth(abmachParams.DepthInfo.LocationOfDepthMeasure);
                    //adjust material removal rate if requested
                    if (abmachParams.RunInfo.RunType == ModelRunType.NewMRR)
                    {
                        abmachParams.RemovalRate = adjustMRR(abmachParams.DepthInfo.DepthAtLocation, matRemRate, runInfo);
                    }
                }//next run
                if (abmachParams.RunInfo.RunType == ModelRunType.NewFeedrates)
                {
                    adjustFeedRates();
                }
            }//next iteration
        }
예제 #10
0
 RemovalRate adjustMRR(double currentDepth, RemovalRate currentMrr, RunInfo runInfo)
 {
     //TODO calc adjust mrr
     return(currentMrr);
 }
예제 #11
0
 double feedrateFactor(double feedrate, double deltaIndex, RemovalRate mrr)
 {
     return(deltaIndex * mrr.DepthPerPass * mrr.SurfaceSpeed / feedrate);
 }
예제 #12
0
 double feedrateFactor(double feedrate, double deltaIndex, RemovalRate mrr)
 {
     return(deltaIndex * mrr.NominalSurfaceSpeed / feedrate);
 }
예제 #13
0
        public void Run(CancellationToken ct, IProgress <int> progress)
        {
            try
            {
                if (checkParms() && checkPath() && checkSurface())
                {
                    double searchRadius = jetRadius + _surface.MeshSize;
                    _currentRemovalRate = abmachParams.RemovalRate;
                    int prevXIndex = _surface.Xindex(_path[0].Position.X);
                    int prevYIndex = _surface.Yindex(_path[0].Position.Y);

                    int    currentRunTotal = 0;
                    int    pathLength      = _path.Count;
                    int    progressTotal   = runInfo.Iterations * runInfo.Runs;
                    double spFactor        = spacingFactor();
                    abmachParams.DepthInfo.CurrentDepth = 0;
                    bool prevJetonState = false;
                    for (int iteration = 1; iteration <= runInfo.Iterations; iteration++)
                    {
                        runInfo.CurrentIteration = iteration;
                        if (iteration > 1)
                        {
                            resetSurface();
                        }
                        for (int run = 1; run <= runInfo.Runs; run++)
                        {
                            runInfo.CurrentRun = run;

                            foreach (ModelPathEntity mpe in _path)
                            {
                                if (!ct.IsCancellationRequested)
                                {
                                    if (mpe.JetOn && mpe.Feedrate.Value != 0)
                                    {
                                        int    xIndex     = _surface.Xindex(mpe.Position.X);
                                        int    yIndex     = _surface.Yindex(mpe.Position.Y);
                                        double deltaIndex = Math.Sqrt(Math.Pow(xIndex - prevXIndex, 2) + Math.Pow(yIndex - prevYIndex, 2));
                                        prevXIndex = xIndex;
                                        prevYIndex = yIndex;
                                        if (deltaIndex != 0 && prevJetonState)
                                        {
                                            int    searchR      = jetR + 1;
                                            int    startXIndex  = Math.Max(0, xIndex - searchR);
                                            int    endXIndex    = Math.Min(_surface.XSize - 1, xIndex + searchR);
                                            int    startYIndex  = Math.Max(0, yIndex - searchR);
                                            int    endYIndex    = Math.Min(_surface.YSize - 1, yIndex + searchR);
                                            double feedFactor   = feedrateFactor(mpe.Feedrate.Value, deltaIndex, _currentRemovalRate);
                                            double removalConst = _currentRemovalRate.DepthPerPass * feedFactor * spFactor;
                                            subtractFootprint(mpe.JetVector, xIndex, yIndex, startXIndex, endXIndex, startYIndex, endYIndex, removalConst);
                                            //smoothFootprint(xIndex, yIndex,startXIndex, endXIndex, startYIndex, endYIndex);
                                            moveTempToModel(xIndex, yIndex, startXIndex, endXIndex, startYIndex, endYIndex);
                                        }
                                    }
                                }
                                prevJetonState = mpe.JetOn;
                            }

                            abmachParams.DepthInfo.CurrentDepth = getDepth(abmachParams.DepthInfo);
                            //adjust mrr after each run
                            if (abmachParams.RunInfo.RunType == ModelRunType.NewMRR)
                            {
                                double targetDepth = 0;
                                if (abmachParams.DepthInfo.ConstTargetDepth)
                                {
                                    targetDepth = abmachParams.DepthInfo.TargetDepth;
                                }
                                else
                                {
                                    targetDepth = abmachParams.DepthInfo.TargetDepth;
                                }
                                abmachParams.RemovalRate = adjustMRR(abmachParams.DepthInfo.CurrentDepth,
                                                                     _currentRemovalRate, runInfo, targetDepth);
                                _currentRemovalRate = abmachParams.RemovalRate;
                            }
                            currentRunTotal++;
                            progress.Report((int)100 * currentRunTotal / progressTotal);
                        }
                        //adjust feedrates after all runs are done
                        if (abmachParams.RunInfo.RunType == ModelRunType.NewFeedrates)
                        {
                            adjustFeedRates(abmachParams.DepthInfo.SearchRadius);
                        }
                    }
                    FileIOLib.FileIO.Save(debugData, "debugValues.csv");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #14
0
 public static AbMachParameters Build(AbMachOperation op, RunInfo runInfo, RemovalRate removalRate,
                                      Material mat, AbMachJet abmachJet, DepthInfo depthInfo, double meshSize)
 {
     return(new AbMachParameters(op, runInfo, removalRate, mat, abmachJet, depthInfo, meshSize));
 }
예제 #15
0
        public void Run(CancellationToken ct, IProgress <int> progress)
        {
            try
            {
                double searchRadius = jetRadius + surface.MeshSize;

                int           pcount    = path.Count * runInfo.Runs * runInfo.Iterations;
                int           count     = 0;
                List <string> pointlist = new List <string>();
                pointlist.Add("run,Nx,Ny,Nz,x,z,pointradius,jetfactor,incidentangle,slopefactor");

                double spFactor      = spacingFactor();
                double testJetRadius = jetRadius + surface.MeshSize;
                for (int iteration = 1; iteration <= runInfo.Iterations; iteration++)
                {
                    runInfo.CurrentIteration = iteration;


                    for (int run = 1; run <= runInfo.Runs; run++)
                    {
                        runInfo.CurrentRun = run;
                        int pathCount = 0;
                        foreach (ModelPathEntity mpe in path)
                        {
                            if (!ct.IsCancellationRequested)
                            {
                                double feedFactor = currentRemovalRate.DepthPerPass * spFactor * feedrateFactor(mpe.Feedrate.Value, currentRemovalRate);
                                pathCount++;
                                if (mpe.JetOn && feedFactor != 0)
                                {
                                    BoundingBox        searchBox        = BoundingBoxBuilder.GetSearchCylinder(surface.BoundingBox, mpe.PositionAsVector3, mpe.JetVector, searchRadius);
                                    List <AbmachPoint> jetIntersectList = surface.GetPointsInsideBox(searchBox);

                                    Octree <AbmachPoint> localSurface = OctreeBuilder <AbmachPoint> .Build(jetIntersectList, surface.MeshSize);// OctreeBuilder<AbmachPoint>.Build(jetIntersectList, searchBox, surface.MeshSize);

                                    var newPts = new List <AbmachPoint>();
                                    var mpeV   = new Vector3(mpe.Position.X, mpe.Position.Y, 0);
                                    var jetRay = new Ray(mpe.PositionAsVector3, mpe.JetVector);

                                    foreach (AbmachPoint jetPt in localSurface.GetAllPoints())
                                    {
                                        if (jetPt != null)
                                        {
                                            //var jetV = new Vector3(jetPt.Position.X, jetPt.Position.Y, 0);

                                            //double pointRadius = jetV.DistanceTo(mpeV);
                                            double pointRadius = GeomUtilities.RayPointDistance(jetRay, jetPt.Position);
                                            if (pointRadius <= testJetRadius)
                                            {
                                                double jFactor = jetFactor(pointRadius);
                                                if (jFactor > 0)
                                                {
                                                    Vector3 localNormal = new Vector3(0, 0, 1); // localSurface.GetNormalAt(jetPt.Position);
                                                    if (localNormal.Length == 0)
                                                    {
                                                        localNormal = new Vector3(mpe.JetVector);
                                                    }
                                                    double angle    = incidentAngle(mpe.JetVector, localNormal);
                                                    double slFactor = slopeFactor(angle);
                                                    //debug


                                                    if (jetPt.Position.X > 0.006 && jetPt.Position.X < .1 && jetPt.Position.Y > .072 && jetPt.Position.Y < .102)
                                                    {
                                                        pointlist.Add(run.ToString() + "," + jetPt.Position.X.ToString("f5") + "," + jetPt.Position.Y.ToString("f5") + "," + jetPt.Position.Z.ToString("f5") + "," + pointRadius.ToString("f5") + "," + jFactor.ToString("F5") + "," + angle.ToString("F5") + "," + slFactor.ToString("F5"));
                                                    }
                                                    //debug

                                                    Vector3 materialRemoved = (feedFactor * slFactor * jFactor) * mpe.JetVector;

                                                    Vector3 newPosition = jetPt.Position - materialRemoved;

                                                    jetPt.Position         = newPosition;
                                                    jetPt.Normal           = localNormal;
                                                    jetPt.OriginalPosition = jetPt.OriginalPosition;
                                                    jetPt.JetHit           = true;
                                                    newPts.Add(jetPt);
                                                }
                                            }
                                            else
                                            {
                                                newPts.Add(jetPt);
                                            }
                                        }    //end foreach jetPt
                                    }
                                    surface.Insert(newPts);
                                }//endif jeton
                            }
                            progress.Report(100 * ++count / pcount);
                        }//next path entity
                        if (runInfo.RunType == ModelRunType.NewMRR)
                        {
                            currentRemovalRate = newRemovalRate(path, runInfo, currentRemovalRate, depthInfo);
                        }
                    } //next run

                    if (runInfo.RunType == ModelRunType.NewFeedrates && runInfo.CurrentIteration < runInfo.Iterations)
                    {
                        path = newFeedrates(path, depthInfo);
                        resetSurface();
                    }
                }//next iteration
                FileIOLib.FileIO.Save(pointlist, "slopefactor.csv");
            }
            catch (Exception)
            {
                throw;
            }
        }