Modif dans le parsing IFC suppressions des espaces avant traitement de la chaine
parent
e6c5095e5b
commit
8267d93537
1938
code/IFCLoader.cpp
1938
code/IFCLoader.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,242 +1,238 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file LineSplitter.h
|
||||||
|
* @brief LineSplitter, a helper class to iterate through all lines
|
||||||
|
* of a file easily. Works with StreamReader.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_LINE_SPLITTER_H
|
||||||
|
#define INCLUDED_LINE_SPLITTER_H
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "StreamReader.h"
|
||||||
|
#include "ParsingUtils.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
/** Usage:
|
||||||
|
@code
|
||||||
|
for(LineSplitter splitter(stream);splitter;++splitter) {
|
||||||
|
|
||||||
|
if (*splitter == "hi!") {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
else if (splitter->substr(0,5) == "hello") {
|
||||||
|
...
|
||||||
|
// access the third token in the line (tokens are space-separated)
|
||||||
|
if (strtol(splitter[2]) > 5) { .. }
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Current line is: " << splitter.get_index() << std::endl;
|
||||||
|
}
|
||||||
|
@endcode */
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
class LineSplitter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef size_t line_idx;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
/** construct from existing stream reader
|
||||||
|
note: trim is *always* assumed true if skyp_empty_lines==true
|
||||||
|
*/
|
||||||
|
LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true)
|
||||||
|
: stream(stream)
|
||||||
|
, swallow()
|
||||||
|
, skip_empty_lines(skip_empty_lines)
|
||||||
|
, trim(trim)
|
||||||
|
{
|
||||||
|
cur.reserve(1024);
|
||||||
|
operator++();
|
||||||
|
|
||||||
|
idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
/** pseudo-iterator increment */
|
||||||
|
LineSplitter& operator++() {
|
||||||
|
if(swallow) {
|
||||||
|
swallow = false;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
if (!*this) {
|
||||||
|
throw std::logic_error("End of file, no more lines to be retrieved.");
|
||||||
|
}
|
||||||
|
char s;
|
||||||
|
cur.clear();
|
||||||
|
while(stream.GetRemainingSize() && (s = stream.GetI1(),1)) {
|
||||||
|
if (s == '\n' || s == '\r') {
|
||||||
|
if (skip_empty_lines) {
|
||||||
|
while (stream.GetRemainingSize() && ((s = stream.GetI1()) == ' ' || s == '\r' || s == '\n'));
|
||||||
|
if (stream.GetRemainingSize()) {
|
||||||
|
stream.IncPtr(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// skip both potential line terminators but don't read past this line.
|
||||||
|
if (stream.GetRemainingSize() && (s == '\r' && stream.GetI1() != '\n')) {
|
||||||
|
stream.IncPtr(-1);
|
||||||
|
}
|
||||||
|
if (trim) {
|
||||||
|
while (stream.GetRemainingSize() && ((s = stream.GetI1()) == ' ' || s == '\t'));
|
||||||
|
if (stream.GetRemainingSize()) {
|
||||||
|
stream.IncPtr(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cur += s;
|
||||||
|
}
|
||||||
|
++idx;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
LineSplitter& operator++(int) {
|
||||||
|
return ++(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------
|
||||||
|
/** get a pointer to the beginning of a particular token */
|
||||||
|
const char* operator[] (size_t idx) const {
|
||||||
|
const char* s = operator->()->c_str();
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
SkipSpaces(&s);
|
||||||
All rights reserved.
|
for(size_t i = 0; i < idx; ++i) {
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
for(;!IsSpace(*s); ++s) {
|
||||||
with or without modification, are permitted provided that the
|
if(IsLineEnd(*s)) {
|
||||||
following conditions are met:
|
throw std::range_error("Token index out of range, EOL reached");
|
||||||
|
}
|
||||||
* Redistributions of source code must retain the above
|
}
|
||||||
copyright notice, this list of conditions and the
|
SkipSpaces(&s);
|
||||||
following disclaimer.
|
}
|
||||||
|
return s;
|
||||||
* Redistributions in binary form must reproduce the above
|
}
|
||||||
copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other
|
// -----------------------------------------
|
||||||
materials provided with the distribution.
|
/** extract the start positions of N tokens from the current line*/
|
||||||
|
template <size_t N>
|
||||||
* Neither the name of the assimp team, nor the names of its
|
void get_tokens(const char* (&tokens)[N]) const {
|
||||||
contributors may be used to endorse or promote products
|
const char* s = operator->()->c_str();
|
||||||
derived from this software without specific prior
|
|
||||||
written permission of the assimp team.
|
SkipSpaces(&s);
|
||||||
|
for(size_t i = 0; i < N; ++i) {
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
if(IsLineEnd(*s)) {
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
throw std::range_error("Token count out of range, EOL reached");
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
}
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
tokens[i] = s;
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
for(;*s && !IsSpace(*s); ++s);
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
SkipSpaces(&s);
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
}
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
}
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
// -----------------------------------------
|
||||||
*/
|
/** member access */
|
||||||
|
const std::string* operator -> () const {
|
||||||
/** @file LineSplitter.h
|
return &cur;
|
||||||
* @brief LineSplitter, a helper class to iterate through all lines
|
}
|
||||||
* of a file easily. Works with StreamReader.
|
|
||||||
*/
|
std::string operator* () const {
|
||||||
#ifndef INCLUDED_LINE_SPLITTER_H
|
return cur;
|
||||||
#define INCLUDED_LINE_SPLITTER_H
|
}
|
||||||
|
|
||||||
#include <stdexcept>
|
// -----------------------------------------
|
||||||
|
/** boolean context */
|
||||||
#include "StreamReader.h"
|
operator bool() const {
|
||||||
#include "ParsingUtils.h"
|
return stream.GetRemainingSize()>0;
|
||||||
|
}
|
||||||
namespace Assimp {
|
|
||||||
|
// -----------------------------------------
|
||||||
// ------------------------------------------------------------------------------------------------
|
/** line indices are zero-based, empty lines are included */
|
||||||
/** Usage:
|
operator line_idx() const {
|
||||||
@code
|
return idx;
|
||||||
for(LineSplitter splitter(stream);splitter;++splitter) {
|
}
|
||||||
|
|
||||||
if (*splitter == "hi!") {
|
line_idx get_index() const {
|
||||||
...
|
return idx;
|
||||||
}
|
}
|
||||||
else if (splitter->substr(0,5) == "hello") {
|
|
||||||
...
|
// -----------------------------------------
|
||||||
// access the third token in the line (tokens are space-separated)
|
/** access the underlying stream object */
|
||||||
if (strtol(splitter[2]) > 5) { .. }
|
StreamReaderLE& get_stream() {
|
||||||
}
|
return stream;
|
||||||
|
}
|
||||||
std::cout << "Current line is: " << splitter.get_index() << std::endl;
|
|
||||||
}
|
// -----------------------------------------
|
||||||
@endcode */
|
/** !strcmp((*this)->substr(0,strlen(check)),check) */
|
||||||
// ------------------------------------------------------------------------------------------------
|
bool match_start(const char* check) {
|
||||||
class LineSplitter
|
const size_t len = strlen(check);
|
||||||
{
|
|
||||||
public:
|
return len <= cur.length() && std::equal(check,check+len,cur.begin());
|
||||||
|
}
|
||||||
typedef size_t line_idx;
|
|
||||||
|
|
||||||
public:
|
// -----------------------------------------
|
||||||
|
/** swallow the next call to ++, return the previous value. */
|
||||||
// -----------------------------------------
|
void swallow_next_increment() {
|
||||||
/** construct from existing stream reader
|
swallow = true;
|
||||||
note: trim is *always* assumed true if skyp_empty_lines==true
|
}
|
||||||
*/
|
|
||||||
LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true)
|
private:
|
||||||
: stream(stream)
|
|
||||||
, swallow()
|
line_idx idx;
|
||||||
, skip_empty_lines(skip_empty_lines)
|
std::string cur;
|
||||||
, trim(trim)
|
StreamReaderLE& stream;
|
||||||
{
|
bool swallow, skip_empty_lines, trim;
|
||||||
cur.reserve(1024);
|
};
|
||||||
operator++();
|
|
||||||
|
}
|
||||||
idx = 0;
|
#endif // INCLUDED_LINE_SPLITTER_H
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** pseudo-iterator increment */
|
|
||||||
LineSplitter& operator++() {
|
|
||||||
if(swallow) {
|
|
||||||
swallow = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!*this) {
|
|
||||||
throw std::logic_error("End of file, no more lines to be retrieved.");
|
|
||||||
}
|
|
||||||
|
|
||||||
char s;
|
|
||||||
|
|
||||||
cur.clear();
|
|
||||||
while(stream.GetRemainingSize() && (s = stream.GetI1(),1)) {
|
|
||||||
if (s == '\n' || s == '\r') {
|
|
||||||
if (skip_empty_lines) {
|
|
||||||
while (stream.GetRemainingSize() && ((s = stream.GetI1()) == ' ' || s == '\r' || s == '\n'));
|
|
||||||
if (stream.GetRemainingSize()) {
|
|
||||||
stream.IncPtr(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// skip both potential line terminators but don't read past this line.
|
|
||||||
if (stream.GetRemainingSize() && (s == '\r' && stream.GetI1() != '\n')) {
|
|
||||||
stream.IncPtr(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trim) {
|
|
||||||
while (stream.GetRemainingSize() && ((s = stream.GetI1()) == ' ' || s == '\t'));
|
|
||||||
if (stream.GetRemainingSize()) {
|
|
||||||
stream.IncPtr(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cur += s;
|
|
||||||
}
|
|
||||||
|
|
||||||
++idx;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
LineSplitter& operator++(int) {
|
|
||||||
return ++(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** get a pointer to the beginning of a particular token */
|
|
||||||
const char* operator[] (size_t idx) const {
|
|
||||||
const char* s = operator->()->c_str();
|
|
||||||
|
|
||||||
SkipSpaces(&s);
|
|
||||||
for(size_t i = 0; i < idx; ++i) {
|
|
||||||
|
|
||||||
for(;!IsSpace(*s); ++s) {
|
|
||||||
if(IsLineEnd(*s)) {
|
|
||||||
throw std::range_error("Token index out of range, EOL reached");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SkipSpaces(&s);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** extract the start positions of N tokens from the current line*/
|
|
||||||
template <size_t N>
|
|
||||||
void get_tokens(const char* (&tokens)[N]) const {
|
|
||||||
const char* s = operator->()->c_str();
|
|
||||||
|
|
||||||
SkipSpaces(&s);
|
|
||||||
for(size_t i = 0; i < N; ++i) {
|
|
||||||
if(IsLineEnd(*s)) {
|
|
||||||
throw std::range_error("Token count out of range, EOL reached");
|
|
||||||
}
|
|
||||||
tokens[i] = s;
|
|
||||||
|
|
||||||
for(;*s && !IsSpace(*s); ++s);
|
|
||||||
SkipSpaces(&s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** member access */
|
|
||||||
const std::string* operator -> () const {
|
|
||||||
return &cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string operator* () const {
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** boolean context */
|
|
||||||
operator bool() const {
|
|
||||||
return stream.GetRemainingSize()>0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** line indices are zero-based, empty lines are included */
|
|
||||||
operator line_idx() const {
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
line_idx get_index() const {
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** access the underlying stream object */
|
|
||||||
StreamReaderLE& get_stream() {
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** !strcmp((*this)->substr(0,strlen(check)),check) */
|
|
||||||
bool match_start(const char* check) {
|
|
||||||
const size_t len = strlen(check);
|
|
||||||
|
|
||||||
return len <= cur.length() && std::equal(check,check+len,cur.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------
|
|
||||||
/** swallow the next call to ++, return the previous value. */
|
|
||||||
void swallow_next_increment() {
|
|
||||||
swallow = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
line_idx idx;
|
|
||||||
std::string cur;
|
|
||||||
StreamReaderLE& stream;
|
|
||||||
bool swallow, skip_empty_lines, trim;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // INCLUDED_LINE_SPLITTER_H
|
|
||||||
|
|
|
@ -192,19 +192,19 @@ namespace STEP {
|
||||||
}
|
}
|
||||||
|
|
||||||
// utilities to deal with SELECT entities, which currently lack automatic
|
// utilities to deal with SELECT entities, which currently lack automatic
|
||||||
// conversion support.
|
// conversion support.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T& ResolveSelect(const DB& db) const {
|
const T& ResolveSelect(const DB& db) const {
|
||||||
return Couple<T>(db).MustGetObject(To<EXPRESS::ENTITY>())->template To<T>();
|
return Couple<T>(db).MustGetObject(To<EXPRESS::ENTITY>())->template To<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T* ResolveSelectPtr(const DB& db) const {
|
const T* ResolveSelectPtr(const DB& db) const {
|
||||||
const EXPRESS::ENTITY* e = ToPtr<EXPRESS::ENTITY>();
|
const EXPRESS::ENTITY* e = ToPtr<EXPRESS::ENTITY>();
|
||||||
return e?Couple<T>(db).MustGetObject(*e)->template ToPtr<T>():(const T*)0;
|
return e?Couple<T>(db).MustGetObject(*e)->template ToPtr<T>():(const T*)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** parse a variable from a string and set 'inout' to the character
|
/** parse a variable from a string and set 'inout' to the character
|
||||||
* behind the last consumed character. An optional schema enables,
|
* behind the last consumed character. An optional schema enables,
|
||||||
|
|
|
@ -175,7 +175,7 @@ bool IsEntityDef(const std::string& snext)
|
||||||
if (*it == '=') {
|
if (*it == '=') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (*it < '0' || *it > '9') {
|
if ((*it < '0' || *it > '9') && *it != ' ') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,16 +197,17 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
|
|
||||||
const DB::ObjectMap& map = db.GetObjects();
|
const DB::ObjectMap& map = db.GetObjects();
|
||||||
LineSplitter& splitter = db.GetSplitter();
|
LineSplitter& splitter = db.GetSplitter();
|
||||||
|
|
||||||
while (splitter) {
|
while (splitter) {
|
||||||
bool has_next = false;
|
bool has_next = false;
|
||||||
std::string s = *splitter;
|
std::string s = *splitter;
|
||||||
if (s == "ENDSEC;") {
|
if (s == "ENDSEC;") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
s.erase(std::remove(s.begin(), s.end(), ' '), s.end());
|
||||||
|
|
||||||
// want one-based line numbers for human readers, so +1
|
// want one-based line numbers for human readers, so +1
|
||||||
const uint64_t line = splitter.get_index()+1;
|
const uint64_t line = splitter.get_index()+1;
|
||||||
|
|
||||||
// LineSplitter already ignores empty lines
|
// LineSplitter already ignores empty lines
|
||||||
ai_assert(s.length());
|
ai_assert(s.length());
|
||||||
if (s[0] != '#') {
|
if (s[0] != '#') {
|
||||||
|
@ -214,12 +215,10 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
++splitter;
|
++splitter;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// extract id, entity class name and argument string,
|
// extract id, entity class name and argument string,
|
||||||
// but don't create the actual object yet.
|
// but don't create the actual object yet.
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
const std::string::size_type n0 = s.find_first_of('=');
|
const std::string::size_type n0 = s.find_first_of('=');
|
||||||
if (n0 == std::string::npos) {
|
if (n0 == std::string::npos) {
|
||||||
DefaultLogger::get()->warn(AddLineNumber("expected token \'=\'",line));
|
DefaultLogger::get()->warn(AddLineNumber("expected token \'=\'",line));
|
||||||
|
@ -233,13 +232,10 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
++splitter;
|
++splitter;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type n1 = s.find_first_of('(',n0);
|
std::string::size_type n1 = s.find_first_of('(',n0);
|
||||||
if (n1 == std::string::npos) {
|
if (n1 == std::string::npos) {
|
||||||
|
|
||||||
has_next = true;
|
has_next = true;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
for( ++splitter; splitter; ++splitter) {
|
for( ++splitter; splitter; ++splitter) {
|
||||||
const std::string& snext = *splitter;
|
const std::string& snext = *splitter;
|
||||||
if (snext.empty()) {
|
if (snext.empty()) {
|
||||||
|
@ -269,13 +265,11 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
|
|
||||||
has_next = true;
|
has_next = true;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
for( ++splitter; splitter; ++splitter) {
|
for( ++splitter; splitter; ++splitter) {
|
||||||
const std::string& snext = *splitter;
|
const std::string& snext = *splitter;
|
||||||
if (snext.empty()) {
|
if (snext.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the next line doesn't start an entity, so maybe it is
|
// the next line doesn't start an entity, so maybe it is
|
||||||
// just a continuation for this line, keep going
|
// just a continuation for this line, keep going
|
||||||
if (!IsEntityDef(snext)) {
|
if (!IsEntityDef(snext)) {
|
||||||
|
@ -287,7 +281,6 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
DefaultLogger::get()->warn(AddLineNumber("expected token \')\'",line));
|
DefaultLogger::get()->warn(AddLineNumber("expected token \')\'",line));
|
||||||
continue;
|
continue;
|
||||||
|
@ -300,24 +293,18 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
|
|
||||||
std::string::size_type ns = n0;
|
std::string::size_type ns = n0;
|
||||||
do ++ns; while( IsSpace(s.at(ns)));
|
do ++ns; while( IsSpace(s.at(ns)));
|
||||||
|
|
||||||
std::string::size_type ne = n1;
|
std::string::size_type ne = n1;
|
||||||
do --ne; while( IsSpace(s.at(ne)));
|
do --ne; while( IsSpace(s.at(ne)));
|
||||||
|
|
||||||
std::string type = s.substr(ns,ne-ns+1);
|
std::string type = s.substr(ns,ne-ns+1);
|
||||||
std::transform( type.begin(), type.end(), type.begin(), &Assimp::ToLower<char> );
|
std::transform( type.begin(), type.end(), type.begin(), &Assimp::ToLower<char> );
|
||||||
|
|
||||||
const char* sz = scheme.GetStaticStringForToken(type);
|
const char* sz = scheme.GetStaticStringForToken(type);
|
||||||
if(sz) {
|
if(sz) {
|
||||||
|
|
||||||
const std::string::size_type len = n2-n1+1;
|
const std::string::size_type len = n2-n1+1;
|
||||||
char* const copysz = new char[len+1];
|
char* const copysz = new char[len+1];
|
||||||
std::copy(s.c_str()+n1,s.c_str()+n2+1,copysz);
|
std::copy(s.c_str()+n1,s.c_str()+n2+1,copysz);
|
||||||
copysz[len] = '\0';
|
copysz[len] = '\0';
|
||||||
|
|
||||||
db.InternInsert(new LazyObject(db,id,line,sz,copysz));
|
db.InternInsert(new LazyObject(db,id,line,sz,copysz));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!has_next) {
|
if(!has_next) {
|
||||||
++splitter;
|
++splitter;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +314,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
||||||
DefaultLogger::get()->warn("STEP: ignoring unexpected EOF");
|
DefaultLogger::get()->warn("STEP: ignoring unexpected EOF");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !DefaultLogger::isNullLogger() ){
|
if ( !DefaultLogger::isNullLogger()){
|
||||||
DefaultLogger::get()->debug((Formatter::format(),"STEP: got ",map.size()," object records with ",
|
DefaultLogger::get()->debug((Formatter::format(),"STEP: got ",map.size()," object records with ",
|
||||||
db.GetRefs().size()," inverse index entries"));
|
db.GetRefs().size()," inverse index entries"));
|
||||||
}
|
}
|
||||||
|
@ -338,7 +325,6 @@ boost::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*&
|
||||||
{
|
{
|
||||||
const char* cur = inout;
|
const char* cur = inout;
|
||||||
SkipSpaces(&cur);
|
SkipSpaces(&cur);
|
||||||
|
|
||||||
if (*cur == ',' || IsSpaceOrNewLine(*cur)) {
|
if (*cur == ',' || IsSpaceOrNewLine(*cur)) {
|
||||||
throw STEP::SyntaxError("unexpected token, expected parameter",line);
|
throw STEP::SyntaxError("unexpected token, expected parameter",line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,10 @@ namespace Assimp {
|
||||||
namespace STEP {
|
namespace STEP {
|
||||||
|
|
||||||
// ### Parsing a STEP file is a twofold procedure ###
|
// ### Parsing a STEP file is a twofold procedure ###
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// 1) read file header and return to caller, who checks if the
|
// 1) read file header and return to caller, who checks if the
|
||||||
// file is of a supported schema ..
|
// file is of a supported schema ..
|
||||||
DB* ReadFileHeader(boost::shared_ptr<IOStream> stream);
|
DB* ReadFileHeader(boost::shared_ptr<IOStream> stream);
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// 2) read the actual file contents using a user-supplied set of
|
// 2) read the actual file contents using a user-supplied set of
|
||||||
// conversion functions to interpret the data.
|
// conversion functions to interpret the data.
|
||||||
|
@ -60,8 +58,6 @@ namespace STEP {
|
||||||
template <size_t N, size_t N2> inline void ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, const char* const (&arr)[N], const char* const (&arr2)[N2]) {
|
template <size_t N, size_t N2> inline void ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, const char* const (&arr)[N], const char* const (&arr2)[N2]) {
|
||||||
return ReadFile(db,scheme,arr,N,arr2,N2);
|
return ReadFile(db,scheme,arr,N,arr2,N2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // ! STEP
|
} // ! STEP
|
||||||
} // ! Assimp
|
} // ! Assimp
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue