Esempio n. 1
0
        public static DependentLineSegment dLineSegment(AbstractPoint point1, AbstractPoint point2)
        {
            DependentLineSegment line = DependentLineSegment.Constructor();

            line.transform.GetComponent <DependentLineSegment>().point1 = point1.transform.GetComponent <AbstractPoint>();
            line.transform.GetComponent <DependentLineSegment>().point2 = point2.transform.GetComponent <AbstractPoint>();
            line.vertex0 = point1.Position3;
            line.vertex1 = point2.Position3;
            line.transform.GetComponent <DependentLineSegment>().InitializeFigure();

            HW_GeoSolver.ins.AddDependence(line, point1);
            HW_GeoSolver.ins.AddDependence(line, point2);

            return(line);
        }
Esempio n. 2
0
        internal static InteractablePrism iPrism(List <AbstractLineSegment> edges)
        {
            InteractablePrism prism = InteractablePrism.Constructor();

            prism.bases        = new List <AbstractPolygon>();
            prism.sides        = new List <AbstractPolygon>();
            prism.lineSegments = edges;

            foreach (AbstractLineSegment line in edges)
            {
                if (line.GetComponent <InteractableLineSegment>() != null)
                {
                    InteractableLineSegment iLineSegment = line.GetComponent <InteractableLineSegment>();
                    if (!prism.vertexPoints.Contains(iLineSegment.point1))
                    {
                        prism.vertexPoints.Add(iLineSegment.point1);
                    }

                    if (!prism.vertexPoints.Contains(iLineSegment.point2))
                    {
                        prism.vertexPoints.Add(iLineSegment.point2);
                    }
                }
                else if (line.GetComponent <DependentLineSegment>() != null)
                {
                    DependentLineSegment dlineSegment = line.GetComponent <DependentLineSegment>();
                    if (!prism.vertexPoints.Contains(dlineSegment.point1))
                    {
                        prism.vertexPoints.Add(dlineSegment.point1);
                    }

                    if (!prism.vertexPoints.Contains(dlineSegment.point2))
                    {
                        prism.vertexPoints.Add(dlineSegment.point2);
                    }
                }
            }

            prism.lineSegments.ForEach(l => HW_GeoSolver.ins.AddDependence(prism, l));
            prism.vertexPoints.ForEach(p => HW_GeoSolver.ins.AddDependence(prism, p));
            prism.InitializeFigure();

            return(prism);
        }
