MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / split

Function split

src/ifcgeom/kernels/opencascade/layerset.cpp:46–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45#if OCC_VERSION_HEX >= 0x70200
46 bool split(const TopoDS_Shape& input, const TopTools_ListOfShape& operands, double eps, std::vector<TopoDS_Shape>& slices) {
47 if (operands.Extent() < 2) {
48 // Needs to have at least two cutting surfaces for the ordering based on surface containment to work.
49 return false;
50 }
51
52 BRepAlgoAPI_Splitter split;
53 TopTools_ListOfShape input_list;
54 input_list.Append(input);
55 split.SetArguments(input_list);
56 split.SetTools(operands);
57 split.SetNonDestructive(true);
58 split.SetFuzzyValue(eps);
59 split.Build();
60
61 if (!split.IsDone()) {
62 return false;
63 } else {
64
65 std::map<Geom_Surface*, int> surfaces;
66
67 // NB 1, since first surface has been excluded
68 int i = 1;
69 for (TopTools_ListIteratorOfListOfShape it(operands); it.More(); it.Next(), ++i) {
70 TopExp_Explorer exp(it.Value(), TopAbs_FACE);
71 for (; exp.More(); exp.Next()) {
72 surfaces.insert(std::make_pair(BRep_Tool::Surface(TopoDS::Face(exp.Current())).get(), i));
73 }
74 }
75
76 auto result_shape = split.Shape();
77 std::list<TopoDS_Shape> subs;
78 subshapes(result_shape, subs);
79
80 // Sometimes there is more nesting of compounds, so when we find a single compound we again try to explode it into a list.
81 if (subs.size() == 1 && (subs.front().ShapeType() == TopAbs_COMPSOLID || subs.front().ShapeType() == TopAbs_COMPOUND)) {
82 auto s = subs.front();
83 subs.clear();
84 subshapes(s, subs);
85 }
86
87 // Initialize storage
88 slices.resize(subs.size());
89
90 for (auto& s : subs) {
91
92 // Iterate over the faces of solid to find correspondence to original
93 // splitting surfaces. For the outmost slices, there will be a single
94 // corresponding surface, because the outmost surfaces that align with
95 // the body geometry have not been added as operands. For intermediate
96 // slices, two surface indices should be find that should be next to
97 // each other in the array of input surfaces.
98
99 TopExp_Explorer exp(s, TopAbs_FACE);
100 int min = std::numeric_limits<int>::max();
101 int max = std::numeric_limits<int>::min();
102 for (; exp.More(); exp.Next()) {
103 auto ssrf = BRep_Tool::Surface(TopoDS::Face(exp.Current()));

Callers 3

apply_folded_layersetMethod · 0.70
apply_layersetMethod · 0.70
istream_helperFunction · 0.50

Calls 13

subshapesFunction · 0.85
HandleFunction · 0.85
MoreMethod · 0.80
resizeMethod · 0.80
push_backMethod · 0.80
ErrorFunction · 0.50
NextMethod · 0.45
insertMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected