示例#1
0
文件: BRep.cs 项目: mh-soft/mh-master
 // Token: 0x06000092 RID: 146 RVA: 0x000042B8 File Offset: 0x000024B8
 public Edge3 GetEdge(int orientedEdgeIndex)
 {
     if (orientedEdgeIndex < 0 || orientedEdgeIndex >= this.IndexedOrientedEdges.Count)
     {
         throw new ArgumentException("BRep.GetEdge(): invalid index.");
     }
     BRep.IndexedOrientedEdge indexedOrientedEdge = this.IndexedOrientedEdges[orientedEdgeIndex];
     BRep.IndexedEdge         indexedEdge         = this.IndexedEdges[indexedOrientedEdge.EdgeIndex];
     return(new Edge3(indexedOrientedEdge.Orientation, this.Curves[indexedEdge.CurveIndex], (indexedOrientedEdge.CurveOnSurfaceIndex < 0) ? null : this.CurvesOnSurface[indexedOrientedEdge.CurveOnSurfaceIndex], indexedEdge.StartParameter, indexedEdge.EndParameter, this.Vertices[indexedEdge.StartVertexIndex], this.Vertices[indexedEdge.EndVertexIndex]));
 }
示例#2
0
文件: BRep.cs 项目: mh-soft/mh-master
        // Token: 0x06000077 RID: 119 RVA: 0x00003894 File Offset: 0x00001A94
        public BRep(IEnumerable <Solid> solids)
        {
            Dictionary <ISurface, int>         dictionary  = new Dictionary <ISurface, int>();
            Dictionary <BRep.IndexedEdge, int> dictionary2 = new Dictionary <BRep.IndexedEdge, int>();
            Dictionary <ICurve3, int>          dictionary3 = new Dictionary <ICurve3, int>();
            Dictionary <ICurve2, int>          dictionary4 = new Dictionary <ICurve2, int>();
            List <BRep.IndexedSolid>           list        = new List <BRep.IndexedSolid>();
            List <BRep.IndexedShell>           list2       = new List <BRep.IndexedShell>();
            List <BRep.IndexedFace>            list3       = new List <BRep.IndexedFace>();
            List <ISurface>                 list4          = new List <ISurface>();
            List <BRep.IndexedWire>         list5          = new List <BRep.IndexedWire>();
            List <BRep.IndexedOrientedEdge> list6          = new List <BRep.IndexedOrientedEdge>();
            List <BRep.IndexedEdge>         list7          = new List <BRep.IndexedEdge>();
            List <ICurve3> list8  = new List <ICurve3>();
            List <ICurve2> list9  = new List <ICurve2>();
            KdTree3        kdTree = new KdTree3(1E-06);

            foreach (Solid solid in solids)
            {
                BRep.IndexedSolid item = new BRep.IndexedSolid
                {
                    ShellIndices = new int[solid.Shells.Count]
                };
                int num = 0;
                foreach (Shell shell in solid.Shells)
                {
                    int count = list2.Count;
                    item.ShellIndices[num++] = count;
                    BRep.IndexedShell item2 = new BRep.IndexedShell
                    {
                        FaceIndices = new int[shell.Faces.Count]
                    };
                    int num2 = 0;
                    foreach (Face face in shell.Faces)
                    {
                        int count2 = list3.Count;
                        item2.FaceIndices[num2++] = count2;
                        if (!dictionary.ContainsKey(face.Surface))
                        {
                            dictionary[face.Surface] = list4.Count;
                            list4.Add(face.Surface);
                        }
                        BRep.IndexedFace item3 = new BRep.IndexedFace
                        {
                            Orientation  = face.Orientation,
                            SurfaceIndex = dictionary[face.Surface],
                            WireIndices  = new int[face.Wires.Count]
                        };
                        Dictionary <int, int> dictionary5 = new Dictionary <int, int>();
                        int num3 = 0;
                        foreach (Wire3 wire in face.Wires)
                        {
                            int count3 = list5.Count;
                            item3.WireIndices[num3++] = count3;
                            BRep.IndexedWire item4 = new BRep.IndexedWire
                            {
                                Orientation         = wire.Orientation,
                                OrientedEdgeIndices = new int[wire.Edges.Count]
                            };
                            int num4 = 0;
                            foreach (Edge3 edge in wire.Edges)
                            {
                                int count4 = list6.Count;
                                item4.OrientedEdgeIndices[num4++] = count4;
                                if (!dictionary3.ContainsKey(edge.Curve))
                                {
                                    dictionary3[edge.Curve] = list8.Count;
                                    list8.Add(edge.Curve);
                                }
                                if (edge.CurveOnSurface != null && !dictionary4.ContainsKey(edge.CurveOnSurface))
                                {
                                    dictionary4[edge.CurveOnSurface] = list9.Count;
                                    list9.Add(edge.CurveOnSurface);
                                }
                                int startVertexIndex         = kdTree.Insert(edge.StartVertex);
                                int endVertexIndex           = kdTree.Insert(edge.EndVertex);
                                BRep.IndexedEdge indexedEdge = new BRep.IndexedEdge
                                {
                                    CurveIndex       = dictionary3[edge.Curve],
                                    StartParameter   = edge.StartParameter,
                                    EndParameter     = edge.EndParameter,
                                    StartVertexIndex = startVertexIndex,
                                    EndVertexIndex   = endVertexIndex
                                };
                                if (!dictionary2.ContainsKey(indexedEdge))
                                {
                                    dictionary2[indexedEdge] = list7.Count;
                                    list7.Add(indexedEdge);
                                }
                                int curveOnSurfaceIndex  = (edge.CurveOnSurface != null) ? dictionary4[edge.CurveOnSurface] : -1;
                                int curveOnSurfaceIndex2 = -1;
                                int num5 = dictionary2[indexedEdge];
                                if (dictionary5.ContainsKey(num5))
                                {
                                    int index = dictionary5[num5];
                                    curveOnSurfaceIndex2 = list6[index].CurveOnSurfaceIndex;
                                }
                                BRep.IndexedOrientedEdge item5 = new BRep.IndexedOrientedEdge
                                {
                                    Orientation          = edge.Orientation,
                                    CurveOnSurfaceIndex  = curveOnSurfaceIndex,
                                    CurveOnSurfaceIndex2 = curveOnSurfaceIndex2,
                                    EdgeIndex            = num5
                                };
                                list6.Add(item5);
                                if (dictionary5.ContainsKey(num5))
                                {
                                    int index2 = dictionary5[num5];
                                    BRep.IndexedOrientedEdge value = list6[index2];
                                    value.CurveOnSurfaceIndex2 = item5.CurveOnSurfaceIndex;
                                    list6[index2] = value;
                                }
                                else
                                {
                                    dictionary5[num5] = count4;
                                }
                            }
                            list5.Add(item4);
                        }
                        list3.Add(item3);
                    }
                    list2.Add(item2);
                }
                list.Add(item);
            }
            this.IndexedSolids        = list.AsReadOnly();
            this.IndexedShells        = list2.AsReadOnly();
            this.IndexedFaces         = list3.AsReadOnly();
            this.Surfaces             = list4.AsReadOnly();
            this.IndexedWires         = list5.AsReadOnly();
            this.IndexedOrientedEdges = list6.AsReadOnly();
            this.IndexedEdges         = list7.AsReadOnly();
            this.Curves          = list8.AsReadOnly();
            this.CurvesOnSurface = list9.AsReadOnly();
            this.Vertices        = new List <Vector3>(kdTree.Vertices).AsReadOnly();
        }