Пример #1
0
        //构建特征中Face的角度属性邻接图
        public AngleGraph(MyNewDefineFeature Feature1)
        {
            int FaceNum = Feature1.FaceNumber;

            NumOfFace = FaceNum;//记录图中面的个数
            //初始化邻接矩阵和顶点数组
            adjmatrix = new double[FaceNum, FaceNum];

            Tag[]  shared_edges;
            double FaceAngle;

            //将代表邻接矩阵的表全初始化为0
            for (int i = 0; i < FaceNum; i++)
            {
                for (int j = 0; j < FaceNum; j++)
                {
                    if (i == j)
                    {
                        adjmatrix[i, j] = 0;
                        continue;
                    }
                    //判断两个面是否相邻
                    ufmodel.AskSharedEdges(Feature1.MyNewFeature[i].FaceTag, Feature1.MyNewFeature[j].FaceTag, out shared_edges);
                    if (shared_edges.Length == 0)//不相邻的情况取-1
                    {
                        adjmatrix[i, j] = -1.0;
                    }
                    else
                    {
                        MyFace.AskAngleOfFace(Feature1.MyNewFeature[i].FaceTag, Feature1.MyNewFeature[j].FaceTag, out FaceAngle);
                        adjmatrix[i, j] = Math.Round(FaceAngle, 2);//四舍五入,保留2位小数
                    }
                }
            }
        }
Пример #2
0
        //获取模型中的凹边
        public static void GetConcaveEdge(out Tag[] Edges)
        {
            Part workPart = theSession.Parts.Work;

            BodyCollection bodis = workPart.Bodies;

            Body[] bodys = bodis.ToArray();

            Tag [] egde_list;
            ufmodel.AskBodyEdges(bodys[0].Tag, out egde_list);

            Tag[]  face_list;
            double Angle;
            int    i = 0;

            Tag[] TemEdges = new Tag[egde_list.Length];

            foreach (Tag egde in egde_list)
            {
                ufmodel.AskEdgeFaces(egde, out face_list);
                MyFace.AskAngleOfFace(face_list[0], face_list[1], out Angle);
                if (Angle < 180.0)
                {
                    TemEdges[i] = egde;
                    ++i;
                }
            }
            Edges = new Tag[i];
            for (int j = 0; j < Edges.Length; ++j)
            {
                Edges[j] = TemEdges[j];
            }
        }
