当前位置: 首页>>代码示例>>C#>>正文


C# Solid类代码示例

本文整理汇总了C#中Solid的典型用法代码示例。如果您正苦于以下问题:C# Solid类的具体用法?C# Solid怎么用?C# Solid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Solid类属于命名空间,在下文中一共展示了Solid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProfile

 GetProfile(Solid solid, double offset, Revit.ApplicationServices.Application app)
 {
     CurveArray curveArray = app.Create.NewCurveArray();
     EdgeArray edgeArray = GetEdgesOnPlaneAtOffset(solid.Edges, GeomUtils.kZAxis, offset);
     curveArray = ToCurveArray(edgeArray, curveArray);
     return curveArray;
 }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:7,代码来源:Geometry.cs

示例2: Create

        /// <summary>
        /// Creates a SimpleSweptSolidAnalyzer and computes the swept solid.
        /// </summary>
        /// <param name="solid">The solid geometry.</param>
        /// <param name="normal">The normal of the reference plane that a path might lie on.  If it is null, try to guess based on the geometry.</param>
        /// <returns>The analyzer.</returns>
        public static SimpleSweptSolidAnalyzer Create(Solid solid, XYZ normal)
        {
            if (solid == null)
                throw new ArgumentNullException();

            ICollection<Face> faces = new List<Face>();
            foreach (Face face in solid.Faces)
            {
                faces.Add(face);
            }
            return Create(faces, normal);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:18,代码来源:SimpleSweptSolidAnalyzer.cs

示例3: Create

        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                SweptSolidExporter sweptSolidExporter = null;
                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                        return null;

                    IList<GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                            profileName = type.Name;
                    }

                    // is extrusion?
                    if (sweptAnalyzer.PathCurve is Line)
                    {
                        Line line = sweptAnalyzer.PathCurve as Line;

                        // invalid case
                        if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                            return null;

                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_IsExtrusion = true;
                        Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                        sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                            line.Direction, line.Length * exporterIFC.LinearScale);
                    }
                    else
                    {
                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                    }
                }
                return sweptSolidExporter;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:59,代码来源:SweptSolidExporter.cs

