mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0023042: Potential mistakes in (s)printf usage
Use PRIuPTR macros for Standard_Size values in printf. Use STL streams instead of printf when reasonable.
This commit is contained in:
@@ -88,49 +88,36 @@ static Standard_Integer bhaspc (Draw_Interpretor& , Standard_Integer , con
|
||||
//function : bclassify
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer bclassify (Draw_Interpretor& aDI,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
Standard_Integer bclassify (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
char sbf[512];
|
||||
|
||||
if (n < 3) {
|
||||
Sprintf(sbf, " Use >bclassify Solid Point [Tolerance=1.e-7]\n");
|
||||
aDI<<sbf;
|
||||
if (theArgNb < 3)
|
||||
{
|
||||
theDI << " Use >bclassify Solid Point [Tolerance=1.e-7]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopoDS_Shape aS = DBRep::Get(a[1]);
|
||||
if (aS.IsNull()) {
|
||||
Sprintf(sbf, " Null Shape is not allowed here\n");
|
||||
aDI<<sbf;
|
||||
|
||||
TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
|
||||
if (aS.IsNull())
|
||||
{
|
||||
theDI << " Null Shape is not allowed here\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aS.ShapeType()!=TopAbs_SOLID) {
|
||||
Sprintf(sbf, " Shape type must be SOLID\n");
|
||||
aDI<<sbf;
|
||||
else if (aS.ShapeType() != TopAbs_SOLID)
|
||||
{
|
||||
theDI << " Shape type must be SOLID\n";
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
Standard_Real aTol=1.e-7;
|
||||
TopAbs_State aState = TopAbs_UNKNOWN;
|
||||
gp_Pnt aP(8., 9., 10.);
|
||||
|
||||
DrawTrSurf::GetPoint(a[2], aP);
|
||||
|
||||
aTol=1.e-7;
|
||||
if (n==4) {
|
||||
aTol=Draw::Atof(a[3]);
|
||||
}
|
||||
//
|
||||
BRepClass3d_SolidClassifier aSC(aS);
|
||||
aSC.Perform(aP,aTol);
|
||||
//
|
||||
aState = aSC.State();
|
||||
//
|
||||
PrintState (aDI, aState);
|
||||
//
|
||||
|
||||
gp_Pnt aP (8., 9., 10.);
|
||||
DrawTrSurf::GetPoint (theArgVec[2], aP);
|
||||
const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7; //Precision::Confusion();
|
||||
|
||||
BRepClass3d_SolidClassifier aSC (aS);
|
||||
aSC.Perform (aP,aTol);
|
||||
|
||||
PrintState (theDI, aSC.State());
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
@@ -138,50 +125,37 @@ Standard_Integer bclassify (Draw_Interpretor& aDI,
|
||||
//function : b2dclassify
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer b2dclassify (Draw_Interpretor& aDI,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
Standard_Integer b2dclassify (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
char sbf[512];
|
||||
|
||||
if (n < 3) {
|
||||
Sprintf(sbf, " Use >bclassify Face Point2d [Tol2D=Tol(Face)]\n");
|
||||
aDI<<sbf;
|
||||
if (theArgNb < 3)
|
||||
{
|
||||
theDI << " Use >bclassify Face Point2d [Tol2D=Tol(Face)]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopoDS_Shape aS = DBRep::Get(a[1]);
|
||||
if (aS.IsNull()) {
|
||||
Sprintf(sbf, " Null Shape is not allowed here\n");
|
||||
aDI<<sbf;
|
||||
|
||||
TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
|
||||
if (aS.IsNull())
|
||||
{
|
||||
theDI << " Null Shape is not allowed here\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aS.ShapeType()!=TopAbs_FACE) {
|
||||
Sprintf(sbf, " Shape type must be FACE\n");
|
||||
aDI<<sbf;
|
||||
else if (aS.ShapeType() != TopAbs_FACE)
|
||||
{
|
||||
theDI << " Shape type must be FACE\n";
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
Standard_Real aTol;
|
||||
TopAbs_State aState = TopAbs_UNKNOWN;
|
||||
gp_Pnt2d aP(8., 9.);
|
||||
|
||||
DrawTrSurf::GetPoint2d(a[2], aP);
|
||||
|
||||
const TopoDS_Face& aF=TopoDS::Face(aS);
|
||||
aTol=BRep_Tool::Tolerance(aF);
|
||||
if (n==4) {
|
||||
aTol=Draw::Atof(a[3]);
|
||||
}
|
||||
//
|
||||
|
||||
gp_Pnt2d aP (8., 9.);
|
||||
DrawTrSurf::GetPoint2d (theArgVec[2], aP);
|
||||
const TopoDS_Face& aF = TopoDS::Face(aS);
|
||||
const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : BRep_Tool::Tolerance (aF);
|
||||
|
||||
BRepClass_FaceClassifier aClassifier;
|
||||
aClassifier.Perform(aF, aP, aTol);
|
||||
//
|
||||
aState = aClassifier.State();
|
||||
//
|
||||
PrintState (aDI, aState);
|
||||
//
|
||||
|
||||
PrintState (theDI, aClassifier.State());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -232,38 +206,19 @@ Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char**
|
||||
|
||||
//=======================================================================
|
||||
//function : PrintState
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void PrintState (Draw_Interpretor& aDI,
|
||||
const TopAbs_State& aState)
|
||||
void PrintState (Draw_Interpretor& theDI,
|
||||
const TopAbs_State& theState)
|
||||
{
|
||||
char sbf[512];
|
||||
TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
|
||||
//
|
||||
Sprintf(sbf, "The point is "); aDI<<sbf;
|
||||
//
|
||||
switch (aState) {
|
||||
case TopAbs_IN:
|
||||
Sprintf(sbf, sIN.ToCString());
|
||||
break;
|
||||
case TopAbs_OUT:
|
||||
Sprintf(sbf, sOUT.ToCString());
|
||||
break;
|
||||
case TopAbs_ON:
|
||||
Sprintf(sbf, sON.ToCString());
|
||||
break;
|
||||
case TopAbs_UNKNOWN:
|
||||
Sprintf(sbf, sUNKNOWN.ToCString());
|
||||
break;
|
||||
default:
|
||||
Sprintf(sbf, sUNKNOWN.ToCString());
|
||||
break;
|
||||
switch (theState)
|
||||
{
|
||||
case TopAbs_IN: theDI << "The point is IN shape\n"; return;
|
||||
case TopAbs_OUT: theDI << "The point is OUT of shape\n"; return;
|
||||
case TopAbs_ON: theDI << "The point is ON shape\n"; return;
|
||||
case TopAbs_UNKNOWN:
|
||||
default: theDI << "The point is UNKNOWN shape\n"; return;
|
||||
}
|
||||
aDI<<sbf;
|
||||
//
|
||||
Sprintf(sbf, " shape\n");
|
||||
aDI<<sbf;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -316,4 +271,3 @@ Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
|
||||
}
|
||||
return nullPCurve;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user