🚧 Work on sampling
This commit is contained in:
parent
15f947a399
commit
513e29dac6
2 changed files with 48 additions and 40 deletions
|
@ -157,7 +157,7 @@ Path.prototype.boundary = function() {
|
||||||
/** Returns a deep copy of this */
|
/** Returns a deep copy of this */
|
||||||
Path.prototype.clone = function() {
|
Path.prototype.clone = function() {
|
||||||
let clone = new Path();
|
let clone = new Path();
|
||||||
clone.render = this.render = true;
|
clone.render = this.render;
|
||||||
if (this.topLeft) clone.topLeft = this.topLeft.clone();
|
if (this.topLeft) clone.topLeft = this.topLeft.clone();
|
||||||
else clone.topLeft = false;
|
else clone.topLeft = false;
|
||||||
if (this.bottomRight) clone.bottomRight = this.bottomRight.clone();
|
if (this.bottomRight) clone.bottomRight = this.bottomRight.clone();
|
||||||
|
|
|
@ -76,37 +76,36 @@ Pattern.prototype.sample = function() {
|
||||||
return this.sampleOption(this.settings.sample.option);
|
return this.sampleOption(this.settings.sample.option);
|
||||||
} else if (this.settings.sample.type === "measurement") {
|
} else if (this.settings.sample.type === "measurement") {
|
||||||
return this.sampleMeasurement(this.settings.sample.measurement);
|
return this.sampleMeasurement(this.settings.sample.measurement);
|
||||||
|
} else if (this.settings.sample.type === "models") {
|
||||||
|
return this.sampleModels(this.settings.sample.models);
|
||||||
}
|
}
|
||||||
this.draft();
|
this.draft();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Pattern.prototype.sampleParts = function() {
|
||||||
|
let parts = {};
|
||||||
|
this.settings.mode = "sample";
|
||||||
|
this.settings.paperless = false;
|
||||||
|
this.draft();
|
||||||
|
for (let i in this.parts) {
|
||||||
|
parts[i] = new Part();
|
||||||
|
parts[i].render = this.parts[i].render;
|
||||||
|
}
|
||||||
|
console.log("sample parts", parts);
|
||||||
|
return parts;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles option sampling
|
* Handles option sampling
|
||||||
*/
|
*/
|
||||||
Pattern.prototype.sampleOption = function(option) {
|
Pattern.prototype.sampleOption = function(option) {
|
||||||
this.settings.mode = "sample";
|
|
||||||
this.settings.paperless = "false";
|
|
||||||
let factor, step, val;
|
let factor, step, val;
|
||||||
let parts = {};
|
let parts = this.sampleParts();
|
||||||
if (typeof this.config.options[option].type === "undefined") factor = 100;
|
if (typeof this.config.options[option].type === "undefined") factor = 100;
|
||||||
else factor = 1;
|
else factor = 1;
|
||||||
val = this.config.options[option].min / factor;
|
val = this.config.options[option].min / factor;
|
||||||
step = (this.config.options[option].max / factor - val) / 9;
|
step = (this.config.options[option].max / factor - val) / 9;
|
||||||
// First run
|
for (let l = 1; l < 11; l++) {
|
||||||
this.options[option] = val;
|
|
||||||
this.draft();
|
|
||||||
for (let i in this.parts) {
|
|
||||||
parts[i] = new Part();
|
|
||||||
parts[i].render = this.parts[i].render;
|
|
||||||
for (let j in this.parts[i].paths) {
|
|
||||||
parts[i].paths[j + "_1"] = this.parts[i].paths[j]
|
|
||||||
.clone()
|
|
||||||
.attr("class", "sample-1", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Consecutive runs
|
|
||||||
for (let l = 2; l < 11; l++) {
|
|
||||||
val += step;
|
|
||||||
this.options[option] = val;
|
this.options[option] = val;
|
||||||
this.debug(`Sampling option ${option} with value ${val}`);
|
this.debug(`Sampling option ${option} with value ${val}`);
|
||||||
this.draft();
|
this.draft();
|
||||||
|
@ -117,6 +116,7 @@ Pattern.prototype.sampleOption = function(option) {
|
||||||
.attr("class", "sample-" + l, true);
|
.attr("class", "sample-" + l, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val += step;
|
||||||
}
|
}
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
|
|
||||||
|
@ -127,28 +127,11 @@ Pattern.prototype.sampleOption = function(option) {
|
||||||
* Handles measurement sampling
|
* Handles measurement sampling
|
||||||
*/
|
*/
|
||||||
Pattern.prototype.sampleMeasurement = function(measurement) {
|
Pattern.prototype.sampleMeasurement = function(measurement) {
|
||||||
this.settings.mode = "sample";
|
let parts = this.sampleParts();
|
||||||
this.settings.paperless = "false";
|
let val = this.settings.measurements[measurement];
|
||||||
let factor, step, val;
|
let step = val / 50;
|
||||||
let parts = {};
|
|
||||||
val = this.settings.measurements[measurement];
|
|
||||||
step = val / 50;
|
|
||||||
val = val * 0.9;
|
val = val * 0.9;
|
||||||
// First run
|
for (let l = 1; l < 11; l++) {
|
||||||
this.settings.measurements[measurement] = val;
|
|
||||||
this.draft();
|
|
||||||
for (let i in this.parts) {
|
|
||||||
parts[i] = new Part();
|
|
||||||
parts[i].render = this.parts[i].render;
|
|
||||||
for (let j in this.parts[i].paths) {
|
|
||||||
parts[i].paths[j + "_1"] = this.parts[i].paths[j]
|
|
||||||
.clone()
|
|
||||||
.attr("class", "sample-1", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Consecutive runs
|
|
||||||
for (let l = 2; l < 11; l++) {
|
|
||||||
val += step;
|
|
||||||
this.settings.measurements[measurement] = val;
|
this.settings.measurements[measurement] = val;
|
||||||
this.debug(`Sampling measurement ${measurement} with value ${val}`);
|
this.debug(`Sampling measurement ${measurement} with value ${val}`);
|
||||||
this.draft();
|
this.draft();
|
||||||
|
@ -159,6 +142,31 @@ Pattern.prototype.sampleMeasurement = function(measurement) {
|
||||||
.attr("class", "sample-" + l, true);
|
.attr("class", "sample-" + l, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val += step;
|
||||||
|
}
|
||||||
|
this.parts = parts;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles models sampling
|
||||||
|
*/
|
||||||
|
Pattern.prototype.sampleModels = function(models) {
|
||||||
|
let parts = this.sampleParts();
|
||||||
|
let count = 0;
|
||||||
|
for (let l in models) {
|
||||||
|
count++;
|
||||||
|
this.settings.measurements = models[l];
|
||||||
|
this.debug(`Sampling model ${l}`);
|
||||||
|
this.draft();
|
||||||
|
for (let i in this.parts) {
|
||||||
|
for (let j in this.parts[i].paths) {
|
||||||
|
parts[i].paths[j + "_" + count] = this.parts[i].paths[j]
|
||||||
|
.clone()
|
||||||
|
.attr("class", "sample-" + count, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue