//将两个特征进行组合成一个特征,把两个特征组合成一个特征主要是把两个特征的面组合到一起 public static void AssociationFeature(MyNewDefineFeature Feature1, MyNewDefineFeature Feature2) { for (int i = 0; i < Feature2.FaceNumber; i++) { Feature1.AddFaceNode(Feature2.MyNewFeature[i]);//把Feature2中的特征面保存到Feature1中,进行特征的组合 } }
//得到图的连通子图,并存储特征 public void GetSubConnectGraph() { List <MyNewDefineFeature> TempFeatureList = new List <MyNewDefineFeature>(); for (int i = 0; i < NumOfFace; i++)//遍历面节点的List { bool IsExit = false; foreach (MyNewDefineFeature feature in TempFeatureList) { //如果特征中包含了这个面,就继续下一个面的判断 if (feature.Contains(FaceNodeList[i].FaceTag)) { IsExit = true; break; } else //在feature这个特征中不包含面FaceNodeList[i]时,需要判断feature中的特征面与FaceNodeList[i]这个面是否有链接 { if (FeatureConncetFace(feature, FaceNodeList[i].FaceTag))//如果特征面与指定面之间存在链接的边则,包含进该边 { feature.AddFaceNode(FaceNodeList[i]); IsExit = true; break; } } } //遍历完所有特征,后发现该面并没有被包含,则为该面定义一个新的特征 if (!IsExit) { MyNewDefineFeature temFeature = new MyNewDefineFeature(); temFeature.AddFaceNode(FaceNodeList[i]); TempFeatureList.Add(temFeature); } } //在判断特征之间是否有两两连接的关系 for (int i = 0; i < TempFeatureList.Count; i++) { for (int j = i + 1; j < TempFeatureList.Count; j++) { foreach (GripchFaceNode Facenode in TempFeatureList[j].MyNewFeature) { if (FeatureConncetFace(TempFeatureList[i], Facenode.FaceTag))//如果一个特征中的面与另一个特征中的面有链接,则合并两个特征 { for (int k = 0; k < TempFeatureList[j].FaceNumber; k++) { TempFeatureList[i].AddFaceNode(TempFeatureList[j].MyNewFeature[k]); } //SubFeaturesList[j] = null; TempFeatureList.RemoveAt(j); } } } } SubFeaturesList = TempFeatureList; }