Пример #3
0
 //判断一个特征是否为一个盲孔
 public static bool IsCounterboreHole(MyNewDefineFeature Feature1)
 {
     //单独的盲孔,边数为3的盲孔是存在阶梯孔的情况
     if (Feature1.FaceNumber == 2 && (Feature1.EdgeNumber >= 2) && Feature1.VertexNumber == 0)
     {
         //先计算两面之间的夹角
         double Angle;
         MyFace.AskAngleOfFace(Feature1.MyNewFeature[0].FaceTag, Feature1.MyNewFeature[1].FaceTag, out Angle);
         if (Angle != 90.0)
         {
             return(false);
         }
         if (Feature1.MyNewFeature[0].NodeFaceType == MyNewFaceType.Cylindrical && Feature1.MyNewFeature[1].NodeFaceType == MyNewFaceType.Planar)
         {
             //判断盲孔:一个面为凹圆柱面,一个面为平面,且两面的交线为凹边
             Tag[] SharedEdges;
             Program.theUfmodel.AskSharedEdges(Feature1.MyNewFeature[0].FaceTag, Feature1.MyNewFeature[1].FaceTag, out SharedEdges);
             if (MyEdges.IsConcaveEdge(SharedEdges[0]) && (MyFace.IsConcaveFace(Feature1.MyNewFeature[0].FaceTag) == 2))
             {
                 return(true);
             }
         }
         else if (Feature1.MyNewFeature[1].NodeFaceType == MyNewFaceType.Cylindrical && Feature1.MyNewFeature[0].NodeFaceType == MyNewFaceType.Planar)
         {
             //判断盲孔:一个面为凹圆柱面,一个面为平面,且两面的交线为凹边
             Tag[] SharedEdges;
             Program.theUfmodel.AskSharedEdges(Feature1.MyNewFeature[0].FaceTag, Feature1.MyNewFeature[1].FaceTag, out SharedEdges);
             if (MyEdges.IsConcaveEdge(SharedEdges[0]) && (MyFace.IsConcaveFace(Feature1.MyNewFeature[1].FaceTag) == 2))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #4
0
 //判断是否为圆柱凸台
 public static bool IsOutterCylinderSurface(MyNewDefineFeature Feature1)
 {
     if (Feature1.FaceNumber == 1 && Feature1.MyNewFeature[0].NodeFaceType == MyNewFaceType.Cylindrical)
     {
         int temp = MyFace.IsConcaveFace(Feature1.MyNewFeature[0].FaceTag);
         if (temp == 1)//同时需要判断该圆柱面为外圆柱面
         {
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
 //判断是否是一个锥孔
 public static bool IsConicalHole(MyNewDefineFeature Feature1)
 {
     if (Feature1.FaceNumber == 1 && Feature1.MyNewFeature[0].NodeFaceType == MyNewFaceType.Conical)
     {
         int temp = MyFace.IsConcaveFace(Feature1.MyNewFeature[0].FaceTag);
         if (temp == 2)//同时需要判断该圆柱面为内圆柱面
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
        //判断边是否为凹边
        public static bool IsConcaveEdge(Tag edge1)
        {
            Tag[] face_list;
            ufmodel.AskEdgeFaces(edge1, out face_list);

            bool   IsConcave = true;
            double Angle;

            MyFace.AskAngleOfFace(face_list[0], face_list[1], out Angle);

            if (Angle >= 180.0)
            {
                IsConcave = false;
            }
            return(IsConcave);
        }
Пример #7
0
 public MyNewFace(Tag faceTag)
 {
     FaceTag  = faceTag;
     FaceType = getFaceType(faceTag);
     if (MyFace.IsConcaveFace(faceTag) == 2)
     {
         FaceConcaConve = FaceConcavity.Concavity;
     }
     else if (MyFace.IsConcaveFace(faceTag) == 1)
     {
         FaceConcaConve = FaceConcavity.Convexity;
     }
     else if (MyFace.IsConcaveFace(faceTag) == 0)
     {
         FaceConcaConve = FaceConcavity.Tangent;//这个面应该称为光顺面
     }
 }
Пример #8
0
        public static EdgeConcavity GetEdgeConca(Tag edge)
        {
            Tag[] face_list;
            Program.theUfmodel.AskEdgeFaces(edge, out face_list);
            EdgeConcavity edgeType;
            double        Angle;

            MyFace.AskAngleOfFace(face_list[0], face_list[1], out Angle);
            if (Angle == 180.0)
            {
                edgeType = EdgeConcavity.TangentLiner;//相切
            }
            else if (Angle > 180.0)
            {
                edgeType = EdgeConcavity.Convexity;//凸边
            }
            else
            {
                edgeType = EdgeConcavity.Concavity;//凹边
            }
            return(edgeType);
        }
Пример #9
0
        //平行平面的标注,1、型腔的标注
        public static void ParallelFaceDime(Tag Face1, Tag Face2, Tag BasicFace)
        {
            Part workPart = theSession.Parts.Work;

            NXOpen.Session.UndoMarkId markId3;
            markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Create Dimension");

            NXOpen.Annotations.DimensionData dimensionData1;
            dimensionData1 = workPart.Annotations.NewDimensionData();

            NXOpen.Annotations.Associativity associativity1;
            associativity1 = workPart.Annotations.NewAssociativity();

            Face face1 = MyFace.GetFaceByTag(Face1);

            associativity1.FirstObject = face1;

            NXObject nullNXObject = null;

            associativity1.SecondObject = nullNXObject;

            associativity1.ObjectView = workPart.ModelingViews.WorkView;

            //得到一个面上的一点
            double[] DefPoint1 = { 0.0, 0.0, 0.0 };
            MyVertex.GetVertexOfFace(Face1, ref DefPoint1);
            Point3d pickPoint1 = new Point3d(DefPoint1[0], DefPoint1[1], DefPoint1[2]);//寻找面face1上的点

            associativity1.PickPoint = pickPoint1;

            NXOpen.Annotations.Associativity[] associativity2 = new NXOpen.Annotations.Associativity[1];
            associativity2[0] = associativity1;
            dimensionData1.SetAssociativity(1, associativity2);
            associativity1.Dispose();

            NXOpen.Annotations.Associativity associativity3;
            associativity3 = workPart.Annotations.NewAssociativity();

            Face face2 = MyFace.GetFaceByTag(Face2);

            associativity3.FirstObject  = face2;
            associativity3.SecondObject = nullNXObject;
            //得到一个面上的一点
            double[] DefPoint2 = { 0.0, 0.0, 0.0 };
            MyVertex.GetVertexOfFace(Face1, ref DefPoint2);

            Point3d pickPoint2 = new Point3d(DefPoint2[0], DefPoint2[1], DefPoint2[2]);//寻找face2上的点

            associativity3.PickPoint = pickPoint2;

            NXOpen.Annotations.Associativity[] associativity4 = new NXOpen.Annotations.Associativity[1];
            associativity4[0] = associativity3;
            dimensionData1.SetAssociativity(2, associativity4);

            NXOpen.Annotations.PmiData pmiData1;
            pmiData1 = workPart.Annotations.NewPmiData();

            Xform xform2;

            if (BasicFace == Tag.Null)
            {
                xform2 = dimensionData1.GetInferredPlane(PmiDefaultPlane.ModelView, NXOpen.Annotations.DimensionType.Perpendicular);
            }
            else
            {
                xform2 = dimensionData1.GetInferredPlane(AutoSelectPMIPlane(Face1, BasicFace), NXOpen.Annotations.DimensionType.Perpendicular);
            }

            Point3d origin1 = new Point3d(0.0, 0.0, 0.0);

            NXOpen.Annotations.PmiPerpendicularDimension pmiPerpendicularDimension1;
            pmiPerpendicularDimension1 = workPart.Dimensions.CreatePmiPerpendicularDimension(dimensionData1, pmiData1, xform2, origin1);

            pmiPerpendicularDimension1.IsOriginCentered = true;

            int nErrs3;

            nErrs3 = theSession.UpdateManager.DoUpdate(markId3);
        }
Пример #10
0
        public static void AskTypeOfFeature(List <List <Tag> > Face_of_Feature, out SelfDefFeatureType[] Types)
        {
            int               FaceNum, EdgeNum, VertexNum;
            HashSet <Tag>     Edge_Feature;
            HashSet <Point3d> Vertex_Feature;

            Types = new SelfDefFeatureType[Face_of_Feature.Count];
            int i = 0;

            foreach (List <Tag> Feature in Face_of_Feature)//List中存储的面
            {
                FaceNum = Feature.Count;
                MyEdges.GetEdgeOfFeature(Feature, out Edge_Feature);
                EdgeNum = Edge_Feature.Count;
                MyVertex.GetVertexOfFeature(Feature, out Vertex_Feature);
                VertexNum = Vertex_Feature.Count;

                //得到燕尾槽的角度图
                AngleGraph Anglegraph = new AngleGraph(Feature);
                //盲孔
                if (FaceNum == 2)//EdegNum=3时为阶梯孔
                {
                    int type1, type2;
                    ufmodel.AskFaceType(Feature[0], out type1);
                    ufmodel.AskFaceType(Feature[1], out type2);
                    if (type1 == 22 && type2 == 16)//16为柱面,22为平面
                    {
                        //判断盲孔:一个面为凹圆柱面,一个面为平面,且两面的交线为凹边
                        Tag [] SharedEdges;
                        ufmodel.AskSharedEdges(Feature[0], Feature[1], out SharedEdges);
                        if (MyEdges.IsConcaveEdge(SharedEdges[0]) && (MyFace.IsConcaveFace(Feature[1]) == 2))
                        {
                            Types[i] = SelfDefFeatureType.BlindHole;
                            //得到盲孔的标注边
                            //Tag Dimeedge = MyEdges.GetDimeEdgeOfHole(Feature[1], Feature[0]);
                            //Dimension.HoleDime(Dimeedge);
                            ++i;
                        }
                    }
                    else if (type1 == 16 && type2 == 22)
                    {
                        //判断盲孔:一个面为凹圆柱面,一个面为平面,且两面的交线为凹边
                        Tag[] SharedEdges;
                        ufmodel.AskSharedEdges(Feature[0], Feature[1], out SharedEdges);
                        if (MyEdges.IsConcaveEdge(SharedEdges[0]) && (MyFace.IsConcaveFace(Feature[0]) == 2))
                        {
                            Types[i] = SelfDefFeatureType.BlindHole;
                            //得到盲孔的标注边
                            //Tag Dimeedge = MyEdges.GetDimeEdgeOfHole(Feature[1], Feature[0]);
                            //Dimension.HoleDime(Dimeedge);
                            ++i;
                        }
                    }
                    else if (type1 == 22 && type2 == 22)
                    {
                        if (Anglegraph.adjmatrix[0, 1] == 90)
                        {
                            Types[i] = SelfDefFeatureType.RECT_STEP;
                            ++i;
                        }
                    }
                }
                else if (FaceNum == 1)
                {
                    int type1;
                    ufmodel.AskFaceType(Feature[0], out type1);
                    if (type1 == 16)
                    {
                        //应该要添加一个判断是否为孔的圆柱面
                        //double[] normal1=MyFace.AskFaceofNormal(Feature[0]);
                        //if (normal1[0] < 0 || normal1[1] < 0 || normal1[2] < 0)//判断圆柱面的法向量是否小于0,如果小于0即为孔的圆柱面
                        //{
                        if (EdgeNum == 4)
                        {
                            Types[i] = SelfDefFeatureType.SEMI_CIRCLE_SOLT;
                            ++i;
                        }
                        else
                        {
                            //Tag[] edge_list;
                            //ufmodel.AskFaceEdges(Feature[0], out edge_list);
                            //Dimension.HoleDime(edge_list[0]);
                            Types[i] = SelfDefFeatureType.ThroughHole;
                            ++i;
                        }
                        //}
                    }
                }
                else if (FaceNum == 5)//型腔
                {
                    if (EdgeNum == 12)
                    {
                        if (VertexNum == 12)
                        {
                            if (MyFace.AllVerticalplane(Anglegraph))//如果相互垂直,则判定为矩形腔
                            {
                                Types[i] = SelfDefFeatureType.ClosePocket;
                                ++i;

                                Tag BasicFace;
                                MyFace.AskBasicFace(Feature, out BasicFace);
                                for (int j = 0; j < FaceNum; ++j)
                                {
                                    //标注矩形腔的长度和宽度
                                    for (int k = j + 1; k < FaceNum; ++k)
                                    {
                                        if (MyFace.ISFaceParallel(Feature[j], Feature[k]))
                                        {
                                            //Dimension.ParallelFaceDime(Feature[j], Feature[k], BasicFace);
                                        }
                                    }
                                }
                                //根据基面来标注矩形槽的深度
                                Tag OutFace;
                                MyFace.AskFaceOutFeature(Feature, out OutFace);
                                Dimension.ParallelFaceDime(OutFace, BasicFace, Tag.Null);
                            }
                        }
                        else if (VertexNum == 8)
                        {
                            bool IsRectSlot = true;
                            for (int index1 = 0; index1 < FaceNum; ++index1)
                            {
                                for (int index2 = index1 + 1; index2 < FaceNum; ++index2)
                                {
                                    double tmp = Anglegraph.adjmatrix[index1, index2];
                                    if (tmp != -1) //相邻,其实还要判断夹角是否相等
                                    {
                                        if (tmp != 90.0 && tmp != 180.0)
                                        {
                                            IsRectSlot = false;
                                        }
                                    }
                                }
                            }
                            if (IsRectSlot)
                            {
                                Types[i] = SelfDefFeatureType.RECT_SOLT;
                                i++;
                            }
                        }
                    }
                }
                else if (FaceNum == 3)
                {
                    if (EdgeNum == 10)
                    {
                        if (VertexNum == 8)
                        {
                            bool IsDoveTatilSolt = true;
                            bool IsRectSolt      = true;
                            for (int index1 = 0; index1 < FaceNum; index1++)
                            {
                                for (int index2 = index1 + 1; index2 < FaceNum; ++index2)
                                {
                                    double tmp = Anglegraph.adjmatrix[index1, index2];
                                    if (tmp != -1)//相邻,其实还要判断夹角是否相等
                                    {
                                        if (tmp >= 90.0 || tmp == 0.0)
                                        {
                                            IsDoveTatilSolt = false;
                                        }
                                        if (tmp != 90.0)
                                        {
                                            IsRectSolt = false;
                                        }
                                    }
                                }
                            }
                            if (IsDoveTatilSolt)
                            {
                                Types[i] = SelfDefFeatureType.DOVE_TAIL_SOLT;
                                ++i;
                            }
                            if (IsRectSolt)//通的矩形槽
                            {
                                Types[i] = SelfDefFeatureType.RECT_THROUGH_SOLT;
                                ++i;
                            }
                        }
                    }
                    else if (EdgeNum == 4)
                    {
                        if (VertexNum == 0)
                        {
                            bool IsCutterSlot = true;
                            for (int index1 = 0; index1 < FaceNum; ++index1)
                            {
                                for (int index2 = index1 + 1; index2 < FaceNum; ++index2)
                                {
                                    double tmp = Anglegraph.adjmatrix[index1, index2];
                                    if (tmp != -1)//相邻,其实还要判断夹角是否相等
                                    {
                                        if (tmp != 90.0 && tmp != 180.0)
                                        {
                                            IsCutterSlot = false;
                                        }
                                    }
                                }
                            }
                            if (IsCutterSlot)
                            {
                                Types[i] = SelfDefFeatureType.Cutter_Slot;//退刀槽
                                i++;
                            }
                        }
                    }
                }
            }
        }
Пример #11
0
        //构建Face的矩阵邻接图属性邻接图
        public FeatureGraphic()
        {
            FaceNodeList         = new List <GripchFaceNode>();
            DeCompseBaseFaceList = new List <Tag>();
            Face[] BodyFace = MyFace.GetFaceOfBody();
            NumOfFace = BodyFace.Length;
            //构建AAG图中的面链表
            for (int i = 0; i < BodyFace.Length; i++)
            {
                GripchFaceNode faceNode = new GripchFaceNode();
                faceNode.AreaOfFace = 0;//的面的表面积
                if (MyFace.IsConcaveFace(BodyFace[i].Tag) == 2)
                {
                    faceNode.FaceConcaConve = FaceConcavity.Concavity;//面的凸凹性
                }
                else if (MyFace.IsConcaveFace(BodyFace[i].Tag) == 1)
                {
                    faceNode.FaceConcaConve = FaceConcavity.Convexity;
                }
                else
                {
                    faceNode.FaceConcaConve = FaceConcavity.Tangent;//光顺面
                }
                int loopNum = 0, InnerloopNum = 0;
                GetLoopsNumber(BodyFace[i].Tag, ref loopNum, ref InnerloopNum);
                faceNode.FaceInnerLoopNumber = InnerloopNum; //面中内环的数目
                faceNode.FaceLoopNumber      = loopNum;      //面中环的数目
                faceNode.FaceTag             = BodyFace[i].Tag;
                faceNode.NodeFaceType        = MyNewFace.getFaceType(BodyFace[i]);
                faceNode.IsDeCompseBaseFace  = faceNode.IsBaseFace();
                if (faceNode.IsDeCompseBaseFace)
                {
                    DeCompseBaseFaceList.Add(BodyFace[i].Tag);
                }
                faceNode.IsConCavityFace    = faceNode.IsConCavityFacebyEdge();
                faceNode.FaceInnerLoopEdges = faceNode.GetFaceInnerListEdges();


                //faceNode.IsConCavityFace = IsConCavityFacebyEdge(faceNode.FaceTag);

                int      type  = 0;                                //面的类型
                double[] point = { 0.0, 0.0, 0.0 };                //圆柱面、圆锥面轴线上的一点
                double[] dir   = { 0.0, 0.0, 0.0 };                //轴线方向
                double[] box   = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; //面的包容盒
                double   radius;
                double   rad_data;
                int      norm_dir = 0;
                Program.theUfmodel.AskFaceData(BodyFace[i].Tag, out type, point, dir, box, out radius, out rad_data, out norm_dir);
                if (faceNode.NodeFaceType == MyNewFaceType.Cylindrical || faceNode.NodeFaceType == MyNewFaceType.Conical)
                {
                    //数组还可这样赋值?
                    faceNode.Face_Axis[0] = Math.Round(dir[0], 2);
                    faceNode.Face_Axis[1] = Math.Round(dir[1], 2);
                    faceNode.Face_Axis[2] = Math.Round(dir[2], 2);


                    faceNode.Face_Axis_Point[0] = Math.Round(point[0], 2);
                    faceNode.Face_Axis_Point[1] = Math.Round(point[1], 2);
                    faceNode.Face_Axis_Point[2] = Math.Round(point[2], 2);
                }
                FaceNodeList.Add(faceNode);
            }
            //构建二维AAG图中的属性邻接图主要包含边的信息
            adjmatrix = new GripchEdgeNode[NumOfFace, NumOfFace];
            Tag[] shared_edges;
            for (int i = 0; i < BodyFace.Length; ++i)
            {
                for (int j = 0; j < BodyFace.Length; ++j)
                {
                    if (i == j)
                    {
                        adjmatrix[i, j] = null;
                        continue;
                    }
                    //判断两个面是否相邻
                    Program.theUfmodel.AskSharedEdges(BodyFace[i].Tag, BodyFace[j].Tag, out shared_edges);
                    if (shared_edges.Length == 0)//不相邻的情况取null
                    {
                        adjmatrix[i, j] = adjmatrix[j, i] = null;
                    }
                    else
                    {
                        GripchEdgeNode EdgeNode = new GripchEdgeNode();
                        EdgeNode.EdgeConcaConve = MyNewEdge.GetEdgeConca(shared_edges[0]);


                        EdgeNode.EdgeTag      = shared_edges[0];
                        EdgeNode.NodeEdgeType = MyNewEdge.GetEdgeType(shared_edges[0]);
                        EdgeNode.LooType      = true;//暂定true;
                        adjmatrix[i, j]       = EdgeNode;
                    }
                }
            }
            InnerLoopEdgeNumber = GetInnerLoopEdgesNumber();
            InnerLoopEdgeList   = new List <Tag>();
            Tag InneerEdge;

            /*GetInnerLoopEdge(InneerEdgeArray,InnerLoopEdgeNumber);*/
            for (int i = 0; i < InnerLoopEdgeNumber; ++i)
            {
                InneerEdge = GetInnerIndexEdge(i);
                InnerLoopEdgeList.Add(InneerEdge);
            }

            //初始化用来存储,AAG图中分解的特征
            SubFeaturesList = new List <MyNewDefineFeature>();
        }
Пример #12
0
        //内环边删除后,根据给定的面List来构建属性邻接图
        public FeatureGraphic(List <Tag> FaceList)
        {
            FaceNodeList         = new List <GripchFaceNode>();
            DeCompseBaseFaceList = new List <Tag>();

            NumOfFace = FaceList.Count;
            //构建AAG图中的面链表
            for (int i = 0; i < NumOfFace; i++)
            {
                GripchFaceNode faceNode = new GripchFaceNode();
                faceNode.AreaOfFace = 0;//的面的表面积
                if (MyFace.IsConcaveFace(FaceList[i]) == 2)
                {
                    faceNode.FaceConcaConve = FaceConcavity.Concavity;//面的凸凹性
                }
                else if (MyFace.IsConcaveFace(FaceList[i]) == 1)
                {
                    faceNode.FaceConcaConve = FaceConcavity.Convexity;
                }
                else
                {
                    faceNode.FaceConcaConve = FaceConcavity.Tangent;//光顺面
                }
                int loopNum = 0, InnerloopNum = 0;
                GetLoopsNumber(FaceList[i], ref loopNum, ref InnerloopNum);
                faceNode.FaceInnerLoopNumber = 0;       //面中内环的数目
                faceNode.FaceLoopNumber      = loopNum; //面中环的数目
                faceNode.FaceTag             = FaceList[i];
                faceNode.NodeFaceType        = MyNewFace.getFaceType(FaceList[i]);
                faceNode.IsDeCompseBaseFace  = faceNode.IsBaseFace();
                if (faceNode.IsDeCompseBaseFace)
                {
                    DeCompseBaseFaceList.Add(FaceList[i]);
                }
                //面凸凹性的判断,需要根据凹边是否存在
                faceNode.IsConCavityFace = faceNode.IsConCavityFacebyEdge();
                //faceNode.FaceInnerLoopEdges = faceNode.GetFaceInnerListEdges();//得到面的内环边

                int      type  = 0;                                //面的类型
                double[] point = { 0.0, 0.0, 0.0 };                //圆柱面、圆锥面轴线上的一点
                double[] dir   = { 0.0, 0.0, 0.0 };                //轴线方向
                double[] box   = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; //面的包容盒
                double   radius;
                double   rad_data;
                int      norm_dir = 0;
                Program.theUfmodel.AskFaceData(FaceList[i], out type, point, dir, box, out radius, out rad_data, out norm_dir);
                if (faceNode.NodeFaceType == MyNewFaceType.Cylindrical || faceNode.NodeFaceType == MyNewFaceType.Cylindrical)
                {
                    //数组还可这样赋值?
                    faceNode.Face_Axis       = dir;
                    faceNode.Face_Axis_Point = point;
                }
                FaceNodeList.Add(faceNode);
            }
            //构建二维AAG图中的属性邻接图主要包含边的信息
            adjmatrix = new GripchEdgeNode[NumOfFace, NumOfFace];
            Tag[] shared_edges;
            for (int i = 0; i < FaceList.Count; ++i)
            {
                for (int j = 0; j < FaceList.Count; ++j)
                {
                    if (i == j)
                    {
                        adjmatrix[i, j] = null;
                        continue;
                    }
                    //判断两个面是否相邻
                    Program.theUfmodel.AskSharedEdges(FaceList[i], FaceList[j], out shared_edges);
                    if (shared_edges.Length == 0)//不相邻的情况取null
                    {
                        adjmatrix[i, j] = adjmatrix[j, i] = null;
                    }
                    else
                    {
                        GripchEdgeNode EdgeNode = new GripchEdgeNode();
                        EdgeNode.EdgeConcaConve = MyNewEdge.GetEdgeConca(shared_edges[0]);


                        EdgeNode.EdgeTag      = shared_edges[0];
                        EdgeNode.NodeEdgeType = MyNewEdge.GetEdgeType(shared_edges[0]);
                        EdgeNode.LooType      = true;//暂定true;
                        adjmatrix[i, j]       = EdgeNode;
                    }
                }
            }
            //初始化用来存储,AAG图中分解的特征
            SubFeaturesList = new List <MyNewDefineFeature>();
        }
Пример #13
0
        //获取子特征的相关面
        public static void GetFaceArray(out List <List <Tag> > Face_of_Feature)
        {
            //获取零件模型中的凹边:
            Tag[] Edges;
            MyEdges.GetConcaveEdge(out Edges);

            Tag [] face_tag;

            //List<List<Tag>> temp_Face_list;
            Face_of_Feature = new List <List <Tag> >();

            bool IsExit;

            foreach (Tag edge_tag in Edges)
            {
                IsExit = false;
                ufmodel.AskEdgeFaces(edge_tag, out face_tag);

                foreach (List <Tag> list_tag in Face_of_Feature)
                {
                    if (list_tag.Contains(face_tag[0]) && (!list_tag.Contains(face_tag[1])))
                    {
                        list_tag.Add(face_tag[1]);
                        IsExit = true;
                    }
                    else if (list_tag.Contains(face_tag[1]) && (!list_tag.Contains(face_tag[0])))
                    {
                        list_tag.Add(face_tag[0]);
                        IsExit = true;
                    }
                }
                if (!IsExit)
                {
                    List <Tag> TempList1 = new List <Tag>();
                    TempList1.Add(face_tag[0]);
                    TempList1.Add(face_tag[1]);

                    Face_of_Feature.Add(TempList1);
                }
            }

            List <List <Tag> > Face_of_Temp;

            Face_of_Temp = new List <List <Tag> >();

            Face_of_Temp = Face_of_Feature;
            //判断Face_of_Feature中是否有重合的情况,如果有,就合并该List
            for (int i = 0; i < Face_of_Temp.Count; ++i)
            {
                for (int j = 0; j < Face_of_Feature.Count; ++j)
                {
                    if (Face_of_Temp[i] == Face_of_Feature[j])
                    {
                        continue;
                    }
                    if (IsContainsAll(Face_of_Temp[i], Face_of_Feature[j]))//如果有包含关系,删除List
                    {
                        Face_of_Feature.Remove(Face_of_Feature[j]);
                        Face_of_Temp = Face_of_Feature;
                        --j;
                    }
                }
            }

            Face[] AllFace = GetFaceOfBody();
            Tag[]  Cylindredge;
            bool   IsThroughHole;

            foreach (Face SinFace in AllFace)
            {
                IsThroughHole = true;
                if (SinFace.SolidFaceType == Face.FaceType.Cylindrical)
                {
                    ufmodel.AskFaceEdges(SinFace.Tag, out Cylindredge);//圆柱面的边
                    foreach (Tag CyEdge1 in Cylindredge)
                    {
                        if (MyEdges.IsConcaveEdge(CyEdge1))
                        {
                            IsThroughHole = false;
                            break;
                        }
                    }

                    if (MyFace.IsConcaveFace(SinFace.Tag) == 2)//如果是内圆柱面;
                    {
                        if (IsThroughHole && Cylindredge.Length == 2)
                        {
                            List <Tag> TempList2 = new List <Tag>();
                            TempList2.Add(SinFace.Tag);
                            Face_of_Feature.Add(TempList2);
                            //Dimension.HoleDime(Cylindredge[0]);
                            //theUfobj.SetColor(SinFace.Tag, 106);//红色186
                        }
                        else if (Cylindredge.Length == 4)
                        {
                            List <Tag> TempList2 = new List <Tag>();
                            TempList2.Add(SinFace.Tag);
                            Face_of_Feature.Add(TempList2);
                        }
                    }
                }
            }
        }