示例4: TestCreate

        public void TestCreate()
        {
            var solid = new Solid();
            Assert.Null(solid.Name);
            Assert.Equal(SolidFormat.Memory, solid.Format);
            Assert.NotNull(solid.Facets);
            Assert.Equal(0, solid.Facets.Count);

            solid = new Solid("Test", new Facet[] { new Facet(), new Facet() });
            Assert.Equal("Test", solid.Name);
            Assert.Equal(SolidFormat.Memory, solid.Format);
            Assert.NotNull(solid.Facets);
            Assert.Equal(2, solid.Facets.Count);
        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:14,代码来源:SolidTest.cs

示例5: Create

        /// <summary>
        /// Creates a SimpleSweptSolidAnalyzer and computes the swept solid.
        /// </summary>
        /// <param name="solid">The solid geometry.</param>
        /// <param name="normal">The normal of the reference plane that a path might lie on.</param>
        /// <returns>The analyzer.</returns>
        public static SimpleSweptSolidAnalyzer Create(Autodesk.Revit.Creation.Application creation, Solid solid, XYZ normal)
        {
            if (solid == null || normal == null)
                throw new ArgumentNullException();

            m_appCreation = creation;

            ICollection<Face> faces = new List<Face>();
            foreach (Face face in solid.Faces)
            {
                faces.Add(face);
            }
            return Create(faces, normal);
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:20,代码来源:SimpleSweptSolidAnalyzer.cs

示例6: Clone

        public static Solid Clone( /*this*/ Solid solid )
        {
            if( solid == null )
              {
            return null;
              }

              // Better than unioning the solid with itself:
              // use a small cube contained within the original
              // solid instead, e.g. a 1x1x1 cube at the origin
              // or something.

              return BooleanOperationsUtils
            .ExecuteBooleanOperation( solid, solid,
              BooleanOperationsType.Union );
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:16,代码来源:CmdExportSolidToSat.cs

示例7: Slicer

 /// <summary>
 /// creates slices using a curve as the spine
 /// </summary>
 /// <param name="solid">Solid: geometry that is to be parsed</param>
 /// <param name="curve">Curve: defines the normal used to create cut planes perpendicular to parameter "plane".
 /// If curve is too short, it will be extended using built-in extend function</param>
 /// <param name="thickness">Thickness: the thickness of the slices, or the thickness of the material to be used for the assembly</param>
 /// <param name="spacing">Spacing: the distance between each slice</param>
 /// <returns>A newly-constructed Slicer object</returns>
 internal Slicer(Solid solid, Curve curve, double thickness, double spacing, double origin)
 {
     Solid = solid;
     Thickness = thickness;
     Spacing = spacing;
     Plane plane = Plane.ByOriginNormal(curve.StartPoint, curve.Normal);
     Curve curvePlanar = curve;
     if(!curve.IsPlanar)
     {
         plane = Plane.ByBestFitThroughPoints(curve.ToNurbsCurve().ControlPoints());
         curvePlanar = curve.PullOntoPlane(plane);
     }
     CutPlanesPrimary.AddRange(GenerateCutPlanes(plane));
     CutPlanesSecondary.AddRange(GenerateCutPlanes(curvePlanar, origin));
     InitialGeometry = new List<Geometry>(1){curvePlanar};
 }
开发者ID:Hanxuelong,项目名称:BecauseWeDynamo,代码行数:25,代码来源:Slicer.cs

示例8: CanExportAsSweptSolid

        /// <summary>
        /// Determines if we can create a swept solid from the passed in geometry.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The optional normal of the plane that the path lies on.</param>
        /// <returns>If it is possible to create a swept solid, the SimpleSweptSolidAnalyzer that contains the information, otherwise null.</returns>
        public static SimpleSweptSolidAnalyzer CanExportAsSweptSolid(ExporterIFC exporterIFC, Solid solid, XYZ normal)
        {
            try
            {
                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(solid, normal);
                if (sweptAnalyzer == null)
                    return null;

                // TODO: support openings and recess for a swept solid
                if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                    return null;

                return sweptAnalyzer;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:27,代码来源:SweptSolidExporter.cs

示例9: WorldDraw

        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return base.WorldDraw(drawable, wd);
            }

            RebarPos pos = drawable as RebarPos;
            if (pos == null || (pos.IncludeInBOQ && !pos.Detached))
            {
                return base.WorldDraw(drawable, wd);
            }

            // Get geometry
            Point3d minpt;
            Point3d maxpt;
            pos.TextBox(out minpt, out maxpt);
            minpt = minpt.DivideBy(pos.Scale);
            maxpt = maxpt.DivideBy(pos.Scale);

            using (Solid solid = new Solid())
            {
                solid.SetPointAt(0, new Point3d(minpt.X - 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(1, new Point3d(maxpt.X + 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(2, new Point3d(minpt.X - 0.15, maxpt.Y + 0.15, 0));
                solid.SetPointAt(3, new Point3d(maxpt.X + 0.15, maxpt.Y + 0.15, 0));
                solid.Color = mColor;
                solid.LayerId = PosUtility.DefpointsLayer;

                Matrix3d trans = Matrix3d.AlignCoordinateSystem(
                    Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
                    pos.BasePoint, pos.DirectionVector, pos.UpVector, pos.NormalVector);

                solid.TransformBy(trans);
                wd.Geometry.Draw(solid);
            }

            // Draw the entity over shading
            return base.WorldDraw(drawable, wd);
        }
开发者ID:oozcitak,项目名称:RebarPos,代码行数:40,代码来源:CountOverrule.cs

示例10: GetDifferenceFromWallJoins

        private static bool GetDifferenceFromWallJoins(Document doc, ElementId wallId, Solid baseSolid, IList<IList<IFCConnectedWallData>> connectedWalls)
        {
            Options options = GeometryUtil.GetIFCExportGeometryOptions();
            foreach (IList<IFCConnectedWallData> wallDataList in connectedWalls)
            {
                foreach (IFCConnectedWallData wallData in wallDataList)
                {
                    ElementId otherWallId = wallData.ElementId;
                    if (otherWallId == wallId)
                        continue;

                    Element otherElem = doc.GetElement(otherWallId);
                    GeometryElement otherGeomElem = (otherElem != null) ? otherElem.get_Geometry(options) : null;
                    if (otherGeomElem == null)
                        continue;

                    SolidMeshGeometryInfo solidMeshInfo = GeometryUtil.GetSplitSolidMeshGeometry(otherGeomElem);
                    if (solidMeshInfo.GetMeshes().Count != 0)
                        return false;

                    IList<Solid> otherSolids = solidMeshInfo.GetSolids();
                    foreach (Solid otherSolid in otherSolids)
                    {
                        try
                        {
                            BooleanOperationsUtils.ExecuteBooleanOperationModifyingOriginalSolid(baseSolid, otherSolid, BooleanOperationsType.Difference);
                        }
                        catch
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:37,代码来源:WallExporter.cs

示例11: TestTextWriter

        public void TestTextWriter()
        {
            Solid solid1 = new Solid("test", new List<Facet>()
            {
                new Facet(new Vertex( 0.23f, 0, 1), new Vertex[]
                {
                    new Vertex( 0, 0, 0),
                    new Vertex(-10.123f, -10, 0),
                    new Vertex(-10.123f, 0, 0)
                }, 0)
            });

            byte[] data;
            string dataString1;

            using (MemoryStream stream = new MemoryStream())
            using (var writer = new StlTextWriter(stream))
            {
                writer.WriteSolid(solid1);
                data = stream.ToArray();
                dataString1 = Consts.FileEncoding.GetString(data);
            }

            Solid solid2;

            using (MemoryStream stream = new MemoryStream(data))
            using (var reader = new StlReader(stream))
            {
                solid2 = reader.ReadSolid();
            }

            Assert.Equal(solid1.Name, solid2.Name);
            Assert.Equal(solid1.Facets.Count, solid2.Facets.Count);
            for (int i = 0; i < solid1.Facets.Count; i++)
                Assert.True(solid1.Facets[i].Equals(solid2.Facets[i]));

        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:37,代码来源:WriterTest.cs

示例12: TestBinaryWriter

        public void TestBinaryWriter()
        {
            Solid solid1 = new Solid("test", new Facet[]
            {
                new Facet(new Vertex( 0, 0, 1), new Vertex[]
                {
                    new Vertex( 0, 0, 0),
                    new Vertex(-10, -10, 0),
                    new Vertex(-10, 0, 0)
                }, 0)
            });

            byte[] data;

            using (MemoryStream stream = new MemoryStream())
            using (var writer = new StlBinaryWriter(stream))
            {
                writer.WriteSolid(solid1);
                data = stream.ToArray();
            }

            Solid solid2;

            using (MemoryStream stream = new MemoryStream(data))
            using (var reader = new StlReader(stream))
            {
                solid2 = reader.ReadSolid();
            }

            Assert.NotEqual(solid1.Name, solid2.Name);
            Assert.Null(solid2.Name);
            Assert.Equal(solid1.Facets.Count, solid2.Facets.Count);
            for (int i = 0; i < solid1.Facets.Count; i++)
                Assert.True(solid1.Facets[i].Equals(solid2.Facets[i]));

        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:36,代码来源:WriterTest.cs

示例13: getFaceNaos

        /// <summary>
        /// Retrieve the planar face normal and origin
        /// from all of the solid's planar faces and
        /// insert them into the map mapping face normals
        /// to a list of all origins of different faces
        /// sharing this normal.
        /// </summary>
        /// <param name="naos">Map mapping each normal vector
        /// to a list of the origins of all planar faces
        /// sharing this normal direction</param>
        /// <param name="solid">Input solid</param>
        void getFaceNaos(
            Dictionary<XYZ, List<XYZ>> naos,
            Solid solid)
        {
            foreach( Face face in solid.Faces )
              {
            PlanarFace planarFace = face as PlanarFace;
            if( null != planarFace )
            {
              XYZ normal = planarFace.Normal;
              XYZ origin = planarFace.Origin;
              List<XYZ> normals = new List<XYZ>( naos.Keys );
              int i = normals.FindIndex(
            delegate( XYZ v )
            {
              return XyzParallel( v, normal );
            } );

              if( -1 == i )
              {
            Debug.Print(
                "Face at {0} has new normal {1}",
                Util.PointString( origin ),
                Util.PointString( normal ) );

            naos.Add( normal, new List<XYZ>() );
            naos[normal].Add( origin );
              }
              else
              {
            Debug.Print(
                "Face at {0} normal {1} matches {2}",
                Util.PointString( origin ),
                Util.PointString( normal ),
                Util.PointString( normals[i] ) );

            naos[normals[i]].Add( origin );
              }
            }
              }
        }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:52,代码来源:CmdWallDimensions.cs

示例14: GetTopFace

 /// <summary>
 /// Return the uppermost horizontal face
 /// of a given "horizontal" solid object
 /// such as a floor slab. Currently only
 /// supports planar faces.
 /// </summary>
 PlanarFace GetTopFace( Solid solid )
 {
     PlanarFace topFace = null;
       FaceArray faces = solid.Faces;
       foreach( Face f in faces )
       {
     PlanarFace pf = f as PlanarFace;
     if( null != pf
       && Util.IsHorizontal( pf ) )
     {
       if( ( null == topFace )
     || ( topFace.Origin.Z < pf.Origin.Z ) )
       {
     topFace = pf;
       }
     }
       }
       return topFace;
 }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:25,代码来源:CmdEditFloor.cs

示例15: CreateSimpleSweptSolid

        /// <summary>
        /// Creates a simple swept solid.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The swept solid representation handle.</returns>
        public static IFCAnyHandle CreateSimpleSweptSolid(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                if (element == null || element.Document == null)
                    return null;

                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                        return null;

                    IList<GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                            profileName = type.Name;
                    }

                    return CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                }
            }
            catch (Exception)
            {
                return null;
            }

            return null;
        }
开发者ID:stiter,项目名称:ifcexporter,代码行数:43,代码来源:SweptSolidExporter.cs


注:本文中的Solid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。