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

### Our Solutions

Need professional assistance?
Consider our:

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

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

### Related pages

Forums:

Hello everybody

I'm a new user of Opencascade, and i need some help...
I have an IGES file using NURBS representing a surface and i need to calculate the normal vectors to the surface on different points.
I thought to find in OpenCascade source code how the file is read, and modify it using the points coordinates to compute normal vectors.
My problem is I didn't understood how OpenCascade read coordinates of the points and draw polygons.

Someone can help me?
Or if anybody knows an other solution for this problem, i'm opened to any suggestion.

Thanks for reading, and sorry for my english, I don't speak very well.

Christian

Hi Quenan,

I would do that like this:

2. Use TopExp_Explorer or TopTools_IndexedMapOfShape to find all the faces of the imported shape.
3. For each face obtain the U and V parameters and iterate.
4. At each U-V-point get the surface normal using BRepLProp_SLProps

It would look something like this:

TopTools_IndexedMapOfShape aMap;

BRepClass3d_SolidClassifier solidClassifier(shape);

TopExp::MapShapes(shape, TopAbs_FACE, aMap);

BRepLProp_SLProps surfaceProperties(1, Precision::Confusion());
double u0, u1, v0, v1;
double u, v;
double uDelta, vDelta;

for(int i = 1; i {
surfaceProperties.SetSurface(surface);

u0 = surface.FirstUParameter();
u1 = surface.LastUParameter();

v0 = surface.FirstVParameter();
v1 = surface.LastVParameter();

u = u0;
v = v0;

uDelta = surface.UResolution(resolution);
vDelta = surface.VResolution(resolution);

while(u {
v = v0;
while(v {
GetSurfaceProperties(u, v,
surfaceProperties, solidClassifier,
output, propertyToCompute);

v += vDelta;
}
if(v != v1)
{
v = v1;
GetSurfaceProperties(u, v,
surfaceProperties, solidClassifier,
output, propertyToCompute);
}

u += uDelta;
}
if(u != u1)
{
u = u1;
v = v0;
while(v {
GetSurfaceProperties(u, v,
surfaceProperties, solidClassifier,
output, propertyToCompute);

v += vDelta;
}
if(v != v1)
{
v = v1;
GetSurfaceProperties(u, v,
surfaceProperties, solidClassifier,
output, propertyToCompute);
}
}
}

Pawel

Hi Pawel,

thank you for your quick answer, and sorry for mine, arriving a little bit late.

But i don't understand some parts of your code.

First, i don't know how to use this line "BRepAdaptor_Surface surface(TopoDS::Face(aMap(i)));"

Secondly, the fonction GetSurfaceProperties(), where it is define? I don't find it.

Sorry if my questions are stupid.

Christian

Hi Christian (sorry for confusing your name/surname ;)

the sample code is taken from my application so let me explain:

- I used BRepLProp_SLProps to get the properties of a surface. To use that class I needed a BRepAdaptor_Surface object which is based on a TopoDS_Face taken from a map filled before

- GetSurfaceProperties looks something like this:

void shellDocObjectProperties::GetSurfaceProperties(double u, double v,
BRepLProp_SLProps & surfaceProperties,
BRepClass3d_SolidClassifier & solidClassifier,
ArrayList ^ output, SurfaceProperties propertyToCompute)
{
gp_Pnt point;
gp_Dir normal;

surfaceProperties.SetParameters(u, v);
point = surfaceProperties.Value();

//=======================
solidClassifier.Perform(point, Precision::Confusion());

//take only points that are on the surface of the object
if( solidClassifier.State() != TopAbs_ON)
{
return;
}
//=======================

switch (propertyToCompute)
{
case SurfaceProperties::CurvatureDirections:
{
gp_Dir minD, maxD;
surfaceProperties.CurvatureDirections(maxD, minD);

}
break;

case SurfaceProperties::GaussianCurvature:
...
case SurfaceProperties::Normal:

This is how you can get the surface normal.

Hope this helps.

Pawel

I have some details to solve to do exactly what I want, but your help was very good !

Sorry for the late response and thx again.

With regards,

Christian

Dear Christian,

I face the same problem right now,would you share it!

Best Regards

Game