Esempio n. 1
0
        public static HeModel ToHeModel(CadMesh src)
        {
            HeModel m = new HeModel();

            m.VertexStore = src.VertexStore;

            Dictionary <uint, HalfEdge> map = new Dictionary <uint, HalfEdge>();

            for (int fi = 0; fi < src.FaceStore.Count; fi++)
            {
                CadFace f = src.FaceStore[fi];

                int      vi         = f.VList[0];
                HalfEdge head       = m.CreateHalfEdge(vi);
                HalfEdge current_he = head;

                HeFace face      = m.CreateFace(head);
                int    faceIndex = m.FaceStore.Add(face);

                current_he.Face = faceIndex;

                HalfEdge next_he;

                for (int pi = 1; pi < f.VList.Count; pi++)
                {
                    vi      = f.VList[pi];
                    next_he = m.CreateHalfEdge(vi);

                    current_he.Next = next_he;
                    next_he.Prev    = current_he;

                    next_he.Face = faceIndex;

                    current_he = next_he;
                }

                head.Prev       = current_he;
                current_he.Next = head;


                HalfEdge c = head;

                for (; ;)
                {
                    HeConnector.SetHalfEdgePair(c, map);

                    map[HeConnector.GetHeKey(c)] = c;

                    c = c.Next;
                    if (c == head)
                    {
                        break;
                    }
                }
            }

            m.RecreateNormals();

            return(m);
        }
Esempio n. 2
0
        public static CadMesh ToCadMesh(HeModel hem)
        {
            CadMesh cm = new CadMesh();

            cm.VertexStore = new VertexList(hem.VertexStore);
            cm.FaceStore   = new FlexArray <CadFace>();

            for (int i = 0; i < hem.FaceStore.Count; i++)
            {
                CadFace cf = ToCadFace(hem.FaceStore[i]);
                if (cf != null)
                {
                    cm.FaceStore.Add(cf);
                }
            }

            return(cm);
        }
Esempio n. 3
0
        public void SetupMap(Dictionary <uint, HalfEdge> map, HeModel hem)
        {
            for (int i = 0; i < hem.FaceStore.Count; i++)
            {
                HalfEdge head = hem.FaceStore[i].Head;
                HalfEdge c    = head;

                for (; ;)
                {
                    map[HeConnector.GetHeKey(c)] = c;

                    c = c.Next;
                    if (c == head)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
 public void Start(HeModel model)
 {
     mHeModel = model;
     SetupMap(HeMap, mHeModel);
 }
Esempio n. 5
0
 public void Start()
 {
     mHeModel = new HeModel();
 }