为什么 RealDWG 文档说某些函数不适用“由于 AcDbSubentId 的图形依赖关系”?
void cmdTestBrep(){
Acad::ErrorStatus es;
AcDbDatabase *db = new AcDbDatabase();
AcDb3dSolid *solid = new AcDb3dSolid;
solid->setDatabaseDefaults(db);
es = solid->createBox(200.0, 300.0, 400.0);
AcDbObjectId idSolid;
es = PostToDb(db, idSolid, solid);
AcBrBrep *pBrep = new AcBrBrep();
AcDbFullSubentPath adfsp(idSolid, kNullSubentId);
AcBr::ErrorStatus ebs = pBrep->setSubentPath(adfsp);
AcBrBrepFaceTraverser faceTraverser;
ebs = faceTraverser.setBrep(*pBrep);
assert(ebs == AcBr::eOk);
std::vector<Face2Edges> facePathToEdgePaths;
AcBrFace face;
AcDbFullSubentPath subFacePath, subEdgePath;
for (ebs = faceTraverser.restart(); !faceTraverser.done(); ebs = faceTraverser.next())
{
ebs = faceTraverser.getFace(face);
if (ebs == AcBr::eOk)
{
ebs = face.getSubentPath(subFacePath);
if (ebs == AcBr::eOk)
{
Face2Edges f2es;
f2es.face = subFacePath;
AcBrFaceLoopTraverser faceLoopTrav;
ebs = faceLoopTrav.setFace(face);
for (; !faceLoopTrav.done(); ebs = faceLoopTrav.next())
{
AcBrLoop loop;
ebs = faceLoopTrav.getLoop(loop);
if (ebs == AcBr::eOk)
{
AcBrLoopEdgeTraverser loopEdgeTrav;
ebs = loopEdgeTrav.setLoop(loop);
for (; !loopEdgeTrav.done(); ebs = loopEdgeTrav.next())
{
AcBrEdge edge;
ebs = loopEdgeTrav.getEdge(edge);
if (ebs == AcBr::eOk)
{
ebs = edge.getSubentPath(subEdgePath);
if (ebs == AcBr::eOk)
f2es.edges.append(subEdgePath);
}
}
}
}
facePathToEdgePaths.push采用back(std::move(f2es));
}
}
}
delete pBrep;
// recolor the faces
if ((es = acdbOpenObject(solid, idSolid, AcDb::kForWrite)) == Acad::eOk)
{
AcCmColor color;
Adesk::UInt16 colorIndex = 0;
for (const Face2Edges & f2es : facePathToEdgePaths)
{
color.setColorIndex(++colorIndex);
es = solid->setSubentColor(f2es.face.subentId(), color);
}
static double dRadius = 10.0;
static double dSetbackStart = 0.0;
static double dSetbackEnd = 0.0;
for (const Face2Edges& f2es : facePathToEdgePaths)
{
int count = f2es.edges.length();
if (count>0)
{
AcArray<AcDbSubentId> edgeIds;
AcArray<AcDbSubentId*> edgeIdPtrs;
AcGeDoubleArray startSetback, endSetback, radius;
edgeIds.setLogicalLength(count);
edgeIdPtrs.setLogicalLength(count);
radius.setLogicalLength(count);
startSetback.setLogicalLength(count);
endSetback.setLogicalLength(count);
for (int i=0; i<count; ++i)
{
color.setColorIndex(++colorIndex);
es = solid->setSubentColor(f2es.edges.subentId(), color);
const AcDbFullSubentPath& path = f2es.edges;
edgeIds = path.subentId();
edgeIdPtrs = &(edgeIds);
radius = dRadius;
startSetback = dSetbackStart;
endSetback = dSetbackEnd;
}
es = solid->filletEdges(edgeIdPtrs, radius, startSetback, endSetback);
break;
}
}
solid->close();
}
db->saveAs(L"c:\\temp\\brep.dwg");
delete db;
}
页:
[1]