Esempio n. 3
0
        private void checkTwoPoints()
        {
            if (prevSet && currSet && _prevPoint != _currPoint)
            {
                currPoint.tag = "Untagged";
                prevPoint.tag = "Untagged";
                switch (thisPinType)
                {
                case pinType.polymaker:
                    lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                    if (_currPoint == pointList[0] && lineList.Count > 1)
                    {
                        GeoObjConstruction.iPolygon(lineList, pointList);
                        Destroy(gameObject, Time.fixedDeltaTime);
                    }
                    break;

                case pinType.wireframe:
                    lineList.Add(GeoObjConstruction.dLineSegment(currPoint, prevPoint));
                    successfullyMade = true;
                    break;

                case pinType.solidmaker:
                    Debug.Log("This isn't setup yet do not use! Object: " + gameObject.name);
                    Destroy(gameObject, Time.fixedDeltaTime);
                    break;

                case pinType.polycut:
                    List <AbstractPolygon> prevPointPolygons = new List <AbstractPolygon>();
                    List <AbstractPolygon> currPointPolygons = new List <AbstractPolygon>();
                    HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(_prevPoint.figName)                                                           //all bidirectional neighbors
                    .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>() != null).ToList()          // list of all abstractpolygons in prev list
                    .ForEach(d => prevPointPolygons.Add(HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>())); //foreach adds the polygon to final list
                    HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(_currPoint.figName)                                                           //same as above but with other point
                    .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>() != null).ToList()
                    .ForEach(d => currPointPolygons.Add(HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <AbstractPolygon>()));
                    //prevPointPolygons.ForEach(p => Debug.Log(_prevPoint.figName + " is in the following: " + p.figName));
                    //Debug.Log("_____+_____");
                    //currPointPolygons.ForEach(p => Debug.Log(_currPoint.figName + " is in the following: " + p.figName));
                    //Debug.Log("_____=_____");
                    List <AbstractPolygon> sharedPolygons;
                    if (prevPointPolygons.Count > currPointPolygons.Count)
                    {
                        sharedPolygons = prevPointPolygons.Intersect(currPointPolygons).Where(poly => poly.lineList.Count > 3).ToList();
                    }
                    else
                    {
                        sharedPolygons = currPointPolygons.Intersect(prevPointPolygons).Where(poly => poly.lineList.Count > 3).ToList();
                    }
                    //sharedPolygons.ForEach(p => Debug.Log("Both are in the following: " + p.figName));
                    //list created from any duplicates from two prev lists that have more than 3 sides
                    //Debug.Log(_prevPoint.figName + " and " + _currPoint.figName + " are both on " + sharedPolygons.Count + " together.");
                    if (sharedPolygons.Count > 0)
                    {
                        DependentLineSegment cutLine = GeoObjConstruction.dLineSegment(_prevPoint, _currPoint);
                        foreach (AbstractPolygon p in sharedPolygons)
                        {
                            List <AbstractPoint>       currPointList = p.pointList;
                            List <AbstractLineSegment> currLineList  = p.lineList;
                            if (Mathf.Abs(currPointList.IndexOf(_prevPoint) - currPointList.IndexOf(_currPoint)) > 1)
                            {
                                List <AbstractPoint> newPointList1 = newPointListGen(currPointList, currPointList.IndexOf(_prevPoint), currPointList.IndexOf(_currPoint));
                                List <AbstractPoint> newPointList2 = newPointListGen(currPointList, currPointList.IndexOf(_currPoint), currPointList.IndexOf(_prevPoint));

                                List <AbstractLineSegment> newLineList1 = new List <AbstractLineSegment>()
                                {
                                    cutLine
                                };                                                                                                                           //creates list and adds the line created by the cut
                                List <AbstractLineSegment> newLineList2 = new List <AbstractLineSegment>()
                                {
                                    cutLine
                                };                                                                                                                   //creates list and adds the line created by the cut
                                foreach (AbstractLineSegment currLine in currLineList                                                                //newLineList1 Generator
                                         .Where(cL => ((cL.GetComponent <InteractableLineSegment>() != null &&                                       //is interactable line segment and point1 or point2 is found in newPointList1
                                                        newPointList1.Any(point => point == cL.GetComponent <InteractableLineSegment>().point1 || point == cL.GetComponent <InteractableLineSegment>().point2)) ||
                                                       ((cL.GetComponent <DependentLineSegment>() != null &&                                         //is dependent line segment and point1 or point2 is found in newPointList1
                                                         newPointList1.Any(point => point == cL.GetComponent <DependentLineSegment>().point1 || point == cL.GetComponent <DependentLineSegment>().point2))))))
                                {
                                    newLineList1.Add(currLine);
                                }
                                foreach (AbstractLineSegment currLine in currLineList                                                                   //newLineList2 Generator
                                         .Where(cL => ((cL.GetComponent <InteractableLineSegment>() != null &&                                          //is interactable line segment and point1 or point2 is found in newPointList1
                                                        newPointList2.Any(point => point == cL.GetComponent <InteractableLineSegment>().point1 || point == cL.GetComponent <InteractableLineSegment>().point2)) ||
                                                       ((cL.GetComponent <DependentLineSegment>() != null &&                                            //is dependent line segment and point1 or point2 is found in newPointList1
                                                         newPointList2.Any(point => point == cL.GetComponent <DependentLineSegment>().point1 || point == cL.GetComponent <DependentLineSegment>().point2))))))
                                {
                                    newLineList2.Add(currLine);
                                }
                                AbstractPolygon          newPoly1      = GeoObjConstruction.iPolygon(newLineList1, newPointList1);
                                AbstractPolygon          newPoly2      = GeoObjConstruction.iPolygon(newLineList2, newPointList2);
                                List <InteractablePrism> currPrismList = new List <InteractablePrism>();
                                HW_GeoSolver.ins.geomanager.bidirectionalNeighborsOfNode(p.figName)                                        //all bidirectional neighbors
                                .Where(d => HW_GeoSolver.ins.geomanager.findGraphNode(d.Value).mytransform.GetComponent <InteractablePrism>() != null).ToList().ForEach(prism => currPrismList.Add(prism.mytransform.GetComponent <InteractablePrism>()));
                                foreach (InteractablePrism cPrism in currPrismList)
                                {
                                    HW_GeoSolver.ins.AddDependence(newPoly1, cPrism);
                                    HW_GeoSolver.ins.AddDependence(newPoly2, cPrism);
                                }
                                HW_GeoSolver.ins.removeComponent(p);
                            }
                        }
                        //GameObject currScissors = Instantiate(scissors);
                        //currScissors.transform.position = _prevPoint.transform.position;														Cuts things
                        //currScissors.GetComponent<scissorAnimator>().travel(_prevPoint.transform.position, _currPoint.transform.position);
                        Destroy(gameObject, Time.fixedDeltaTime);
                    }
                    break;

                default:
                    break;
                }
            }
        }