コード例 #1
0
        /// <summary>
        /// 创建面对象
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        private static SWFace CreateSWFace(Face2 face)
        {
            if (face == null)
            {
                return(null);
            }

            //复制Face信息
            SWFace swFace = new SWFace();

            //ID
            swFace.ID = face.GetFaceId();
            //包围盒
            swFace.BoundingBox = CreateSWBoundingBox(face.GetBox());

            //三角面片
            //int tessTriCount = face.GetTessTriangleCount();
            swFace.TessTriangles = face.GetTessTriangles(false);
            swFace.TessNormals   = face.GetTessNorms();

            //OutPutTessTriangles(tessTriCount, arrTriangles);

            /*
             * if (arrTriangles != null) {
             *  for (int i = 0; i < tessTriCount; i += 9) {
             *      swFace.TessTriangles.Add(CreateSWTriangle(arrTriangles, i));
             *  }
             * }
             */

            //几何信息
            swFace.Surface = CreateSWSurface(face.GetSurface());

            return(swFace);
        }
コード例 #2
0
        /// <summary>
        /// The my adjacence face.
        /// </summary>
        /// <param name="face">
        /// The face.
        /// </param>
        /// <returns>
        /// The <see cref="List{T}"/>.
        /// </returns>
        public static List <Face2> MyAdjacenceFace(Face2 face, SldWorks swApplWorks)
        {
            var listAdjacentFace = new List <Face2>();

            // Aggiungo la faccia stessa e tutte le sue adiacenti,
            // Se non aggiungo anche se stessa poi controlla la presenza di edge virtuali tra sé e sé.
            // listAdjacentFace.Add(face);
            var myEdgeOfFace = (Array)face.GetEdges();

            foreach (Edge edge in myEdgeOfFace)
            {
                Array myAdiacenceFaces = edge.GetTwoAdjacentFaces2();
                Face2 myAdiacenceFace  = null;
                var   firstFace        = (Face2)myAdiacenceFaces.GetValue(0);
                var   secondFace       = (Face2)myAdiacenceFaces.GetValue(1);

                // Se non c'è un'altra faccia adiacente allora ho un valore NULL e c'è un errore nel modello
                //(se ho un modello manifold devo avere per ogni edge due facce).
                if (firstFace == null || secondFace == null)
                {
                    swApplWorks.SendMsgToUser("ERROR: the model is defective and the adjacency relation cannot be stored correctly (NOT ALL THE EDGES ARE SHARED BY 2 FACES).");
                    return(listAdjacentFace);
                }

                // Se la faccia non è quella che ho già la salvo come faccia adiacente, altrimenti salvo l'altra.
                if (firstFace.GetFaceId() == face.GetFaceId())
                {
                    myAdiacenceFace = secondFace;
                }
                else if (secondFace.GetFaceId() == face.GetFaceId())
                {
                    myAdiacenceFace = firstFace;
                }

                listAdjacentFace.Add(myAdiacenceFace);
            }

            return(listAdjacentFace);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: flair2005/dlnuvaar
        /// <summary>
        /// 创建面对象
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        private static SWFace CreateSWFace(Face2 face) {
            if (face == null)
                return null;

            //复制Face信息
            SWFace swFace = new SWFace();

            //ID
            swFace.ID = face.GetFaceId();
            //包围盒
            swFace.BoundingBox = CreateSWBoundingBox(face.GetBox());

            //三角面片
            //int tessTriCount = face.GetTessTriangleCount();
            swFace.TessTriangles = face.GetTessTriangles(false);
            swFace.TessNormals = face.GetTessNorms();

            //OutPutTessTriangles(tessTriCount, arrTriangles);
            /* 
            if (arrTriangles != null) {
                for (int i = 0; i < tessTriCount; i += 9) {
                    swFace.TessTriangles.Add(CreateSWTriangle(arrTriangles, i));
                }
            }
            */
           
            //几何信息
            swFace.Surface = CreateSWSurface(face.GetSurface());

            return swFace;
        }