Thu, 05/30/2019 - 13:17
Forums:
I want to split an Irregular TopAbs_FACE,the aS1 is an Irregular TopAbs_FACE and the aS2 is formed by four TopAbs_FACE(colsed).
the aInterCurve2 is a Closed curve which are formed by four TopAbs_EDGE .
I add the four edge and face to the split ,however ,An Exception Thrown in Split2.Build();
I don't know why this happen,I check my code for many times,suprprisely ,in some shape my code performed successly ,but in the Irregular TopAbs_FACE ,it failed.
please tell how it happen ,thank you !
TopTools_ListOfShape GraphicalCalculation::DoSplit2(TopoDS_Shape aS1,
TopoDS_Shape aS2)
{
TopTools_ListOfShape ValidLists;
BRepAlgoAPI_Section sec2(aS1, aS2, Standard_False);
sec2.SetRunParallel(Standard_True);
sec2.SetFuzzyValue(aFuzzyValue);
Standard_Integer iErr;
sec2.ComputePCurveOn1(Standard_True);
sec2.Build();
iErr = sec2.ErrorStatus();
if (iErr) {
// an error treatment
cout << "an error treatment" << endl;
return ValidLists;
}
TopoDS_Shape aInterCurve2 = sec2.Shape();
for (TopExp_Explorer exFace(aS1, TopAbs_FACE); exFace.More(); exFace.Next())
{
TopoDS_Face aFace = TopoDS::Face(exFace.Current());
BRepFeat_SplitShape Split2 = BRepFeat_SplitShape(aFace);
for (TopExp_Explorer exEdge(aInterCurve2, TopAbs_EDGE); exEdge.More(); exEdge.Next())
{
TopoDS_Edge aE = TopoDS::Edge(exEdge.Current());
TopoDS_Shape aF = TopoDS_Shape();
if (sec2.HasAncestorFaceOn1(aE, aF))
{
TopoDS_Face aAncFace = TopoDS::Face(aF);
if (aAncFace.IsSame(aFace))
{
Split2.Add(aE, aAncFace);
}
}
try
{
Split2.Build();
}
catch (Standard_Failure)
{
cout << "An Exception Thrown! " << endl;
}
for (TopExp_Explorer exface2(Split2.Shape(), TopAbs_FACE); exface2.More(); exface2.Next())
{
ValidLists.Append(exface2.Current());
}
}
}
return ValidLists;
}
Thu, 05/30/2019 - 14:04
Hello, if you already using Boolean Operations to build the section curves, why don't you perform splitting using Booleans as well? The class you need to use is BRepAlgoAPI_Splitter.
Try using the following code (no BRepAlgoAPI_Section and BRepFeat_SplitShape need to be used). The result will contain all split parts of aS1. The parts of aS2 will not be included.
Thu, 05/30/2019 - 15:43
thanks for your help,because I use opencascade6.9.0,I don't find BRepAlgoAPI_Splitter,I find it in opencascade 7.3.0.
I will try it Immediately,if I success ,I will tell you ,thank you !
Thu, 05/30/2019 - 15:52
Sun, 06/02/2019 - 15:55
Thanks for your suggestion,I have got the right result! Thank you !