- UID
- 1
- 积分
- 15892
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
void removeHoles()
{
AcDb3dSolid* pSolid;
AcDbObjectId solidId;
AcBr::ErrorStatus bs;
AcBrBrep brep;
AcBrBrepFaceTraverser bft;
AcBrFaceLoopTraverser flt;
AcBrLoopEdgeTraverser let;
AcBrEdgeLoopTraverser elt;
AcBrFace face;
AcBrLoop loop,loop2;
AcBrEdge edge;
AcBr::LoopType loopType;
AcArray<AcDbSubentId*> faces;
AcBrFace faceToRemove;
if((pSolid = selectSolid("\nSelect a solid",solidId,AcDb::kForWrite)) == NULL)
{
acutPrintf("\nSelection failed");
return;
}
// Initialize the Brep
AcDbFullSubentPath path(solidId,AcDbSubentId());
try
{
bs = brep.setSubentPath(path);
if(bs != AcBr::eOk)
{
acutPrintf("\nsetSubentPath failed");
throw bs;
}
// Initialize the BrepFace traverser
bs = bft.setBrep(brep);
if(bs != AcBr::eOk)
{
acutPrintf("\nsetBrep failed");
throw bs;
}
// Traverse all faces
for(;!bft.done();bft.next())
{
bs = bft.getFace(face);
if(bs != Acad::eOk)
{
acutPrintf("\ngetFace failed");
throw bs;
}
// Initialize the face-loop traverser
bs = flt.setFace(face);
if(bs != Acad::eOk)
{
acutPrintf("\nsetFace failed");
throw bs;
}
// Traverse all loops of the actual face
for(;!flt.done();flt.next())
{
bs = flt.getLoop(loop);
if(bs != Acad::eOk)
{
acutPrintf("\ngetLoop failed");
throw bs;
}
loop.getType(loopType);
// If we got an outer loop continue with the face traversing
if(loopType != AcBr::kLoopInterior)
break;
// Traverse all edges of current interior loop
bs = let.setLoop(flt);
if(bs != AcBr::eOk)
{
acutPrintf("\nsetLoop failed");
throw bs;
}
for(;!let.done();let.next())
{
bs = let.getEdge(edge);
if(bs != Acad::eOk)
{
acutPrintf("\ngetEdge failed");
throw bs;
}
// Traverse all loops of current edge
bs = elt.setEdge(edge);
if(bs != AcBr::eOk)
acutPrintf("\nsetEdgeAndLoop failed");
for(;!elt.done();elt.next())
{
bs = elt.getLoop(loop2);
if(bs != AcBr::eOk)
{
acutPrintf("\ngetLoop failed");
throw bs;
}
// if it is the same loop as the loop processed by flt
// continue
if(loop.isEqualTo(&loop2))
continue;
loop2.getFace(faceToRemove);
faceToRemove.getSubentPath(path);
Adesk::Boolean isInList = Adesk::kFalse;
for(int i=0;i<faces.length();i++)
{
if(path.subentId() == *(faces))
isInList = Adesk::kTrue;
}
if(!isInList)
faces.append(new AcDbSubentId(path.subentId()));
}
}
}
}
acutPrintf("\nGot %d faces ",faces.length());
pSolid->removeFaces(faces);
}
catch(AcBr::ErrorStatus bs)
{
acutPrintf(" bs = %d",bs);
}
pSolid->close();
} |
|