Exemple #1
0
        public static BezierSurfaceWorldObject CreateFlatGrid(
            int segmentsU,
            int segmentsV,
            double width,
            double height
            )
        {
            var surface = new BezierSurfaceWorldObject
            {
                _segmentsU = segmentsU,
                _segmentsV = segmentsV,
            };

            surface.SetupVirtualPointsGrid(
                3 * segmentsU + 1,
                3 * segmentsV + 1,
                width,
                height
                );

            return(surface);
        }
Exemple #2
0
        public static BezierSurfaceWorldObject CreateCylindrical(
            int segmentsU,
            int segmentsV,
            double radius,
            double height
            )
        {
            var surface = new BezierSurfaceWorldObject
            {
                _segmentsU = segmentsU,
                _segmentsV = segmentsV,
                _folded    = true,
            };

            surface.SetupVirtualPointsCylinder(
                3 * segmentsU + 1,
                3 * segmentsV,
                radius,
                height
                );

            return(surface);
        }
Exemple #3
0
        public static List <VirtualPoint> FindHoleOutline(
            List <BezierSurfaceWorldObject> gregoryAdjacentPatches
            )
        {
            var outline = new List <VirtualPoint>();
            BezierSurfaceWorldObject lastProcessedPatch = null;
            var nonProcessedPatches = new LinkedList <BezierSurfaceWorldObject>(
                gregoryAdjacentPatches
                );

            var currentPatch = nonProcessedPatches.First();

            while (nonProcessedPatches.Count > 0)
            {
                nonProcessedPatches.Remove(currentPatch);

                var importantCollapsedPoints = currentPatch._virtualPoints
                                               .Where(t => gregoryAdjacentPatches.Intersect(
                                                          GetAdjacentSurfaces(t)
                                                          ).Count() >= 2
                                                      )
                                               .ToList();

                if (importantCollapsedPoints.Count != 2)
                {
                    return(new List <VirtualPoint>());
                }

                /*
                 * throw new ApplicationException(string.Join(
                 *  "Expected two shared points between adjacent patches,",
                 *  $" but found ${importantCollapsedPoints.Count}."
                 * ));*/

                if (lastProcessedPatch != null)
                {
                    var firstPoint = importantCollapsedPoints.First();
                    if (!GetAdjacentSurfaces(firstPoint)
                        .Contains(lastProcessedPatch))
                    {
                        importantCollapsedPoints.Reverse();
                    }
                }

                if (lastProcessedPatch == null)
                {
                    outline.Add(importantCollapsedPoints[0]);
                }

                var a = currentPatch.GetVirtualPointCoordinate(
                    importantCollapsedPoints[0]
                    );

                var b = currentPatch.GetVirtualPointCoordinate(
                    importantCollapsedPoints[1]
                    );

                for (var i = 1; i < 3; ++i)
                {
                    var xcoord = (a.Item1 * (3 - i) + b.Item1 * i) / 3;
                    var ycoord = (a.Item2 * (3 - i) + b.Item2 * i) / 3;
                    outline.Add(currentPatch.GetVirtualPoint(xcoord, ycoord));
                }

                if (nonProcessedPatches.Count > 0)
                {
                    outline.Add(importantCollapsedPoints[1]);
                }

                lastProcessedPatch = currentPatch;
                currentPatch       = GetAdjacentSurfaces(
                    importantCollapsedPoints[1]
                    ).First(t => t != lastProcessedPatch);
            }

            return(outline);
        }