Exemplo n.º 1
0
        public bool ReadDrawing(string fileName, Stream fileStream, out Drawing drawing, out ViewPort viewPort)
        {
            var file  = IgesFile.Load(fileStream);
            var layer = new Layer("igs");

            foreach (var entity in file.Entities)
            {
                var cadEntity = entity.ToEntity();
                if (cadEntity != null)
                {
                    layer = layer.Add(cadEntity);
                }
            }

            drawing = new Drawing(
                new DrawingSettings(fileName, UnitFormat.Architectural, 8),
                new ReadOnlyTree <string, Layer>().Insert(layer.Name, layer),
                layer.Name,
                file.Author);
            drawing.Tag = file;

            viewPort = null; // auto-set it later

            return(true);
        }
Exemplo n.º 2
0
        public bool WriteDrawing(string fileName, Stream fileStream, Drawing drawing, ViewPort viewPort, INotifyPropertyChanged fileSettings)
        {
            var file    = new IgesFile();
            var oldFile = drawing.Tag as IgesFile;

            if (oldFile != null)
            {
                // preserve settings from original file
                file.TimeStamp = oldFile.TimeStamp;
            }

            file.Author           = drawing.Author;
            file.FullFileName     = fileName;
            file.Identification   = Path.GetFileName(fileName);
            file.Identifier       = Path.GetFileName(fileName);
            file.ModelUnits       = drawing.Settings.UnitFormat.ToIgesUnits();
            file.ModifiedTime     = DateTime.Now;
            file.SystemIdentifier = "BCad";
            file.SystemVersion    = "1.0";
            foreach (var entity in drawing.GetEntities())
            {
                var igesEntity = entity.ToIgesEntity();
                if (igesEntity != null)
                {
                    file.Entities.Add(igesEntity);
                }
            }

            file.Save(fileStream);
            return(true);
        }
Exemplo n.º 3
0
 public IgesRationalBSplineCurve(IgesFile file)
     : base(file)
 {
     KnotValues    = new List <double>();
     Weights       = new List <double>();
     ControlPoints = new List <Point3D>();
 }
Exemplo n.º 4
0
 public IgesParametricSplineSurface(IgesFile file)
     : base(file)
 {
     SplineType   = IgesSplineType.Linear;
     UBreakpoints = new List <double>();
     VBreakpoints = new List <double>();
 }
Exemplo n.º 5
0
 public IgesSelectedComponent(IgesFile file, IgesBooleanTree booleanTree, Point3D selectionPoint)
     : base(file)
 {
     EntityUseFlag  = IgesEntityUseFlag.Other;
     BooleanTree    = booleanTree;
     SelectionPoint = selectionPoint;
 }
