Tue, 04/28/2020 - 05:30
Hello.
I am trying to get common part of two shapes by following codes, but it is not working.
The shape type of common part is "TopAbs_COMPOUND", but it does not include face.
I use OpenCascade version 7.4.0.
----------------------- code ----------------------->
TopoDS_Shape shape1;
BRep_Builder bb1;
BRepTools::Read( shape1, "C:/@test/shape1.brep", bb1 );
TopoDS_Shape shape2;
BRep_Builder bb2;
BRepTools::Read( shape2, "C:/@test/shape2.brep", bb2 );
BRepAlgoAPI_Common common( shape1, shape2 );
common.Build();
if( common.Shape().IsNull() == Standard_False ){
// not null and shape type is TopAbs_COMPOUND
for( TopExp_Explorer expFace( common.Shape(), TopAbs_FACE ); expFace.More(); expFace.Next() ){
// not exec this loop -> not include face
}
}
<----------------------- code -----------------------
When I rotete shape1 before use BRepAlgoAPI_Common, I can get common part of two shapes.
------------------------ rotate code ---------------->
gp_Trsf trsfRotate;
trsfRotate.SetRotation( gp::OZ(), -20.0 * M_PI / 180.0 );
BRepBuilderAPI_Transform buildTransRotate( trsfRotate );
buildTransRotate.Perform( shape1, false );
shape1 = buildTransRotate.Shape();
<------------------------ rotate code ----------------
Anyone had this problem?
Best regards.
Tue, 04/28/2020 - 11:23
It seems that shape1 has self intersected vertex,so boolean operation failed.May be using BOPAlgo_Splitter to spit the shape
Fri, 05/01/2020 - 14:48
Hello, liuhuiwei.
Thank you for your reply.
I can get shape that shape1 cutted by shape2 by using BOPAlgo_Splitter.
I want to check the shape is good or bad.
How can I check that shape1 has self intersected vertex or not ?
Best regards.
Sat, 05/02/2020 - 04:16
//code from salome
BOPAlgo_CheckerSI aCSI;
aCSI.AddArguments(aShape);
aCSI.SetLevelOfCheck(theCheckLevel);
aCSI.Perform();
const BOPDS_DS& aDS = aCSI.DS();
aNbS = aDS.NbShapes();
const BOPDS_MapOfPair& aMPK = aDS.Interferences();
aItMPK.Initialize(aMPK);
if (!aItMPK.More())
{
//no self-interferences
}
else
{...}
Fri, 05/22/2020 - 10:59
Thank you for your reply.
I could check self-interferences by following codes.
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPDS_DS.hxx>
BOPAlgo_CheckerSI aCSI;
aCSI.AddArgument( shape );
aCSI.SetLevelOfCheck( 9 );
aCSI.Perform();
const BOPDS_DS& aDS = aCSI.DS();
Standard_Integer aNbS = aDS.NbShapes();
const BOPDS_MapOfPair& aMPK = aDS.Interferences();
BOPDS_MapIteratorOfMapOfPair aItMPK;
aItMPK.Initialize(aMPK);
if (!aItMPK.More())
{
//no self-interferences
}else{
/has self-interferences;
}