# Point Uniqueness

How can I give an id to a point in OpenCascade?
I need to calculate the number of unique points in a 3D shape,so i should give id numbers to points?

How can I handle it?

#include

includes this library first.

then under the include files add this statement:

static TopTools_DataMapOfShapeInteger _map_shape_int;

For example,you can give ID manually to the vertexes such that:

int vertex_id = 0;

TopExp_Explorer ex,ex1;
TopoDS_Vertex vertex;

for (ex.Init(cubian, TopAbs_FACE);ex.More();ex.Next())
{
for(ex1.Init(ex.Current(),TopAbs_VERTEX);ex1.More();ex1.Next())
{
vertex = TopoDS::Vertex(ex1.Current());
if(!_map_shape_int.IsBound(vertex))
{
_map_shape_int.Bind(vertex,vertex_id);
vertex_id++;
}
}
}

HI;

this method return the number of vertex in the face not ID;
//***for example
when you try to use this method to get the id of vertex in occ_face
"plane" , you get "ID=4" the number of occ_vertex not "ID: 1, 2, 3, 4"

how can 'i retrive the vertex by ID.

A++

Hi HICHEM,

The code sample that I sent is just an example,and the code counts the number of vertexes in all faces,but does not include the common vertexes.

For example,I have done it for a cube and count the number of vertexes,and it counts 8.Because,the cube has 8 unique vertexes.

You asked how you could retrive the vertex by ID.

For example;

#include

// declare a class
static TopTools_DataMapOfIntegerShape _map_int_shape;

...

TopoDS_Vertex vertex = TopoDS::Vertex(_map_int_shape.Find(vertex_id));

hi;

when i' try to use this method, i'get evry time the same ID , i'don't understand why?
//***
in my class OCC_FONCTION1 i'use this method :

void OCC_FONCTION1::SetID(TopoDS_Face face)
{
TopTools_IndexedMapOfShape faces;
TopExp::MapShapes(ashape,TopAbs_FACE, faces);
int nb_face_occ=faces.Extent();
for(int k=1; k<=nb_face_occ;++k)
{
face=TopoDS::Face(faces.FindKey(k));
id_face=faces.FindIndex(face);
if(!map_integer.IsBound(face))
{
map_integer.Bind(face, id_face);
id_face++;
}
}

}

// to get id i'use this method

int OCC_FONCTION1::GetID(TopoDS_Face face)
{
return id_face;
}

when i'try to get the face from id or dump him from id , i'get the same face what's the bug??