Exemplo n.º 6
0
        public void WriteCommonPointersTest()
        {
            // all other write tests validate the case where there are no common pointers
            var line = new IgesLine();

            line.AssociatedEntities.Add(new IgesLabelDisplayAssociativity());
            line.AssociatedEntities.Add(new IgesGeneralNote());
            line.AssociatedEntities.Add(new IgesTextDisplayTemplate());
            line.Properties.Add(new IgesLocation());
            var file = new IgesFile();

            file.Entities.Add(line);
            VerifyFileContains(file, @"
     402       1       0       0       0                        00000000D      1
     402       0       0       1       5                                D      2
     212       2       0       0       0                        00000100D      3
     212       0       0       1       0                                D      4
     312       3       0       0       0                        00000200D      5
     312       0       0       1       0                                D      6
     116       4       0       0       0                        00000000D      7
     116       0       0       1       0                                D      8
     110       5       0       0       0                        00000000D      9
     110       0       0       1       0                                D     10
402,0;                                                                 1P      1
212,0;                                                                 3P      2
312,0.,0.,1,0.,0.,0,0,0.,0.,0.;                                        5P      3
116,0.,0.,0.;                                                          7P      4
110,0.,0.,0.,0.,0.,0.,3,1,3,5,1,7;                                     9P      5
");

            // no properties
            line.Properties.Clear();
            VerifyFileContains(file, @"
     402       1       0       0       0                        00000000D      1
     402       0       0       1       5                                D      2
     212       2       0       0       0                        00000100D      3
     212       0       0       1       0                                D      4
     312       3       0       0       0                        00000200D      5
     312       0       0       1       0                                D      6
     110       4       0       0       0                        00000000D      7
     110       0       0       1       0                                D      8
402,0;                                                                 1P      1
212,0;                                                                 3P      2
312,0.,0.,1,0.,0.,0,0,0.,0.,0.;                                        5P      3
110,0.,0.,0.,0.,0.,0.,3,1,3,5;                                         7P      4
");

            // no associated entities
            line.AssociatedEntities.Clear();
            line.Properties.Add(new IgesLocation());
            VerifyFileContains(file, @"
     116       1       0       0       0                        00000000D      1
     116       0       0       1       0                                D      2
     110       2       0       0       0                        00000000D      3
     110       0       0       1       0                                D      4
116,0.,0.,0.;                                                          1P      1
110,0.,0.,0.,0.,0.,0.,0,1,1;                                           3P      2
");
        }
Exemplo n.º 7
0
 public IgesTextFontDefinition(IgesFile file)
     : base(file)
 {
     SubordinateEntitySwitchType = IgesSubordinateEntitySwitchType.Independent;
     EntityUseFlag = IgesEntityUseFlag.Definition;
     FormNumber    = 0;
     Characters    = new List <IgesTextFontDefinitionCharacter>();
 }
Exemplo n.º 8
0
 public IgesEllipsoid(IgesFile file)
     : base(file)
 {
     EntityUseFlag = IgesEntityUseFlag.Geometry;
     Center        = Point3D.Origin;
     XAxis         = IgesVector.XAxis;
     ZAxis         = IgesVector.ZAxis;
 }
Exemplo n.º 9
0
        public IgesSolidOfRevolution(IgesFile file)
            : base(file)

        {
            RevolutionAmount = 1.0;
            PointOnAxis      = Point3D.Origin;
            AxisDirection    = IgesVector.ZAxis;
        }
Exemplo n.º 10
0
 public IgesCircularArc(Point3D center, Point2D start, Point2D end, IgesFile file)
     : base(file)
 {
     this.PlaneDisplacement = center.Z;
     this.Center            = new Point2D(center.X, center.Y);
     this.StartPoint        = start;
     this.EndPoint          = end;
 }
Exemplo n.º 11
0
 public IgesBoundary(IgesFile file)
     : base(file)
 {
     IsBounaryParametric = false;
     TrimCurvePreference = IgesTrimCurvePreference.Unspecified;
     Entity        = null;
     BoundaryItems = new List <IgesBoundaryItem>();
 }
Exemplo n.º 12
0
 public IgesNewGeneralNote(IgesFile file)
     : base(file)
 {
     EntityUseFlag = IgesEntityUseFlag.Annotation;
     TextContainmentAreaLocation = Point3D.Origin;
     FirstBaseLineLocation       = Point3D.Origin;
     Strings = new List <IgesNewTextString>();
 }
Exemplo n.º 13
0
 public IgesLeader(IgesFile file)
     : base(file)
 {
     ArrowType            = IgesArrowType.Wedge;
     EntityUseFlag        = IgesEntityUseFlag.Annotation;
     ArrowheadCoordinates = Point3D.Origin;
     LineSegments         = new List <Point3D>();
 }
Exemplo n.º 14
0
 public IgesSubfigureDefinition(IgesFile file)
     : base(file)
 {
     this.Depth         = 0;
     this.Name          = null;
     this.EntityUseFlag = IgesEntityUseFlag.Definition;
     Entities           = new List <IgesEntity>();
 }
Exemplo n.º 15
0
 public IgesTextDisplayTemplate(IgesFile file)
     : base(file)
 {
     SubordinateEntitySwitchType = IgesSubordinateEntitySwitchType.Independent;
     EntityUseFlag    = IgesEntityUseFlag.Definition;
     Hierarchy        = IgesHierarchy.GlobalTopDown;
     FontCode         = 1;
     LocationOrOffset = IgesVector.Zero;
 }
Exemplo n.º 16
0
 public IgesRigidBody(
     IgesFile file,
     Point3D p1,
     Point3D p2)
     : base(file, IgesTopologyType.RigidBody)
 {
     P1 = p1;
     P2 = p2;
 }
Exemplo n.º 17
0
 public IgesSpring(
     IgesFile file,
     Point3D p1,
     Point3D p2)
     : base(file, IgesTopologyType.Spring)
 {
     P1 = p1;
     P2 = p2;
 }
Exemplo n.º 18
0
 public IgesDirection(IgesFile file, double x, double y, double z)
     : base(file)
 {
     this.SubordinateEntitySwitchType = IgesSubordinateEntitySwitchType.PhysicallyDependent;
     this.EntityUseFlag = IgesEntityUseFlag.Definition;
     this.X             = x;
     this.Y             = y;
     this.Z             = z;
 }
Exemplo n.º 19
0
 public IgesOffsetMass(
     IgesFile file,
     Point3D location,
     Point3D centerOfMass)
     : base(file, IgesTopologyType.OffsetMass)
 {
     Location     = location;
     CenterOfMass = centerOfMass;
 }
Exemplo n.º 20
0
 public IgesAxisymmetricLinarLine(
     IgesFile file,
     Point3D p1,
     Point3D p2)
     : base(file, IgesTopologyType.AxisymmetricLinarLine)
 {
     P1 = p1;
     P2 = p2;
 }
Exemplo n.º 21
0
 public IgesBeam(
     IgesFile file,
     Point3D p1,
     Point3D p2)
     : base(file, IgesTopologyType.Beam)
 {
     P1 = p1;
     P2 = p2;
 }
Exemplo n.º 22
0
 public IgesDamper(
     IgesFile file,
     Point3D p1,
     Point3D p2)
     : base(file, IgesTopologyType.Damper)
 {
     P1 = p1;
     P2 = p2;
 }
Exemplo n.º 23
0
 public IgesColorDefinition(IgesFile file, double r, double g, double b, string name = null)
     : base(file)
 {
     this.SubordinateEntitySwitchType = IgesSubordinateEntitySwitchType.Independent;
     this.EntityUseFlag  = IgesEntityUseFlag.Definition;
     this.RedIntensity   = r;
     this.GreenIntensity = g;
     this.BlueIntensity  = b;
     this.Name           = name;
 }
Exemplo n.º 24
0
 public IgesView(IgesFile file, int viewNumber, double scaleFactor, IgesPlane left, IgesPlane top, IgesPlane right, IgesPlane bottom, IgesPlane back, IgesPlane front)
     : base(file, viewNumber, scaleFactor)
 {
     this.FormNumber  = 0;
     ViewVolumeLeft   = left;
     ViewVolumeTop    = top;
     ViewVolumeRight  = right;
     ViewVolumeBottom = bottom;
     ViewVolumeBack   = back;
     ViewVolumeFront  = front;
 }
Exemplo n.º 25
0
 public IgesThreeNodeBeam(
     IgesFile file,
     Point3D p1,
     Point3D p2,
     Point3D p3)
     : base(file, IgesTopologyType.ThreeNodeBeam)
 {
     P1 = p1;
     P2 = p2;
     P3 = p3;
 }
Exemplo n.º 26
0
 public IgesAxisymmetricParabolicLine(
     IgesFile file,
     Point3D p1,
     Point3D p2,
     Point3D p3)
     : base(file, IgesTopologyType.AxisymmetricParabolicLine)
 {
     P1 = p1;
     P2 = p2;
     P3 = p3;
 }
Exemplo n.º 27
0
        private static void VerifyFileText(IgesFile file, string expected, Action <string, string> verifier)
        {
            var stream = new MemoryStream();

            file.Save(stream);
            stream.Seek(0, SeekOrigin.Begin);
            var bytes  = stream.ToArray();
            var actual = Encoding.ASCII.GetString(bytes);

            verifier(expected.Trim('\r', '\n').Replace("\r", ""), actual.Trim('\r', '\n'));
        }
Exemplo n.º 28
0
 public IgesLinearTriangle(
     IgesFile file,
     Point3D p1,
     Point3D p2,
     Point3D p3)
     : base(file, IgesTopologyType.LinearTriangle)
 {
     P1 = p1;
     P2 = p2;
     P3 = p3;
 }
Exemplo n.º 29
0
 protected IgesEntity(IgesFile file)
 {
     File               = file;
     Levels             = new HashSet <int>();
     AssociatedEntities = new List <IgesEntity>();
     Properties         = new List <IgesEntity>();
     if (!(this is IgesTransformationMatrix))
     {
         TransformationMatrix = IgesTransformationMatrix.Identity(file);
     }
 }
Exemplo n.º 30
0
 public IgesCubicSolidWedge(
     IgesFile file,
     Point3D p1,
     Point3D p1P2Control1,
     Point3D p1P2Control2,
     Point3D p2,
     Point3D p2P3Control1,
     Point3D p2P3Control2,
     Point3D p3,
     Point3D p3P1Control1,
     Point3D p3P1Control2,
     Point3D p4P1Control1,
     Point3D p5P2Control1,
     Point3D p6P3Control1,
     Point3D p4P1Control2,
     Point3D p5P2Control2,
     Point3D p6P3Control2,
     Point3D p4,
     Point3D p4P5Control1,
     Point3D p4P5Control2,
     Point3D p5,
     Point3D p5P6Control1,
     Point3D p5P6Control2,
     Point3D p6,
     Point3D p6P4Control1,
     Point3D p6P4Control2)
     : base(file, IgesTopologyType.CubicSolidWedge)
 {
     P1           = p1;
     P1P2Control1 = p1P2Control1;
     P1P2Control2 = p1P2Control2;
     P2           = p2;
     P2P3Control1 = p2P3Control1;
     P2P3Control2 = p2P3Control2;
     P3           = p3;
     P3P1Control1 = p3P1Control1;
     P3P1Control2 = p3P1Control2;
     P4P1Control1 = p4P1Control1;
     P5P2Control1 = p5P2Control1;
     P6P3Control1 = p6P3Control1;
     P4P1Control2 = p4P1Control2;
     P5P2Control2 = p5P2Control2;
     P6P3Control2 = p6P3Control2;
     P4           = p4;
     P4P5Control1 = p4P5Control1;
     P4P5Control2 = p4P5Control2;
     P5           = p5;
     P5P6Control1 = p5P6Control1;
     P5P6Control2 = p5P6Control2;
     P6           = p6;
     P6P4Control1 = p6P4Control1;
     P6P4Control2 = p6P4Control2;
 }