예제 #1
0
        public static void GetVertexFromSingleCurve(CurveData curve, out Vertex vStart, out Vertex vEnd)
        {
            vStart = new Vertex(curve.Points[0].X, curve.Points[0].Y, curve.Points[0].Z);
            vEnd = new Vertex(curve.Points[1].X, curve.Points[1].Y, curve.Points[1].Z);

            if (curve.IsArc)
            {
                var vtmp = vStart;
                vStart = vEnd;
                vEnd = vtmp;

                int dDirection = curve.Normal.Z > 0 ? 1 : -1;
                double angle = curve.StartParameter - curve.EndParameter;

                // 凸度的定义是:圆弧段圆心角四分之一的正切值。正负决定圆弧方向
                vStart.Bulge = dDirection * Math.Tan(angle / 4);
            }
        }
예제 #2
0
        public static CurveData ToCurveData(this Curve curve)
        {
            CurveData cd = new CurveData();

            cd.Points.Add(curve.GetEndPoint(0).ToPointData());
            cd.Points.Add(curve.GetEndPoint(1).ToPointData());
            cd.StartParameter = curve.GetEndParameter(0);
            cd.EndParameter = curve.GetEndParameter(1);

            var arc = curve as Arc;
            cd.IsArc = arc != null;

            if (cd.IsArc)
            {
                cd.Normal = arc.Normal.ToPointData();
                cd.Center = arc.Center.ToPointData();
                cd.Radius = arc.Radius;
            }

            return cd;
        }
예제 #3
0
        /// <summary>
        /// 从实体中得到属性
        /// </summary>
        /// <param name="elem"></param>
        /// <returns>返回的是一个 属性组名-同组下的属性列表 字典</returns>
        private Dictionary <string, List <PropertyData> > GetPropertiesAndLocationFromElement(Element elem)
        {
            Dictionary <string, List <PropertyData> > dictProperties = new Dictionary <string, List <PropertyData> >();

            if (!ExportSetting.SystemSetting.IsExportProperty)
            {
                return(dictProperties);
            }

            // 属性中添加族和类型信息
            var internalProps = new List <PropertyData> {
                new PropertyData {
                    GroupName = "#Internal", Name = "#name", Value = CurrentElement.Name
                }
            };

            if (CurrentElement.Category != null)
            {
                internalProps.Add(new PropertyData {
                    GroupName = "#Internal", Name = "#category", Value = CurrentElement.Category.Name
                });
            }
            internalProps.Add(new PropertyData {
                GroupName = "#Internal", Name = "#guid", Value = CurrentElement.UniqueId
            });
            var fname = GetFamilyName(elem);

            if (!string.IsNullOrEmpty(fname) && !(CurrentElement is MEPCurve))
            {
                internalProps.Add(new PropertyData {
                    GroupName = "#Internal", Name = "#family", Value = fname
                });
            }
            dictProperties["#Internal"] = internalProps;

            if (elem is Wall wall && ExportSetting.SystemSetting.IsExportWallSideArea)
            {
                var innerArea = Math.Round(Tools.GetWallSideFaceArea(wall, false) * Tools.SqrFt2SqrM, 3);
                var outerArea = Math.Round(Tools.GetWallSideFaceArea(wall, true) * Tools.SqrFt2SqrM, 3);

                var sideAreaProps = new List <PropertyData>
                {
                    new PropertyData {
                        GroupName = "算量信息", Name = "内测面积", Value = innerArea.ToString()
                    },
                    new PropertyData {
                        GroupName = "算量信息", Name = "外侧面积", Value = outerArea.ToString()
                    }
                };
                dictProperties["算量信息"] = sideAreaProps;
            }

            // 读取位置信息
            if (InstanceLocation == null)
            {
                InstanceLocation = new Dictionary <string, LocationData>();
            }

            if (!(elem is MEPCurve) && elem.Location is LocationCurve && elem is FamilyInstance)
            {
                var curve     = (elem.Location as LocationCurve).Curve;
                var fi        = (elem as FamilyInstance);
                var curvedata = new CurveData();
                if (curve is Arc arc)
                {
                    curvedata.IsArc          = true;
                    curvedata.Center         = new PointData(arc.Center.X, arc.Center.Y, arc.Center.Z);
                    curvedata.Normal         = new PointData(arc.Normal.X, arc.Normal.Y, arc.Normal.Z);
                    curvedata.StartParameter = arc.GetEndParameter(0);
                    curvedata.EndParameter   = arc.GetEndParameter(1);
                    curvedata.Radius         = arc.Radius;
                    var pt = arc.GetEndPoint(0);
                    curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                    pt = arc.GetEndPoint(1);
                    curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                }
                else
                {
                    curvedata.IsArc = false;
                    var points = curve.Tessellate();
                    foreach (var point in points)
                    {
                        curvedata.Points.Add(new PointData(point.X, point.Y, point.Z));
                    }
                }

                var faceV = new PointData(fi.FacingOrientation.X, fi.FacingOrientation.Y, fi.FacingOrientation.Z);
                var handV = new PointData(fi.HandOrientation.X, fi.HandOrientation.Y, fi.HandOrientation.Z);

                InstanceLocation[CurrentElement.UniqueId] = new LocationData {
                    LocationCurve = curvedata, FaceVec = faceV, HandVec = handV
                };
            }


            if (elem.Parameters != null)
            {
                foreach (Parameter param in elem.Parameters)
                {
                    string groupName = LabelUtils.GetLabelFor(param.Definition.ParameterGroup);
                    if (string.IsNullOrEmpty(groupName))
                    {
                        groupName = param.Definition.ParameterGroup.ToString();
                    }

                    PropertyData proData = new PropertyData
                    {
                        Name      = param.Definition.Name,
                        GroupName = groupName,
                        Value     = param.StorageType == StorageType.String ? param.AsString() : param.AsValueString()
                    };

                    // 去掉多余的属性
                    if (proData.Name.Contains("Extensions."))
                    {
                        continue;
                    }

                    if (dictProperties.ContainsKey(groupName))
                    {
                        dictProperties[groupName].Add(proData);
                    }
                    else
                    {
                        var listTmp = new List <PropertyData> {
                            proData
                        };
                        dictProperties.Add(groupName, listTmp);
                    }
                }
            }

            if (m_bIsExportCylinderProperty)
            {
                List <Solid>  slds        = GetSolidFromElement(elem);
                List <string> cyFacesInfo = new List <string>();
                foreach (Solid sld in slds)
                {
                    cyFacesInfo.AddRange(GetCylinderFaceInfoFromSolid(sld));
                }
                dictProperties["CylinderFaceData"] = GetUniqueCylinderFacePropertyData(cyFacesInfo);
            }

            return(dictProperties);
        }
