1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead of "unsigned int"

Code has been updated to remove no-op casts and implicit casts to Standard_Boolean.

Places of inproper use of Standard_Boolean instead of Standard_Integer
have been corrected:
- Bnd_Box, Bnd_Box2d
  Bit flags are now defined as private enum
- HLRAlgo_BiPoint, HLRAlgo_EdgesBlock, HLRBRep_EdgeData, HLRBRep_FaceData
  Bit flags are now defined as enum
- HLRAlgo_EdgeStatus, HLRBRep_BiPnt2D, HLRBRep_BiPoint
  Bit flags are now defined as bool fields
- HLRAlgo_PolyData
  Bit flags are now defined as Standard_Integer
- OSD_DirectoryIterator, OSD_FileIterator
  Boolean flag is now defined as Standard_Boolean
- ShapeAnalysis_Surface::SurfaceNewton()
  now returns Standard_Integer (values 0, 1 or 3)
- ChFi2d_FilletAlgo
  now uses TColStd_SequenceOfBoolean instead of TColStd_SequenceOfInteger
  for storing boolean flags

Method IFSelect_Dispatch::PacketsCount() has been dropped from interface.

ShapeFix_Solid::Status() has been fixed to decode requested status
instead of returning integer value.

TopOpeBRepBuild_Builder1 now defines map storing Standard_Boolean values
instead of Standard_Integer.

Persistence for Standard_Boolean type has been corrected
to keep backward compatibility:
- BinMDataStd, BinTools, FSD_BinaryFile

Broken Draw Harness commands vdisplaymode and verasemode have been removed.

BRepMesh_FastDiscretFace::initDataStructure() - workaround old gcc limitations

BRepMesh_IncrementalMesh::clear() - avoid ambiguity
This commit is contained in:
kgv
2016-08-25 14:58:51 +03:00
committed by abv
parent 3fe9ce0edd
commit dde6883382
211 changed files with 1324 additions and 2667 deletions

View File

