1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import 'dart:typed_data';
- import 'package:vid/us/vid_us_data_reader.dart';
- import 'package:vid/us/vid_us_data_writer.dart';
- import 'package:vid/us/vid_us_point.dart';
- import 'package:vid/us/vid_us_rect.dart';
- enum VidUs3DAreaIndicator { Global, A, B, C, ThreeD }
- class VidUsTissue3DArea {
- late VidUsRect _bounds;
- late double _cmPerPixel;
- late VidUsPoint _globalOffset;
- late VidUs3DAreaIndicator _indicator;
- VidUsRect get bounds => _bounds;
- double get cmPerPixel => _cmPerPixel;
- VidUsPoint get globalOffset => _globalOffset;
- VidUs3DAreaIndicator get indicator => _indicator;
- VidUsTissue3DArea(VidUsRect bounds, double cmPerPixel,
- VidUsPoint globalOffset, VidUs3DAreaIndicator indicator) {
- _indicator = indicator;
- _globalOffset = globalOffset;
- _cmPerPixel = cmPerPixel;
- _bounds = bounds;
- }
- Uint8List toBytes() {
- var writer = new VidUsDataWriter();
- writer.writeByte(_indicator.index);
- writer.writeDouble(_cmPerPixel);
- writer.writeDouble(_globalOffset.x);
- writer.writeDouble(_globalOffset.y);
- writer.writeDouble(_bounds.left);
- writer.writeDouble(_bounds.top);
- writer.writeDouble(_bounds.right);
- writer.writeDouble(_bounds.bottom);
- return writer.data;
- }
- static VidUsTissue3DArea fromBytes(Uint8List tissue3DAreaData) {
- var reader = new VidUsDataReader(tissue3DAreaData);
- var indicator = VidUs3DAreaIndicator.values[reader.readByte()];
- var cmPerPixel = reader.readDouble();
- var x = reader.readDouble();
- var y = reader.readDouble();
- var globalOffset = new VidUsPoint(x, y);
- var left = reader.readDouble();
- var top = reader.readDouble();
- var right = reader.readDouble();
- var bottom = reader.readDouble();
- var bounds = new VidUsRect.tlbr(
- new VidUsPoint(left, top), new VidUsPoint(right, bottom));
- return new VidUsTissue3DArea(bounds, cmPerPixel, globalOffset, indicator);
- }
- }
|