天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 92|回复: 0

对象 arx 对实体进行三角测量。

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
bool getMesh(ap::STrng& mesh, const AcDb3dSolid* solid)
{
AcArray<AcGePoint3d> vs;
AcArray<Adesk::Int32> is;
AcGiFaceData* fs = nullptr;
AcDbFaceterSettings set = {};
AcDbExtents ext = {};

ThrowIfFailed(solid->getGeomExtents(ext));
const AcGeVector3d dir = ext.maxPoint() - ext.minPoint();
set.faceterMeshType = 2;
set.faceterMaxEdgeLength = dir.length() * 0.1;

AcDb3dSolid* s = const_cast<AcDb3dSolid*>(solid);
ThrowIfFailed(acdbGetObjectMesh(s, &set, vs, is, fs));

struct Triangle
{
int32_t m_dummy;
int32_t m_i0;
int32_t m_i1;
int32_t m_i2;
};

const auto size = is.length() / sizeof(Triangle);
const Triangle* ts = reinterpret_cast<const Triangle*>(&is[0]);

for (auto i = 0; i < size; ++i)
{
const Triangle* t = ts + i;

const AcGePoint3d pa = vs[t->m_i0];
const AcGePoint3d pb = vs[t->m_i1];
const AcGePoint3d pc = vs[t->m_i2];

const D3 p0 = { pa.x, pa.y, pa.z };
const D3 p1 = { pb.x, pb.y, pb.z };
const D3 p2 = { pc.x, pc.y, pc.z };

addTr(mesh, p0, p1, p2);

return true;
}

代码2 :



// Description : get mesh from face
bool getMesh(ap::STrng& mesh, const AcBrFace& face)
{
AcBr::ErrorStatus returnValue = AcBr::eOk;

AcGe::EntityId entId;
if(face.getSurfaceType(entId) != AcBr::eOk)
return false;

// conditionally set the mesh controls based on surface type
AcBrMesh2dControl meshCtrl;
meshCtrl.setElementShape(AcBr::kAllTriangles);

// make the mesh filter from the topology entity and the mesh controls
const AcBrEntity* meshEnt = (AcBrEntity*)&face;
AcBrMesh2dFilter meshFilter;
meshFilter.insert(make_pair(meshEnt, (const AcBrMesh2dControl)meshCtrl));

// generate the mesh, display any errors and attempt to dump all
// generated elements (most errors are not fatal so we want to do
// the best we can with whatever subset of the face was meshed).
AcBrMesh2d faceMesh;
if(faceMesh.generate(meshFilter) != eOk)
return false;

// traverse elements (triangles)
TVectorN<D3, 3> aPt;
AcBrMesh2dElement2dTraverser meshElemTrav;
meshElemTrav.setMesh(faceMesh);
for(; !meshElemTrav.done(); meshElemTrav.next())
{
// traverse nodes (points)
AcBrElement2dNodeTraverser elemNodeTrav;
elemNodeTrav.setElement(meshElemTrav);
aPt.setSize(0);
for(; !elemNodeTrav.done(); elemNodeTrav.next())
{
AcBrNode node;
elemNodeTrav.getNode(node);
AcGePoint3d p;
node.getPoint(p);
aPt.add().setValue(p.x, p.y, p.z);
}
addTr(mesh, aPt[0], aPt[1], aPt[2]);
}
return true;
}


bool getMesh(ap::STrng& mesh, const AcDb3dSolid* solid)
{

//create brep traverser
std::unique_ptr<AcBrBrep> brep = std::make_unique<AcBrBrep>();
if(brep->set(*solid) != AcBr::eOk)
return false;
AcBrBrepFaceTraverser trav;
if(trav.setBrep(*brep.get()) != AcBr::eOk)
return false;

//traverse all faces
AcBrFace face;
while(!trav.done())
{
trav.getFace(face);
getMesh(mesh, face);
if(trav.next() != AcBr::eOk)
break;
}

return true;
}

 

 

 

 

对象 arx 对实体进行三角测量。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 09:28 , Processed in 0.148811 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表