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

The return value of BRep_Tool::Degenerated

Cauchy Ding's picture
Forums: 

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.

-Ding

Cauchy Ding's picture

BRep_Tool::IsClosed is the same.

Lodyzhensky'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.

Stephen

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) {
}

Lodyzhensky'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.

Lodyzhensky'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,

Stephane

Lodyzhensky's picture

SDear tephane Routelous.

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

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.