Skip to content

Commit b5f5d51

Browse files
unified documentation of repeated float count expectations for all vector block types that use.
Included performance reasoning behind OVF design in the OVF definition file as documentation.
1 parent 7738009 commit b5f5d51

1 file changed

Lines changed: 31 additions & 13 deletions

File tree

open_vector_format.proto

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -488,49 +488,67 @@ message VectorBlock {
488488
WIRESTRUCTURE = 2;
489489
POINTS = 3;
490490
}
491+
492+
//--- Vetor Block Type Definitions ---
493+
//--- OVF performance: why use unstructured repeated float in vector block type definitions? ---
494+
495+
//The choice of using unstructured repeated float in OVF is very deliberate and the reasoning is performance.
496+
//Approx. 99% of the data volume in OVF is the coordinate data.
497+
//Using repeated float enables reinterpreting the float data as an array of structs using equivalents of "memcast" in the target programming languages.
498+
//This enables using different definitions of point structs without allocating again or copying the data.
499+
500+
//Example use cases are struct definitions for different domain models or libraries,
501+
//or Single Input Multipe Data (SIMD) vector types.
502+
//Zero copy in place is the minimal overhead possible of any solution.
503+
//This works in all cases where libraries use single precision floats.
504+
505+
//Using repeated float also minimizes overhead in the wire format.
506+
//The resulting packed proto encoding only needs a single TAG byte and a varint for the length,
507+
//resulting in only 2-5 bytes of encoding overhead per vector block.
508+
//"Parsing" repeated float is a minimal overhead memcopy of the floating point data, e.g. from the file/network stream buffer.
491509

492510
//LineSequence:
493511
//A lineSequence is defined by a set of vertex points (x,y),
494512
//connected contiguously in the listed order by straight line segments.
495513
//A closed lineSequence can also be called a polygon.
496514
message LineSequence {
497-
repeated float points = 1;
515+
repeated float points = 1; // len % 2 == 0, len >= 4
498516
}
499517

500518
//LineSequence3D:
501519
//A lineSequence3D is defined by a set of vertex points (x,y,z) in 3D space,
502520
//connected contiguously in the listed order by straight line segments.
503521
//A closed lineSequence can also be called a polygon.
504522
message LineSequence3D {
505-
repeated float points = 1;
523+
repeated float points = 1; // len % 3 == 0, len >= 6
506524
}
507525

508526
//Hatches:
509527
//A hatch is a set of independent straight lines,
510528
//each defined by one start and one end point (x,y) for 2D.
511529
message Hatches {
512-
repeated float points = 1;
530+
repeated float points = 1; // len % 4 == 0, len >= 4
513531
}
514532

515533
//Hatches3D:
516534
//A hatch is a set of independent straight lines,
517535
//each defined by one start and one end point (x,y,z) for 3D.
518536
message Hatches3D {
519-
repeated float points = 1;
537+
repeated float points = 1; // len % 6 == 0, len >= 6
520538
}
521539

522540
//PointSequence:
523541
//A point sequence is a set of points, each marked
524542
//for a fixed period of time. Each point consists of (x,y) for 2D.
525543
message PointSequence {
526-
repeated float points = 1;
544+
repeated float points = 1; // len % 2 == 0, len >= 2
527545
}
528546

529547
//PointSequence3D:
530548
//A point sequence is a set of points, each marked
531549
//for a fixed period of time. Each point consists of (x,y,z) for 3D.
532550
message PointSequence3D {
533-
repeated float points = 1;
551+
repeated float points = 1; // len % 3 == 0, len >= 3
534552
}
535553

536554
//An arc is defined by a start point on the circle,
@@ -542,7 +560,7 @@ message VectorBlock {
542560
double angle = 1;
543561
float start_dx = 2;
544562
float start_dy = 3;
545-
repeated float centers = 4;
563+
repeated float centers = 4; // len % 2 == 0, len >= 2
546564
}
547565

548566
//An arc3D (edge of a plate) is defined by a start point on the circle,
@@ -555,7 +573,7 @@ message VectorBlock {
555573
float start_dx = 2;
556574
float start_dy = 3;
557575
float start_dz = 4;
558-
repeated float centers = 5;
576+
repeated float centers = 5; // len % 3 == 0, len >= 3
559577
}
560578

561579
//An ellipse is defined like an arc, with additional parameters
@@ -580,7 +598,7 @@ message VectorBlock {
580598
//scaling linear along the vector. The goal gets priority and overwrites settings of the
581599
//parameter set.
582600
message LineSequenceParaAdapt {
583-
repeated float points_with_paras = 1;
601+
repeated float points_with_paras = 1; // len % 3 == 0, len >= 3
584602

585603
AdaptedParameter parameter = 2;
586604
enum AdaptedParameter {
@@ -601,14 +619,14 @@ message VectorBlock {
601619
// Each segment: (x0, y0, cx, cy, x1, y1) => 6 floats/segment.
602620
// Pack N: [x0,y0,cx,cy,x1,y1, x0,y0,cx,cy,x1,y1, ...]
603621
message QuadraticBezierHatches {
604-
repeated float segments = 1;
622+
repeated float segments = 1; // len % 6 == 0, len >= 6
605623
}
606624

607625
// Cubic Bézier segments in 2D.
608626
// Each segment: (x0, y0, c1x, c1y, c2x, c2y, x1, y1) => 8 floats/segment.
609627
// Pack N: [x0,y0,c1x,c1y,c2x,c2y,x1,y1, ...]
610628
message CubicBezierHatches {
611-
repeated float segments = 1;
629+
repeated float segments = 1; // len % 8 == 0, len >= 8
612630
}
613631

614632
// Linked Quadratic Bézier spline in 2D (continuous).
@@ -632,14 +650,14 @@ message VectorBlock {
632650
// Each segment: (x0, y0, z0, cx, cy, cz, x1, y1, z1) => 9 floats/segment.
633651
// Pack N: [x0,y0,z0,cx,cy,cz,x1,y1,z1, x0,y0,z0,cx,cy,cz,x1,y1,z1, ...]
634652
message QuadraticBezierHatches3D {
635-
repeated float segments = 1;
653+
repeated float segments = 1; // len % 9 == 0, len >= 9
636654
}
637655

638656
// Cubic Bézier segments in 3D.
639657
// Each segment: (x0, y0, z0, c1x, c1y, c1z, c2x, c2y, c2z, x1, y1, z1) => 12 floats/segment.
640658
// Pack N: [x0,y0,z0,c1x,c1y,c1z,c2x,c2y,c2z,x1,y1,z1, ...]
641659
message CubicBezierHatches3D {
642-
repeated float segments = 1;
660+
repeated float segments = 1; // len % 12 == 0, len >= 12
643661
}
644662

645663
// Linked Quadratic Bézier spline in 3D (continuous).

0 commit comments

Comments
 (0)