For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

BRepFeat_SplitShape split Irregular TopAbs_FACE

bwg bwg's picture
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;

}

Eugeny's picture

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.

BRepAlgoAPI_Splitter aSplitter;
TopTools_ListOfShape aListOfArguments, aListOfTools;
aListOfArguments.Append (aS1);
aListOfTools.Append (aS2);
aSplitter.SetArgumens (aListOfArguments);
aSplitter.SetTools (aListOfTools);
aSplitter.Build();

TopoDS_Shape aSplitShape = aSplitter.Shape();

bwg bwg's picture

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 ! 

bwg bwg's picture

bwg bwg's picture

Thanks for your suggestion,I have got the right result! Thank you !