public MeshModel Convert(IStpModel model) { var vectors = new List <Vector3>(); var indices = new List <int>(); GetValue <ClosedShell>(model, indices, vectors); var mesh = new MeshModel(vectors, indices); return(mesh); }
private void GetValue <T>(IStpModel model, List <int> indices, List <Vector3> vectors) where T : Entity { foreach (var element in model.All <T>()) { var offset = vectors.Count; var convertable = CreateConvertable(element, model); var circleVectors = convertable.Points; var circleIndices = convertable.Indices; vectors.AddRange(circleVectors); indices.AddRange(circleIndices.Select(x => x + offset)); } }
private static IConvertable Convertable(Surface surface, IStpModel model) { if (surface.GetType() == typeof(CylindricalSurface)) { return(new CylindricalSurfaceConvertable(surface, model)); } else if (surface.GetType() == typeof(ConicalSurface)) { return(new ConicalSurfaceConvertable(surface, model)); } else if (surface.GetType() == typeof(Plane)) { return(new PlaneConvertable(surface, model)); } else if (surface.GetType() == typeof(ToroidalSurface)) { return(new ToroidalSurfaceConvertable(surface, model)); } throw new Exception("No convertable found!"); }
private static IConvertable CreateConvertable <T>(T element, IStpModel model) where T : Entity { var type = typeof(T); if (type == typeof(Circle)) { return(new CircleConvertable(element as Circle, model)); } if (type == typeof(Line)) { return(new LineConvertable(element as Line, model)); } if (type == typeof(AdvancedFace)) { return(new AdvancedFaceConvertable(element as AdvancedFace, model)); } if (type == typeof(ClosedShell)) { return(new ClosedShellConveratable(element as ClosedShell, model)); } throw new Exception("Not supported"); }
public LineConvertable(Line line, IStpModel model) { _line = line; _model = model; Init(); }
public void SetUp() { var data = TestData.Content; _model = new StpParser().Parse(new MemoryStream(Encoding.UTF8.GetBytes(data))); }
public ClosedShellConveratable(ClosedShell closedShell, IStpModel model) { _closedShell = closedShell; _model = model; Init(); }
public CylindricalSurfaceConvertable(Surface surface, IStpModel model) { _surface = (CylindricalSurface)surface; _model = model; Init(); }
public PlaneConvertable(Surface surface, IStpModel model) { _surface = (Plane)surface; _model = model; Init(); }
public ToroidalSurfaceConvertable(Surface surface, IStpModel model) { _surface = surface; _model = model; Init(); }
public CircleConvertable(Circle circle, IStpModel model) { _circle = circle; _model = model; Init(); }
public BoundConvertable(Bound bound, IStpModel model) { _bound = bound; _model = model; Init(); }
public AdvancedFaceConvertable(AdvancedFace face, IStpModel model) { _face = face; _model = model; Init(); }
public ConicalSurfaceConvertable(Surface surface, IStpModel model) { _surface = surface; _model = model; Init(); }
private static IConvertable Convertable(Surface surface, IStpModel model) { if (surface.GetType() == typeof (CylindricalSurface)) { return new CylindricalSurfaceConvertable(surface, model); } else if (surface.GetType() == typeof(ConicalSurface)) { return new ConicalSurfaceConvertable(surface, model); } else if (surface.GetType() == typeof(Plane)) { return new PlaneConvertable(surface, model); } else if (surface.GetType() == typeof(ToroidalSurface)) { return new ToroidalSurfaceConvertable(surface, model); } throw new Exception("No convertable found!"); }