Hi All,
I am developing a plugin where I use the function RhinoBrepSplit, the version that takes
const ON_SimpleArray<const ON_Curve*>
as splitter curves.
The sample code that uses this function is below. It asks user for two breps, one as splitter and the second as object to be splitted. Then intersection curves are created, which in later stage are used as splitter curves to split the splitted brep. I know that in this particular case it is better to just split one brep by another, but the point in my plug-in is to use curves as splitters.
CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context) { CRhinoGetObject go; context.m_doc.UnselectAll(); go.SetCommandPrompt(L"choose splitter brep"); go.SetGeometryFilter(ON::brep_object); CRhinoGet::result res = go.GetObjects(1, 1); if (res != CRhinoGet::object) return CRhinoCommand::cancel; const ON_Brep* splitter = go.Object(0).Brep(); context.m_doc.UnselectAll(); go.SetCommandPrompt(L"choose brep to be splitted"); res = go.GetObjects(1, 1); if (res != CRhinoGet::object) return CRhinoCommand::cancel; const ON_Brep* brep = go.Object(0).Brep(); if (!splitter || !brep)return CRhinoCommand::failure; ON_SimpleArray<ON_Curve*> curves; if (!RhinoIntersectBreps(*splitter, *brep, context.m_doc.AbsoluteTolerance(), curves)) return CRhinoCommand::failure; ON_SimpleArray<const ON_Curve*> constcurves; constcurves.Append(curves.Count(), curves.Array()); ON_SimpleArray<ON_Brep*> pieces; RhinoBrepSplit(*brep, constcurves, context.m_doc.AbsoluteTolerance(), pieces); if (pieces.Count() > 0)context.m_doc.DeleteObject(go.Object(0)); //original brep is deleted here for (int i = 0; i < pieces.Count(); ++i) { context.m_doc.AddBrepObject(*pieces[i]); delete pieces[i]; } for (int i = 0; i < curves.Count(); ++i) { delete curves[i]; } return CRhinoCommand::success; }
here:
surfaces2.3dm (361.8 KB)
you can find the model where by splitting the red surface by the grey one, you get the following result:
I mean result of the splitting are three surfaces instead of two.
When I modified the code above, to use RhinoBrepSplit that takes const ON_Brep& as splitter, the result was OK.
From the other side, when I do everything that the above code does, but with Rhino built-in functions (I mean first intersect two surfaces and then split the red one by the result curve), results are also OK.
I just have an impression that there is something wrong with the RhinoBrepSplit taking splitter curves, it is important for me to use just this version in my plug-in.
Dale, maybe you have got some idea?
Regards,
Andrzej