Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:17:03

0001 // Author: Kirill Gavrilov
0002 // Copyright (c) 2017-2019 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _RWObj_Tools_HeaderFile
0016 #define _RWObj_Tools_HeaderFile
0017 
0018 #include <gp_XYZ.hxx>
0019 #include <NCollection_Vec3.hxx>
0020 #include <Standard_TypeDef.hxx>
0021 #include <TCollection_AsciiString.hxx>
0022 
0023 //! Auxiliary tools for OBJ format parser.
0024 namespace RWObj_Tools
0025 {
0026 //! Read 3 float values.
0027 inline bool ReadVec3(const char* thePos, char*& theNext, NCollection_Vec3<float>& theVec)
0028 {
0029   const char* aPos = thePos;
0030   theVec.x()       = (float)Strtod(aPos, &theNext);
0031   aPos             = theNext;
0032   theVec.y()       = (float)Strtod(aPos, &theNext);
0033   aPos             = theNext;
0034   theVec.z()       = (float)Strtod(aPos, &theNext);
0035   return aPos != theNext;
0036 }
0037 
0038 //! Read 3 double values.
0039 inline bool ReadVec3(const char* thePos, char*& theNext, gp_XYZ& theVec)
0040 {
0041   const char* aPos = thePos;
0042   theVec.SetX(Strtod(aPos, &theNext));
0043   aPos = theNext;
0044   theVec.SetY(Strtod(aPos, &theNext));
0045   aPos = theNext;
0046   theVec.SetZ(Strtod(aPos, &theNext));
0047   return aPos != theNext;
0048 }
0049 
0050 //! Read string.
0051 inline bool ReadName(const char* thePos, TCollection_AsciiString& theName)
0052 {
0053   int aFrom = 0;
0054   int aTail = (int)std::strlen(thePos) - 1;
0055   if (aTail >= 0 && thePos[aTail] == '\n')
0056   {
0057     --aTail;
0058   }
0059   if (aTail >= 0 && thePos[aTail] == '\r')
0060   {
0061     --aTail;
0062   }
0063   for (; aTail >= 0 && IsSpace(thePos[aTail]); --aTail)
0064   {
0065   } // RightAdjust
0066   for (; aFrom < aTail && IsSpace(thePos[aFrom]); ++aFrom)
0067   {
0068   } // LeftAdjust
0069   if (aFrom > aTail)
0070   {
0071     theName.Clear();
0072     return false;
0073   }
0074   theName = TCollection_AsciiString(thePos + aFrom, aTail - aFrom + 1);
0075   return true;
0076 }
0077 
0078 //! Return true if specified char is a white space.
0079 inline bool isSpaceChar(const char theChar)
0080 {
0081   return theChar == ' ' || theChar == '\t';
0082   // return IsSpace (theChar);
0083 }
0084 } // namespace RWObj_Tools
0085 
0086 #endif // _RWObj_Tools_HeaderFile