1 // Author: Kirill Gavrilov
2 // Copyright (c) 2017-2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _RWObj_Tools_HeaderFile
16 #define _RWObj_Tools_HeaderFile
19 #include <Graphic3d_Vec3.hxx>
20 #include <TCollection_AsciiString.hxx>
22 //! Auxiliary tools for OBJ format parser.
25 //! Read 3 float values.
26 inline bool ReadVec3 (const char* thePos,
28 Graphic3d_Vec3& theVec)
30 const char* aPos = thePos;
31 theVec.x() = (float )Strtod (aPos, &theNext);
33 theVec.y() = (float )Strtod (aPos, &theNext);
35 theVec.z() = (float )Strtod (aPos, &theNext);
36 return aPos != theNext;
39 //! Read 3 double values.
40 inline bool ReadVec3 (const char* thePos,
44 const char* aPos = thePos;
45 theVec.SetX (Strtod (aPos, &theNext));
47 theVec.SetY (Strtod (aPos, &theNext));
49 theVec.SetZ (Strtod (aPos, &theNext));
50 return aPos != theNext;
54 inline bool ReadName (const char* thePos,
55 TCollection_AsciiString& theName)
57 Standard_Integer aFrom = 0;
58 Standard_Integer aTail = (Standard_Integer )std::strlen (thePos) - 1;
59 if (aTail >= 0 && thePos[aTail] == '\n') { --aTail; }
60 if (aTail >= 0 && thePos[aTail] == '\r') { --aTail; }
61 for (; aTail >= 0 && IsSpace (thePos[aTail]); --aTail) {} // RightAdjust
62 for (; aFrom < aTail && IsSpace (thePos[aFrom]); ++aFrom) {} // LeftAdjust
68 theName = TCollection_AsciiString (thePos + aFrom, aTail - aFrom + 1);
72 //! Return true if specified char is a white space.
73 inline bool isSpaceChar (const char theChar)
77 //return IsSpace (theChar);
81 #endif // _RWObj_Tools_HeaderFile