Пример #1
0
        public IFrame Import(string inputPath, string dataType)
        {
            extension = Path.GetExtension(inputPath);
            switch (extension)
            {
            case ".vtk":
            case ".vtu":
            case ".vtp":
                return(ImportVTKFrame(inputPath, dataType));

            default:
                throw Log.ThrowError("Wrong file extension! Only supporting VTK files", new IOException());
            }
        }
Пример #2
0
 private void GetFilepaths(string layerDirectory)
 {
     try
     {
         filePaths = Directory.GetFiles(layerDirectory + @"\");
     }
     catch (DirectoryNotFoundException ex)
     {
         throw Log.ThrowError("Directory does not exist at: " + layerDirectory, ex);
     }
     if (filePaths == null)
     {
         throw Log.ThrowError("No files found in: " + layerDirectory, new FileNotFoundException());
     }
 }
Пример #3
0
 private string[] GetFilepaths(string rootDirectory)
 {
     string[] filePaths = Directory.GetFiles(rootDirectory + @"\");
     if (filePaths == null)
     {
         throw Log.ThrowError("No files found in: " + rootDirectory, new FileNotFoundException());
     }
     return filePaths;
 }
Пример #4
0
 private Vector3[] ImportVector3Array(string vectorsStr, int NumberOfVectors, string arrayName)
 {
     try
     {
         Vector3[] vectorArray   = new Vector3[NumberOfVectors];
         float[]   coordinates   = Array.ConvertAll(vectorsStr.Split(' '), s => float.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat));
         int       currentVector = 0;
         for (int i = 0; i < coordinates.Length; i += 3)
         {
             vectorArray[currentVector].Set(coordinates[i], coordinates[i + 1], coordinates[i + 2]);
             currentVector++;
         }
         return(vectorArray);
     }
     catch (FormatException ex)
     {
         throw Log.ThrowError("Incorrect " + arrayName + " data in: " + filePath, ex);
     }
 }
Пример #5
0
        protected void ReadInfoFile(string rootDirectory)
        {
            try
            {
                ReadModelInfoJson(rootDirectory);
            }
            catch (FileNotFoundException ex)
            {
                throw Log.ThrowError("No ModelInfo.json found in root folder!", ex);
            }
            foreach (ModelLayerInfo layerInfo in Info.Layers)
            {
                layerInfo.Directory = rootDirectory + @"\" + layerInfo.Directory;
            }

            if (Info.Layers.Count == 0)
            {
                throw Log.ThrowError("No layers found in ModelInfo.json file", new InvalidDataException());
            }
        }
Пример #6
0
        protected void ReadInfoFile()
        {
            if (!File.Exists(RootDirectory + @"\" + "ModelInfo.json"))
            {
                throw Log.ThrowError("No ModelInfo.json found in root folder!", new FileNotFoundException());
            }

            using (StreamReader r = new StreamReader(RootDirectory + @"\" + "ModelInfo.json"))
            {
                try
                {
                    string json = r.ReadToEnd();
                    Info = JsonConvert.DeserializeObject <ModelInfo>(json);
                }
                catch (JsonReaderException ex)
                {
                    throw Log.ThrowError("Corrupted ModelInfo.json file!", ex);
                }
            }

            // convert some paths to be absolute filenames
            foreach (ModelLayerInfo layerInfo in Info.Layers)
            {
                layerInfo.Directory = RootDirectory + @"\" + layerInfo.Directory;
            }
            if (!string.IsNullOrEmpty(Info.IconFileName))
            {
                Info.IconFileName = RootDirectory + @"\" + Info.IconFileName;
            }

            // simple validation of the structure
            if (Info.Layers.Count == 0)
            {
                throw Log.ThrowError("No layers found in ModelInfo.json file at:" + RootDirectory, new InvalidDataException());
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            LoggingConfiguration.Configure();
            Log.Info("VTKConverter started!");
            if (args.Length != 2)
            {
                throw Log.ThrowError("Wrong number of parameters at the input!\n VTKconverter.exe <path/to/model/root/folder> <path/to/the/root/folder>",
                                     new IOException());
            }
            string inputRootDir = args[0];
            string outputFolder = args[1];

            ModelConverter modelConverter = new ModelConverter();

            modelConverter.Convert(inputRootDir, outputFolder);
        }
Пример #8
0
        // Prepare the go for taking preview icon.
        // We need to configure blend shapes state, material -- otherwise icon would look bad.
        private void PrepareForPreview(GameObject go)
        {
            SkinnedMeshRenderer renderer = go.GetComponent <SkinnedMeshRenderer>();

            if (renderer != null &&
                renderer.sharedMesh != null &&
                renderer.sharedMesh.blendShapeCount != 0)
            {
                renderer.SetBlendShapeWeight(0, 100f);
                Material defaultMaterial = AssetDatabase.LoadAssetAtPath <Material>(DefaultMaterialAsset);
                if (defaultMaterial == null)
                {
                    Log.ThrowError("Cannot read default material asset from " + DefaultMaterialAsset, new IOException());
                }
                renderer.material = defaultMaterial;
            }
        }
Пример #9
0
        protected override void ImportLayer(ModelLayerInfo layerInfo)
        {
            string objectName   = Info.Caption + "_" + Path.GetFileName(layerInfo.Directory);
            string absolutePath = layerInfo.Directory + "/" + layerInfo.AssetFileName;
            string objectPath   = "Assets" + absolutePath.Substring(Application.dataPath.Length);

            GameObject modelGameObject = AssetDatabase.LoadAssetAtPath <GameObject>(@"Test Models/Skull/skull_body");

            if (modelGameObject == null)
            {
                throw Log.ThrowError("Cannot import model from " + objectPath, new IOException());
            }
            GameObject modelInstance = UnityEngine.Object.Instantiate(modelGameObject);

            AddLayerComponent(modelInstance, layerInfo);
            CreatePrefab(layerInfo, modelInstance, objectName);
            if (layerInfo.UseAsIcon)
            {
                LayerAutomaticIconGenerate(modelInstance);
            }
            GameObject.DestroyImmediate(modelInstance);
        }