public override IVolume Forward(IVolume input, bool isTraining = false) { this.InputActivation = input; var output = input.Clone(); var length = input.Length; if (isTraining) { // do dropout for (var i = 0; i < length; i++) { if (Random.NextDouble() < this.DropProb) { output.Set(i, 0); this.dropped[i] = true; } // drop! else { this.dropped[i] = false; } } } else { // scale the activations during prediction for (var i = 0; i < length; i++) { output.Set(i, output.Get(i) * (1 - this.DropProb)); } } this.OutputActivation = output; return(this.OutputActivation); // dummy identity function for now }
public virtual IVolumeModel MapToModel(IVolume entity, int currentDepth = 1) { currentDepth++; var model = NameableEntityMapper.MapToModel <IVolume, VolumeModel>(entity); // Volume Properties model.Startyear = entity.Startyear; // Related Objects model.PrimaryImageFileId = entity.PrimaryImageFileId; model.PrimaryImageFile = entity.PrimaryImageFile?.MapToModel(); model.FirstIssueId = entity.FirstIssueId; model.FirstIssue = entity.FirstIssue?.MapToModel(); model.LastIssueId = entity.LastIssueId; model.LastIssue = entity.LastIssue?.MapToModel(); model.PublisherId = entity.PublisherId; model.Publisher = entity.Publisher?.MapToModel(); // Associated Objects model.Issues = entity.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToModelLite).ToList(); model.VolumeAliases = entity.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToModelLite).ToList(); model.VolumeCharacters = entity.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToModelLite).ToList(); model.VolumeConcepts = entity.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToModelLite).ToList(); model.VolumeLocations = entity.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToModelLite).ToList(); model.VolumeObjects = entity.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToModelLite).ToList(); model.VolumeTeams = entity.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToModelLite).ToList(); model.VolumeWriters = entity.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToModelLite).ToList(); // Return Entity return(model); }
public virtual void MapToEntity(IVolumeModel model, ref IVolume entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // Volume Properties entity.Startyear = model.Startyear; // Related Objects entity.PrimaryImageFileId = model.PrimaryImageFileId; entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity(); entity.FirstIssueId = model.FirstIssueId; entity.FirstIssue = (Issue)model.FirstIssue?.MapToEntity(); entity.LastIssueId = model.LastIssueId; entity.LastIssue = (Issue)model.LastIssue?.MapToEntity(); entity.PublisherId = model.PublisherId; entity.Publisher = (Publisher)model.Publisher?.MapToEntity(); // Associated Objects entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).ToList(); entity.VolumeAliases = model.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToEntity).ToList(); entity.VolumeCharacters = model.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToEntity).ToList(); entity.VolumeConcepts = model.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToEntity).ToList(); entity.VolumeLocations = model.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToEntity).ToList(); entity.VolumeObjects = model.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToEntity).ToList(); entity.VolumeTeams = model.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToEntity).ToList(); entity.VolumeWriters = model.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToEntity).ToList(); }
public void AddFrom(IVolume volume) { for (var i = 0; i < this.Weights.Length; i++) { this.Weights[i] += volume.GetWeight(i); } }
public virtual void MarkModified() { HUtils.log(); if (!BuildRSettings.AUTO_UPDATE) { return; } _isModified = true; _regenerate = true; if (_rGen == null) { _rGen = new RandomGen(); } _rGen.seed = seed; IVolume modifiedPlan = GetModifiedPlan(); if (modifiedPlan != null) { // CheckPlanHeights(); CheckPointMovements(modifiedPlan); CheckBuildingLegality(); } SaveData(); MarkUnmodified(); }
public int VolumeBaseFloor(IVolume vol) { HUtils.log(); int volumeCount = _volumes.Count; int output = 0; // Debug.Log("VolumeBaseFloor "+vol.name); for (int v = 0; v < volumeCount; v++) { IVolume other = _volumes[v]; if (other == vol) { continue; } if (other.ContainsPlanAbove(vol)) {//start the loop again - register the floors below current plan - use parent plan to find other parents v = -1; vol = other; output += vol.floors; // Debug.Log("above plan "+ vol.name); } } // Debug.Log("VolumeBaseFloor is " + output); return(output); }
public DefaultVolumeManager(Config.IConnectorConfig config, IEnumerable <IVolume> volumes) { _config = config; // validate config if (string.IsNullOrWhiteSpace(_config.DefaultVolumeName)) { throw new ArgumentNullException("Default volume name not specified in configuration, please specify one"); } _hashedVolumes = new Dictionary <string, IVolume>(); var volList = volumes.ToList(); for (int i = 0; i < volList.Count; ++i) { string vId = volumePrefix + i + "_"; volList[i].Id = vId; //TODO: right now we have to set volume ID like this, but it would be better if we could not have setter for ID in IVolume _hashedVolumes.Add(vId, volList[i]); // check if this is our default volume if (volList[i].Name.Equals(_config.DefaultVolumeName, StringComparison.OrdinalIgnoreCase)) { DefaultVolume = volList[i]; } } if (DefaultVolume == null) { throw new InvalidOperationException("Default volume with name " + _config.DefaultVolumeName + " not found"); } }
public AudioPresenter( IAudioInputPort audioInputPort, IVolume volume) { _audioInputPort = audioInputPort; _volume = volume; }
internal PodSleuthDevice(IVolume volume) { this.volume = volume; volume_info = new _VolumeInfo(volume); production_info = new _ProductionInfo(volume); model_info = new _ModelInfo(volume); if (volume.PropertyExists(PodsleuthPrefix + "control_path")) { string relative_control = volume.GetPropertyString(PodsleuthPrefix + "control_path"); if (relative_control[0] == Path.DirectorySeparatorChar) { relative_control = relative_control.Substring(1); } ControlPath = Path.Combine(VolumeInfo.MountPoint, relative_control); } ArtworkFormats = new ReadOnlyCollection <ArtworkFormat> (LoadArtworkFormats()); if (volume.PropertyExists(PodsleuthPrefix + "firmware_version")) { FirmwareVersion = volume.GetPropertyString(PodsleuthPrefix + "firmware_version"); } if (volume.PropertyExists(PodsleuthPrefix + "firewire_id")) { FirewireId = volume.GetPropertyString(PodsleuthPrefix + "firewire_id"); } RescanDisk(); }
public static List <IVolume> GetLinkablePlans(IBuilding building, IVolume plan) { List <IVolume> output = new List <IVolume>(building.AllPlans()); int planCount = building.numberOfPlans; for (int p = 0; p < planCount; p++) { if (building[p] == plan) { continue; //cannot link to oneself } if (building[p].ContainsPlanAbove(plan)) { return(building[p].AbovePlanList()); } int aPlans = building[p].abovePlanCount; for (int ap = 0; ap < aPlans; ap++) { output.Remove(building[p].AbovePlanList()[ap]); } if (plan.IsLinkedPlan(building[p])) { output.Remove(building[p]); } } return(output);//return base plans }
public static Vector3 CalculateVertexNormal(this Vector3 vertex, IVolume volume) { var inTriangles = GetTriangleIndexesHaving(vertex, volume); if(!inTriangles.Any()) return Vector3.Zero; var sum = inTriangles.Select(idx => volume.Triangles[idx].CalculateNormal(volume.Vertices)).Distinct().Aggregate((v1, v2) => v1 + v2); return Vector3.Normalize(sum); }
static void Main(string[] args) { GLib.GType.Init(); VolumeMonitor monitor = VolumeMonitor.Default; Console.WriteLine("Volumes:"); foreach (IVolume v in monitor.Volumes) { Console.WriteLine("\t{0}", v.Name); } Console.WriteLine("\nMounts:"); foreach (IMount m in monitor.Mounts) { Console.WriteLine("\tName:{0}, UUID:{1}, root:{2}, CanUnmount: {3}", m.Name, m.Uuid, m.Root, m.CanUnmount); IVolume v = m.Volume; if (v != null) { Console.WriteLine("\t\tVolume:{0}", v.Name); } IDrive d = m.Drive; if (d != null) { Console.WriteLine("\t\tDrive:{0}", d.Name); } } Console.WriteLine("\nConnectedDrives:"); foreach (IDrive d in monitor.ConnectedDrives) { Console.WriteLine("\t{0}, HasVolumes:{1}", d.Name, d.HasVolumes); } }
public static IVolume[] GetBelowVolumes(IBuilding building, IVolume volume) { List <IVolume> output = new List <IVolume>(); IVolume[] volumeList = building.AllPlans(); int volumeCount = volumeList.Length; for (int v = 0; v < volumeCount; v++) { IVolume other = volumeList[v]; if (other == volume) { continue; } if (other.ContainsPlanAbove(volume)) { output.Add(other); output.AddRange(other.LinkPlanList()); break; } } output.Remove(volume); return(output.ToArray()); }
public void RemovePlan(IVolume plan) { Volume newVolume = plan as Volume; if (newVolume == null) { throw new NullReferenceException("Runtime Building Not Using Right Volume Type"); } _volumes.Remove(newVolume); List <IVolume> childPlans = new List <IVolume>(plan.AbovePlanList()); int childPlanCount = childPlans.Count; for (int cp = 0; cp < childPlanCount; cp++) { // childPlans--; // cp--; RemovePlan(plan.AbovePlanList()[cp]); } #if UNITY_EDITOR DestroyImmediate(plan.gameObject); #else Destroy(plan.gameObject); #endif MarkModified(); }
public void AddFromScaled(IVolume volume, double a) { for (var i = 0; i < this.Weights.Length; i++) { this.Weights[i] += a * volume.Get(i); } }
public void AddGradientFrom(IVolume volume) { for (var i = 0; i < this.WeightGradients.Length; i++) { this.WeightGradients[i] += volume.GetGradient(i); } }
public void CalculateSubmeshes(SubmeshLibrary submeshLibrary) { for (int v = 0; v < numberOfVolumes; v++) { IVolume volume = this[v]; int numberOfPoints = volume.numberOfPoints; for (int p = 0; p < numberOfPoints; p++) { Facade facadeDesign = volume.GetFacade(p); if (facadeDesign != null) { submeshLibrary.Add(facadeDesign.stringCourseSurface); List <WallSection> usedWallSections = facadeDesign.usedWallSections; int sectionCount = usedWallSections.Count; for (int u = 0; u < sectionCount; u++) { submeshLibrary.Add(usedWallSections[u]); } } if (volume[p].isGabled && volume[p].gableStyle != null) { submeshLibrary.Add(volume[p].gableStyle.surface); } } submeshLibrary.Add(volume.roof.mainSurface); submeshLibrary.Add(volume.roof.wallSurface); submeshLibrary.Add(volume.roof.floorSurface); submeshLibrary.Add(volume.roof.wallSection); } }
public override void OnLoad(ConfigNode node) { // KSP Seems to want to make an instance of my partModule during initial load if (vessel == null) { return; } foreach (var hdNode in node.GetNodes("harddisk")) { var newDisk = new Harddisk(hdNode); HardDisk = newDisk; } UnityEngine.Debug.Log("******************************* ON LOAD "); InitCpu(); UnityEngine.Debug.Log("******************************* CPU Inited "); if (cpu != null) { cpu.OnLoad(node); } base.OnLoad(node); }
public _ProductionInfo(IVolume volume) { SerialNumber = volume.GetPropertyString(PodsleuthPrefix + "serial_number"); FactoryId = volume.GetPropertyString(PodsleuthPrefix + "production.factory_id"); Number = volume.GetPropertyInteger(PodsleuthPrefix + "production.number"); Week = volume.GetPropertyInteger(PodsleuthPrefix + "production.week"); Year = volume.GetPropertyInteger(PodsleuthPrefix + "production.year"); }
public async Task <bool> DeleteAsync(IVolume volume) { Ensure.NotNull(volume, nameof(volume)); return(await db.Volumes.PatchAsync(volume.Id, new[] { Change.Replace("deleted", Func("NOW")) }, condition : IsNull("deleted")) > 0); }
public InstantVolumeMeasurement(string name, IVolume vol, IInstantBodyMeasurement <T> bodyMeasurement, Func <T, IBody, T> accumFunc, Func <T, T> finalizeFunc = null) { Name = name; Volume = vol; BodyMeasurement = bodyMeasurement; AccumulationFunc = accumFunc; FinalizeFunc = finalizeFunc ?? (r => r); }
public void LinkPlans(IVolume link) { if (!linkedPlans.Contains(link)) { linkedPlans.Add(link); link.LinkPlans(this); } }
public void UnlinkPlans(IVolume link) { if (linkedPlans.Contains(link)) { linkedPlans.Remove(link); link.UnlinkPlans(this); } }
/// <summary> /// Appends string items to archive. The instance is NOT thread-safe /// </summary> public JsonArchiveAppender(IVolume volume, ITimeSource time, Atom app, string host, Action <object, Bookmark> onPageCommit = null) : base(volume, time, app, host, onPageCommit) { }
public void Train(IVolume x, double[] y) { this.Forward(x); this.Backward(y); this.TrainImplem(); }
public _ProductionInfo (IVolume volume) { SerialNumber = volume.GetPropertyString (PodsleuthPrefix + "serial_number"); FactoryId = volume.GetPropertyString (PodsleuthPrefix + "production.factory_id"); Number = volume.GetPropertyInteger (PodsleuthPrefix + "production.number"); Week = volume.GetPropertyInteger (PodsleuthPrefix + "production.week"); Year = volume.GetPropertyInteger (PodsleuthPrefix + "production.year"); }
/// <summary> /// Appends byte[] items to archive. The instance is NOT thread-safe /// </summary> public BinaryArchiveAppender(IVolume volume, ITimeSource time, Atom app, string host, Action <byte[], Bookmark> onPageCommit = null) : base(volume, time, app, host, onPageCommit) { }
public _VolumeInfo (IVolume volume) { this.volume = volume; MountPoint = volume.MountPoint; Label = volume.GetPropertyString ("volume.label"); IsMountedReadOnly = volume.IsReadOnly; Uuid = volume.GetPropertyString ("volume.uuid"); }
public void Undo(IDataCommand dataCommand) { IVolume volume = dataCommand.GetDevice() as IVolume; if (volume != null) { volume.DecrementVolume(); } }
public override void DeviceInitialize(IDevice device) { base.DeviceInitialize(device); volume = device as IVolume; if (volume == null || !volume.IsMounted || (usb_device = volume.ResolveRootUsbDevice()) == null) { throw new InvalidDeviceException(); } ms_device = DeviceMapper.Map(this); try { if (ms_device.ShouldIgnoreDevice() || !ms_device.LoadDeviceConfiguration()) { ms_device = null; } } catch { ms_device = null; } if (!HasMediaCapabilities && ms_device == null) { throw new InvalidDeviceException(); } // Ignore iPods, except ones with .is_audio_player files if (MediaCapabilities != null && MediaCapabilities.IsType("ipod")) { if (ms_device != null && ms_device.HasIsAudioPlayerFile) { Log.Information( "Mass Storage Support Loading iPod", "The USB mass storage audio player support is loading an iPod because it has an .is_audio_player file. " + "If you aren't running Rockbox or don't know what you're doing, things might not behave as expected." ); } else { throw new InvalidDeviceException(); } } Name = ms_device == null ? volume.Name : ms_device.Name; mount_point = volume.MountPoint; Initialize(); if (ms_device != null) { ms_device.SourceInitialize(); } AddDapProperties(); // TODO differentiate between Audio Players and normal Disks, and include the size, eg "2GB Audio Player"? //GenericName = Catalog.GetString ("Audio Player"); }
public AbsoluteFilePath(IVolume volume, string path) { this.Volume = volume; this.FileExtension = Path.GetExtension(path); this.FileName = Path.GetFileName(path); this.FileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); this.DirectoryName = Path.GetDirectoryName(path); this.FullPath = path; }
public void Execute(IDataCommand dataCommand) { IVolume volume = dataCommand.GetDevice() as IVolume; if (volume != null) { volume.IncrementVolume(); } }
public MusicService(ILogger logger, IMusicProviderFactory musicProviderFactory, IAutoPlay autoplayer, IDataService<QueuedTrack> queuedTrackDataService, IDataService<User> adminUserDataService, ISearchSuggestionService searchSuggestionService, IRickRollService rickRollService, IBroadcastService broadcastService, ISoundBoardService soundBoardService, ISkipHelper skipHelper, IVolume volume, IQueueManager queueManager, IAlreadyQueuedHelper alreadyQueuedHelper, IMusicPlayer musicPlayer, ICallbackClient callbackClient, IUserService userService, IVetoHelper vetoHelper, IQueueRuleHelper queueRuleHelper, ISettings settings, ISearchRuleHelper searchRuleHelper ) { this.vetoHelper = vetoHelper; this.callbackClient = callbackClient; this.alreadyQueuedHelper = alreadyQueuedHelper; this.queueManager = queueManager; this.broadcastService = broadcastService; this.rickRollService = rickRollService; this.logger = logger; this.musicProviderFactory = musicProviderFactory; this.autoplayer = autoplayer; this.queuedTrackDataService = queuedTrackDataService; this.adminUserDataService = adminUserDataService; this.searchSuggestionService = searchSuggestionService; this.soundBoardService = soundBoardService; this.skipHelper = skipHelper; this.volume = volume; this.musicPlayer = musicPlayer; this.callbackClient = callbackClient; this.userService = userService; this.queueRuleHelper = queueRuleHelper; this.settings = settings; this.searchRuleHelper = searchRuleHelper; foreach (var provider in musicProviderFactory.GetAllMusicProviders()) { provider.TrackEnded += musicProvider_TrackEnded; } if (settings.AutoStart) { PlayNextTrack(); } }
// a method to test private static void Mute(IVolume volume) { var timesTried = 0; while (volume.CurrentVolume() != "0") { timesTried++; if(timesTried > 10) return; volume.Quieter(10); } }
public BasicBody(IDynamicBody dynamics, IElectroMag eMProps, BasicMaterial material, IEdgeIntersector collisionShape, IVolume shape, IOverlapable boundVolume) { Dynamics = dynamics; EMProps = eMProps; Material = material; CollisionShape = collisionShape; Shape = shape; BoundVolume = boundVolume; Dynamics.FrameFinished += (sender, e) => FrameFinished?.Invoke(sender, e); }
public virtual bool AreEqual(IVolumeModel model, IVolume entity) { return NameableEntityMapper.AreEqual(model, entity) // Volume Properties && model.Startyear == entity.Startyear // Related Objects && model.PrimaryImageFileId == entity.PrimaryImageFileId && model.FirstIssueId == entity.FirstIssueId && model.LastIssueId == entity.LastIssueId && model.PublisherId == entity.PublisherId ; }
public override void DeviceInitialize (IDevice device) { base.DeviceInitialize (device); volume = device as IVolume; if (volume == null || (usb_device = volume.ResolveRootUsbDevice ()) == null) { throw new InvalidDeviceException (); } ms_device = DeviceMapper.Map (this); try { if (ms_device.ShouldIgnoreDevice () || !ms_device.LoadDeviceConfiguration ()) { ms_device = null; } } catch { ms_device = null; } if (!HasMediaCapabilities && ms_device == null) { throw new InvalidDeviceException (); } // Ignore iPods, except ones with .is_audio_player files if (MediaCapabilities != null && MediaCapabilities.IsType ("ipod")) { if (ms_device != null && ms_device.HasIsAudioPlayerFile) { Log.Information ( "Mass Storage Support Loading iPod", "The USB mass storage audio player support is loading an iPod because it has an .is_audio_player file. " + "If you aren't running Rockbox or don't know what you're doing, things might not behave as expected." ); } else { throw new InvalidDeviceException (); } } Name = ms_device == null ? volume.Name : ms_device.Name; mount_point = volume.MountPoint; Initialize (); if (ms_device != null) { ms_device.SourceInitialize (); } AddDapProperties (); // TODO differentiate between Audio Players and normal Disks, and include the size, eg "2GB Audio Player"? //GenericName = Catalog.GetString ("Audio Player"); }
/// <summary> /// Takes two points, one of which is in the volume and one of which isn't. /// /// Finds the distance along the segment a...b that intersects the boundary of the volume. /// /// Note: this assumes that there is only one such intersection! If this is not the case, use a finer mesh. /// </summary> public static Vector3 FindBoundary(Vector3 a, Vector3 b, IVolume volume) { Debug.Assert(volume.Contains(a) != volume.Contains(b)); bool contains = volume.Contains(a); Vector3 v1 = a, v2 = b; for (int i = 0; i < 10; i++) { Vector3 mid = (v1+v2)/2; if (contains == volume.Contains(mid)) { v1 = mid; } else { v2 = mid; } } return (v1 + v2) / 2; }
public static async Task<FdpOxoVolumeViewModel> GetFullAndPartialViewModel(IDataContext context, IVolume forVolume) { var modelBase = GetBaseModel(context); var volumeModel = new FdpOxoVolumeViewModel(modelBase) { Volume = (Volume)forVolume, Configuration = context.ConfigurationSettings, Countries = context.References.ListReferencesByKey(countryKey) }; HydrateOxoDocument(context, volumeModel); HydrateFdpVolumeHeaders(context, volumeModel); await HydrateFdpVolumeHeadersFromOxoDocument(context, volumeModel); HydrateVehicle(context, volumeModel); HydrateLookups(context, forVolume, volumeModel); HydrateMarkets(context, volumeModel); HydrateData(context, volumeModel); return volumeModel; }
public DefaultVolumeManager( Config.IConnectorConfig config, IEnumerable<IVolume> volumes ) { _config = config; // validate config if( string.IsNullOrWhiteSpace( _config.DefaultVolumeName ) ) throw new ArgumentNullException( "Default volume name not specified in configuration, please specify one" ); _hashedVolumes = new Dictionary<string,IVolume>(); var volList = volumes.ToList(); for( int i = 0; i < volList.Count; ++i ) { string vId = volumePrefix + i + "_"; volList[ i ].Id = vId; //TODO: right now we have to set volume ID like this, but it would be better if we could not have setter for ID in IVolume _hashedVolumes.Add( vId, volList[ i ] ); // check if this is our default volume if( volList[ i ].Name.Equals( _config.DefaultVolumeName, StringComparison.OrdinalIgnoreCase ) ) DefaultVolume = volList[ i ]; } if( DefaultVolume == null ) throw new InvalidOperationException( "Default volume with name " + _config.DefaultVolumeName + " not found" ); }
public _ModelInfo (IVolume volume) { AdvertisedCapacity = GetVolumeSizeString (volume); IsUnknown = true; if (volume.PropertyExists (PodsleuthPrefix + "is_unknown")) { IsUnknown = volume.GetPropertyBoolean (PodsleuthPrefix + "is_unknown"); } if (volume.PropertyExists (PodsleuthPrefix + "images.album_art_supported")) { AlbumArtSupported = volume.GetPropertyBoolean (PodsleuthPrefix + "images.album_art_supported"); } if (volume.PropertyExists (PodsleuthPrefix + "images.photos_supported")) { PhotosSupported = volume.GetPropertyBoolean (PodsleuthPrefix + "images.photos_supported"); } if (volume.PropertyExists (PodsleuthPrefix + "model.device_class")) { DeviceClass = volume.GetPropertyString (PodsleuthPrefix + "model.device_class"); } if (volume.PropertyExists (PodsleuthPrefix + "model.generation")) { Generation = volume.GetPropertyDouble (PodsleuthPrefix + "model.generation"); } if (volume.PropertyExists (PodsleuthPrefix + "model.shell_color")) { ShellColor = volume.GetPropertyString (PodsleuthPrefix + "model.shell_color"); } if (volume.PropertyExists ("info.icon_name")) { IconName = volume.GetPropertyString ("info.icon_name"); } if (volume.PropertyExists (PodsleuthPrefix + "capabilities")) { foreach (string capability in volume.GetPropertyStringList (PodsleuthPrefix + "capabilities")) { AddCapability (capability); } } }
public Nickel() { volume = new FluidOunces(); volume.Unit = 243; currency = new USCurrency(); currency.UnitPrice = 5; }
public HalfDollar() { volume = new FluidOunces(); volume.Unit = 534; currency = new USCurrency(); currency.UnitPrice = 50; }
public Dollar() { volume = new FluidOunces(); volume.Unit = 800; // just a guess, could not get the real figures.... currency = new USCurrency(); currency.UnitPrice = 100; }
public Dime() { volume = new FluidOunces(); volume.Unit = 115; currency = new USCurrency(); currency.UnitPrice = 10; }
public override string GetVolumeBestIdentifier(IVolume selected) { var localIndex = volumes.IndexOf(selected); if (!string.IsNullOrEmpty(selected.Name)) return "#" + localIndex + ": \"" + selected.Name + "\""; return "#" + localIndex; }
public static void Split(Mesh input, IVolume volume, out Mesh output, out bool[] trisInside) { /** * * for triangle in input * if triangle is entirely inside or outside * add to corresponding mesh * else split triangle into 4 pieces. * three go in one mesh, one goes into the other * * Splitting a triangle, Before: * * * vA * / \ * boundary --- /---\ --- * / \ * vB1 *-------* vB2 * * * After: * * * vA * vMid1 / \ vMid2 * boundary --- *---* --- * / \ / \ * vB1 *---*---* vB2 * vMidB * **/ int np = input.points.Length, nt = input.triangles.Length; List<Vector3> points = input.points.ToList(); List<Vector3> norms = input.normals.ToList(); List<Mesh.Triangle> tris = new List<Mesh.Triangle>(); List<bool> trisIn = new List<bool>(); for(int i = 0; i < nt; i++){ var tri = input.triangles[i]; Vector3 vA = input.points[tri.vertexA]; Vector3 vB = input.points[tri.vertexB]; Vector3 vC = input.points[tri.vertexC]; int ncontains = (volume.Contains(vA) ? 1 : 0) + (volume.Contains(vB) ? 1 : 0) + (volume.Contains(vC) ? 1 : 0); if (ncontains==3) { tris.Add(tri); trisIn.Add(true); } else if (ncontains==0){ tris.Add(tri); trisIn.Add(false); } else { // see comment above for explanation Debug.Assert(ncontains == 1 || ncontains == 2); bool containsA = (ncontains==1); int ixA, ixB1, ixB2; if (volume.Contains(vA) == containsA) { ixA = tri.vertexA; ixB1 = tri.vertexB; ixB2 = tri.vertexC; } else if (volume.Contains(vB) == containsA) { ixA = tri.vertexB; ixB1 = tri.vertexA; ixB2 = tri.vertexC; } else { Debug.Assert(volume.Contains(vC) == containsA); ixA = tri.vertexC; ixB1 = tri.vertexA; ixB2 = tri.vertexB; } Vector3 vAO = input.points[ixA]; Vector3 vB1 = input.points[ixB1]; Vector3 vB2 = input.points[ixB2]; Vector3 vMid1 = FindBoundary(vAO, vB1, volume); Vector3 vMid2 = FindBoundary(vAO, vB2, volume); Vector3 vMidB = input.points[ixB1]*0.5f + input.points[ixB2]*0.5f; points.Add(vMid1); points.Add(vMid2); points.Add(vMidB); float b1 = (vMid1 - vAO).Length / ((vB1 - vAO).Length + float.Epsilon); float b2 = (vMid2 - vAO).Length / ((vB2 - vAO).Length + float.Epsilon); Debug.Assert(0 <= b1 && b1 <= 1 && 0 <= b2 && b2 <= 1); Vector3 nMid1 = input.normals[ixA] * (1 - b1) + input.normals[ixB1] * b1; Vector3 nMid2 = input.normals[ixA] * (1 - b2) + input.normals[ixB2] * b2; Vector3 nMidB = input.normals[ixB1] * 0.5f + input.normals[ixB2] * 0.5f; nMid1.Normalize(); nMid2.Normalize(); nMidB.Normalize(); norms.Add(nMid1); norms.Add(nMid2); norms.Add(nMidB); //norms.Add(input.normals[ixA]); norms.Add(input.normals[ixA]); norms.Add(input.normals[ixA]); var tri1 = new Mesh.Triangle(ixA, points.Count - 3, points.Count - 2); var tri2 = new Mesh.Triangle(ixB1, points.Count - 3, points.Count - 1); var tri3 = new Mesh.Triangle(points.Count - 3, points.Count - 2, points.Count - 1); var tri4 = new Mesh.Triangle(ixB2, points.Count - 2, points.Count - 1); tri1.normal = tri2.normal = tri3.normal = tri4.normal = tri.normal; tris.Add(tri1); tris.Add(tri2); tris.Add(tri3); tris.Add(tri4); trisIn.Add(containsA); trisIn.Add(!containsA); trisIn.Add(!containsA); trisIn.Add(!containsA); } } // done Logger.info("split mesh, started with " + nt + " tris, added " + (tris.Count-nt)); Debug.Assert(points.Count==norms.Count); output = new Mesh(points.ToArray(), norms.ToArray(), tris.ToArray()); trisInside = trisIn.ToArray(); }
public virtual IVolumeModel MapToModel(IVolume entity, int currentDepth = 1) { currentDepth++; var model = NameableEntityMapper.MapToModel<IVolume, VolumeModel>(entity); // Volume Properties model.Startyear = entity.Startyear; // Related Objects model.PrimaryImageFileId = entity.PrimaryImageFileId; model.PrimaryImageFile = entity.PrimaryImageFile?.MapToModel(); model.FirstIssueId = entity.FirstIssueId; model.FirstIssue = entity.FirstIssue?.MapToModel(); model.LastIssueId = entity.LastIssueId; model.LastIssue = entity.LastIssue?.MapToModel(); model.PublisherId = entity.PublisherId; model.Publisher = entity.Publisher?.MapToModel(); // Associated Objects model.Issues = entity.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToModelLite).ToList(); model.VolumeAliases = entity.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToModelLite).ToList(); model.VolumeCharacters = entity.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToModelLite).ToList(); model.VolumeConcepts = entity.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToModelLite).ToList(); model.VolumeLocations = entity.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToModelLite).ToList(); model.VolumeObjects = entity.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToModelLite).ToList(); model.VolumeTeams = entity.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToModelLite).ToList(); model.VolumeWriters = entity.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToModelLite).ToList(); // Return Entity return model; }
public override void CreateGeometryForObjects(Device device, ICollection<IAtom> objs, GeomDataBufferStream geomStream, int stream, ref BufferedGeometryData buffer, CompleteOutputDescription coDesc) { // fillable fields int positionPos = -1; int normalPos = -1; int diffusePos = -1; // match field locations for (int i = 0; i < fields.Length; i++) { for (int gf = 0; gf < geomStream.Fields.Length; gf++) { if (fields[i].Format == geomStream.Fields[gf]) { if (fields[i].Usage == "POSITION") positionPos = geomStream.FieldPositions[gf]; else if (fields[i].Usage == "NORMAL") normalPos = geomStream.FieldPositions[gf]; else if (fields[i].Usage == "DIFFUSE") diffusePos = geomStream.FieldPositions[gf]; break; } } } // actually create the metaball triangles or points IVolume[] volumes = new IVolume[objs.Count]; int sIdx = 0; AtomShadingDesc aShading = coDesc.AtomShadingDesc; IMoleculeMaterialLookup lookup = aShading.MoleculeMaterials; foreach (IAtom atom in objs) { IMoleculeMaterialTemplate matTemp = lookup.ResolveBySymbol(atom.Symbol); IMoleculeMaterial material = null; if (matTemp != null) material = matTemp.BySymbol; else { PeriodicTableElement pe = (PeriodicTableElement)atom.Properties["PeriodicTableElement"]; if (pe != null) material = lookup.GetBySeries(pe.ChemicalSerie); } volumes[sIdx++] = new Metaball(new Vector3((float)atom.X3d, (float)atom.Y3d, (float)atom.Z3d), 0.17f, material.BaseColor); } // process volume into triangles GenericVolumeScene scene = new GenericVolumeScene(volumes); int[] triangles = null; Vector3[] vertices; Color[] colours; Vector3[] normals = null; if (!pointsOnly) { IsosurfaceGenerator3D.GenerateSimpleMesh(scene, new Vector3(), scene.EstimateVolumeMaxSize(), 40, false, out triangles, out vertices, out colours); MeshOptimzer.GenerateTriPointNormals(triangles, vertices, out normals); } else IsosurfaceGenerator3D.GenerateSimplePointOutline(scene, new Vector3(), scene.EstimateVolumeMaxSize(), 40, out vertices, out colours); // create buffers buffer = new BufferedGeometryData(device, objs.Count); buffer.vBuffers = new BufferedGeometryData.VertexData[1]; buffer.vBuffers[0] = new BufferedGeometryData.VertexData(); buffer.vBuffers[0].Buffer = new VertexBuffer(device, geomStream.Stride * vertices.Length, Usage.WriteOnly, geomStream.Format, Pool.Managed); buffer.vBuffers[0].Stride = geomStream.Stride; buffer.vBuffers[0].NumElements = vertices.Length; buffer.vBuffers[0].Format = geomStream.Format; buffer.iBuffers = new BufferedGeometryData.IndexData[1]; buffer.iBuffers[0] = new BufferedGeometryData.IndexData(); buffer.iBuffers[0].Desc = BufferedGeometryData.IndexData.Description.Geometry; if (pointsOnly) { buffer.iBuffers[0].NumPrimitives = vertices.Length; buffer.iBuffers[0].PrimType = PrimitiveType.PointList; buffer.Light = false; } else { buffer.iBuffers[0].NumPrimitives = triangles.Length / 3; buffer.iBuffers[0].PrimType = PrimitiveType.TriangleList; buffer.iBuffers[0].Buffer = new IndexBuffer(typeof(int), triangles.Length, device, Usage.WriteOnly, Pool.Managed); } // lock stream GraphicsStream data = buffer.vBuffers[0].Buffer.Lock(0, 0, LockFlags.None); // fill fields int clr = Color.FromArgb(255, 255, 255).ToArgb(); long pos = 0; for (int i = 0; i < vertices.Length; i++) { if (positionPos != -1) { data.Seek(pos + positionPos, SeekOrigin.Begin); data.Write(vertices[i].X); data.Write(vertices[i].Y); data.Write(vertices[i].Z); } if (normalPos != -1 && !pointsOnly) { data.Seek(pos + normalPos, SeekOrigin.Begin); data.Write(normals[i].X); data.Write(normals[i].Y); data.Write(normals[i].Z); } if (diffusePos != -1) { data.Seek(pos + diffusePos, SeekOrigin.Begin); data.Write(colours[i].ToArgb()); } //verts[i].Color = colours[i].ToArgb(); pos += geomStream.Stride; } buffer.vBuffers[0].Buffer.Unlock(); if (!pointsOnly) buffer.iBuffers[0].Buffer.SetData(triangles, 0, LockFlags.None); // dispose of temp data }
public Volume (Context context, ObjectPath opath) { this.volume = context.GetObject<IVolume> (opath); }
public override void DeviceInitialize(IDevice device) { Volume = device as IVolume; if (Volume == null) { throw new InvalidDeviceException (); } if (!Volume.IsMounted && device.MediaCapabilities != null && device.MediaCapabilities.IsType ("ipod")) { Hyena.Log.Information ("Found potential unmounted iDevice, trying to mount it now"); Volume.Mount (); } if (!Volume.IsMounted) { Hyena.Log.Information ("AppleDeviceSource is ignoring unmounted volume " + Volume.Name); throw new InvalidDeviceException (); } Device = new GPod.Device (Volume.MountPoint); if (GPod.ITDB.GetControlPath (Device) == null) { throw new InvalidDeviceException (); } base.DeviceInitialize (device); Name = Volume.Name; SupportsPlaylists = true; SupportsPodcasts = Device.SupportsPodcast; SupportsVideo = Device.SupportsVideo; Initialize (); GPod.ITDB.InitIpod (Volume.MountPoint, Device.IpodInfo == null ? null : Device.IpodInfo.ModelNumber, Name); // HACK: ensure that m4a, and mp3 are set as accepted by the device; bgo#633552 AcceptableMimeTypes = (AcceptableMimeTypes ?? new string [0]).Union (new string [] { "taglib/m4a", "taglib/mp3" }).ToArray (); // FIXME: Properly parse the device, color and generation and don't use the fallback strings // IpodInfo is null on Macos formated ipods. I don't think we can really do anything with them // but they get loaded as UMS devices if we throw an NRE here. if (Device.IpodInfo != null) { AddDapProperty (Catalog.GetString ("Device"), Device.IpodInfo.ModelString); AddDapProperty (Catalog.GetString ("Generation"), Device.IpodInfo.GenerationString); } // FIXME //AddDapProperty (Catalog.GetString ("Color"), "black"); AddDapProperty (Catalog.GetString ("Capacity"), string.Format ("{0:0.00}GB", BytesCapacity / 1024.0 / 1024.0 / 1024.0)); AddDapProperty (Catalog.GetString ("Available"), string.Format ("{0:0.00}GB", BytesAvailable / 1024.0 / 1024.0 / 1024.0)); AddDapProperty (Catalog.GetString ("Serial number"), Volume.Serial); //AddDapProperty (Catalog.GetString ("Produced on"), ipod_device.ProductionInfo.DisplayDate); //AddDapProperty (Catalog.GetString ("Firmware"), ipod_device.FirmwareVersion); //string [] capabilities = new string [ipod_device.ModelInfo.Capabilities.Count]; //ipod_device.ModelInfo.Capabilities.CopyTo (capabilities, 0); //AddDapProperty (Catalog.GetString ("Capabilities"), String.Join (", ", capabilities)); AddYesNoDapProperty (Catalog.GetString ("Supports cover art"), Device.SupportsArtwork); AddYesNoDapProperty (Catalog.GetString ("Supports photos"), Device.SupportsPhoto); }
private static void HydrateLookups(IDataContext context, IVolume volume, FdpOxoVolumeViewModel volumeModel) { volumeModel.VehicleLookup = GetLookup(context, volume.Vehicle); }
public static void MapToEntity(this IVolumeModel model, ref IVolume entity, int currentDepth = 1) { Mapper.MapToEntity(model, ref entity, currentDepth); }
public Penny() { volume = new FluidOunces(); volume.Unit = 122; currency = new USCurrency(); currency.UnitPrice = 1; }
public BasicBody WithShape(IVolume newShape) => new BasicBody(Dynamics, EMProps, Material, CollisionShape, newShape, BoundVolume);
public Quarter() { volume = new FluidOunces(); volume.Unit = 270; currency = new USCurrency(); currency.UnitPrice = 25; }
public void AttachVolume(IVolume hardDisk) { Volumes.Add(hardDisk); SelectedVolume = hardDisk; }
internal PodSleuthDevice (IVolume volume) { this.volume = volume; volume_info = new _VolumeInfo (volume); production_info = new _ProductionInfo (volume); model_info = new _ModelInfo (volume); if (volume.PropertyExists (PodsleuthPrefix + "control_path")) { string relative_control = volume.GetPropertyString (PodsleuthPrefix + "control_path"); if (relative_control[0] == Path.DirectorySeparatorChar) { relative_control = relative_control.Substring (1); } ControlPath = Path.Combine(VolumeInfo.MountPoint, relative_control); } ArtworkFormats = new ReadOnlyCollection<ArtworkFormat> (LoadArtworkFormats ()); if (volume.PropertyExists (PodsleuthPrefix + "firmware_version")) { FirmwareVersion = volume.GetPropertyString (PodsleuthPrefix + "firmware_version"); } if (volume.PropertyExists (PodsleuthPrefix + "firewire_id")) { FirewireId = volume.GetPropertyString (PodsleuthPrefix + "firewire_id"); } RescanDisk (); }
private static string GetVolumeSizeString (IVolume volume) { string format = "GiB"; double value = volume.GetPropertyUInt64 ("volume.size") / 1000.0 / 1000.0 / 1000.0; if(value < 1.0) { format = "MiB"; value *= 1000.0; } return String.Format ("{0} {1}", (int)Math.Round (value), format); }