private static bool HasDependence(ShapeBlueprint @from, CanDependOnShapeBlueprint to, HashSet <ShapeBlueprint> visited) { if (@from == to) { return(true); } if (visited == null) { visited = new HashSet <ShapeBlueprint>(); } foreach (ShapeBlueprint blueprint in @from.DependenciesOnOtherShapes) { if (visited.Contains(blueprint)) { continue; } visited.Add(blueprint); if (blueprint == to) { return(true); } return(HasDependence(blueprint, to, visited)); } return(false); }
public ShapeBlueprint CreateShapeBlueprint(ShapeBlueprintType type) { ShapeBlueprint blueprint = null; switch (type) { case ShapeBlueprintType.Point: blueprint = new PointBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Line: blueprint = new LineBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Polygon: blueprint = new PolygonBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Parallelepiped: blueprint = new ParallelepipedBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Cube: blueprint = new CubeBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Pyramid: blueprint = new PyramidBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.RegularPyramid: blueprint = new RegularPyramidBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Tetrahedron: blueprint = new TetrahedronBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.Prism: blueprint = new PrismBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.RegularPrism: blueprint = new RegularPrismBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointPerpendicularProjection: blueprint = new PointPerpendicularProjectionBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointOfIntersection: blueprint = new PointOfIntersectionBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointOnSurface: blueprint = new PointOnSurfaceBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointProjectionFromPoint: blueprint = new PointProjectionFromPointBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointProjectionAlongLine: blueprint = new PointProjectionAlongLineBlueprint(m_ShapeDataFactory); break; case ShapeBlueprintType.PointOnLine: blueprint = new PointOnLineBlueprint(m_ShapeDataFactory); break; } if (blueprint != null) { m_ShapeBlueprints.Add(blueprint); } return(blueprint); }
public void Remove(ShapeBlueprint blueprint) { blueprint.Destroy(); m_ShapeBlueprints.Remove(blueprint); }