admin管理员组文章数量:1356959
From an OpenCascade TopoDS_CompSolid
, I'm trying to
- get a list of all external faces (the outer shell/envelope of the
TopoDS_CompSolid
) - get a list of all internal faces (in the case of the screenshot below, just the shared faces of the
TopoDS_Solid
s in theTopoDS_CompSolid
)
Screenshot of OpenCascade's topologic hierarchy from training PDF for reference:
Currently, following this BOPAlgo_CellsBuilder
doc, I create the TopoDS_CompSolid
from a list of TopoDS_Solid
s, remove internal boundaries, and then compare TopoDS_Face
s of the external boundary solid and list of solids (if not in external, should be internal), but this does not find any internal boundaries.
void GetExternalBoundary(const TArray<TopoDS_Solid>& Solids, TopoDS_Solid& ExternalBoundary)
{
// Get the Cells
TopTools_ListOfShape BuilderArguments;
for (const TopoDS_Solid& Solid : Solids)
{
BuilderArguments.Append(Solid);
}
// Build CompSolid
BOPAlgo_CellsBuilder Builder;
Builder.SetArguments(BuilderArguments);
Builder.Perform();
if (Builder.HasErrors())
{
UE_LOG(LogTemp, Error, TEXT("OCCT solids union failed."));
return;
}
// Add results
int32 Material = 1;
bool bUpdate = false;
Builder.AddAllToResult(Material, bUpdate);
Builder.RemoveInternalBoundaries();
// Return the first shape
for (TopExp_Explorer ExternalBoundaryShapeExplorer(ExternalBoundaryShape, TopAbs_SOLID); ExternalBoundaryShapeExplorer.More(); ExternalBoundaryShapeExplorer.Next())
{
ExternalBoundary = TopoDS::Solid(ExternalBoundaryShapeExplorer.Current());
return;
}
}
void TestGetBoundaries(const TArray<TopoDS_Solid>& Solids)
{
// Compute the envelope Cell
TopoDS_Solid ExternalBoundary;
GetExternalBoundary(Solids, ExternalBoundary);
// Get the envelope Faces
TArray<TopoDS_Face> ExternalBoundaryFaces;
for (TopExp_Explorer ExternalBoundaryExplorer(ExternalBoundary, TopAbs_FACE); ExternalBoundaryExplorer.More(); ExternalBoundaryExplorer.Next())
{
ExternalBoundaryFaces.Add(TopoDS::Face(ExternalBoundaryExplorer.Current()));
}
// Get the original Faces
TArray<TopoDS_Face> Faces;
for (const TopoDS_Solid& Solid : Solids)
{
for (TopExp_Explorer SolidExplorer(Solid, TopAbs_FACE); SolidExplorer.More(); SolidExplorer.Next())
{
Faces.Add(TopoDS::Face(SolidExplorer.Current()));
}
}
// An internal Face can be found in the original Face list, but not in the envelope Face list.
TArray<TopoDS_Face> InternalFaces;
Handle(IntTools_Context) pOcctIntToolsContext = new IntTools_Context();
for (const TopoDS_Face& Face : Faces)
{
bool isExternalFace = false;
for (const TopoDS_Face& ExternalBoundaryFace : ExternalBoundaryFaces)
{
if (BOPTools_AlgoTools::AreFacesSameDomain(Face, ExternalBoundaryFace, pOcctIntToolsContext))
{
isExternalFace = true;
break;
}
}
if (!isExternalFace)
{
InternalFaces.Add(Face);
}
}
UE_LOG(LogTemp, Warning, TEXT("Found %d exterior faces and %d interior faces."), ExternalBoundaryFaces.Num(), InternalFaces.Num());
}
From performing shape analysis,
ShapeAnalysis_ShapeContents ShapeAnalysis;
ShapeAnalysis.Perform(Shape);
and logging number TopoDS_Face
s, it seems like RemoveInternalBoundaries()
doesn't do anything/all faces are in the resulting external boundary.
本文标签: c17How to get external and internal faces from a TopoDSCompSolid in OpenCascade CStack Overflow
版权声明:本文标题:c++17 - How to get external and internal faces from a TopoDS_CompSolid in OpenCascade C++ - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744064383a2584715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论