Exemple #1
0
        public ModalModel GetModalModel(SimpleMesh simpleMesh, int propertyIndex = 0)
        {
            try
            {
                // Get the (modal) material properties
                string mesh_id = simpleMesh.MeshName;
                if (ModelPresets.Instance.PresetsAvailableFor(mesh_id) <= 0)
                {
                    return(null);
                }

                var presets = ModelPresets.Instance.Presets[mesh_id];
                ModalMaterialProperties props = presets[propertyIndex];

                // Call the API to fetch the modal model
                // Only fetch if we have not computed a model
                // for a similar mesh with same props
                if (!modalModelsDict.ContainsKey(props.MaterialName))
                {
                    var respTask = api.GetModalModelAsync(simpleMesh, props);
                    modalModelsDict.Add(props.MaterialName, respTask.Result.Data);
                }

                ModalModel model = modalModelsDict[props.MaterialName];
                return(model);
            }
            catch (System.Exception e)
            {
                Debug.Log(e.ToString());
                return(null);
            }
        }
Exemple #2
0
        private ModalAPIRequestContent GetRequestObject(SimpleMesh mesh, ModalMaterialProperties material)
        {
            ModalAPIRequestContent cont = new ModalAPIRequestContent
            {
                Mesh = new ModalAPIMesh
                {
                    Triangles = mesh.Triangles,
                    Vertices  = mesh.Vertices
                },
                Material = new ModalAPIMaterial
                {
                    Youngs       = material.YoungsModulus,
                    Thickness    = material.Thickness,
                    Density      = material.Density,
                    ViscoDamping = material.ViscoElasticDamping,
                    FluidDamping = material.FluidElasticDamping
                }
            };

            return(cont);
        }
Exemple #3
0
        public Task <IRestResponse <ModalModel> > GetModalModelAsync(SimpleMesh mesh, ModalMaterialProperties material)
        {
            var requestContent = GetRequestObject(mesh, material);
            var request        = MakePostRequest(requestContent, "1");

            return(client.ExecuteAsync <ModalModel>(request));
        }