예제 #4
0
 public LocationData()
 {
     LocationCurve = new CurveData();
     FaceVec       = new PointData();
     HandVec       = new PointData();
 }
예제 #5
0
        /// <summary>
        /// 获取指定拉伸体的拉伸面信息
        /// </summary>
        /// <param name="skt"></param>
        /// <returns></returns>
        private SketchData GetDataFromProfile(Sketch skt)
        {
            if (skt == null)
            {
                return(null);
            }

            var sketchData = new SketchData();

            foreach (object curArr in skt.Profile)
            {
                if (curArr is CurveArray)
                {
                    foreach (var cur in (CurveArray)curArr)
                    {
                        var curve = (Curve)cur;
                        if (curve != null && curve.IsBound)
                        {
                            CurveData curvedata = new CurveData();

                            if (curve is Arc)
                            {
                                var arc = (Arc)curve;
                                curvedata.IsArc          = true;
                                curvedata.Center         = new PointData(arc.Center.X, arc.Center.Y, arc.Center.Z);
                                curvedata.Normal         = new PointData(arc.Normal.X, arc.Normal.Y, arc.Normal.Z);
                                curvedata.StartParameter = arc.GetEndParameter(0);
                                curvedata.EndParameter   = arc.GetEndParameter(1);
                                curvedata.Radius         = arc.Radius;
                                var pt = arc.GetEndPoint(0);
                                curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                                pt = arc.GetEndPoint(1);
                                curvedata.Points.Add(new PointData(pt.X, pt.Y, pt.Z));
                            }
                            else
                            {
                                curvedata.IsArc = false;
                                var points = curve.Tessellate();
                                foreach (var point in points)
                                {
                                    curvedata.Points.Add(new PointData(point.X, point.Y, point.Z));
                                }
                            }

                            sketchData.Curves.Add(curvedata);
                        }
                    }
                }
            }

            if (sketchData.Curves.Count < 1)
            {
                return(null);
            }

            var plan = skt.SketchPlane.GetPlane();

            sketchData.Normal  = new PointData(plan.Normal.X, plan.Normal.Y, plan.Normal.Z);
            sketchData.Origin  = new PointData(plan.Origin.X, plan.Origin.Y, plan.Origin.Z);
            sketchData.XVector = new PointData(plan.XVec.X, plan.XVec.Y, plan.XVec.Z);
            sketchData.YVector = new PointData(plan.YVec.X, plan.YVec.Y, plan.YVec.Z);

            return(sketchData);
        }