For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How to get the unique vertices for a shape

Jewel Pervez's picture
Forums: 

Hello,

I want to get all unique vertices from a shape. For example, if we consider a box, it has 8 vertices. I want to get the 8 vertices values. I used the following codes. However, it returns 48 vertices (6 faces * 4 wires in each face * 2 vertices in each wire).

TopExp_Explorer ex;
Standard_Integer count=0;
for (ex.Init(topoDSShape, TopAbs_VERTEX); ex.More(); ex.Next()) 
{
	TopoDS_Vertex vertex = TopoDS::Vertex(ex.Current());
	gp_Pnt pt = BRep_Tool::Pnt(vertex);
	Standard_Real x= pt.X();
	Standard_Real y= pt.Y();
	Standard_Real z= pt.Z();
	TCollection_ExtendedString msg = "Vertex ";
	msg += ++count;
	msg += " is: X=";
	msg += x;
	msg += ", Y=";
	msg += y;
	msg += ", Z=";
	msg += z;
	LOG.info(__FUNCTION__, msg);
}

TCollection_ExtendedString msg = "Total Vertices are: ";
msg += count;
LOG.info(__FUNCTION__, msg);

How can I get the unique 8 vertices for a box or unique vertices for any shape (cylinder, sphere ….)?

I am looking forward your help.