jsketcher/test/coreTests/testCases/legacy/brep-bool-topo.js
2020-03-24 00:08:30 -07:00

283 lines
17 KiB
JavaScript

import {defineTests} from '../craftTestUtils';
export default defineTests([
{
'name': 'CutInMiddle',
'state': {
'sketches': {'0:3': {'Segment': [[[-101, 100], [100, 100]], [[100, 100], [100, -100]], [[100, -100], [-101, -100]], [[-101, -100], [-101, 100]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 250, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -100, -101], [-250, -100, 100], [-250, 100, -101], [-250, 100, 100], [-250, 250, -250], [-250, 250, 250], [0, -100, -101], [0, -100, 100], [0, 100, -101], [0, 100, 100], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[12, 13, 1, 0]], [[14, 15, 13, 12]], [[6, 7, 15, 14]], [[7, 1, 13, 15]], [[12, 0, 6, 14]], [[4, 2, 8, 10]], [[2, 3, 9, 8]], [[3, 5, 11, 9]], [[5, 4, 10, 11]], [[11, 10, 8, 9]], [[6, 0, 1, 7], [3, 2, 4, 5]]]
}
},
{
'name': 'ExtrudeInMiddle',
'state': {
'sketches': {'0:3': {'Segment': [[[-101, 100], [100, 100]], [[100, 100], [100, -100]], [[100, -100], [-101, -100]], [[-101, -100], [-101, 100]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': 250, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-500, -100, -101], [-500, -100, 100], [-500, 100, -101], [-500, 100, 100], [-250, -250, -250], [-250, -250, 250], [-250, -100, -101], [-250, -100, 100], [-250, 100, -101], [-250, 100, 100], [-250, 250, -250], [-250, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[12, 13, 5, 4]], [[14, 15, 13, 12]], [[10, 11, 15, 14]], [[11, 5, 13, 15]], [[12, 4, 10, 14]], [[3, 9, 8, 2]], [[1, 7, 9, 3]], [[0, 6, 7, 1]], [[2, 8, 6, 0]], [[3, 2, 0, 1]], [[10, 4, 5, 11], [7, 6, 8, 9]]]
}
},
{
'name': 'cutThroughAdjacent',
'state': {
'sketches': {'0:3': {'Segment': [[[-101, 100], [100, 100]], [[100, 100], [100, -100]], [[100, -100], [-101, -100]], [[-101, -100], [-101, 100]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 500, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -100, -101], [-250, -100, 100], [-250, 100, -101], [-250, 100, 100], [-250, 250, -250], [-250, 250, 250], [250, -250, -250], [250, -250, 250], [250, -100, -101], [250, -100, 100], [250, 100, -101], [250, 100, 100], [250, 250, -250], [250, 250, 250]],
'faces': [[[8, 9, 1, 0]], [[6, 7, 15, 14]], [[7, 1, 9, 15]], [[8, 0, 6, 14]], [[4, 2, 10, 12]], [[2, 3, 11, 10]], [[3, 5, 13, 11]], [[5, 4, 12, 13]], [[8, 14, 15, 9], [11, 13, 12, 10]], [[6, 0, 1, 7], [3, 2, 4, 5]]]
}
},
{
'name': 'Adjacent2Edges2Face',
'state': {
'sketches': {'0:3': {'Segment': [[[250, 250], [0, 250]], [[0, 250], [0, 0]], [[0, 0], [250, 0]], [[250, 0], [250, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 250, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, 0, 0], [-250, 0, 250], [-250, 250, -250], [-250, 250, 0], [0, 0, 0], [0, 0, 250], [0, 250, 0], [0, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[10, 11, 1, 0]], [[12, 13, 11, 10]], [[10, 0, 4, 12]], [[5, 2, 6, 8]], [[2, 3, 7, 6]], [[7, 9, 8, 6]], [[5, 8, 9, 13, 12, 4]], [[3, 2, 5, 4, 0, 1]], [[9, 7, 3, 1, 11, 13]]]
}
},
{
'name': 'Adjacent2Edges2FaceExtrude',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 250], [250, 250]], [[250, 250], [250, -8]], [[250, -8], [-21, -8]], [[-21, -8], [-21, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-300, -8, -21], [-300, -8, 250], [-300, 250, -21], [-300, 250, 250], [-250, -250, -250], [-250, -250, 250], [-250, -8, -21], [-250, -8, 250], [-250, 250, -250], [-250, 250, -21], [-250, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[11, 12, 5, 4]], [[13, 14, 12, 11]], [[11, 4, 8, 13]], [[0, 6, 7, 1]], [[2, 9, 6, 0]], [[3, 2, 0, 1]], [[2, 3, 10, 14, 13, 8, 9]], [[7, 6, 9, 8, 4, 5]], [[3, 1, 7, 5, 12, 14, 10]]]
}
},
{
'name': 'VertexOnEdge',
'state': {
'sketches': {
'0:4': {'Segment': [[[250, 140], [78, -146]], [[78, -146], [466, -131]], [[466, -131], [250, 140]]]},
},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:4'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, 250, -250], [-250, 250, 250], [78, -146, 200], [78, -146, 250], [250, -139, 200], [250, -250, -250], [250, -250, 250], [250, -139, 250], [250, 140, 200], [250, 140, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[7, 8, 1, 0]], [[10, 6, 9, 8, 7, 12, 13, 11]], [[2, 3, 13, 12]], [[0, 1, 3, 2]], [[7, 0, 2, 12]], [[11, 5, 4, 10]], [[9, 6, 4, 5]], [[6, 10, 4]], [[9, 5, 11, 13, 3, 1, 8]]]
}
},
{
'name': 'AdjacentAndStickingOut',
'state': {
'sketches': {'0:3': {'Segment': [[[-510, 250], [91, 250]], [[91, 250], [91, -1]], [[91, -1], [-510, -1]], [[-510, -1], [-510, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -1, -250], [-250, -1, 91], [-250, 250, 91], [-250, 250, 250], [-200, -1, -250], [-200, -1, 91], [-200, 250, -250], [-200, 250, 91], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[10, 11, 1, 0]], [[12, 13, 11, 10]], [[5, 1, 11, 13]], [[6, 8, 12, 10, 0, 2]], [[6, 2, 3, 7]], [[3, 4, 9, 7]], [[8, 6, 7, 9]], [[8, 9, 4, 5, 13, 12]], [[4, 3, 2, 0, 1, 5]]]
}
},
{
'name': 'MergedFacesCreateIntersectionCurve',
'state': {
'sketches': {
'1:5': {'Segment': [[[92, 144], [351, 144]], [[351, 144], [351, -106]], [[351, -106], [92, -106]], [[92, -106], [92, 144]]]},
'0:2': {'Segment': [[[-172, 145], [30, 145]], [[30, 145], [30, -99]], [[30, -99], [-172, -99]], [[-172, -99], [-172, 145]]]}
},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:2'}
}, {'type': 'CUT', 'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '1:5'}}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, 200, -106], [-250, 200, 144], [-250, 250, -250], [-250, 250, -106], [-250, 250, 144], [-250, 250, 250], [-92, 200, -106], [-92, 200, 144], [-92, 250, -106], [-92, 250, 144], [-30, 200, -99], [-30, 200, 145], [-30, 250, -99], [-30, 250, 145], [172, 200, -99], [172, 200, 145], [172, 250, -99], [172, 250, 145], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[0, 20, 21, 1]], [[20, 22, 23, 21]], [[3, 2, 5, 4, 0, 1, 7, 6]], [[23, 7, 1, 21]], [[22, 20, 0, 4]], [[17, 19, 18, 16]], [[16, 18, 14, 12]], [[12, 14, 15, 13]], [[13, 15, 19, 17]], [[11, 10, 8, 9]], [[5, 2, 8, 10]], [[3, 6, 11, 9]], [[2, 3, 9, 8]], [[16, 12, 13, 17]], [[10, 11, 6, 7, 23, 22, 4, 5], [15, 14, 18, 19]]]
}
},
{
'name': 'StickingOut2FacesHalfCut',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 426], [464, 426]], [[464, 426], [464, -8]], [[464, -8], [-21, -8]], [[-21, -8], [-21, 426]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 250, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -8, -21], [-250, -8, 250], [-250, 250, -250], [-250, 250, -21], [0, -8, -21], [0, -8, 250], [0, 250, -21], [0, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[10, 11, 1, 0]], [[12, 13, 11, 10]], [[8, 9, 13, 12, 4, 5]], [[9, 7, 3, 1, 11, 13]], [[10, 0, 4, 12]], [[8, 5, 2, 6]], [[3, 7, 6, 2]], [[7, 9, 8, 6]], [[3, 2, 5, 4, 0, 1]]]
}
},
{
'name': 'StickingOut2FacesFullCut',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 426], [464, 426]], [[464, 426], [464, -8]], [[464, -8], [-21, -8]], [[-21, -8], [-21, 426]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 500, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -8, -21], [-250, -8, 250], [-250, 250, -250], [-250, 250, -21], [250, -250, -250], [250, -250, 250], [250, -8, -21], [250, -8, 250], [250, 250, -250], [250, 250, -21]],
'faces': [[[6, 7, 1, 0]], [[5, 11, 10, 4]], [[9, 3, 1, 7]], [[6, 0, 4, 10]], [[11, 5, 2, 8]], [[3, 9, 8, 2]], [[11, 8, 9, 7, 6, 10]], [[3, 2, 5, 4, 0, 1]]]
}
},
{
'name': 'StickingOut2FacesHalfUnion',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 426], [464, 426]], [[464, 426], [464, -8]], [[464, -8], [-21, -8]], [[-21, -8], [-21, 426]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': -250, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -8, 250], [-250, -8, 464], [-250, 250, -250], [-250, 250, -21], [-250, 426, -21], [-250, 426, 464], [0, -8, 250], [0, -8, 464], [0, 250, -21], [0, 250, 250], [0, 426, -21], [0, 426, 464], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[14, 15, 1, 0]], [[16, 17, 15, 14]], [[10, 11, 17, 16, 4, 5]], [[11, 8, 2, 1, 15, 17]], [[14, 0, 4, 16]], [[10, 5, 6, 12]], [[2, 8, 9, 3]], [[13, 7, 3, 9]], [[12, 6, 7, 13]], [[8, 11, 10, 12, 13, 9]], [[3, 7, 6, 5, 4, 0, 1, 2]]]
}
},
{
'name': 'StickingOut2FacesFullUnion',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 426], [464, 426]], [[464, 426], [464, -8]], [[464, -8], [-21, -8]], [[-21, -8], [-21, 426]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': -500, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, 250], [-250, -8, 250], [-250, -8, 464], [-250, 250, -250], [-250, 250, -21], [-250, 426, -21], [-250, 426, 464], [250, -250, -250], [250, -250, 250], [250, -8, 250], [250, -8, 464], [250, 250, -250], [250, 250, -21], [250, 426, -21], [250, 426, 464]],
'faces': [[[8, 9, 1, 0]], [[5, 13, 12, 4]], [[10, 2, 1, 9]], [[8, 0, 4, 12]], [[13, 5, 6, 14]], [[2, 10, 11, 3]], [[15, 7, 3, 11]], [[14, 6, 7, 15]], [[12, 13, 14, 15, 11, 10, 9, 8]], [[3, 7, 6, 5, 4, 0, 1, 2]]]
}
},
{
'name': 'StickingOut2FacesExtrude',
'state': {
'sketches': {'0:3': {'Segment': [[[-21, 426], [464, 426]], [[464, 426], [464, -8]], [[464, -8], [-21, -8]], [[-21, -8], [-21, 426]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-300, -8, -21], [-300, -8, 464], [-300, 426, -21], [-300, 426, 464], [-250, -250, -250], [-250, -250, 250], [-250, -8, -21], [-250, -8, 250], [-250, -8, 464], [-250, 250, -250], [-250, 250, -21], [-250, 250, 250], [-250, 426, -21], [-250, 426, 464], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[14, 15, 5, 4]], [[16, 17, 15, 14]], [[10, 11, 17, 16, 9]], [[7, 5, 15, 17, 11]], [[14, 4, 9, 16]], [[3, 13, 12, 2]], [[1, 8, 13, 3]], [[0, 6, 7, 8, 1]], [[2, 12, 10, 6, 0]], [[3, 2, 0, 1]], [[7, 6, 10, 9, 4, 5]], [[7, 11, 10, 12, 13, 8]]]
}
},
{
'name': 'AllEdgesAdjacentExtrude',
'state': {
'sketches': {'0:3': {'Segment': [[[-250, 250], [250, 250]], [[250, 250], [250, -250]], [[250, -250], [-250, -250]], [[-250, -250], [-250, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-300, -250, -250], [-300, -250, 250], [-300, 250, -250], [-300, 250, 250], [-250, -250, -250], [-250, -250, 250], [-250, 250, -250], [-250, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[10, 11, 9, 8]], [[3, 2, 0, 1]], [[1, 0, 4, 8, 9, 5]], [[2, 3, 7, 11, 10, 6]], [[3, 1, 5, 9, 11, 7]], [[0, 2, 6, 10, 8, 4]]]
}
},
{
'name': 'AllEdgesAdjacentCut',
'state': {
'sketches': {'0:3': {'Segment': [[[-250, 250], [250, 250]], [[250, 250], [250, -250]], [[250, -250], [-250, -250]], [[-250, -250], [-250, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 50, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-200, -250, -250], [-200, -250, 250], [-200, 250, -250], [-200, 250, 250], [250, -250, -250], [250, -250, 250], [250, 250, -250], [250, 250, 250]],
'faces': [[[6, 7, 5, 4]], [[3, 2, 0, 1]], [[1, 0, 4, 5]], [[2, 3, 7, 6]], [[3, 1, 5, 7]], [[0, 2, 6, 4]]]
}
},
{
'name': '2AdjacentParallelEdgesAllTheWayCut',
'state': {
'sketches': {'0:3': {'Segment': [[[-163, 250], [157, 250]], [[157, 250], [157, -250]], [[157, -250], [-163, -250]], [[-163, -250], [-163, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'CUT',
'params': {'value': 500, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -250], [-250, -250, -163], [-250, -250, 157], [-250, -250, 250], [-250, 250, -250], [-250, 250, -163], [-250, 250, 157], [-250, 250, 250], [250, -250, -250], [250, -250, -163], [250, -250, 157], [250, -250, 250], [250, 250, -250], [250, 250, -163], [250, 250, 157], [250, 250, 250]],
'faces': [[[7, 3, 11, 15]], [[8, 0, 4, 12]], [[5, 1, 9, 13]], [[2, 6, 14, 10]], [[2, 10, 11, 3]], [[9, 1, 0, 8]], [[13, 9, 8, 12]], [[10, 14, 15, 11]], [[5, 13, 12, 4]], [[14, 6, 7, 15]], [[6, 2, 3, 7]], [[1, 5, 4, 0]]]
}
},
{
'name': '4AdjacentFacesUnion_BUG_47',
'state': {
'sketches': {'0:3': {'Segment': [[[-379, 250], [157, 250]], [[157, 250], [157, -250]], [[157, -250], [-379, -250]], [[-379, -250], [-379, 250]]]}},
'operations': [{'type': 'BOX', 'params': {'width': 500, 'height': 500, 'depth': 500}}, {
'type': 'EXTRUDE',
'params': {'value': -500, 'prism': 1, 'angle': 0, 'rotation': 0, 'face': '0:3'}
}]
},
'expected': {
'format': 'LOOPS',
'vertices': [[-250, -250, -379], [-250, -250, -250], [-250, -250, 157], [-250, -250, 250], [-250, 250, -379], [-250, 250, -250], [-250, 250, 157], [-250, 250, 250], [250, -250, -379], [250, -250, -250], [250, -250, 157], [250, -250, 250], [250, 250, -379], [250, 250, -250], [250, 250, 157], [250, 250, 250]],
'faces': [[[7, 3, 11, 15]], [[8, 0, 4, 12]], [[0, 8, 9, 10, 11, 3, 2, 1]], [[9, 8, 12, 13, 14, 15, 11, 10]], [[13, 12, 4, 5, 6, 7, 15, 14]], [[6, 5, 4, 0, 1, 2, 3, 7]]]
}
}
]);