Exemplo n.º 1
0
        private static void ReInsert(PlanningSurface surface, List <PlanningSurface> orderedPrimitives)
        {
            int endIndex = orderedPrimitives.Count;

            if (endIndex == 0)
            {
                orderedPrimitives.Add(surface);
                return;
            }
            int startIndex = 0;
            var midIndex   = endIndex / 2;

            do
            {
                if (surface.Metric > orderedPrimitives[midIndex].Metric)
                {
                    endIndex = midIndex;
                }
                else
                {
                    startIndex = midIndex;
                }
                midIndex = startIndex + (endIndex - startIndex) / 2;
            } while (midIndex != endIndex && midIndex != startIndex);
            orderedPrimitives.Insert(midIndex, surface);
        }
Exemplo n.º 2
0
        private static PrimitiveSurface CreatePrimitiveSurface(PlanningSurface topPlannedSurface)
        {
            var surfaceType = topPlannedSurface.SurfaceType;
            var faces       = new List <PolygonalFace>(topPlannedSurface.Faces.Select(f => f.Face));

            switch (surfaceType)
            {
            case PrimitiveSurfaceType.Flat:
                return(new Flat(faces));

            case PrimitiveSurfaceType.Cylinder:
                double[] axis;
                double   coneAngle;
                if (IsReallyACone(faces, out axis, out coneAngle))
                {
                    return(new Cone(faces, axis, coneAngle));
                }
                if (IsReallyAFlat(faces))
                {
                    return(new Flat(faces));
                }
                return(new Cylinder(faces, axis));

            case PrimitiveSurfaceType.Sphere:
                if (IsReallyATorus(faces))
                {
                    return(new Torus(faces));
                }
                return(new Sphere(faces));

            default: throw new Exception("Cannot build Create Primitive Surface of type: " + surfaceType);
            }
        }
Exemplo n.º 3
0
 private static bool AlreadySearchedPrimitive(PlanningSurface newSeed, List <PlanningSurface> candidatePatches)
 {
     return(candidatePatches.Any(p => p.SurfaceType == newSeed.SurfaceType &&
                                 p.Faces.Contains(newSeed.Faces[0])));
 }