The return value of BRep_Tool::Degenerated

Hi All,

The result type of BRep_Tool::Degenerated is Standard_Boolean, but the definition of a degenerated edge lists as follows:
Standard_Boolean BRep_TEdge::Degenerated()const
return myFlags & DegeneratedMask;
I wonder know whether is a bug since the result of "myFlags & DegeneratedMask" may be other values except 0 and 1.


Cauchy Ding's picture

BRep_Tool::IsClosed is the same.

Evgeny Lodyzhehsky's picture

Dear Cauchy Ding.

The definition of Standard_Boolean is the following:
typedef unsigned int Standard_Boolean;
see Standard_TypeDef.hxx for more details.

Stephen Leary's picture

This would appear to be a very serious bug if booleans are assumed to be integers by the returning functions. Its fine that they are represented by integers but in doing so the developers should only use 2 values in the integer.

If you need more than 2 values use a different datatype.


Roman Lygin's picture

If you write your code as

if (BRep_Tool::IsDegenerated (myEdge)) {

it works fine.
The (potential) bug may though break the construction like this:

if (BRep_Tool::IsDegenerated (myEdge) = Standard_True) {

Roman Lygin's picture

if (BRep_Tool::IsDegenerated (myEdge) == Standard_True) {

Evgeny Lodyzhehsky's picture

Dear Roman Lygin.

The method IsDegenerated does not exist in the class BRep_Tool.

Roman Lygin's picture

Correct, thanks.
Should be BRep_Tool::Degenerated(). That was obvious.

Evgeny Lodyzhehsky's picture

Dear Stephen Leary.

>developers should only use 2 values in the integer.
Why? It is your own opinion. You may use only Standard_True or Standard_False.
In fact developpers can use any unsigned int number (not only Standard_True or Standard_False) for Standard_Boolean variables.

Stephane Routelous's picture

a Boolean is true or false.
if you want to return other values, use a Standard_Integer or an enumeration.
(at least for code readability and maintenance)

So I would typedef Standard_Boolean to bool and for the methods / functions returning something else than Standard_True or Standard_False, change them to return something meaningful.

just my 2 cents,


Evgeny Lodyzhehsky's picture

SDear tephane Routelous.

>So I would typedef Standard_Boolean to bool ...
Go ahead. I hope that your modifications will be included in next release of Open Cascade.