コード例 #1
0
ファイル: AvoidElement.cs プロジェクト: wzfxue/Revit
        /// <summary>
        /// 计算线面交点
        /// 平行为null
        /// </summary>
        public XYZ GetConflictPoint(MEPCurve mepCurve)
        {
            var line           = (MEPCurve.Location as LocationCurve).Curve as Line;
            var lineToAvoid    = (mepCurve.Location as LocationCurve).Curve as Line;
            var lineDirection1 = line.Direction;
            var lineDirection2 = lineToAvoid.Direction;

            if ((Math.Abs(lineDirection1.DotProductByCoordinate(lineDirection2, VLCoordinateType.XY)) - lineDirection1.GetLengthByCoordinate(VLCoordinateType.XY) * lineDirection2.GetLengthByCoordinate(VLCoordinateType.XY)).IsMiniValue())
            {
                return(null);
            }
            VLTriangle triangle = new VLTriangle(lineToAvoid.GetEndPoint(0), lineToAvoid.GetEndPoint(1), lineToAvoid.GetEndPoint(0) + new XYZ(0, 0, 1));

            return(VLGeometryHelper.GetIntersection(triangle, line.GetEndPoint(0), line.Direction));
        }
コード例 #2
0
ファイル: LeveledOutLines.cs プロジェクト: wzfxue/Revit
        ///// <summary>
        ///// 检测轮廓是否相交或包含 有限线段
        ///// </summary>
        ///// <param name="outLine"></param>
        ///// <returns></returns>
        //public bool IsCover(XYZ pointZ0)
        //{
        //    foreach (var subOutLine in OutLines)
        //    {
        //        if (subOutLine.GetContainer(pointZ0) != null)
        //        {
        //            return true;
        //        }
        //    }
        //    return false;
        //}

        /// <summary>
        /// 获得拆分点
        /// </summary>
        /// <returns></returns>
        public SeperatePoints GetFitLines(Line beamLineZ0)
        {
            SeperatePoints fitLines = new SeperatePoints();
            var            p0       = beamLineZ0.GetEndPoint(0);
            var            p1       = beamLineZ0.GetEndPoint(1);

            foreach (var SubOutLine in OutLines)
            {
                var coverType = SubOutLine.IsCover(beamLineZ0);
                if (coverType != CoverType.Disjoint)
                {
                    fitLines.AdvancedPoints.AddRange(SubOutLine.GetFitLines(beamLineZ0).AdvancedPoints);
                }
                //线的端点增加 注意检测是否已存在
                var point = p0;
                if (fitLines.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(point)) == null)
                {
                    var triangle = SubOutLine.GetContainer(point);
                    if (triangle != null)
                    {
                        var directOutLine = SubOutLine.GetContainedOutLine(point);
                        fitLines.AdvancedPoints.Add(new AdvancedPoint(VLGeometryHelper.GetIntersection(triangle, point, new XYZ(0, 0, 1)), beamLineZ0.Direction, directOutLine.IsSolid));
                    }
                }
                point = p1;
                if (fitLines.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(point)) == null)
                {
                    var triangle = SubOutLine.GetContainer(point);
                    if (triangle != null)
                    {
                        var directOutLine = SubOutLine.GetContainedOutLine(point);
                        fitLines.AdvancedPoints.Add(new AdvancedPoint(VLGeometryHelper.GetIntersection(triangle, point, new XYZ(0, 0, 1)), beamLineZ0.Direction, directOutLine.IsSolid));
                    }
                }
            }
            return(fitLines);
        }
コード例 #3
0
ファイル: OutLineManager0802.cs プロジェクト: wzfxue/Revit
        /// <summary>
        /// 处理逻辑:
        /// 首先获取板的分层嵌套轮廓
        /// 然后检测线是否与上诉轮廓集合有相交
        /// 如果相交则进行线的裁剪处理
        /// (
        ///   获取所有交点
        ///   检测是否包含线的端点
        ///   结合交点和端点进行梁的分段处理
        ///   返回镂空区间的梁
        /// )
        /// 没有相交则返回完整的线,交于其他板进行裁剪处理
        /// </summary>
        internal List <Line> Deal(Element beam, Line beamLineZ0, LevelFloor levelFloor)
        {
            var           beamLine        = (beam.Location as LocationCurve).Curve as Line;
            List <Line>   undealedZ0      = new List <Line>();
            LevelOutLines leveledOutLines = GetLeveledOutLines(levelFloor);

            if (leveledOutLines.IsCover(beamLineZ0))
            {
                var seperatePoints = leveledOutLines.GetFitLines(beamLineZ0);
                var pBeamZ0        = beamLineZ0.GetEndPoint(0);
                var pBeamZ1        = beamLineZ0.GetEndPoint(1);
                if (seperatePoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(pBeamZ0)) == null)
                {
                    seperatePoints.AdvancedPoints.Add(new AdvancedPoint(pBeamZ0, beamLine.Direction, false));
                }
                if (seperatePoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(pBeamZ1)) == null)
                {
                    seperatePoints.AdvancedPoints.Add(new AdvancedPoint(pBeamZ1, beamLine.Direction, false));
                }
                seperatePoints.AdvancedPoints = new AdvancedPoints(seperatePoints.AdvancedPoints.OrderByDescending(c => c.Point.X).ThenBy(c => c.Point.Y).ToList());
                bool isSolid    = seperatePoints.AdvancedPoints.First().IsSolid;//点的IsSolid可能是其他分层的记录,需更新为当前分层的最新值
                var  beamSymbol = (beam as FamilyInstance).Symbol;
                var  beamLevel  = Document.GetElement(beam.LevelId) as Level;
                for (int i = 0; i < seperatePoints.AdvancedPoints.Count - 1; i++)
                {
                    var sp0 = seperatePoints.AdvancedPoints[i].Point;
                    var sp1 = seperatePoints.AdvancedPoints[i + 1].Point;
                    if (isSolid)
                    {
                        var triangle = leveledOutLines.GetContainer(sp0);
                        if (triangle == null)
                        {
                            throw new NotImplementedException("Container Not Found");
                        }
                        var fixedSP0 = VLGeometryHelper.GetIntersection(triangle, sp0, new XYZ(0, 0, 1));
                        triangle = leveledOutLines.GetContainer(sp1);
                        if (triangle == null)
                        {
                            throw new NotImplementedException("Container Not Found");
                        }
                        var fixedSP1    = VLGeometryHelper.GetIntersection(triangle, sp1, new XYZ(0, 0, 1));
                        var sectionBeam = Document.Create.NewFamilyInstance(Line.CreateBound(fixedSP0, fixedSP1), beamSymbol, beamLevel, Autodesk.Revit.DB.Structure.StructuralType.Beam);
                        CreatedBeams.Add(sectionBeam);
                    }
                    else
                    {
                        var fixedSP0 = VLGeometryHelper.VL_GetIntersectionOnLine(sp0, pBeamZ0, beamLineZ0.Direction);
                        var fixedSP1 = VLGeometryHelper.VL_GetIntersectionOnLine(sp1, pBeamZ0, beamLineZ0.Direction);
                        undealedZ0.Add(Line.CreateBound(fixedSP0, fixedSP1));
                    }
                    isSolid = !isSolid;
                }
                //CARE23415
                GraphicsDisplayerManager.Display(seperatePoints);
            }
            else
            {
                undealedZ0.Add(beamLineZ0);
            }
            return(undealedZ0);
        }