ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble with meshCtrl.setElementShape(AcBr::kAllPolygons), get only triangles

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
ynapeu
249 Views, 3 Replies

Trouble with meshCtrl.setElementShape(AcBr::kAllPolygons), get only triangles

I will get all faces from a solid, but i get only triangles. No Polygons.

here the sample.

 

// pSolid is the used Solid
AcBr::ErrorStatus esBr;
AcBrMesh2dControl meshCtrl;
//----------------------------------------------
// i use the following settings
// AcBr::kAllTriangles ...... i get triangles
// AcBr::kAllPolygons ...... i get triangles
//---------------------------------------------
meshCtrl.setElementShape(AcBr::kAllPolygons);
AcBrBrep brep;
esBr = brep.set(*pSolid);
AcBrBrep brepOwner;
esBr = brep.getBrep(brepOwner);
// make the mesh filter from the topology entity and the mesh controls
AcBrMesh2dFilter meshFilter;
const auto *pMeshEnt = (AcBrEntity *)&brep;
meshFilter.insert(make_pair(pMeshEnt, (const AcBrMesh2dControl)meshCtrl));
AcBrMesh2d brepMesh;
esBr = brepMesh.generate(meshFilter);
AcBrEntity* meshOwner = NULL;
esBr = brepMesh.getEntityAssociated(meshOwner);

AcBrMesh2dElement2dTraverser meshElemTrav;
esBr = meshElemTrav.setMesh(brepMesh);

for (; !meshElemTrav.done(); meshElemTrav.next())
{
AcGeVector3d vector;
AcBrElement2dNodeTraverser elemNodeTrav;
elemNodeTrav.setElement(meshElemTrav);
elemNodeTrav.getSurfaceNormal(vector);
int countpoint=0;
while (!elemNodeTrav.done() && (elemNodeTrav.next() == AcBr::eOk))
{
AcBrNode node;
esBr = elemNodeTrav.getNode(node);
AcGePoint3d nodePoint;
esBr = node.getPoint(nodePoint);
countpoint++;
}
// here countpoint is alwas 3 ?????
}

3 REPLIES 3
Message 2 of 4
ynapeu
in reply to: ynapeu

if i choose AcBr::kAllQuadrilaterals i get Quadrilaterals. Only kAllPolygons do not work.

Message 3 of 4
tbrammer
in reply to: ynapeu

I can reproduce your findings with the <ARX>\utils\brep\samples\brepsamp project.

Using kAllPolygons produced triangles in nearly all cases I tried. The only exception was a sphere. It produced a mix of triangles and quadrangles. Even a box and a polygon region produced triangles. I never saw a polygon with more than 4 edges.

 

This is what is written in the header brglb.h:

enum Element2dShape	{
 kDefault              = 0,	// use system defaults (i.e., by surface type)
 kAllPolygons		   = 1,	// attempt to only produce ngons, where n>4                  
 kAllQuadrilaterals    = 2,	// attempt to only produce 4gons (complete quadrangles)
 kAllTriangles         = 3	// attempt to only produce 3gons (approx. equilateral)
};

 

Well, "attempt" apparently doesn't mean that the attempt will ever succeed.

So if you need i.e. the largest possible 2D polygons you have to stitch the triangles and quads together to polygons yourself.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 4
ynapeu
in reply to: tbrammer

Thanks.

I get the same results.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta