Skip to content

Commit

Permalink
Read and Write TransitionSpirals (IntegratedSpiral3d) and PolyfaceAux…
Browse files Browse the repository at this point in the history
…Data in FlatBuffer (iTwin#313)

* Flatbuffer Read and Write for PolyfaceAuxData

* Read and Write PolyfaceAuxData and IntegratedSpiral in flatbuffer

* api

* lint

* module markup

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
EarlinLutz and mergify[bot] authored Nov 27, 2020
1 parent e2163d1 commit 12d79c0
Show file tree
Hide file tree
Showing 9 changed files with 6,128 additions and 5,721 deletions.
3 changes: 2 additions & 1 deletion common/api/geometry-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class AuxChannel {

// @public
export class AuxChannelData {
constructor(input: number, values: number[]);
constructor(input: number, values: number[] | Float64Array);
clone(): AuxChannelData;
copyValues(other: AuxChannelData, thisIndex: number, otherIndex: number, blockSize: number): void;
input: number;
Expand Down Expand Up @@ -4689,6 +4689,7 @@ export class RuledSweep extends SolidPrimitive {

// @alpha
export class Sample {
static addAuxDataScalarChannel(data: PolyfaceData, channelIndex: number, name: string | undefined, inputName: string | undefined, input0: number, inputStep: number, numInput: number, dataType: AuxChannelDataType, scalarFunction: (input: number, xyz: Point3d) => number): void;
static readonly angle: Angle[];
static readonly angleSweep: AngleSweep[];
static appendPhases(linestring: LineString3d, numPhase: number, ...vectors: Vector3d[]): void;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/geometry-core",
"comment": "Flatbuffer i/o for TransitionSpiral and PolyfaceAuxData",
"type": "none"
}
],
"packageName": "@bentley/geometry-core",
"email": "[email protected]"
}
2 changes: 1 addition & 1 deletion core/geometry/src/curve/spiral/NormalizedTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export abstract class NormalizedTransition {
if (name === "clothoid")
return this._clothoidEvaluator ? this._clothoidEvaluator : (this._clothoidEvaluator = new NormalizedClothoidTransition());
if (name === "bloss")
return this._blossEvaluator ? this._clothoidEvaluator : (this._blossEvaluator = new NormalizedBlossTransition());
return this._blossEvaluator ? this._blossEvaluator : (this._blossEvaluator = new NormalizedBlossTransition());
if (name === "biquadratic")
return this._biquadraticEvaluator ? this._biquadraticEvaluator : (this._biquadraticEvaluator = new NormalizedBiQuadraticTransition());
if (name === "sine")
Expand Down
16 changes: 10 additions & 6 deletions core/geometry/src/polyface/AuxData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ export class AuxChannelData {
/** The vertex values for this data. A single value per vertex for scalar types and 3 values (x,y,z) for normal or vector channels. */
public values: number[];
/** Construct a new [[AuxChannelData]] from input value and vertex values. */
constructor(input: number, values: number[]) {
constructor(input: number, values: number[] | Float64Array) {
this.input = input;
this.values = values;
if (values instanceof Float64Array) {
this.values = [];
for (const v of values) this.values.push(v);
} else
this.values = values;
}
/** Copy blocks of size `blockSize` from (blocked index) `thisIndex` in this AuxChannelData to (blockIndex) `otherIndex` of `other` */
public copyValues(other: AuxChannelData, thisIndex: number, otherIndex: number, blockSize: number) {
Expand All @@ -49,7 +53,7 @@ export class AuxChannelData {
return new AuxChannelData(this.input, this.values.slice());
}
/** toleranced comparison of the `input` and `value` fields.
* * Default tolernace is 1.0e-8
* * Default tolerance is 1.0e-8
*/
public isAlmostEqual(other: AuxChannelData, tol?: number) {
const tolerance = tol ? tol : 1.0E-8;
Expand Down Expand Up @@ -114,12 +118,12 @@ export class AuxChannel {
/** The `PolyfaceAuxData` structure contains one or more analytical data channels for each vertex of a `Polyface`.
* Typically a `Polyface` will contain only vertex data required for its basic display,the vertex position, normal
* and possibly texture parameter. The `PolyfaceAuxData` structure contains supplemental data that is generally computed
* in an analysis program or other external data source. This can be scalar data used to either overide the vertex colors through *Thematic Colorization* or
* XYZ data used to deform the mesh by adjusting the vertex postions or normals.
* in an analysis program or other external data source. This can be scalar data used to either override the vertex colors through *Thematic Colorization* or
* XYZ data used to deform the mesh by adjusting the vertex positions or normals.
* @public
*/
export class PolyfaceAuxData {
/** Array with one or more channels of auxilliary data for the associated polyface. */
/** Array with one or more channels of auxiliary data for the associated polyface. */
public channels: AuxChannel[];
/** indices The indices (shared by all data in all channels) mapping the data to the mesh facets. */
public indices: number[];
Expand Down
Loading

0 comments on commit 12d79c0

Please sign in to comment.