Example #1
0
        // Token: 0x06000002 RID: 2 RVA: 0x000020AC File Offset: 0x000002AC
        public void Build(FacetedBRep brep)
        {
            this.Edges = new List <FacetedBRepEdgeBuilder.Edge>();
            this.Faces = new List <List <int> >();
            int count = brep.Faces.Count;
            Dictionary <FacetedBRepEdgeBuilder.Edge, Tuple <int, int> > dictionary = new Dictionary <FacetedBRepEdgeBuilder.Edge, Tuple <int, int> >();
            List <UnitVector3> list = new List <UnitVector3>();
            int num = 0;

            foreach (FacetedBRepFace facetedBRepFace in brep.Faces)
            {
                UnitVector3 polygonNormal = this.getPolygonNormal(facetedBRepFace.Vertices);
                list.Add(polygonNormal);
                int count2 = facetedBRepFace.VerticeIndexes.Count;
                for (int i = 0; i < count2; i++)
                {
                    int index = (i + 1) % count2;
                    FacetedBRepEdgeBuilder.Edge edge = new FacetedBRepEdgeBuilder.Edge(facetedBRepFace.VerticeIndexes[i], facetedBRepFace.VerticeIndexes[index]);
                    this.addFace(dictionary, edge, num);
                }
                if (facetedBRepFace.HasHoles)
                {
                    foreach (FacetedBRepFaceHole facetedBRepFaceHole in facetedBRepFace.Holes)
                    {
                        int count3 = facetedBRepFaceHole.VerticeIndexes.Count;
                        for (int j = 0; j < count3; j++)
                        {
                            int index2 = (j + 1) % count3;
                            FacetedBRepEdgeBuilder.Edge edge2 = new FacetedBRepEdgeBuilder.Edge(facetedBRepFaceHole.VerticeIndexes[j], facetedBRepFaceHole.VerticeIndexes[index2]);
                            this.addFace(dictionary, edge2, num);
                        }
                    }
                }
                num++;
            }
            this.Edges = this.TagEdgesByFeatureAngle(dictionary, list);
            foreach (FacetedBRepEdgeBuilder.Edge key in this.Edges)
            {
                Tuple <int, int> tuple = dictionary[key];
                List <int>       list2 = new List <int>();
                if (tuple.Item1 != -1)
                {
                    list2.Add(tuple.Item1);
                }
                if (tuple.Item2 != -1)
                {
                    list2.Add(tuple.Item2);
                }
                this.Faces.Add(list2);
            }
        }
Example #2
0
        // Token: 0x0600000B RID: 11 RVA: 0x00002444 File Offset: 0x00000644
        private List <FacetedBRepEdgeBuilder.Edge> TagEdgesByFeatureAngle(Dictionary <FacetedBRepEdgeBuilder.Edge, Tuple <int, int> > edges, List <UnitVector3> normals)
        {
            List <FacetedBRepEdgeBuilder.Edge> list = new List <FacetedBRepEdgeBuilder.Edge>();

            foreach (KeyValuePair <FacetedBRepEdgeBuilder.Edge, Tuple <int, int> > keyValuePair in edges)
            {
                bool sharp = true;
                int  item  = keyValuePair.Value.Item1;
                int  item2 = keyValuePair.Value.Item2;
                if (item != -1 && item2 != -1)
                {
                    UnitVector3 unitVector = normals[keyValuePair.Value.Item1];
                    UnitVector3 vector     = normals[keyValuePair.Value.Item2];
                    if (Math.Acos(unitVector.Dot(vector)) < this.FeatureAngle)
                    {
                        sharp = false;
                    }
                }
                FacetedBRepEdgeBuilder.Edge item3 = new FacetedBRepEdgeBuilder.Edge(keyValuePair.Key.FirstVertex, keyValuePair.Key.SecondVertex, sharp);
                list.Add(item3);
            }
            return(list);
        }
Example #3
0
 // Token: 0x0600000A RID: 10 RVA: 0x00002404 File Offset: 0x00000604
 private void addFace(Dictionary <FacetedBRepEdgeBuilder.Edge, Tuple <int, int> > edges, FacetedBRepEdgeBuilder.Edge edge, int face)
 {
     if (edges.ContainsKey(edge))
     {
         int item = edges[edge].Item1;
         edges[edge] = new Tuple <int, int>(item, face);
         return;
     }
     edges[edge] = new Tuple <int, int>(face, -1);
 }