修复:圆的包围盒错误的问题

pull/1826/head
ChenX 3 years ago
parent bd0bc02bb3
commit 2c744de1e0

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`圆的包围盒 1`] = `
Box3 {
"max": Vector3 {
"x": 797.2893269281506,
"y": 28.66753717738038,
"z": 0,
},
"min": Vector3 {
"x": -653.9554950751378,
"y": -1422.577284825908,
"z": 0,
},
}
`;

@ -0,0 +1,9 @@
import { Circle } from "../../src/api";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('圆的包围盒', () =>
{
let d = { "file": [1, "Region", 8, 2, 105, false, 1, 7, 0, [0.6691018466770633, 0.7431707198035619, 0, 0, -0.7431707198035619, 0.6691018466770633, 0, 0, 0, 0, -1, 0, 71.6669159265063, -696.9548738242638, 0, 1], 0, 0, true, [0.6691018466770633, 0.7431707198035619, 0, 0, -0.7431707198035619, 0.6691018466770633, 0, 0, 0, 0, -1, 0, 71.6669159265063, -696.9548738242638, 0, 1], 0, 1, 1, 1, 1, "Circle", 8, 2, 0, false, 0, 7, 0, [0.6691018466770633, 0.7431707198035619, 0, 0, 0.7431707198035619, -0.6691018466770633, 0, 0, 0, 0, -1, 0, 71.6669159265063, -696.9548738242638, 0, 1], 0, 0, true, [0.7431707198035619, -0.6691018466770633, 0, 0, 0.6691018466770633, 0.7431707198035619, 0, 0, 0, 0, -1, 0, -2215.799673512821, 1439.917154472948, 0, 1], 0, 1, 725.6224110016442, 0], "basePt": { "x": -653.9554950751378, "y": -1422.577284825908, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let ens = LoadEntityFromFileData(d) as Circle[];
expect(ens[0].BoundingBox).toMatchSnapshot();
});

@ -1,6 +1,6 @@
import { Matrix4, Quaternion, Vector2, Vector3 } from 'three'; import { Matrix4, Quaternion, Vector2, Vector3 } from 'three';
import { CoordinateSystem } from '../Geometry/CoordinateSystem'; import { CoordinateSystem } from '../Geometry/CoordinateSystem';
import { equaln, isParallelTo, ZAxis } from '../Geometry/GeUtils'; import { equaln, isParallelTo } from '../Geometry/GeUtils';
/** /**
* *
@ -167,4 +167,4 @@ export function NormalMatrix(mtx: Matrix4)
export const tempMatrix1 = new Matrix4; export const tempMatrix1 = new Matrix4;
export const ZMirrorMatrix = GetMirrorMat(ZAxis); export const ZMirrorMatrix = GetMirrorMat(new Vector3(0, 0, 1));

@ -10,6 +10,7 @@ import { ObjectSnapMode } from '../../Editor/ObjectSnapMode';
import { Box3Ext } from '../../Geometry/Box'; import { Box3Ext } from '../../Geometry/Box';
import { BufferGeometryUtils } from '../../Geometry/BufferGeometryUtils'; import { BufferGeometryUtils } from '../../Geometry/BufferGeometryUtils';
import { angle, AsVector3, equaln, equalv2, MoveMatrix, polar, ZeroVec } from '../../Geometry/GeUtils'; import { angle, AsVector3, equaln, equalv2, MoveMatrix, polar, ZeroVec } from '../../Geometry/GeUtils';
import { Orbit } from '../../Geometry/Orbit';
import { IntersectCircleAndArc, IntersectCircleAndCircle, IntersectEllipseAndCircleOrArc, IntersectLineAndCircle, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../../GraphicsSystem/IntersectWith'; import { IntersectCircleAndArc, IntersectCircleAndCircle, IntersectEllipseAndCircleOrArc, IntersectLineAndCircle, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../../GraphicsSystem/IntersectWith';
import { RenderType } from '../../GraphicsSystem/RenderType'; import { RenderType } from '../../GraphicsSystem/RenderType';
import { Factory } from '../CADFactory'; import { Factory } from '../CADFactory';
@ -238,9 +239,20 @@ export class Circle extends Curve
} }
//******************** Curve function end*****************// //******************** Curve function end*****************//
get BoundingBoxInOCS(): Box3Ext
{
return new Box3Ext(new Vector3(-this.Radius, -this.Radius), new Vector3(this.Radius, this.Radius));
}
get BoundingBox(): Box3Ext get BoundingBox(): Box3Ext
{ {
return new Box3Ext().setFromPoints(this.GetGripPoints()); let z = this.Normal;
let x = new Vector3;
let y = new Vector3;
Orbit.ComputUpDirection(z, y, x);
let m = new Matrix4().makeBasis(x, y, z).setPosition(this.Center);
//使用任意轴坐标系 以便我们正确的对齐世界坐标系
return this.BoundingBoxInOCS.applyMatrix4(m);
} }
InitDrawObject(renderType: RenderType = RenderType.Wireframe) InitDrawObject(renderType: RenderType = RenderType.Wireframe)

@ -1,13 +1,13 @@
import { Box3, Matrix4, Vector3 } from "three"; import { Box3, Matrix4, Vector3 } from "three";
import { MatrixPlanarizere } from "../../Common/Matrix4Utils"; import { MatrixPlanarizere } from "../../Common/Matrix4Utils";
import { Contour } from "../../DatabaseServices/Contour";
import { Board } from "../../DatabaseServices/Entity/Board"; import { Board } from "../../DatabaseServices/Entity/Board";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { Region } from "../../DatabaseServices/Entity/Region"; import { Region } from "../../DatabaseServices/Entity/Region";
import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils"; import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
import { Box3Ext } from "../Box"; import { Box3Ext } from "../Box";
import { equaln, XAxis } from "../GeUtils"; import { equaln, XAxis } from "../GeUtils";
import { BoardFaceType } from "./BoardGetFace"; import { BoardFaceType } from "./BoardGetFace";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { Contour } from "../../DatabaseServices/Contour";
export interface BoardFaceParams export interface BoardFaceParams
{ {

Loading…
Cancel
Save