Esempio n. 1
0
    /*
     * Creates a fake bin in incoming directory
     */
    public void GenerateBin(string name, long size, int nSlices)
    {
        string binPath = ExplodedPrefs.IncomingBin(name);
        string cloudPath = ExplodedPrefs.IncomingCloud(name);

        if (!Directory.Exists(ExplodedPrefs.IncomingPath)) {
            Directory.CreateDirectory(ExplodedPrefs.IncomingPath);
        }

        using( FileStream fs = new FileStream( binPath, FileMode.Create ) ) {

            Vector3 scale = 2.0f * Vector3.one + Random.insideUnitSphere;

            CloudStream.Writer writer = new CloudStream.Writer(fs);
            for(int i = 0; i<size; ++i) {
                Vector3 v = Random.insideUnitSphere;

                v.x *= scale.x;
                v.y *= scale.y;
                v.z *= scale.z;

                Color c = RandomExt.color;
                writer.WritePoint(v, c);
            }
        }

        using( StreamWriter writer = new StreamWriter(cloudPath) ) {
            writer.WriteLine(binPath);
            long sliceSize = size / nSlices;
            for(int i = 0; i<nSlices; i ++) {
                writer.WriteLine(string.Format("{0}\t{1}\t{2}",
                                               i,
                                               i * sliceSize,
                                               // the last slice may be larger
                                               (i==nSlices-1)? size - i*sliceSize : sliceSize ));
            }
        }
    }
Esempio n. 2
0
 void setup(Transform box, Transform cloud, string path, bool shadow)
 {
     IOExt.Directory.EnsureExists( Path.GetDirectoryName(path) );
     writer = new CloudStream.Writer (new FileStream (path, FileMode.Create));
     this.path = path;
     // find a matrix to convert cloud vertex coordinate into box coordinate...
     cloud2box = box.worldToLocalMatrix * cloud.localToWorldMatrix;
     count = 0;
     boxTransform = box;
     this.cloudRootTransform = cloud;
     this.shadow = shadow;
 }
Esempio n. 3
0
 public WriterTest()
 {
     writer = new CloudStream.Writer( TmpFileStream(FileMode.Truncate) );
     Assert_Equal(0, writer.BaseStream.Length);
     foreach(ColoredPoint cp in mockCloud) {
         writer.WritePoint(cp.v, cp.c);
     }
 }
Esempio n. 4
0
    void ShuffleBin(string path)
    {
        using(FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)) {
            CloudStream.Reader reader = new CloudStream.Reader(fs);
            CloudStream.Writer writer = new CloudStream.Writer(fs);

            byte[] tmp_i = new byte[CloudStream.pointRecSize] , tmp_j = new byte[CloudStream.pointRecSize];
            ShuffleUtility.WithSwap((int)fs.Length / CloudStream.pointRecSize,
                                    (i, j) => {
                reader.SeekPoint(i);
                tmp_i = reader.ReadBytes( tmp_i.Length);
                reader.SeekPoint(j);
                tmp_j = reader.ReadBytes( tmp_j.Length);
                writer.SeekPoint(j);
                writer.Write(tmp_i);
                writer.SeekPoint(i);
                writer.Write(tmp_j);
            });
        }
    }