📄 polyhedralboundedsolidmodelingtools.java
字号:
private static PolyhedralBoundedSolid[] buildCsgTest3() { PolyhedralBoundedSolid operands[]; PolyhedralBoundedSolid a, b; operands = new PolyhedralBoundedSolid[2]; //----------------------------------------------------------------- a = new PolyhedralBoundedSolid(); a.mvfs( new Vector3D(0.00+0.05, 0.42+0.05, 0.00+0.05), 1, 1); a.smev(1, 1, 2, new Vector3D(0.92+0.05, 0.42+0.05, 0.00+0.05)); a.smev(1, 2, 3, new Vector3D(0.92+0.05, 0.42+0.05, 0.72+0.05)); a.smev(1, 3, 4, new Vector3D(0.70+0.05, 0.42+0.05, 0.72+0.05)); a.smev(1, 4, 5, new Vector3D(0.70+0.05, 0.42+0.05, 0.18+0.05)); a.smev(1, 5, 6, new Vector3D(0.00+0.05, 0.42+0.05, 0.18+0.05)); a.mef(1, 1, 6, 5, 1, 2, 2); a.validateModel(); Matrix4x4 T = new Matrix4x4(); T.translation(0, -0.42, 0); GeometricModeler.translationalSweepExtrudeFacePlanar( a, a.findFace(1), T); //----------------------------------------------------------------- Matrix4x4 R = new Matrix4x4(); R.translation(0.05 +0.58/2.0+(0.92-0.58) /*+ 0.0001*/, 0.05 + 0.42/2.0 - 0.42/2.0, 0.05 + 0.18/2.0 + 0.18 /*+ 0.0001*/); Box box = new Box(new Vector3D(0.58, 0.42, 0.18)); b = box.exportToPolyhedralBoundedSolid(); b.applyTransformation(R); b.validateModel(); //----------------------------------------------------------------- operands[0] = a; operands[1] = b; return operands; } public static PolyhedralBoundedSolid[] buildCsgTest4() { PolyhedralBoundedSolid operands[]; operands = new PolyhedralBoundedSolid[2]; PolyhedralBoundedSolid a; PolyhedralBoundedSolid b; PolyhedralBoundedSolid c; PolyhedralBoundedSolid d; PolyhedralBoundedSolid x; PolyhedralBoundedSolid y; Matrix4x4 T; Box box; //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.1, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); a = box.exportToPolyhedralBoundedSolid(); a.applyTransformation(T); a.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.9, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); b = box.exportToPolyhedralBoundedSolid(); b.applyTransformation(T); b.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); c = box.exportToPolyhedralBoundedSolid(); c.applyTransformation(T); c.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.9, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); d = box.exportToPolyhedralBoundedSolid(); d.applyTransformation(T); d.validateModel(); //----------------------------------------------------------------- x = GeometricModeler.setOp(b, c, GeometricModeler.UNION); y = GeometricModeler.setOp(a, d, GeometricModeler.UNION); operands[0] = x; operands[1] = y; return operands; } public static PolyhedralBoundedSolid[] buildCsgTest5() { PolyhedralBoundedSolid operands[]; operands = new PolyhedralBoundedSolid[2]; PolyhedralBoundedSolid a; PolyhedralBoundedSolid b; PolyhedralBoundedSolid c; PolyhedralBoundedSolid d; PolyhedralBoundedSolid e; PolyhedralBoundedSolid f; PolyhedralBoundedSolid g; PolyhedralBoundedSolid h; PolyhedralBoundedSolid ac; PolyhedralBoundedSolid bd; PolyhedralBoundedSolid eg; PolyhedralBoundedSolid fh; PolyhedralBoundedSolid abcd; PolyhedralBoundedSolid efgh; PolyhedralBoundedSolid total; Matrix4x4 T; Box box; //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.1, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); a = box.exportToPolyhedralBoundedSolid(); a.applyTransformation(T); a.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.9, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); b = box.exportToPolyhedralBoundedSolid(); b.applyTransformation(T); b.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); c = box.exportToPolyhedralBoundedSolid(); c.applyTransformation(T); c.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.9, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); d = box.exportToPolyhedralBoundedSolid(); d.applyTransformation(T); d.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); e = box.exportToPolyhedralBoundedSolid(); e.applyTransformation(T); e.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.9); box = new Box(new Vector3D(0.2, 1, 0.2)); f = box.exportToPolyhedralBoundedSolid(); f.applyTransformation(T); f.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.1, 0.5); box = new Box(new Vector3D(0.2, 0.2, 1)); g = box.exportToPolyhedralBoundedSolid(); g.applyTransformation(T); g.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.9, 0.5); box = new Box(new Vector3D(0.2, 0.2, 1)); h = box.exportToPolyhedralBoundedSolid(); h.applyTransformation(T); h.validateModel(); //-----------------------------------------------------------------/* ac = GeometricModeler.setOp(a, c, GeometricModeler.UNION); bd = GeometricModeler.setOp(b, d, GeometricModeler.UNION); abcd = GeometricModeler.setOp(bd, ac, GeometricModeler.UNION); eg = GeometricModeler.setOp(e, g, GeometricModeler.UNION); fh = GeometricModeler.setOp(f, h, GeometricModeler.UNION); efgh = GeometricModeler.setOp(eg, fh, GeometricModeler.UNION); total = GeometricModeler.setOp(abcd, efgh, GeometricModeler.UNION);*/ ac = GeometricModeler.setOp(a, c, GeometricModeler.UNION); operands[0] = ac; operands[1] = g; return operands; } public static PolyhedralBoundedSolid csgTest(int part, int op, int set) { PolyhedralBoundedSolid res = null; PolyhedralBoundedSolid operands[] = null; switch ( set ) { case 0: operands = buildCsgTest1(); break; case 1: operands = buildCsgTest2(); break; case 2: default: operands = buildCsgTest3(); break; case 3: operands = buildCsgTest4(); break; case 4: operands = buildCsgTest5(); break; } //----------------------------------------------------------------- if ( op == 0 ) { res = GeometricModeler.setOp(operands[0], operands[1], GeometricModeler.UNION); } else if ( op == 1 ) { res = GeometricModeler.setOp(operands[0], operands[1], GeometricModeler.INTERSECTION); } else if ( op == 2 ) { res = GeometricModeler.setOp(operands[0], operands[1], GeometricModeler.DIFFERENCE); } else { res = vsdk.toolkit.processing.PolyhedralBoundedSolidSetOperator.setOp(operands[1], operands[0], GeometricModeler.DIFFERENCE, true); } //----------------------------------------------------------------- //operands[0].validateModel(); //operands[1].validateModel(); //res.validateModel(); if ( part == 2 ) { return operands[0]; } if ( part == 3 ) { return operands[1]; } return res; } /** This method uses basic blocks and constructive solid geometry to build up a test object similar to the one appearing in the middle of figure [APPE1967].7. */ public static PolyhedralBoundedSolid createTestObjectAPPE1967_1() { PolyhedralBoundedSolid a; PolyhedralBoundedSolid b; PolyhedralBoundedSolid c; PolyhedralBoundedSolid d; PolyhedralBoundedSolid e; PolyhedralBoundedSolid f; PolyhedralBoundedSolid g; PolyhedralBoundedSolid h; PolyhedralBoundedSolid ac; PolyhedralBoundedSolid bd; PolyhedralBoundedSolid eg; PolyhedralBoundedSolid fh; PolyhedralBoundedSolid abcd; PolyhedralBoundedSolid efgh; PolyhedralBoundedSolid total; Matrix4x4 T; Box box; //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.1, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); a = box.exportToPolyhedralBoundedSolid(); a.applyTransformation(T); a.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.5, 0.9, 0.1); box = new Box(new Vector3D(1, 0.2, 0.2)); b = box.exportToPolyhedralBoundedSolid(); b.applyTransformation(T); b.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); c = box.exportToPolyhedralBoundedSolid(); c.applyTransformation(T); c.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.9, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); d = box.exportToPolyhedralBoundedSolid(); d.applyTransformation(T); d.validateModel(); //----------------------------------------------------------------- ac = GeometricModeler.setOp(a, c, GeometricModeler.UNION); bd = GeometricModeler.setOp(b, d, GeometricModeler.UNION); abcd = GeometricModeler.setOp(bd, ac, GeometricModeler.UNION); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.1); box = new Box(new Vector3D(0.2, 1, 0.2)); e = box.exportToPolyhedralBoundedSolid(); e.applyTransformation(T); e.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.5, 0.9); box = new Box(new Vector3D(0.2, 1, 0.2)); f = box.exportToPolyhedralBoundedSolid(); f.applyTransformation(T); f.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.1, 0.5); box = new Box(new Vector3D(0.2, 0.2, 1)); g = box.exportToPolyhedralBoundedSolid(); g.applyTransformation(T); g.validateModel(); //----------------------------------------------------------------- T = new Matrix4x4(); T.translation(0.1, 0.9, 0.5); box = new Box(new Vector3D(0.2, 0.2, 1)); h = box.exportToPolyhedralBoundedSolid(); h.applyTransformation(T); h.validateModel(); //----------------------------------------------------------------- eg = GeometricModeler.setOp(e, g, GeometricModeler.UNION); fh = GeometricModeler.setOp(f, h, GeometricModeler.UNION); efgh = GeometricModeler.setOp(eg, fh, GeometricModeler.UNION); total = GeometricModeler.setOp(abcd, efgh, GeometricModeler.UNION); return total; } public static PolyhedralBoundedSolid featuredObject() { return createTestObjectAPPE1967_1(); }}//===========================================================================//= EOF =//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -