Use PRIuPTR macros for Standard_Size values in printf.
Use STL streams instead of printf when reasonable.
//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;
}
//
//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;
}
//=======================================================================
//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;
-
}
//=======================================================================
}
return nullPCurve;
}
-
for (;;) {
char ligne[100];
- if (!lefic) printf (theprompt.ToCString());
+ if (!lefic) std::cout << theprompt.ToCString();
ligne[0] = '\0';
fgets(ligne,100,fic);
if (feof(fic)) break;
#include <NCollection_Map.hxx>
#include <NCollection_List.hxx>
#include <Standard_Mutex.hxx>
+#include <fstream>
+#include <iomanip>
IMPLEMENT_STANDARD_HANDLE(NCollection_BaseAllocator,MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(NCollection_BaseAllocator,MMgt_TShared)
}
Standard_Size aTotAlloc = 0;
Standard_Size aTotLeft = 0;
+
// print
- FILE * ff = fopen("memstat.d", "wt");
- if (ff == NULL)
+ std::ofstream aFileOut ("memstat.d", std::ios_base::trunc | std::ios_base::out);
+ if (!aFileOut.is_open())
{
- cout << "failure writing file memstat.d" << endl;
+ std::cout << "failure writing file memstat.d" << std::endl;
return;
}
- fprintf(ff, "%12s %12s %12s %12s %12s\n",
- "BlockSize", "NbAllocated", "NbLeft", "Allocated", "Left");
+ aFileOut.imbue (std::locale ("C"));
+
+ // header
+ aFileOut << std::setw(20) << "BlockSize" << ' '
+ << std::setw(12) << "NbAllocated" << ' '
+ << std::setw(12) << "NbLeft" << ' '
+ << std::setw(20) << "Allocated" << ' '
+ << std::setw(20) << "Left" << '\n';
+
+ // body
for (itLst.Init(aColl); itLst.More(); itLst.Next())
{
const StorageInfo& aInfo = itLst.Value();
Standard_Integer nbLeft = aInfo.nbAlloc - aInfo.nbFree;
Standard_Size aSizeAlloc = aInfo.nbAlloc * aInfo.roundSize;
Standard_Size aSizeLeft = nbLeft * aInfo.roundSize;
- fprintf(ff, "%12d %12d %12d %12d %12d\n", aInfo.roundSize,
- aInfo.nbAlloc, nbLeft, aSizeAlloc, aSizeLeft);
+
+ aFileOut << std::setw(20) << aInfo.roundSize << ' '
+ << std::setw(12) << aInfo.nbAlloc << ' '
+ << std::setw(12) << nbLeft << ' '
+ << std::setw(20) << aSizeAlloc << ' '
+ << std::setw(20) << aSizeLeft << '\n';
+
aTotAlloc += aSizeAlloc;
- aTotLeft += aSizeLeft;
+ aTotLeft += aSizeLeft;
}
- fprintf(ff, "%12s %12s %12s %12d %12d\n", "Total:", "", "",
- aTotAlloc, aTotLeft);
+
+ // footer
+ aFileOut << std::setw(20) << "Total:" << ' '
+ << std::setw(12) << "" << ' '
+ << std::setw(12) << "" << ' '
+ << std::setw(20) << aTotAlloc << ' '
+ << std::setw(20) << aTotLeft << '\n';
if (!StorageIDSet().IsEmpty())
{
- fprintf(ff, "Alive allocation numbers of size=%d\n", StandardCallBack_CatchSize());
- NCollection_Map<Standard_Size>::Iterator itMap1(StorageIDSet());
- for (; itMap1.More(); itMap1.Next())
- fprintf(ff, "%d\n", itMap1.Key());
+ aFileOut << "Alive allocation numbers of size=" << StandardCallBack_CatchSize() << '\n';
+ for (NCollection_Map<Standard_Size>::Iterator itMap1(StorageIDSet()); itMap1.More(); itMap1.Next())
+ {
+ aFileOut << itMap1.Key() << '\n';
+ }
}
- fclose(ff);
+ aFileOut.close();
}
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
-
#include <NCollection_HeapAllocator.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_Mutex.hxx>
{
// the size is rounded up to word size.
const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
- void * pResult = malloc(aRoundSize);
- if (!pResult) {
- char buf[128];
- sprintf (buf, "Failed to allocate %d bytes in global dynamic heap",theSize);
- Standard_OutOfMemory::Raise(&buf[0]);
+ void* aResult = malloc (aRoundSize);
+ if (aResult == NULL)
+ {
+ char aBuffer[96];
+ Sprintf (aBuffer, "Failed to allocate %" PRIuPTR " bytes in global dynamic heap", theSize);
+ Standard_OutOfMemory::Raise (aBuffer);
}
- return pResult;
+ return aResult;
}
//=======================================================================
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
#include <NCollection_IncAllocator.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
#include <Standard_Mutex.hxx>
#include <Standard_OutOfMemory.hxx>
#include <stdio.h>
+#include <fstream>
+#include <iomanip>
IMPLEMENT_STANDARD_HANDLE (NCollection_IncAllocator,NCollection_BaseAllocator)
IMPLEMENT_STANDARD_RTTIEXT (NCollection_IncAllocator,NCollection_BaseAllocator)
Standard_EXPORT void IncAllocator_PrintAlive()
{
- if (!StorageIDSet().IsEmpty())
+ if (StorageIDSet().IsEmpty())
{
- FILE * ff = fopen("inc_alive.d", "wt");
- if (ff == NULL)
- {
- cout << "failure writing file inc_alive.d" << endl;
- }
- else
- {
- fprintf(ff, "Alive IncAllocators (number, size in Kb)\n");
- NCollection_DataMap<Standard_Address, Standard_Size>::Iterator
- itMap(StorageIDMap());
- Standard_Size aTotSize = 0;
- Standard_Integer nbAlloc = 0;
- for (; itMap.More(); itMap.Next())
- {
- NCollection_IncAllocator* anAlloc =
- static_cast<NCollection_IncAllocator*>(itMap.Key());
- Standard_Size anID = itMap.Value();
- Standard_Size aSize = anAlloc->GetMemSize();
- aTotSize += aSize;
- nbAlloc++;
- fprintf(ff, "%-8d %8.1f\n", anID, double(aSize)/1024);
- }
- fprintf(ff, "Total:\n%-8d %8.1f\n", nbAlloc, double(aTotSize)/1024);
- fclose(ff);
- }
+ return;
+ }
+
+ std::ofstream aFileOut ("inc_alive.d", std::ios_base::trunc | std::ios_base::out);
+ if (!aFileOut.is_open())
+ {
+ std::cout << "failure writing file inc_alive.d" << std::endl;
+ return;
+ }
+ aFileOut.imbue (std::locale ("C"));
+ aFileOut << std::fixed << std::setprecision(1);
+
+ aFileOut << "Alive IncAllocators (number, size in Kb)\n";
+ Standard_Size aTotSize = 0;
+ Standard_Integer nbAlloc = 0;
+ for (NCollection_DataMap<Standard_Address, Standard_Size>::Iterator itMap (StorageIDMap());
+ itMap.More(); itMap.Next())
+ {
+ const NCollection_IncAllocator* anAlloc = static_cast<NCollection_IncAllocator*>(itMap.Key());
+ Standard_Size anID = itMap.Value();
+ Standard_Size aSize = anAlloc->GetMemSize();
+ aTotSize += aSize;
+ nbAlloc++;
+ aFileOut << std::setw(20) << anID << ' '
+ << std::setw(20) << (double(aSize) / 1024.0)
+ << '\n';
}
+ aFileOut << "Total:\n"
+ << std::setw(20) << nbAlloc << ' '
+ << std::setw(20) << (double(aTotSize) / 1024.0)
+ << '\n';
+ aFileOut.close();
}
//=======================================================================
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
-
#ifndef NCollection_IncAllocator_HeaderFile
#define NCollection_IncAllocator_HeaderFile
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (NCollection_IncAllocator, NCollection_BaseAllocator)
-
#endif
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
#include <OSD_MAllocHook.hxx>
#ifndef WNT
#include <set>
#include <map>
#include <cstdlib>
+#include <iomanip>
#ifndef SIZE_MAX
#define SIZE_MAX UINT_MAX
//=======================================================================
OSD_MAllocHook::LogFileHandler::LogFileHandler()
-: myLogFile(NULL),
- myBreakSize(0)
+: myBreakSize(0)
{
+ myLogFile.imbue (std::locale ("C"));
}
//=======================================================================
Standard_Boolean OSD_MAllocHook::LogFileHandler::Open(const char* theFileName)
{
Close();
- myLogFile = fopen(theFileName, "w");
- if (myLogFile != NULL)
+ myLogFile.open (theFileName);
+ if (!myLogFile.is_open())
{
- fputs("Operation type; Request Number; Block Size\n", myLogFile);
- fputs("------------------------------------------\n", myLogFile);
+ return Standard_False;
}
- return myLogFile != NULL;
+
+ myLogFile << "Operation type; Request Number; Block Size\n"
+ "------------------------------------------\n";
+ return Standard_True;
}
//=======================================================================
void OSD_MAllocHook::LogFileHandler::Close()
{
- if (myLogFile != NULL)
+ if (myLogFile.is_open())
{
- fclose(myLogFile);
- myLogFile = NULL;
+ myLogFile.close();
}
}
fclose(aLogFile);
// print the report
- FILE* aRepFile = fopen(theOutFile, "w");
- if (aRepFile == NULL)
+ std::ofstream aRepFile (theOutFile);
+ if(!aRepFile.is_open())
+ {
return Standard_False;
- fprintf(aRepFile, "%10s %10s %10s %10s %10s %10s %10s\n",
- "BlockSize", "NbAlloc", "NbLeft", "NbLeftPeak",
- "AllocSize", "LeftSize", "PeakSize");
+ }
+ aRepFile.imbue (std::locale ("C"));
+
+ aRepFile << std::setw(20) << "BlockSize "
+ << std::setw(10) << "NbAlloc "
+ << std::setw(10) << "NbLeft "
+ << std::setw(10) << "NbLeftPeak "
+ << std::setw(20) << "AllocSize "
+ << std::setw(20) << "LeftSize "
+ << std::setw(20) << "PeakSize " << std::endl;
+
Standard_Size aTotAlloc = 0;
for (std::set<StorageInfo>::const_iterator it = aStMap.begin();
it != aStMap.end(); ++it)
Standard_Size aSizeAlloc = aInfo.nbAlloc * aInfo.size;
Standard_Size aSizeLeft = nbLeft * aInfo.size;
Standard_Size aSizePeak = aInfo.nbLeftPeak * aInfo.size;
- fprintf(aRepFile, "%10d %10d %10d %10d %10Iu %10Iu %10Iu\n", aInfo.size,
- aInfo.nbAlloc, nbLeft, aInfo.nbLeftPeak,
- aSizeAlloc, aSizeLeft, aSizePeak);
+
+ aRepFile << std::setw(20) << aInfo.size << ' '
+ << std::setw(10) << aInfo.nbAlloc << ' '
+ << std::setw(10) << nbLeft << ' '
+ << std::setw(10) << aInfo.nbLeftPeak << ' '
+ << std::setw(20) << aSizeAlloc << ' '
+ << std::setw(20) << aSizeLeft << ' '
+ << std::setw(20) << aSizePeak << std::endl;
+
if (aTotAlloc + aSizeAlloc < aTotAlloc) // overflow ?
aTotAlloc = SIZE_MAX;
else
{
for (std::set<unsigned long>::const_iterator it1 = aInfo.alive->begin();
it1 != aInfo.alive->end(); ++it1)
- fprintf(aRepFile, "%10lu\n", *it1);
+ aRepFile << std::setw(10) << *it1;
}
}
- fprintf(aRepFile, "%10s %10s %10s %10s%c%10Iu %10Iu %10Iu\n", "Total:",
- "", "", "", (aTotAlloc == SIZE_MAX ? '>' : ' '), aTotAlloc,
- aTotalLeftSize, aTotalPeakSize);
- fclose(aRepFile);
+ aRepFile << std::setw(20) << "Total:"
+ << std::setw(10) << "" << ' '
+ << std::setw(10) << "" << ' '
+ << std::setw(10) << "" << ' '
+ << (aTotAlloc == SIZE_MAX ? '>' : ' ')
+ << std::setw(20) << aTotAlloc << ' '
+ << std::setw(20) << aTotalLeftSize << ' '
+ << std::setw(20) << aTotalPeakSize << std::endl;
+
+ aRepFile.close();
return Standard_True;
}
(size_t theSize,
long theRequestNum)
{
- if (myLogFile != NULL)
+ if (myLogFile.is_open())
{
myMutex.Lock();
- fprintf(myLogFile, "alloc %10lu %10u\n", theRequestNum, theSize);
+ myLogFile << "alloc "<< std::setw(10) << theRequestNum
+ << std::setw(20) << theSize << std::endl;
myMutex.Unlock();
if (myBreakSize == theSize)
{
size_t theSize,
long theRequestNum)
{
- if (myLogFile != NULL)
+ if (myLogFile.is_open())
{
myMutex.Lock();
- fprintf(myLogFile, "free %10lu %10u\n", theRequestNum, theSize);
+ myLogFile << "free " << std::setw(20) << theRequestNum
+ << std::setw(20) << theSize << std::endl;
myMutex.Unlock();
}
}
Standard_Boolean OSD_MAllocHook::CollectBySize::MakeReport(const char* theOutFile)
{
// print the report
- FILE* aRepFile = fopen(theOutFile, "w");
- if (aRepFile == NULL)
+ std::ofstream aRepFile(theOutFile);
+ if (!aRepFile.is_open())
return Standard_False;
- fprintf(aRepFile, "%10s %10s %10s %10s %10s %10s %10s\n",
- "BlockSize", "NbAlloc", "NbLeft", "NbLeftPeak",
- "AllocSize", "LeftSize", "PeakSize");
+ std::locale aCLoc("C");
+ aRepFile.imbue(aCLoc);
+
+ aRepFile << std::setw(10) << "BlockSize "
+ << std::setw(10) << "NbAlloc "
+ << std::setw(10) << "NbLeft "
+ << std::setw(10) << "NbLeftPeak "
+ << std::setw(20) << "AllocSize "
+ << std::setw(20) << "LeftSize "
+ << std::setw(20) << "PeakSize " << std::endl;
+
Standard_Size aTotAlloc = 0;
for (int i = 0; i < MAX_ALLOC_SIZE; i++)
{
Standard_Size aSizeAlloc = myArray[i].nbAlloc * aSize;
ptrdiff_t aSizeLeft = nbLeft * aSize;
Standard_Size aSizePeak = myArray[i].nbLeftPeak * aSize;
- fprintf(aRepFile, "%10d %10d %10d %10d %10Iu %10Id %10Iu\n", aSize,
- myArray[i].nbAlloc, nbLeft, myArray[i].nbLeftPeak,
- aSizeAlloc, aSizeLeft, aSizePeak);
+
+ aRepFile << std::setw(10) << aSize << ' '
+ << std::setw(10) << myArray[i].nbAlloc << ' '
+ << std::setw(10) << nbLeft << ' '
+ << std::setw(10) << myArray[i].nbLeftPeak << ' '
+ << std::setw(20) << aSizeAlloc << ' '
+ << std::setw(20) << aSizeLeft << ' '
+ << std::setw(20) << aSizePeak << std::endl;
+
if (aTotAlloc + aSizeAlloc < aTotAlloc) // overflow ?
aTotAlloc = SIZE_MAX;
else
aTotAlloc += aSizeAlloc;
}
}
- fprintf(aRepFile, "%10s %10s %10s %10s%c%10Iu %10Id %10Iu\n", "Total:",
- "", "", "", (aTotAlloc == SIZE_MAX ? '>' : ' '), aTotAlloc,
- myTotalLeftSize, myTotalPeakSize);
- fclose(aRepFile);
+ aRepFile << std::setw(10) << "Total:" << ' '
+ << std::setw(10) << "" << ' '
+ << std::setw(10) << "" << ' '
+ << std::setw(10) << "" << ' '
+ << (aTotAlloc == SIZE_MAX ? '>' : ' ')
+ << std::setw(20) << aTotAlloc << ' '
+ << std::setw(20) << myTotalLeftSize << ' '
+ << std::setw(20) << myTotalPeakSize << std::endl;
+ aRepFile.close();
return Standard_True;
}
#include <Standard_TypeDef.hxx>
#include <Standard_Mutex.hxx>
#include <stdio.h>
+#include <fstream>
/**
* This class provides the possibility to set callback for memory
Standard_EXPORT virtual void FreeEvent(void*, size_t, long);
private:
- FILE* myLogFile;
+ std::ofstream myLogFile;
Standard_Mutex myMutex;
size_t myBreakSize;
};
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
-
#include <stdio.h>
#include <QABugs.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
-Standard_Integer OCC299bug (Draw_Interpretor& di,
- Standard_Integer n,
- const char ** a)
+Standard_Integer OCC299bug (Draw_Interpretor& theDi,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
{
- char sbf[512];
-
- if (n < 3) {
- di << "Usage : " << a[0] << " Solid Point [Tolerance=1.e-7]" << "\n";
+ if (theArgNb < 3)
+ {
+ theDi << "Usage : " << theArgVec[0] << " 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");
- di<<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");
- di<<sbf;
+ else if (aS.ShapeType() != TopAbs_SOLID)
+ {
+ theDi << " Shape type must be SOLID\n";
return 1;
}
- //
- Standard_Real aTol=1.e-7;
- TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
- TopAbs_State aState = TopAbs_UNKNOWN;
- gp_Pnt aP(8., 9., 10.);
-
- if (!DrawTrSurf::GetPoint(a[2], aP) ) {
- Sprintf(sbf, " Null Point is not allowed here\n");
- di<<sbf;
+
+ gp_Pnt aP (8., 9., 10.);
+ if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
+ {
+ theDi << " Null Point is not allowed here\n";
return 1;
}
+ const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
- aTol=1.e-7;
- if (n==4) {
- aTol=Draw::Atof(a[3]);
- }
- //
- BRepClass3d_SolidClassifier aSC(aS);
- aSC.Perform(aP,aTol);
- //
- aState = aSC.State();
- //
- Sprintf(sbf, "The point is "); di<<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;
- }
- di<<sbf;
- //
- Sprintf(sbf, " shape\n");
- di<<sbf;
+ BRepClass3d_SolidClassifier aSC (aS);
+ aSC.Perform (aP, aTol);
- return 0;
+ switch (aSC.State())
+ {
+ case TopAbs_IN: theDi << "The point is IN shape\n"; return 0;
+ case TopAbs_OUT: theDi << "The point is OUT of shape\n"; return 0;
+ case TopAbs_ON: theDi << "The point is ON shape\n"; return 0;
+ case TopAbs_UNKNOWN:
+ default: theDi << "The point is UNKNOWN shape\n"; return 0;
+ }
}
#include <OSD_Process.hxx>
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
#include <QABugs.hxx>
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <Standard_ErrorHandler.hxx>
#include <tcl.h>
+#include <fstream>
+
static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
{
if(argc!=4)
return 0;
}
-//#include <fstream.h>
-#ifdef HAVE_FSTREAM
-# include <fstream>
-#elif defined (HAVE_FSTREAM_H)
-# include <fstream.h>
-#endif
-//#include <Standard_Stream.hxx>
//==========================================================================
//function : CoordLoad
// chargement d une face dans l explorer.
//==========================================================================
-static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+static Standard_Integer coordload (Draw_Interpretor& theDi,
+ Standard_Integer theArgsNb,
+ const char** theArgVec)
{
- char line[256];
- char X[30], Y[30];
- int fr;
- TopoDS_Vertex V1,V2;
- TopoDS_Edge Edge;
- TopoDS_Wire Wire;
- TopoDS_Face Face;
-
- if (argc < 3) return 1;
-
- ifstream file(argv[2], ios::in);
- if(!file)
+ if (theArgsNb < 3)
+ {
+ return 1;
+ }
+
+ std::ifstream aFile (theArgVec[2], ios::in);
+ if (!aFile)
+ {
+ theDi << "unable to open " << theArgVec[2] << " for input\n";
+ return 2;
+ }
+
+ char aLine[80];
+ memset (aLine, 0, 40);
+ aFile.getline (aLine, 80);
+
+ gp_Pnt aPnt (0.0, 0.0, 0.0);
+ aLine[40] = '\0';
+ aPnt.SetY (Draw::Atof (&aLine[20]));
+ aLine[20] = '\0';
+ aPnt.SetX (Draw::Atof (aLine));
+ TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
+ BRepBuilderAPI_MakeWire aMakeWire;
+ for (;;)
+ {
+ memset (aLine, 0, 40);
+ aFile.getline (aLine, 80);
+ if (!aFile)
{
- di<<"unable to open "<<argv[2]<<" for input"<<"\n";
- return 2;
+ break;
}
- BRepBuilderAPI_MakeWire WB;
- file.getline(line,80);
- for(int i=0;i<30;i++) X[i]=Y[i]=0;
- fr = sscanf(line,"%20c%20c",&X,&Y);
- V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(Draw::Atof(X),Draw::Atof(Y),0.0));
+ aLine[40] = '\0';
+ aPnt.SetY (Draw::Atof (&aLine[20]));
+ aLine[20] = '\0';
+ aPnt.SetX (Draw::Atof (aLine));
+ TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
+ aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
+ aVert1 = aVert2;
+ }
+ aFile.close();
- for(;;)
- {
- file.getline(line,80);
- if (!file) break;
- for(int i=0;i<30;i++) X[i]=Y[i]=0;
- fr = sscanf(line,"%20c%20c",&X,&Y);
- V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(Draw::Atof(X),Draw::Atof(Y),0.0));
- Edge = BRepBuilderAPI_MakeEdge(V1,V2);
- WB.Add(Edge);
- V1=V2;
+ if (!aMakeWire.IsDone())
+ {
+ DBRep::Set (theArgVec[1], TopoDS_Face());
+ return 0;
}
-
- file.close();
- if (WB.IsDone()) Wire = WB.Wire();
- Face = BRepBuilderAPI_MakeFace(Wire);
- DBRep::Set (argv[1],Face);
+ BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
+ DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
return 0;
}
#include <stdint.h>
#endif
+#if(defined(_MSC_VER) && (_MSC_VER < 1800))
+ // only Visual Studio 2013 (vc12) provides <cinttypes> header
+ // we do not defined all macros here - only used by OCCT framework
+ #ifdef _WIN64
+ #define PRIdPTR "I64d"
+ #define PRIuPTR "I64u"
+ #define SCNdPTR "I64d"
+ #define SCNuPTR "I64u"
+ #else
+ #define PRIdPTR "d"
+ #define PRIuPTR "u"
+ #define SCNdPTR "d"
+ #define SCNuPTR "u"
+ #endif
+#else
+ // should be just <cinttypes> since C++11
+ // however we use this code for compatibility with old C99 compilers
+ #ifndef __STDC_FORMAT_MACROS
+ #define __STDC_FORMAT_MACROS
+ #endif
+ #include <inttypes.h>
+#endif
+
#define Standard_False (Standard_Boolean)0
#define Standard_True (Standard_Boolean)1
#include <Standard_Macro.hxx>
#endif
-typedef int Standard_Integer;
-typedef double Standard_Real;
-typedef unsigned int Standard_Boolean;
-typedef float Standard_ShortReal;
-typedef char Standard_Character;
-typedef short Standard_ExtCharacter;
-typedef unsigned char Standard_Byte;
-typedef void* Standard_Address;
-typedef size_t Standard_Size;
+typedef int Standard_Integer;
+typedef double Standard_Real;
+typedef unsigned int Standard_Boolean;
+typedef float Standard_ShortReal;
+typedef char Standard_Character;
+typedef short Standard_ExtCharacter;
+typedef unsigned char Standard_Byte;
+typedef void* Standard_Address;
+typedef size_t Standard_Size;
+typedef std::time_t Standard_Time;
//
-typedef const char* Standard_CString;
-typedef const short* Standard_ExtString;
+typedef const char* Standard_CString;
+typedef const short* Standard_ExtString;
// Unicode primitives, char16_t, char32_t
typedef char Standard_Utf8Char; //!< signed UTF-8 char
typedef uint32_t Standard_Utf32Char; //!< UTF-32 char (always unsigned)
typedef wchar_t Standard_WideChar; //!< wide char (unsigned UTF-16 on Windows platform and signed UTF-32 on Linux)
-typedef std::time_t Standard_Time;
-
-#endif
+#endif // _Standard_TypeDef_HeaderFile
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-
#include <VrmlData_Scene.hxx>
#include <VrmlData_InBuffer.hxx>
#include <VrmlData_Appearance.hxx>
const Standard_Integer ** ppDummy;
const Standard_Size nCoord = aNode->Coordinates()->Length();
const Standard_Size nPoly = aNode->Polygons (ppDummy);
- char buf[64];
- Sprintf (buf, "IndexedFaceSet (%d vertices, %d polygons)", nCoord, nPoly);
+ char buf[80];
+ Sprintf (buf, "IndexedFaceSet (%" PRIuPTR " vertices, %" PRIuPTR " polygons)",
+ nCoord, nPoly);
+
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
} else if (theNode->IsKind(STANDARD_TYPE(VrmlData_IndexedLineSet))) {
const Handle(VrmlData_IndexedLineSet) aNode =
const Standard_Integer ** ppDummy;
const Standard_Size nCoord = aNode->Coordinates()->Length();
const Standard_Size nPoly = aNode->Polygons (ppDummy);
- char buf[64];
- Sprintf (buf, "IndexedLineSet (%d vertices, %d polygons)", nCoord, nPoly);
+
+ char buf[80];
+ Sprintf(buf, "IndexedLineSet (%" PRIuPTR " vertices, %" PRIuPTR " polygons)",
+ nCoord, nPoly);
+
dumpNodeHeader (theStream, theIndent, buf, theNode->Name());
} else if (theNode->IsKind(STANDARD_TYPE(VrmlData_Material))) {
// const Handle(VrmlData_Material) aMaterial =