Example #1
0
 internal static extern void setPattern(ref CPolyLines polylines, IntPtr topoData);
Example #2
0
        public static bool RhinoPolylinesToCPolyline(
            List <Curve> parts,
            List <Curve> boundaries,
            ref CPolyLines outPolylines,
            bool flipYZ)
        {
            outPolylines = new CPolyLines();
            List <float> points     = new List <float>();
            List <int>   sta_ends   = new List <int>();
            List <int>   atBoundary = new List <int>();

            //Add Parts
            int count = 0;

            foreach (var curve in parts)
            {
                int      sta = count;
                Polyline polyline;
                curve.TryGetPolyline(out polyline);

                for (int id = 0; id < polyline.Count - 1; id++)
                {
                    Point3d pt = polyline[id];
                    points.Add((float)pt.X);

                    if (flipYZ)
                    {
                        //flip YZ because the coordianate systems of rhino and C++ are different
                        points.Add((float)pt.Z);
                        points.Add(-(float)pt.Y);
                    }
                    else
                    {
                        points.Add((float)pt.Y);
                        points.Add((float)pt.Z);
                    }
                    count++;
                }
                int end = count - 1;
                sta_ends.Add(sta);
                sta_ends.Add(end);
                atBoundary.Add(0);
            }


            //Add Boundries
            foreach (var curve in boundaries)
            {
                int      sta = count;
                Polyline polyline;
                curve.TryGetPolyline(out polyline);

                for (int id = 0; id < polyline.Count - 1; id++)
                {
                    Point3d pt = polyline[id];
                    if (flipYZ)
                    {
                        //flip YZ because the coordianate systems of rhino and C++ are different
                        points.Add((float)pt.Z);
                        points.Add(-(float)pt.Y);
                    }
                    else
                    {
                        points.Add((float)pt.Y);
                        points.Add((float)pt.Z);
                    }
                    count++;
                }
                int end = count - 1;
                sta_ends.Add(sta);
                sta_ends.Add(end);
                atBoundary.Add(1);
            }

            outPolylines.n_polyline = sta_ends.Count / 2;
            outPolylines.n_points   = points.Count / 3;

            outPolylines.points   = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(float)) * points.Count);
            outPolylines.sta_ends = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * sta_ends.Count);

            float[] array_points   = points.ToArray();
            int[]   array_sta_ends = sta_ends.ToArray();
            Marshal.Copy(array_points, 0, outPolylines.points, points.Count);
            Marshal.Copy(array_sta_ends, 0, outPolylines.sta_ends, sta_ends.Count);

            if (boundaries.Count != 0)
            {
                int[] array_atBoundary = atBoundary.ToArray();
                outPolylines.atBoundary = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * atBoundary.Count);
                Marshal.Copy(array_atBoundary, 0, outPolylines.atBoundary, atBoundary.Count);
            }

            return(true);
        }
Example #3
0
 internal static extern void setCrossMesh(ref CPolyLines polylines, IntPtr topoData, bool haveBoundary);