@@ -1043,42 +1043,46 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
return 0;
}
//==============================================================================
//function : Displays,Erase...
//purpose :
//Draw arg :
//==============================================================================
static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO,
const Standard_Integer Mode,
const Standard_Integer TypeOfOperation,
const Standard_Boolean Upd)
enum TypeOfDispOperation
{
Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
TypeOfDispOperation_SetDispMode,
TypeOfDispOperation_UnsetDispMode
};
switch(TypeOfOperation){
case 1:
Ctx->Display(IO,Mode,Upd);
break;
case 2:{
Ctx->Erase(IO,Upd);
break;
//! Displays,Erase...
static void VwrTst_DispErase (const Handle(AIS_InteractiveObject)& thePrs,
const Standard_Integer theMode,
const TypeOfDispOperation theType,
const Standard_Boolean theToUpdate)
{
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
switch (theType)
{
case TypeOfDispOperation_SetDispMode:
{
if (!thePrs.IsNull())
{
aCtx->SetDisplayMode (thePrs, theMode, theToUpdate);
}
else
{
aCtx->SetDisplayMode ((AIS_DisplayMode )theMode, theToUpdate);
}
break;
}
case TypeOfDispOperation_UnsetDispMode:
{
if (!thePrs.IsNull())
{
aCtx->UnsetDisplayMode (thePrs, theToUpdate);
}
else
{
aCtx->SetDisplayMode (AIS_WireFrame, theToUpdate);
}
break;
}
}
case 3:{
if(IO.IsNull())
Ctx->SetDisplayMode((AIS_DisplayMode)Mode,Upd);
else
Ctx->SetDisplayMode(IO,Mode,Upd);
break;
}
case 4:{
if(IO.IsNull())
Ctx->SetDisplayMode(0,Upd);
else
Ctx->UnsetDisplayMode(IO,Upd);
break;
}
}
return 0;
}
//=======================================================================
@@ -1087,65 +1091,73 @@ static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO,
//=======================================================================
static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv)
{
TCollection_AsciiString name;
if(argc>3)
if (argc < 1
|| argc > 3)
{
std::cout << "Syntax error: wrong number of arguments\n";
return 1;
// display others presentations
Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"vdispmode")==0)? 1:
(strcasecmp(argv[0],"verasemode")==0) ? 2 :
(strcasecmp(argv[0],"vsetdispmode")==0) ? 3 :
(strcasecmp(argv[0],"vunsetdispmode")==0) ? 4 : -1;
}
Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
//unset displaymode.. comportement particulier...
if(TypeOfOperation==4){
if(argc==1){
if(Ctx->NbSelected()==0){
Handle(AIS_InteractiveObject) IO;
VwrTst_DispErase(IO,-1,4,Standard_False);
TypeOfDispOperation aType = TCollection_AsciiString (argv[0]) == "vunsetdispmode"
? TypeOfDispOperation_UnsetDispMode
: TypeOfDispOperation_SetDispMode;
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (aType == TypeOfDispOperation_UnsetDispMode)
{
if (argc == 1)
{
if (aCtx->NbSelected() == 0)
{
VwrTst_DispErase (Handle(AIS_InteractiveObject)(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
}
else{
for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
VwrTst_DispErase(Ctx->SelectedInteractive(),-1,4,Standard_False);}
Ctx->UpdateCurrentViewer();
else
{
for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
{
VwrTst_DispErase (aCtx->SelectedInteractive(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
}
}
aCtx->UpdateCurrentViewer();
}
else{
Handle(AIS_InteractiveObject) IO;
name = argv[1];
if(GetMapOfAIS().IsBound2(name)){
IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
if (!IO.IsNull())
VwrTst_DispErase(IO,-1,4,Standard_True);
else
{
TCollection_AsciiString aName = argv[1];
if (GetMapOfAIS().IsBound2 (aName))
{
Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
if (!aPrs.IsNull())
{
VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
}
}
}
}
else if(argc==2){
Standard_Integer Dmode = Draw::Atoi(argv[1]);
if(Ctx->NbSelected()==0 && TypeOfOperation==3){
Handle(AIS_InteractiveObject) IO;
VwrTst_DispErase(IO,Dmode,TypeOfOperation,Standard_True);
else if (argc == 2)
{
Standard_Integer aDispMode = Draw::Atoi (argv[1]);
if (aCtx->NbSelected() == 0
&& aType == TypeOfDispOperation_SetDispMode)
{
VwrTst_DispErase (Handle(AIS_InteractiveObject)(), aDispMode, TypeOfDispOperation_SetDispMode, Standard_True);
}
if(!Ctx->HasOpenedContext()){
// set/unset display mode sur le Contexte...
for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){
VwrTst_DispErase(Ctx->SelectedInteractive(),Dmode,TypeOfOperation,Standard_False);
}
Ctx->UpdateCurrentViewer();
}
else{
for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
Ctx->Display(Ctx->SelectedInteractive(),Dmode);
for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
{
VwrTst_DispErase (aCtx->SelectedInteractive(), aDispMode, aType, Standard_False);
}
aCtx->UpdateCurrentViewer();
}
else{
Handle(AIS_InteractiveObject) IO;
name = argv[1];
if(GetMapOfAIS().IsBound2(name))
IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
if (!IO.IsNull())
VwrTst_DispErase(IO,Draw::Atoi(argv[2]),TypeOfOperation,Standard_True);
else
{
Handle(AIS_InteractiveObject) aPrs;
TCollection_AsciiString aName (argv[1]);
if (GetMapOfAIS().IsBound2 (aName))
{
aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
}
if (!aPrs.IsNull())
{
VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True);
}
}
return 0;
}
@@ -5525,7 +5537,7 @@ static int VAutoActivateSelection (Draw_Interpretor& theDi,
}
else
{
Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]);
Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]) != 0;
aCtx->SetAutoActivateSelection (toActivate);
}
@@ -5642,14 +5654,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"vdisplaytype : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
__FILE__,VDisplayType,group);
theCommands.Add("vdisplaymode",
"vdispmode : vdispmode [name] mode(1,2,..) : no name -> on selected objects ",
__FILE__,VDispMode,group);
theCommands.Add("verasemode",
"verasemode : verasemode [name] mode(1,2,..) : no name -> on selected objects",
__FILE__,VDispMode,group);
theCommands.Add("vsetdispmode",
"vsetdispmode [name] mode(1,2,..)"
"\n\t\t: Sets display mode for all, selected or named objects.",

View File

@@ -248,5 +248,5 @@ Standard_Integer ViewerTest_CmdParser::ArgInt (const std::string& theOptionName,
//===============================================================================================
Standard_Boolean ViewerTest_CmdParser::ArgBool (const std::string& theOptionName, const Standard_Integer theArgumentIndex)
{
return static_cast<Standard_Boolean> (Draw::Atoi (Arg (theOptionName, theArgumentIndex).c_str()));
return Draw::Atoi (Arg (theOptionName, theArgumentIndex).c_str()) != 0;
}

View File

@@ -2150,7 +2150,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
{
// Get arguments
TCollection_AsciiString aName(argv[1]);
Standard_Boolean isFilled = (Standard_Boolean)Draw::Atoi(argv[5]);
Standard_Boolean isFilled = Draw::Atoi(argv[5]) != 0;
Handle(AIS_InteractiveObject) theShapeA;
Handle(AIS_InteractiveObject) theShapeB;
@@ -4445,7 +4445,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
}
const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]);
const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]);
const Standard_Boolean toTurnOn = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]) != 0;
if (aSelectionMode == 0 && anAISContext->HasOpenedContext())
{
anAISContext->CloseLocalContext();

View File

@@ -1887,7 +1887,7 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
}
VT_ProcessButton1Release (fwKeys & MK_SHIFT);
VT_ProcessButton1Release ((fwKeys & MK_SHIFT) != 0);
}
IsDragged = Standard_False;
return ViewerWindowProc( hwnd, Msg, wParam, lParam );
@@ -2069,13 +2069,13 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
if (Msg == WM_LBUTTONDOWN)
{
if (fwKeys & MK_CONTROL)
if ((fwKeys & MK_CONTROL) != 0)
{
Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
}
else
{
VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) != 0);
}
}
else if (Msg == WM_RBUTTONDOWN)
@@ -2117,27 +2117,32 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
Y_Motion = HIWORD(lParam);
if ( Up &&
fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) {
(fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON )) != 0 )
{
Up = 0;
X_ButtonPress = LOWORD(lParam);
Y_ButtonPress = HIWORD(lParam);
if ( fwKeys & MK_RBUTTON ) {
if ((fwKeys & MK_RBUTTON) != 0) {
// Start rotation
VT_ProcessButton3Press();
}
}
if ( fwKeys & MK_CONTROL ) {
if ( fwKeys & MK_LBUTTON ) {
if ((fwKeys & MK_CONTROL) != 0)
{
if ((fwKeys & MK_LBUTTON) != 0)
{
ProcessControlButton1Motion();
}
else if ( fwKeys & MK_MBUTTON ||
((fwKeys&MK_LBUTTON) &&
(fwKeys&MK_RBUTTON) ) ){
VT_ProcessControlButton2Motion();
}
else if ( fwKeys & MK_RBUTTON ) {
else if ((fwKeys & MK_MBUTTON) != 0
|| ((fwKeys & MK_LBUTTON) != 0
&& (fwKeys & MK_RBUTTON) != 0))
{
VT_ProcessControlButton2Motion();
}
else if ((fwKeys & MK_RBUTTON) != 0)
{
VT_ProcessControlButton3Motion();
}
}
@@ -5637,7 +5642,7 @@ static Standard_Integer VSelect (Draw_Interpretor& di,
}
Standard_Integer isToAllow = isShiftSelection ? Draw::Atoi(argv[argc - 2]) : Draw::Atoi(argv[argc - 1]);
myAIScontext->MainSelector()->AllowOverlapDetection((Standard_Boolean)isToAllow);
myAIScontext->MainSelector()->AllowOverlapDetection (isToAllow != 0);
aCoordsNb -= 2;
}