Sat, 10/12/2024 - 10:16
Code in question:
//read model from STEP file
TopoDS_Shape readModel(const std::string& filepath)
{
STEPControl_Reader stepReader;
IFSelect_ReturnStatus ret = stepReader.ReadFile(filepath.c_str());
Standard_Integer count = stepReader.TransferRoots();
Standard_Integer shapeCount = stepReader.NbShapes();
TopoDS_Shape stepShape = stepReader.OneShape();
return stepShape;
}
//explorer all faces in the shape
std::vector<TopoDS_Face> faces(const TopoDS_Shape& shape)
{
std::vector<TopoDS_Face> res;
for (TopExp_Explorer exp(shape, TopAbs_FACE); exp.More(); exp.Next()) {
const TopoDS_Face& f = TopoDS::Face(exp.Current());
res.push_back(f);
}
return res;
}
int main(int argc, char** argv)
{
//just two face in the STEP file
TopoDS_Shape model = readModel("./TEST_STEP/face_face_common_error.STEP");
std::vector<TopoDS_Face> fs = faces(model);//TopExp_Explorer
TopoDS_Face f1 = fs[0];
TopoDS_Face f2 = fs[1];
//BRepAlgoAPI_Common
BRepAlgoAPI_Common com(f1, f2);
TopoDS_Shape comShape = com.Shape();
//show errors
if (com.HasErrors())
{
std::cout << "errors : " << std::endl;
Message_ListOfAlert erroes = com.GetReport()->GetAlerts(Message_Fail);
for (Message_ListOfAlert::Iterator it(erroes); it.More(); it.Next())
{
Handle(Message_Alert) aerror = it.Value();
std::cout << aerror->GetMessageKey() << std::endl;
}
}
//show warnings
if (com.HasWarnings())
{
std::cout << "warnings : " << std::endl;
Message_ListOfAlert warnings = com.GetReport()->GetAlerts(Message_Warning);
for (Message_ListOfAlert::Iterator it(warnings); it.More(); it.Next())
{
Handle(Message_Alert) awarning = it.Value();
std::cout << awarning->GetMessageKey() << std::endl;
}
}
}
Output:
errors :
BOPAlgo_AlertBuilderFailed
warnings :
BOPAlgo_AlertBuildingPCurveFailed
BOPAlgo_AlertBuildingPCurveFailed
The two faces are overlapping.the type of the large one(f2) is SurfaceOfExtrusion,.the type of f1 is plane.why BRepAlgoAPI_Common do not work?what am i missing?