!736 修复:可视化空间组合模块重新插入后位置错误

pull/736/MERGE
ChenX 5 years ago
parent 17238d13e6
commit 27e1782e38

@ -63,6 +63,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -70,11 +71,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
12894.930226116076, 12894.930226116076,
2842.319170941113, 2842.319170941113,
@ -151,6 +151,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -158,11 +159,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
10446.983595066009, 10446.983595066009,
1388.102138836301, 1388.102138836301,
@ -239,17 +239,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
1,
0, 0,
0, 0,
12914.564115164869, 12914.564115164869,
@ -327,17 +327,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
1,
0, 0,
0, 0,
10466.617484114802, 10466.617484114802,
@ -415,6 +415,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -422,11 +423,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
6616.16932305587, 6616.16932305587,
-742.3895682910902, -742.3895682910902,
@ -503,6 +503,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -510,11 +511,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
5161.952290951059, 5161.952290951059,
1705.5570627589764, 1705.5570627589764,
@ -591,18 +591,18 @@ Array [
0, 0,
true, true,
Array [ Array [
1, 0,
-1,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
0, 0,
1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
6627.832949827407, 6627.832949827407,
-762.023457339882, -762.023457339882,
@ -679,17 +679,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
1,
0, 0,
0, 0,
5173.615917722596, 5173.615917722596,
@ -767,6 +767,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -774,11 +775,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1751.8974541083676, 1751.8974541083676,
299.7749726109571, 299.7749726109571,
@ -855,6 +855,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -862,11 +863,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
3431.595987302148, 3431.595987302148,
2598.8623399199423, 2598.8623399199423,
@ -943,18 +943,18 @@ Array [
0, 0,
true, true,
Array [ Array [
1, 0,
-1,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
0, 0,
1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1738.4253406979547, 1738.4253406979547,
281.3350173804545, 281.3350173804545,
@ -1031,18 +1031,18 @@ Array [
0, 0,
true, true,
Array [ Array [
1, 0,
-1,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
0, 0,
1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
3418.123873891735, 3418.123873891735,
2580.42238468944, 2580.42238468944,
@ -1129,7 +1129,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
165.07177033492815, 165.07177033492815,
-28.708133971291886, -28.708133971291886,
@ -1217,7 +1217,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
165.07177033492815, 165.07177033492815,
325.3588516746412, 325.3588516746412,
@ -1295,7 +1295,7 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0, 0,
0, 0,
0, 0,
@ -1383,7 +1383,7 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0, 0,
0, 0,
0, 0,
@ -1481,7 +1481,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
536.4832535885167, 536.4832535885167,
-57.41626794258377, -57.41626794258377,
@ -1569,7 +1569,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
536.4832535885167, 536.4832535885167,
355.2631578947369, 355.2631578947369,
@ -1657,7 +1657,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
536.4832535885167, 536.4832535885167,
361.244019138756, 361.244019138756,
@ -1745,7 +1745,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
536.4832535885167, 536.4832535885167,
-130.38277511961724, -130.38277511961724,
@ -1833,7 +1833,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1312.6190866251177, 1312.6190866251177,
106.24566430597008, 106.24566430597008,
@ -1921,7 +1921,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1513.842375671903, 1513.842375671903,
396.11977300273793, 396.11977300273793,
@ -1999,7 +1999,7 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0, 0,
0, 0,
0, 0,
@ -2087,7 +2087,7 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0, 0,
0, 0,
0, 0,
@ -2185,7 +2185,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1559.0621642262122, 1559.0621642262122,
-190.05604619216146, -190.05604619216146,
@ -2273,7 +2273,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1835.999978982127, 1835.999978982127,
208.889337302373, 208.889337302373,
@ -2361,7 +2361,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1835.999978982127, 1835.999978982127,
208.8893373023729, 208.8893373023729,
@ -2449,7 +2449,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
1559.0621642262122, 1559.0621642262122,
-190.0560461921616, -190.0560461921616,
@ -2537,7 +2537,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
2647.8208243286344, 2647.8208243286344,
272.7242103631359, 272.7242103631359,
@ -2625,7 +2625,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
3169.8822406013596, 3169.8822406013596,
272.7242103631359, 272.7242103631359,
@ -2703,17 +2703,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -0.9999999999999999,
0, 0,
0, 0,
0, 0,
0, 0,
1, 0.9999999999999998,
0, 0,
0, 0,
0, 0,
0, 0,
1, 0.9999999999999999,
0, 0,
2722.4010266533096, 2722.4010266533096,
272.7242103631359, 272.7242103631359,
@ -2791,17 +2791,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -0.9999999999999999,
0, 0,
0, 0,
0, 0,
0, 0,
1, 0.9999999999999998,
0, 0,
0, 0,
0, 0,
0, 0,
1, 0.9999999999999999,
0, 0,
3337.122694299116, 3337.122694299116,
272.7242103631359, 272.7242103631359,
@ -2884,13 +2884,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
2966.0573424695885, 2966.0573424695885,
0, 0,
493.8714486099474, 493.8714486099474,
@ -2972,13 +2972,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
2966.0573424695885, 2966.0573424695885,
0, 0,
1488.0701817589372, 1488.0701817589372,
@ -3060,13 +3060,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
2966.0573424695885, 2966.0573424695885,
0, 0,
1494.526017688476, 1494.526017688476,
@ -3148,13 +3148,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
2966.0573424695885, 2966.0573424695885,
0, 0,
355.0709761248611, 355.0709761248611,
@ -3236,13 +3236,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
3787.5624645034113, 3787.5624645034113,
0, 0,
280.8288629351637, 280.8288629351637,
@ -3324,13 +3324,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
3787.5624645034113, 3787.5624645034113,
0, 0,
1568.7681308781732, 1568.7681308781732,
@ -3407,7 +3407,8 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0,
0, 0,
0, 0,
0, 0,
@ -3415,10 +3416,9 @@ Array [
1, 1,
0, 0,
0, 0,
-1,
0, 0,
0, 0,
1,
0,
3787.5624645034113, 3787.5624645034113,
0, 0,
287.28469886470253, 287.28469886470253,
@ -3495,17 +3495,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1, -1,
0, 0,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
-1,
0, 0,
1,
0, 0,
3787.5624645034113, 3787.5624645034113,
0, 0,
@ -3588,13 +3588,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
5138.446132759425, 5138.446132759425,
0, 0,
468.0481048917915, 468.0481048917915,
@ -3676,13 +3676,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
5138.446132759425, 5138.446132759425,
0, 0,
1820.5457321301901, 1820.5457321301901,
@ -3764,13 +3764,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
5138.446132759425, 5138.446132759425,
0, 0,
1865.7365836369622, 1865.7365836369622,
@ -3852,13 +3852,13 @@ Array [
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
1,
0, 0,
0, 0,
1, 1,
0, 0,
0,
5138.446132759425, 5138.446132759425,
0, 0,
225.95425753408313, 225.95425753408313,
@ -3945,7 +3945,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
4345.085428747755, 4345.085428747755,
243.34413065947604, 243.34413065947604,
@ -4033,7 +4033,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
4776.746599778449, 4776.746599778449,
243.34413065947604, 243.34413065947604,
@ -4121,7 +4121,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
5095.4074642566065, 5095.4074642566065,
243.34413065947604, 243.34413065947604,
@ -4209,7 +4209,7 @@ Array [
0, 0,
0, 0,
0, 0,
1, -1,
0, 0,
4220.785091539963, 4220.785091539963,
243.34413065947604, 243.34413065947604,
@ -4287,17 +4287,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
1,
0, 0,
0, 0,
-9261.8098163142, -9261.8098163142,
@ -4375,17 +4375,17 @@ Array [
0, 0,
true, true,
Array [ Array [
1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0, 0,
1,
0, 0,
1,
0, 0,
0, 0,
1,
0, 0,
0, 0,
-12908.882324806651, -12908.882324806651,
@ -4463,6 +4463,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -4470,11 +4471,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
-9179.088411275692, -9179.088411275692,
-1281.0752449021734, -1281.0752449021734,
@ -4551,6 +4551,7 @@ Array [
0, 0,
true, true,
Array [ Array [
0,
1, 1,
0, 0,
0, 0,
@ -4558,11 +4559,10 @@ Array [
0, 0,
1, 1,
0, 0,
-1,
0, 0,
0, 0,
0, 0,
1,
0,
0, 0,
-12826.160919768143, -12826.160919768143,
5118.948770000711, 5118.948770000711,

@ -61,7 +61,6 @@ export class DrawVisualSpaceBox implements Command
let box = template.Objects[0].Object as VisualSpaceBox; let box = template.Objects[0].Object as VisualSpaceBox;
m.setPosition(pt); m.setPosition(pt);
box.ApplyMatrix(m); box.ApplyMatrix(m);
box.SpaceOCS = m;
} }
} }

@ -3,6 +3,8 @@ import { TemplateVisualSpace } from "../../DatabaseServices/Template/ProgramTemp
import { Command } from "../../Editor/CommandMachine"; import { Command } from "../../Editor/CommandMachine";
import { HotCMD } from "../../Hot/HotCommand"; import { HotCMD } from "../../Hot/HotCommand";
import { TemplateSplitType } from "../../DatabaseServices/Template/TemplateType"; import { TemplateSplitType } from "../../DatabaseServices/Template/TemplateType";
import { SelectTempate } from "../../DatabaseServices/Template/TemplateTest";
import { Entity } from "../../DatabaseServices/Entity/Entity";
@HotCMD @HotCMD
export class Test implements Command export class Test implements Command
@ -10,42 +12,15 @@ export class Test implements Command
async exec() async exec()
{ {
// let ent = new VisualSpaceBox(1000, 1000, 1000); let t = await SelectTempate();
// TestDraw(ent); if (!t) return;
let template = new TemplateVisualSpace();
template.InitBaseParams();
template.LParam.expr = 2000;
template.HParam.expr = 1800;
template.WParam.expr = 600;
app.Database.TemplateTable.Append(template); let objs = t.Objects.map(t => t.Object).filter(o => o !== undefined && !o.IsErase) as Entity[];
if (true) for (let o of objs)
{ {
await template.UpdateTemplateTree(); o.ApplyMatrix(o.SpaceOCSInv);
return;
};
let t = template;
if (t.Children.length === 0)
{
t.SplitType = TemplateSplitType.X;
for (let i = 0; i < 3; i++)
{
let tc = new TemplateVisualSpace().InitBaseParams();
tc.LParam.expr = "_DIV";
tc.WParam.expr = "_W";
tc.HParam.expr = "_H";
tc.PXParam.expr = "_POS";
app.Database.TemplateTable.Append(tc);
t.Children.push(tc.Id);
}
await t.UpdateTemplateTree();
} }
await template.UpdateTemplateTree();
} }
} }

@ -550,13 +550,12 @@ export class Board extends ExtrudeSolid
return this._Rotation; return this._Rotation;
} }
ApplyMatrix(m: Matrix4): this // ApplyMatrix(m: Matrix4): this
{ // {
super.ApplyMatrix(m); // super.ApplyMatrix(m);
if (equaln(m.getMaxScaleOnAxis(), 1)) // return this;
this._SpaceOCS.multiplyMatrices(m, this._SpaceOCS); // }
return this;
}
protected ApplyScaleMatrix(m: Matrix4): this protected ApplyScaleMatrix(m: Matrix4): this
{ {
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();

@ -471,6 +471,7 @@ export class Entity extends CADObject
let zA = new Vector3(); let zA = new Vector3();
m.extractBasis(xA, yA, zA); m.extractBasis(xA, yA, zA);
this._Matrix.multiplyMatrices(m, this._Matrix); this._Matrix.multiplyMatrices(m, this._Matrix);
this._SpaceOCS.multiplyMatrices(m, this._SpaceOCS);
if (!equalv3(xA.clone().cross(yA).normalize(), zA)) if (!equalv3(xA.clone().cross(yA).normalize(), zA))
this.ApplyMirrorMatrix(m); this.ApplyMirrorMatrix(m);
else else

@ -1079,7 +1079,8 @@ export function ReplaceTemplate(oldTemp: TemplateRecord, newTemp: TemplateRecord
{ {
for (let i = 0; i < 9; i++) for (let i = 0; i < 9; i++)
{ {
newTemp.Params[i].expr = oldTemp.Params[i].expr; let p = oldTemp.Params[i];
newTemp.Params[i].expr = p.expr === "" ? p.value : p.expr;
} }
newTemp.Positioning = oldTemp.Positioning; newTemp.Positioning = oldTemp.Positioning;
if (oldTemp.Parent) if (oldTemp.Parent)

@ -125,12 +125,21 @@ export class TemplateRecord extends SymbolTableRecord
}); });
} }
get Entitys()
{
return this.Objects.map(o => o.Object as Entity);
}
get AllEntitys(): Entity[] get AllEntitys(): Entity[]
{ {
let entitys: Entity[] = []; let entitys: Entity[] = [];
this.Traverse((t) => this.Traverse((t) =>
{ {
entitys.push(...t.Objects.map(o => o.Object as Entity)); for (let o of t.Objects)
{
if (!o.IsErase)
entitys.push(o.Object as Entity);
}
}); });
return entitys; return entitys;
} }

@ -247,7 +247,7 @@ export class TemplateManage extends React.Component<{ store?: TempalteEditorStor
for (let e of nens) for (let e of nens)
e.ApplyMatrix(mtx); e.ApplyMatrix(mtx);
await (nens[0].Template.Object as TemplateRecord).Root.UpdateTemplateTree(); await newTemp.Root.UpdateTemplateTree();
} }
break; break;
} }
@ -322,16 +322,6 @@ export class TemplateManage extends React.Component<{ store?: TempalteEditorStor
template.WParam.expr = parse.Size.y; template.WParam.expr = parse.Size.y;
template.HParam.expr = parse.Size.z; template.HParam.expr = parse.Size.z;
} }
let ens = template.Objects.map(obj => obj.Object as Board).filter(br => !br.IsErase);
if (ens.length > 0)
{
let parseOCS = parse.SpaceOCS.clone().setPosition(parse.SpaceBox.min.clone().applyMatrix4(parse.SpaceOCS));
let mtx = ens[0].SpaceOCSInv.premultiply(parseOCS);
for (let e of ens)
e.ApplyMatrix(mtx);
}
} }
await template.UpdateTemplateTree(); await template.UpdateTemplateTree();
}; };

Loading…
Cancel
Save