Пример #1
0
        /// <summary>
        /// Create a conical revolve body
        /// </summary>
        /// <param name="builder">Geometry builder</param>
        /// <param name="center">Center of the cone base</param>
        /// <param name="axis">Cone axis</param>
        /// <param name="baseDiam">Base diameter of the cone</param>
        /// <param name="topDiam">Top diameter of the cone</param>
        /// <param name="height">Height of the cone</param>
        /// <returns></returns>
        public static IXRevolve CreateSolidCone(this IXGeometryBuilder builder, Point center, Vector axis,
                                                double baseDiam, double topDiam, double height)
        {
            var refDir = axis.CreateAnyPerpendicular();

            var profile = builder.WireBuilder.PreCreatePolyline();

            profile.Points = new Point[]
            {
                center,
                center.Move(axis, height),
                center.Move(axis, height).Move(refDir, topDiam / 2),
                center.Move(refDir, baseDiam / 2),
                center
            };
            profile.Commit();

            var revLine = builder.WireBuilder.PreCreateLine();

            revLine.StartCoordinate = center;
            revLine.EndCoordinate   = center.Move(axis, 1);
            revLine.Commit();

            var rev = builder.SolidBuilder.PreCreateRevolve();

            rev.Axis     = revLine;
            rev.Angle    = Math.PI * 2;
            rev.Profiles = new IXRegion[] { builder.CreatePlanarSheet(profile).Bodies.First() };
            rev.Commit();

            return(rev);
        }
Пример #2
0
        public static IXBody CreateBox(this IXGeometryBuilder builder, Point center, Vector dir,
                                       double width, double length, double height, out Vector refDir)
        {
            refDir = FindRefDir(dir);

            return(builder.CreateBox(center, dir, refDir, width, length, height));
        }
Пример #3
0
        public static IXBody CreateCone(this IXGeometryBuilder builder, Point center, Vector axis,
                                        double baseRadius, double topRadius, double height)
        {
            Vector refDir;

            return(CreateCone(builder, center, axis, baseRadius, topRadius, height, out refDir));
        }
Пример #4
0
        /// <summary>
        /// Creates a box body from the specified parameters
        /// </summary>
        /// <param name="builder">Geometry builder</param>
        /// <param name="center">Center of the box base face</param>
        /// <param name="dir">Direction of the box</param>
        /// <param name="refDir">Reference direction of the box base face (this is the vector perpendicular to 'dir'</param>
        /// <param name="width">Width of the box. This size is parallel to 'refDir' vector</param>
        /// <param name="length">Length of the box</param>
        /// <param name="height">Height of the box. THis size is parallel to 'dir' vector</param>
        /// <returns>Box extrusion</returns>
        public static IXExtrusion CreateSolidBox(this IXGeometryBuilder builder, Point center, Vector dir, Vector refDir,
                                                 double width, double length, double height)
        {
            var secondRefDir = dir.Cross(refDir);

            var polyline = builder.WireBuilder.PreCreatePolyline();

            polyline.Points = new Point[]
            {
                center.Move(refDir, width / 2).Move(secondRefDir, length / 2),
                center.Move(refDir * -1, width / 2).Move(secondRefDir, length / 2),
                center.Move(refDir * -1, width / 2).Move(secondRefDir * -1, length / 2),
                center.Move(refDir, width / 2).Move(secondRefDir * -1, length / 2),
                center.Move(refDir, width / 2).Move(secondRefDir, length / 2),
            };
            polyline.Commit();

            var extr = builder.SolidBuilder.PreCreateExtrusion();

            extr.Depth     = height;
            extr.Direction = dir;
            extr.Profiles  = new IXRegion[] { builder.CreatePlanarSheet(polyline).Bodies.First() };
            extr.Commit();

            return(extr);
        }
Пример #5
0
        public static IXBody CreateBox(this IXGeometryBuilder builder, Point center, Vector dir,
                                       double width, double length, double height)
        {
            Vector refDir;

            return(CreateBox(builder, center, dir, width, length, height, out refDir));
        }
Пример #6
0
        public static IXBody CreateCylinder(this IXGeometryBuilder builder, Point center, Vector axis,
                                            double radius, double height)
        {
            Vector refDir;

            return(CreateCylinder(builder, center, axis, radius, height, out refDir));
        }
Пример #7
0
        public static IXPlanarSheet CreatePlanarSheet(this IXGeometryBuilder builder, params IXSegment[] boundary)
        {
            var surf = builder.SheetBuilder.PreCreatePlanarSheet();

            surf.Boundary = boundary;
            surf.Commit();

            return(surf);
        }
Пример #8
0
        public static IXPlanarSheet CreatePlanarSheet(this IXGeometryBuilder builder, IXRegion boundary)
        {
            var surf = builder.SheetBuilder.PreCreatePlanarSheet();

            surf.Region = boundary;
            surf.Commit();

            return(surf);
        }
Пример #9
0
        public static IXLine CreateLine(this IXGeometryBuilder builder, Point startPt, Point endPt)
        {
            var line = builder.WireBuilder.PreCreateLine();

            line.StartCoordinate = startPt;
            line.EndCoordinate   = endPt;
            line.Commit();

            return(line);
        }
Пример #10
0
        public static IXSweep CreateSolidSweep(this IXGeometryBuilder builder, IXSegment path, params IXRegion[] profiles)
        {
            var sweep = builder.SolidBuilder.PreCreateSweep();

            sweep.Profiles = profiles;
            sweep.Path     = path;
            sweep.Commit();

            return(sweep);
        }
Пример #11
0
        public static IXArc CreateCircle(this IXGeometryBuilder builder, Point centerPt, Vector axis, double diameter)
        {
            var circle = builder.WireBuilder.PreCreateArc();

            circle.Center   = centerPt;
            circle.Axis     = axis;
            circle.Diameter = diameter;
            circle.Commit();

            return(circle);
        }
Пример #12
0
        public static IXRevolve CreateSolidRevolve(this IXGeometryBuilder builder, IXLine axis, double angle, params IXRegion[] profiles)
        {
            var rev = builder.SolidBuilder.PreCreateRevolve();

            rev.Angle    = angle;
            rev.Axis     = axis;
            rev.Profiles = profiles;
            rev.Commit();

            return(rev);
        }
Пример #13
0
        public static IXExtrusion CreateSolidExtrusion(this IXGeometryBuilder builder,
                                                       double depth, Vector direction, params IXRegion[] profiles)
        {
            var extr = builder.SolidBuilder.PreCreateExtrusion();

            extr.Depth     = depth;
            extr.Direction = direction;
            extr.Profiles  = profiles;
            extr.Commit();

            return(extr);
        }
Пример #14
0
        /// <summary>
        /// Creates cylindrical extrusion from input parameters
        /// </summary>
        /// <param name="builder">Geometry builder</param>
        /// <param name="center">Center of the cylinder base</param>
        /// <param name="axis">Direction of the cylinder</param>
        /// <param name="radius">Radius of the cylinder</param>
        /// <param name="height">Height of the cylinder</param>
        /// <returns>Cylindrical extrusion</returns>
        public static IXExtrusion CreateSolidCylinder(this IXGeometryBuilder builder, Point center, Vector axis,
                                                      double radius, double height)
        {
            var arc = builder.WireBuilder.PreCreateArc();

            arc.Center   = center;
            arc.Axis     = axis;
            arc.Diameter = radius * 2;
            arc.Commit();

            var extr = builder.SolidBuilder.PreCreateExtrusion();

            extr.Depth     = height;
            extr.Direction = arc.Axis;
            extr.Profiles  = new IXRegion[] { builder.CreatePlanarSheet(arc).Bodies.First() };
            extr.Commit();

            return(extr);
        }
Пример #15
0
 internal SwApplication(ISldWorks app, ILogger logger)
 {
     Application     = app;
     SwDocuments     = new SwDocumentCollection(app, logger);
     GeometryBuilder = new SwGeometryBuilder(app.IGetMathUtility(), app.IGetModeler());
 }
Пример #16
0
 public static IXBody CreateCone(this IXGeometryBuilder builder, Point center, Vector axis,
                                 double baseRadius, double topRadius, double height, out Vector refDir)
 {
     refDir = FindRefDir(axis);
     return(builder.CreateCone(center, axis, refDir, baseRadius, topRadius, height));
 }
Пример #17
0
 public static IXBody CreateCylinder(this IXGeometryBuilder builder, Point center, Vector axis,
                                     double radius, double height, out Vector refDir)
 {
     refDir = FindRefDir(axis);
     return(builder.CreateCylinder(center, axis, refDir, radius, height));
 }