X3D importer: Implemented support for binary X3D files
parent
e66dc5c9ad
commit
457dff1bf1
|
@ -647,6 +647,9 @@ ADD_ASSIMP_IMPORTER(X3D
|
||||||
X3DImporter_Rendering.cpp
|
X3DImporter_Rendering.cpp
|
||||||
X3DImporter_Shape.cpp
|
X3DImporter_Shape.cpp
|
||||||
X3DImporter_Texturing.cpp
|
X3DImporter_Texturing.cpp
|
||||||
|
FIReader.hpp
|
||||||
|
FIReader.cpp
|
||||||
|
X3DVocabulary.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_ASSIMP_IMPORTER( GLTF
|
ADD_ASSIMP_IMPORTER( GLTF
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,171 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2017, 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 FIReader.hpp
|
||||||
|
/// \brief Reader for Fast Infoset encoded binary XML files.
|
||||||
|
/// \date 2017
|
||||||
|
/// \author Patrick Daehne
|
||||||
|
|
||||||
|
#ifndef INCLUDED_AI_FI_READER_H
|
||||||
|
#define INCLUDED_AI_FI_READER_H
|
||||||
|
|
||||||
|
#include <irrXML.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
struct FIValue {
|
||||||
|
virtual const std::string &toString() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIStringValue: public FIValue {
|
||||||
|
std::string value;
|
||||||
|
static std::shared_ptr<FIStringValue> create(std::string &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIByteValue: public FIValue {
|
||||||
|
std::vector<uint8_t> value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIHexValue: public FIByteValue {
|
||||||
|
static std::shared_ptr<FIHexValue> create(std::vector<uint8_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIBase64Value: public FIByteValue {
|
||||||
|
static std::shared_ptr<FIBase64Value> create(std::vector<uint8_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIShortValue: public FIValue {
|
||||||
|
std::vector<int16_t> value;
|
||||||
|
static std::shared_ptr<FIShortValue> create(std::vector<int16_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIIntValue: public FIValue {
|
||||||
|
std::vector<int32_t> value;
|
||||||
|
static std::shared_ptr<FIIntValue> create(std::vector<int32_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FILongValue: public FIValue {
|
||||||
|
std::vector<int64_t> value;
|
||||||
|
static std::shared_ptr<FILongValue> create(std::vector<int64_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIBoolValue: public FIValue {
|
||||||
|
std::vector<bool> value;
|
||||||
|
static std::shared_ptr<FIBoolValue> create(std::vector<bool> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIFloatValue: public FIValue {
|
||||||
|
std::vector<float> value;
|
||||||
|
static std::shared_ptr<FIFloatValue> create(std::vector<float> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIDoubleValue: public FIValue {
|
||||||
|
std::vector<double> value;
|
||||||
|
static std::shared_ptr<FIDoubleValue> create(std::vector<double> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIUUIDValue: public FIByteValue {
|
||||||
|
static std::shared_ptr<FIUUIDValue> create(std::vector<uint8_t> &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FICDATAValue: public FIStringValue {
|
||||||
|
static std::shared_ptr<FICDATAValue> create(std::string &&value);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIDecoder {
|
||||||
|
virtual std::shared_ptr<const FIValue> decode(const uint8_t *data, size_t len) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIQName {
|
||||||
|
const char *name;
|
||||||
|
const char *prefix;
|
||||||
|
const char *uri;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FIVocabulary {
|
||||||
|
const char **restrictedAlphabetTable;
|
||||||
|
size_t restrictedAlphabetTableSize;
|
||||||
|
const char **encodingAlgorithmTable;
|
||||||
|
size_t encodingAlgorithmTableSize;
|
||||||
|
const char **prefixTable;
|
||||||
|
size_t prefixTableSize;
|
||||||
|
const char **namespaceNameTable;
|
||||||
|
size_t namespaceNameTableSize;
|
||||||
|
const char **localNameTable;
|
||||||
|
size_t localNameTableSize;
|
||||||
|
const char **otherNCNameTable;
|
||||||
|
size_t otherNCNameTableSize;
|
||||||
|
const char **otherURITable;
|
||||||
|
size_t otherURITableSize;
|
||||||
|
const std::shared_ptr<const FIValue> *attributeValueTable;
|
||||||
|
size_t attributeValueTableSize;
|
||||||
|
const std::shared_ptr<const FIValue> *charactersTable;
|
||||||
|
size_t charactersTableSize;
|
||||||
|
const std::shared_ptr<const FIValue> *otherStringTable;
|
||||||
|
size_t otherStringTableSize;
|
||||||
|
const FIQName *elementNameTable;
|
||||||
|
size_t elementNameTableSize;
|
||||||
|
const FIQName *attributeNameTable;
|
||||||
|
size_t attributeNameTableSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IOStream;
|
||||||
|
|
||||||
|
class FIReader: public irr::io::IIrrXMLReader<char, irr::io::IXMLBase> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual std::shared_ptr<const FIValue> getAttributeEncodedValue(int idx) const = 0;
|
||||||
|
|
||||||
|
virtual std::shared_ptr<const FIValue> getAttributeEncodedValue(const char *name) const = 0;
|
||||||
|
|
||||||
|
virtual void registerDecoder(const std::string &algorithmUri, std::unique_ptr<FIDecoder> decoder) = 0;
|
||||||
|
|
||||||
|
virtual void registerVocabulary(const std::string &vocabularyUri, const FIVocabulary *vocabulary) = 0;
|
||||||
|
|
||||||
|
static std::unique_ptr<FIReader> create(IOStream *stream);
|
||||||
|
|
||||||
|
};// class IFIReader
|
||||||
|
|
||||||
|
}// namespace Assimp
|
||||||
|
|
||||||
|
#endif // INCLUDED_AI_FI_READER_H
|
|
@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include <assimp/DefaultIOSystem.h>
|
#include <assimp/DefaultIOSystem.h>
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
|
#include "FIReader.hpp"
|
||||||
|
|
||||||
// Header files, stdlib.
|
// Header files, stdlib.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -66,15 +67,16 @@ const aiImporterDesc X3DImporter::Description = {
|
||||||
"smalcom",
|
"smalcom",
|
||||||
"",
|
"",
|
||||||
"See documentation in source code. Chapter: Limitations.",
|
"See documentation in source code. Chapter: Limitations.",
|
||||||
aiImporterFlags_SupportTextFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
|
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"x3d"
|
"x3d x3db"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string X3DImporter::whitespace(" ,\t\n\r");
|
const std::regex X3DImporter::pattern_nws(R"([^, \t\r\n]+)");
|
||||||
|
const std::regex X3DImporter::pattern_true(R"(^\s*(?:true|1)\s*$)", std::regex::icase);
|
||||||
|
|
||||||
X3DImporter::X3DImporter()
|
X3DImporter::X3DImporter()
|
||||||
: NodeElement_Cur( nullptr )
|
: NodeElement_Cur( nullptr )
|
||||||
|
@ -83,7 +85,6 @@ X3DImporter::X3DImporter()
|
||||||
}
|
}
|
||||||
|
|
||||||
X3DImporter::~X3DImporter() {
|
X3DImporter::~X3DImporter() {
|
||||||
delete mReader;
|
|
||||||
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
@ -370,6 +371,14 @@ bool X3DImporter::XML_SearchNode(const std::string& pNodeName)
|
||||||
|
|
||||||
bool X3DImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
|
bool X3DImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
|
||||||
{
|
{
|
||||||
|
auto boolValue = std::dynamic_pointer_cast<const FIBoolValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (boolValue) {
|
||||||
|
if (boolValue->value.size() == 1) {
|
||||||
|
return boolValue->value.front();
|
||||||
|
}
|
||||||
|
throw DeadlyImportError("Invalid bool value");
|
||||||
|
}
|
||||||
|
else {
|
||||||
std::string val(mReader->getAttributeValue(pAttrIdx));
|
std::string val(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
if(val == "false")
|
if(val == "false")
|
||||||
|
@ -379,9 +388,18 @@ std::string val(mReader->getAttributeValue(pAttrIdx));
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Bool attribute value can contain \"false\" or \"true\" not the \"" + val + "\"");
|
throw DeadlyImportError("Bool attribute value can contain \"false\" or \"true\" not the \"" + val + "\"");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
|
float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
|
||||||
{
|
{
|
||||||
|
auto floatValue = std::dynamic_pointer_cast<const FIFloatValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (floatValue) {
|
||||||
|
if (floatValue->value.size() == 1) {
|
||||||
|
return floatValue->value.front();
|
||||||
|
}
|
||||||
|
throw DeadlyImportError("Invalid float value");
|
||||||
|
}
|
||||||
|
else {
|
||||||
std::string val;
|
std::string val;
|
||||||
float tvalf;
|
float tvalf;
|
||||||
|
|
||||||
|
@ -390,18 +408,28 @@ float X3DImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
|
||||||
|
|
||||||
return tvalf;
|
return tvalf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t X3DImporter::XML_ReadNode_GetAttrVal_AsI32(const int pAttrIdx)
|
int32_t X3DImporter::XML_ReadNode_GetAttrVal_AsI32(const int pAttrIdx)
|
||||||
{
|
{
|
||||||
|
auto intValue = std::dynamic_pointer_cast<const FIIntValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (intValue) {
|
||||||
|
if (intValue->value.size() == 1) {
|
||||||
|
return intValue->value.front();
|
||||||
|
}
|
||||||
|
throw DeadlyImportError("Invalid int value");
|
||||||
|
}
|
||||||
|
else {
|
||||||
return strtol10(mReader->getAttributeValue(pAttrIdx));
|
return strtol10(mReader->getAttributeValue(pAttrIdx));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsCol3f(const int pAttrIdx, aiColor3D& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsCol3f(const int pAttrIdx, aiColor3D& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
std::list<float>::iterator it;
|
std::vector<float>::iterator it;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);
|
||||||
if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
it = tlist.begin();
|
it = tlist.begin();
|
||||||
|
@ -412,10 +440,10 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsCol3f(const int pAttrIdx, aiColor3D&
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsVec2f(const int pAttrIdx, aiVector2D& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsVec2f(const int pAttrIdx, aiVector2D& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
std::list<float>::iterator it;
|
std::vector<float>::iterator it;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);
|
||||||
if(tlist.size() != 2) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
if(tlist.size() != 2) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
it = tlist.begin();
|
it = tlist.begin();
|
||||||
|
@ -425,10 +453,10 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsVec2f(const int pAttrIdx, aiVector2D
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsVec3f(const int pAttrIdx, aiVector3D& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsVec3f(const int pAttrIdx, aiVector3D& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
std::list<float>::iterator it;
|
std::vector<float>::iterator it;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);
|
||||||
if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
if(tlist.size() != 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
it = tlist.begin();
|
it = tlist.begin();
|
||||||
|
@ -437,166 +465,75 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsVec3f(const int pAttrIdx, aiVector3D
|
||||||
pValue.z = *it;
|
pValue.z = *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListB(const int pAttrIdx, std::list<bool>& pValue)
|
|
||||||
{
|
|
||||||
const char *tok_cur = mReader->getAttributeValue(pAttrIdx);
|
|
||||||
const char *tok_end = tok_cur + strlen(tok_cur);
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
while((tok_cur < tok_end) && (whitespace.find_first_of(*tok_cur) != std::string::npos)) tok_cur++;// skip spaces between values.
|
|
||||||
if (tok_cur >= tok_end)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(strncmp(tok_cur, "true", 4) == 0)
|
|
||||||
{
|
|
||||||
pValue.push_back(true);
|
|
||||||
tok_cur += 4;
|
|
||||||
}
|
|
||||||
else if(strncmp(tok_cur, "false", 5) == 0)
|
|
||||||
{
|
|
||||||
pValue.push_back(false);
|
|
||||||
tok_cur += 5;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
|
|
||||||
}
|
|
||||||
}// for(;;)
|
|
||||||
}
|
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector<bool>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector<bool>& pValue)
|
||||||
{
|
{
|
||||||
std::list<bool> tlist;
|
auto boolValue = std::dynamic_pointer_cast<const FIBoolValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (boolValue) {
|
||||||
XML_ReadNode_GetAttrVal_AsListB(pAttrIdx, tlist);// read as list
|
pValue = boolValue->value;
|
||||||
// and copy to array
|
|
||||||
if(tlist.size() > 0)
|
|
||||||
{
|
|
||||||
pValue.reserve(tlist.size());
|
|
||||||
for(std::list<bool>::iterator it = tlist.begin(); it != tlist.end(); it++) pValue.push_back(*it);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
const char *val = mReader->getAttributeValue(pAttrIdx);
|
||||||
|
std::cregex_iterator wordItBegin(val, val + strlen(val), pattern_nws);
|
||||||
|
const std::cregex_iterator wordItEnd;
|
||||||
|
pValue.clear();
|
||||||
|
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const std::cmatch &match) { return std::regex_match(match.str(), pattern_true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListI32(const int pAttrIdx, std::list<int32_t>& pValue)
|
|
||||||
{
|
|
||||||
const char* tstr = mReader->getAttributeValue(pAttrIdx);
|
|
||||||
const char* tstr_end = tstr + strlen(tstr);
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const char* ostr;
|
|
||||||
|
|
||||||
int32_t tval32;
|
|
||||||
|
|
||||||
while((tstr < tstr_end) && (whitespace.find_first_of(*tstr) != std::string::npos)) tstr++;// skip spaces between values.
|
|
||||||
|
|
||||||
tval32 = strtol10(tstr, &ostr);
|
|
||||||
if(ostr == tstr) break;
|
|
||||||
|
|
||||||
tstr = ostr;
|
|
||||||
pValue.push_back(tval32);
|
|
||||||
} while(tstr < tstr_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector<int32_t>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector<int32_t>& pValue)
|
||||||
{
|
{
|
||||||
std::list<int32_t> tlist;
|
auto intValue = std::dynamic_pointer_cast<const FIIntValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (intValue) {
|
||||||
XML_ReadNode_GetAttrVal_AsListI32(pAttrIdx, tlist);// read as list
|
pValue = intValue->value;
|
||||||
// and copy to array
|
|
||||||
if(tlist.size() > 0)
|
|
||||||
{
|
|
||||||
pValue.reserve(tlist.size());
|
|
||||||
for(std::list<int32_t>::iterator it = tlist.begin(); it != tlist.end(); it++) pValue.push_back(*it);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
const char *val = mReader->getAttributeValue(pAttrIdx);
|
||||||
|
std::cregex_iterator wordItBegin(val, val + strlen(val), pattern_nws);
|
||||||
|
const std::cregex_iterator wordItEnd;
|
||||||
|
pValue.clear();
|
||||||
|
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const std::cmatch &match) { return std::stoi(match.str()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListF(const int pAttrIdx, std::list<float>& pValue)
|
|
||||||
{
|
|
||||||
std::string str_fixed;
|
|
||||||
|
|
||||||
// at first check string values like '.xxx'.
|
|
||||||
ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), str_fixed);
|
|
||||||
|
|
||||||
// and convert all values and place it in list.
|
|
||||||
const char* pstr = str_fixed.c_str();
|
|
||||||
const char* pstr_end = pstr + str_fixed.size();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
float tvalf;
|
|
||||||
|
|
||||||
while((pstr < pstr_end) && (whitespace.find_first_of(*pstr) != std::string::npos)) pstr++;// skip spaces between values.
|
|
||||||
|
|
||||||
if(pstr < pstr_end)// additional check, because attribute value can be ended with spaces.
|
|
||||||
{
|
|
||||||
pstr = fast_atoreal_move(pstr, tvalf, false);
|
|
||||||
pValue.push_back(tvalf);
|
|
||||||
}
|
|
||||||
} while(pstr < pstr_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector<float>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector<float>& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
auto floatValue = std::dynamic_pointer_cast<const FIFloatValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (floatValue) {
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);// read as list
|
pValue = floatValue->value;
|
||||||
// and copy to array
|
|
||||||
if(tlist.size() > 0)
|
|
||||||
{
|
|
||||||
pValue.reserve(tlist.size());
|
|
||||||
for(std::list<float>::iterator it = tlist.begin(); it != tlist.end(); it++) pValue.push_back(*it);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
const char *val = mReader->getAttributeValue(pAttrIdx);
|
||||||
|
std::cregex_iterator wordItBegin(val, val + strlen(val), pattern_nws);
|
||||||
|
const std::cregex_iterator wordItEnd;
|
||||||
|
pValue.clear();
|
||||||
|
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const std::cmatch &match) { return std::stof(match.str()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListD(const int pAttrIdx, std::list<double>& pValue)
|
|
||||||
{
|
|
||||||
std::string str_fixed;
|
|
||||||
|
|
||||||
// at first check string values like '.xxx'.
|
|
||||||
ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), str_fixed);
|
|
||||||
|
|
||||||
// and convert all values and place it in list.
|
|
||||||
const char* pstr = str_fixed.c_str();
|
|
||||||
const char* pstr_end = pstr + str_fixed.size();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
double tvald;
|
|
||||||
|
|
||||||
while((pstr < pstr_end) && (whitespace.find_first_of(*pstr) != std::string::npos)) pstr++;// skip spaces between values.
|
|
||||||
|
|
||||||
if(pstr < pstr_end)// additional check, because attribute value can be ended with spaces.
|
|
||||||
{
|
|
||||||
pstr = fast_atoreal_move(pstr, tvald, false);
|
|
||||||
pValue.push_back(tvald);
|
|
||||||
}
|
|
||||||
} while(pstr < pstr_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector<double>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector<double>& pValue)
|
||||||
{
|
{
|
||||||
std::list<double> tlist;
|
auto doubleValue = std::dynamic_pointer_cast<const FIDoubleValue>(mReader->getAttributeEncodedValue(pAttrIdx));
|
||||||
|
if (doubleValue) {
|
||||||
XML_ReadNode_GetAttrVal_AsListD(pAttrIdx, tlist);// read as list
|
pValue = doubleValue->value;
|
||||||
// and copy to array
|
}
|
||||||
if(tlist.size() > 0)
|
else {
|
||||||
{
|
const char *val = mReader->getAttributeValue(pAttrIdx);
|
||||||
pValue.reserve(tlist.size());
|
std::cregex_iterator wordItBegin(val, val + strlen(val), pattern_nws);
|
||||||
for(std::list<double>::iterator it = tlist.begin(); it != tlist.end(); it++) pValue.push_back(*it);
|
const std::cregex_iterator wordItEnd;
|
||||||
|
pValue.clear();
|
||||||
|
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const std::cmatch &match) { return std::stod(match.str()); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol3f(const int pAttrIdx, std::list<aiColor3D>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol3f(const int pAttrIdx, std::list<aiColor3D>& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);// read as list
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list
|
||||||
if(tlist.size() % 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
if(tlist.size() % 3) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
// copy data to array
|
// copy data to array
|
||||||
for(std::list<float>::iterator it = tlist.begin(); it != tlist.end();)
|
for(std::vector<float>::iterator it = tlist.begin(); it != tlist.end();)
|
||||||
{
|
{
|
||||||
aiColor3D tcol;
|
aiColor3D tcol;
|
||||||
|
|
||||||
|
@ -622,13 +559,13 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol3f(const int pAttrIdx, std::ve
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol4f(const int pAttrIdx, std::list<aiColor4D>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsListCol4f(const int pAttrIdx, std::list<aiColor4D>& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);// read as list
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list
|
||||||
if(tlist.size() % 4) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
if(tlist.size() % 4) Throw_ConvertFail_Str2ArrF(mReader->getAttributeValue(pAttrIdx));
|
||||||
|
|
||||||
// copy data to array
|
// copy data to array
|
||||||
for(std::list<float>::iterator it = tlist.begin(); it != tlist.end();)
|
for(std::vector<float>::iterator it = tlist.begin(); it != tlist.end();)
|
||||||
{
|
{
|
||||||
aiColor4D tcol;
|
aiColor4D tcol;
|
||||||
|
|
||||||
|
@ -658,16 +595,16 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrCol4f(const int pAttrIdx, std::ve
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec2f(const int pAttrIdx, std::list<aiVector2D>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec2f(const int pAttrIdx, std::list<aiVector2D>& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);// read as list
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list
|
||||||
if ( tlist.size() % 2 )
|
if ( tlist.size() % 2 )
|
||||||
{
|
{
|
||||||
Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) );
|
Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy data to array
|
// copy data to array
|
||||||
for(std::list<float>::iterator it = tlist.begin(); it != tlist.end();)
|
for(std::vector<float>::iterator it = tlist.begin(); it != tlist.end();)
|
||||||
{
|
{
|
||||||
aiVector2D tvec;
|
aiVector2D tvec;
|
||||||
|
|
||||||
|
@ -695,16 +632,16 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrVec2f(const int pAttrIdx, std::ve
|
||||||
|
|
||||||
void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec3f(const int pAttrIdx, std::list<aiVector3D>& pValue)
|
void X3DImporter::XML_ReadNode_GetAttrVal_AsListVec3f(const int pAttrIdx, std::list<aiVector3D>& pValue)
|
||||||
{
|
{
|
||||||
std::list<float> tlist;
|
std::vector<float> tlist;
|
||||||
|
|
||||||
XML_ReadNode_GetAttrVal_AsListF(pAttrIdx, tlist);// read as list
|
XML_ReadNode_GetAttrVal_AsArrF(pAttrIdx, tlist);// read as list
|
||||||
if ( tlist.size() % 3 )
|
if ( tlist.size() % 3 )
|
||||||
{
|
{
|
||||||
Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) );
|
Throw_ConvertFail_Str2ArrF( mReader->getAttributeValue( pAttrIdx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy data to array
|
// copy data to array
|
||||||
for(std::list<float>::iterator it = tlist.begin(); it != tlist.end();)
|
for(std::vector<float>::iterator it = tlist.begin(); it != tlist.end();)
|
||||||
{
|
{
|
||||||
aiVector3D tvec;
|
aiVector3D tvec;
|
||||||
|
|
||||||
|
@ -894,9 +831,9 @@ void X3DImporter::GeometryHelper_MakeQL_RectParallelepiped(const aiVector3D& pSi
|
||||||
|
|
||||||
#undef MESH_RectParallelepiped_CREATE_VERT
|
#undef MESH_RectParallelepiped_CREATE_VERT
|
||||||
|
|
||||||
void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::list<int32_t>& pCoordIdx, std::vector<aiFace>& pFaces, unsigned int& pPrimitiveTypes) const
|
void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::vector<int32_t>& pCoordIdx, std::vector<aiFace>& pFaces, unsigned int& pPrimitiveTypes) const
|
||||||
{
|
{
|
||||||
std::list<int32_t> f_data(pCoordIdx);
|
std::vector<int32_t> f_data(pCoordIdx);
|
||||||
std::vector<unsigned int> inds;
|
std::vector<unsigned int> inds;
|
||||||
unsigned int prim_type = 0;
|
unsigned int prim_type = 0;
|
||||||
|
|
||||||
|
@ -909,7 +846,7 @@ void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::list<int32_t>&
|
||||||
pFaces.reserve(f_data.size() / 3);
|
pFaces.reserve(f_data.size() / 3);
|
||||||
inds.reserve(4);
|
inds.reserve(4);
|
||||||
//PrintVectorSet("build. ci", pCoordIdx);
|
//PrintVectorSet("build. ci", pCoordIdx);
|
||||||
for(std::list<int32_t>::iterator it = f_data.begin(); it != f_data.end(); it++)
|
for(std::vector<int32_t>::iterator it = f_data.begin(); it != f_data.end(); it++)
|
||||||
{
|
{
|
||||||
// when face is got count how many indices in it.
|
// when face is got count how many indices in it.
|
||||||
if(*it == (-1))
|
if(*it == (-1))
|
||||||
|
@ -1001,7 +938,7 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor4D
|
||||||
}// if(pColorPerVertex) else
|
}// if(pColorPerVertex) else
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx,
|
void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pColorIdx,
|
||||||
const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const
|
const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const
|
||||||
{
|
{
|
||||||
std::list<aiColor4D> tcol;
|
std::list<aiColor4D> tcol;
|
||||||
|
@ -1016,7 +953,7 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
MeshGeometry_AddColor(pMesh, pCoordIdx, pColorIdx, tcol, pColorPerVertex);
|
MeshGeometry_AddColor(pMesh, pCoordIdx, pColorIdx, tcol, pColorPerVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx,
|
void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pColorIdx,
|
||||||
const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const
|
const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const
|
||||||
{
|
{
|
||||||
std::vector<aiColor4D> col_tgt_arr;
|
std::vector<aiColor4D> col_tgt_arr;
|
||||||
|
@ -1047,7 +984,7 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex.
|
// create list with colors for every vertex.
|
||||||
col_tgt_arr.resize(pMesh.mNumVertices);
|
col_tgt_arr.resize(pMesh.mNumVertices);
|
||||||
for(std::list<int32_t>::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); colidx_it++, coordidx_it++)
|
for(std::vector<int32_t>::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); colidx_it++, coordidx_it++)
|
||||||
{
|
{
|
||||||
if ( *colidx_it == ( -1 ) )
|
if ( *colidx_it == ( -1 ) )
|
||||||
{
|
{
|
||||||
|
@ -1095,7 +1032,7 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
// create list with colors for every vertex using faces indices.
|
// create list with colors for every vertex using faces indices.
|
||||||
col_tgt_arr.resize(pMesh.mNumFaces);
|
col_tgt_arr.resize(pMesh.mNumFaces);
|
||||||
|
|
||||||
std::list<int32_t>::const_iterator colidx_it = pColorIdx.begin();
|
std::vector<int32_t>::const_iterator colidx_it = pColorIdx.begin();
|
||||||
for(size_t fi = 0; fi < pMesh.mNumFaces; fi++)
|
for(size_t fi = 0; fi < pMesh.mNumFaces; fi++)
|
||||||
{
|
{
|
||||||
if((unsigned int)*colidx_it > pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddColor2. Face idx is out of range.");
|
if((unsigned int)*colidx_it > pMesh.mNumFaces) throw DeadlyImportError("MeshGeometry_AddColor2. Face idx is out of range.");
|
||||||
|
@ -1125,7 +1062,7 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
MeshGeometry_AddColor(pMesh, col_tgt_list, pColorPerVertex);
|
MeshGeometry_AddColor(pMesh, col_tgt_list, pColorPerVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pNormalIdx,
|
void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pNormalIdx,
|
||||||
const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const
|
const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const
|
||||||
{
|
{
|
||||||
std::vector<size_t> tind;
|
std::vector<size_t> tind;
|
||||||
|
@ -1146,7 +1083,7 @@ void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<int32_t>
|
||||||
if(pNormalIdx.size() != pCoordIdx.size()) throw DeadlyImportError("Normals and Coords inidces count must be equal.");
|
if(pNormalIdx.size() != pCoordIdx.size()) throw DeadlyImportError("Normals and Coords inidces count must be equal.");
|
||||||
|
|
||||||
tind.reserve(pNormalIdx.size());
|
tind.reserve(pNormalIdx.size());
|
||||||
for(std::list<int32_t>::const_iterator it = pNormalIdx.begin(); it != pNormalIdx.end(); it++)
|
for(std::vector<int32_t>::const_iterator it = pNormalIdx.begin(); it != pNormalIdx.end(); it++)
|
||||||
{
|
{
|
||||||
if(*it != (-1)) tind.push_back(*it);
|
if(*it != (-1)) tind.push_back(*it);
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1115,7 @@ void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<int32_t>
|
||||||
{
|
{
|
||||||
if(pMesh.mNumFaces != pNormalIdx.size()) throw DeadlyImportError("Normals faces count must be equal to mesh faces count.");
|
if(pMesh.mNumFaces != pNormalIdx.size()) throw DeadlyImportError("Normals faces count must be equal to mesh faces count.");
|
||||||
|
|
||||||
std::list<int32_t>::const_iterator normidx_it = pNormalIdx.begin();
|
std::vector<int32_t>::const_iterator normidx_it = pNormalIdx.begin();
|
||||||
|
|
||||||
tind.reserve(pNormalIdx.size());
|
tind.reserve(pNormalIdx.size());
|
||||||
for(size_t i = 0, i_e = pNormalIdx.size(); i < i_e; i++) tind.push_back(*normidx_it++);
|
for(size_t i = 0, i_e = pNormalIdx.size(); i < i_e; i++) tind.push_back(*normidx_it++);
|
||||||
|
@ -1231,7 +1168,7 @@ void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<aiVector
|
||||||
}// if(pNormalPerVertex) else
|
}// if(pNormalPerVertex) else
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pTexCoordIdx,
|
void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pTexCoordIdx,
|
||||||
const std::list<aiVector2D>& pTexCoords) const
|
const std::list<aiVector2D>& pTexCoords) const
|
||||||
{
|
{
|
||||||
std::vector<aiVector3D> texcoord_arr_copy;
|
std::vector<aiVector3D> texcoord_arr_copy;
|
||||||
|
@ -1304,7 +1241,7 @@ void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list<aiVect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const
|
aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::vector<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const
|
||||||
{
|
{
|
||||||
std::vector<aiFace> faces;
|
std::vector<aiFace> faces;
|
||||||
unsigned int prim_type = 0;
|
unsigned int prim_type = 0;
|
||||||
|
@ -1407,9 +1344,12 @@ void X3DImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern FIVocabulary X3D_vocabulary_3_2;
|
||||||
|
extern FIVocabulary X3D_vocabulary_3_3;
|
||||||
|
|
||||||
void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
|
std::unique_ptr<FIReader> OldReader = std::move(mReader);// store current XMLreader.
|
||||||
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
|
@ -1417,19 +1357,18 @@ void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError( "Failed to open X3D file " + pFile + "." );
|
throw DeadlyImportError( "Failed to open X3D file " + pFile + "." );
|
||||||
}
|
}
|
||||||
// generate a XML reader for it
|
mReader = FIReader::create(file.get());
|
||||||
std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
|
|
||||||
mReader = irr::io::createIrrXMLReader(mIOWrapper.get());
|
|
||||||
if ( !mReader )
|
if ( !mReader )
|
||||||
{
|
{
|
||||||
throw DeadlyImportError( "Failed to create XML reader for file" + pFile + "." );
|
throw DeadlyImportError( "Failed to create XML reader for file" + pFile + "." );
|
||||||
}
|
}
|
||||||
|
mReader->registerVocabulary("urn:web3d:x3d:fi-vocabulary-3.2", &X3D_vocabulary_3_2);
|
||||||
|
mReader->registerVocabulary("urn:web3d:x3d:fi-vocabulary-3.3", &X3D_vocabulary_3_3);
|
||||||
// start reading
|
// start reading
|
||||||
ParseNode_Root();
|
ParseNode_Root();
|
||||||
|
|
||||||
delete mReader;
|
|
||||||
// restore old XMLreader
|
// restore old XMLreader
|
||||||
mReader = OldReader;
|
mReader = std::move(OldReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::ParseNode_Root()
|
void X3DImporter::ParseNode_Root()
|
||||||
|
@ -1643,7 +1582,7 @@ bool X3DImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool p
|
||||||
{
|
{
|
||||||
const std::string extension = GetExtension(pFile);
|
const std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
if(extension == "x3d") return true;
|
if((extension == "x3d") || (extension == "x3db")) return true;
|
||||||
|
|
||||||
if(!extension.length() || pCheckSig)
|
if(!extension.length() || pCheckSig)
|
||||||
{
|
{
|
||||||
|
@ -1658,6 +1597,7 @@ bool X3DImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool p
|
||||||
void X3DImporter::GetExtensionList(std::set<std::string>& pExtensionList)
|
void X3DImporter::GetExtensionList(std::set<std::string>& pExtensionList)
|
||||||
{
|
{
|
||||||
pExtensionList.insert("x3d");
|
pExtensionList.insert("x3d");
|
||||||
|
pExtensionList.insert("x3db");
|
||||||
}
|
}
|
||||||
|
|
||||||
const aiImporterDesc* X3DImporter::GetInfo () const
|
const aiImporterDesc* X3DImporter::GetInfo () const
|
||||||
|
|
|
@ -56,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "irrXMLWrapper.h"
|
#include "irrXMLWrapper.h"
|
||||||
|
#include "FIReader.hpp"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
@ -449,33 +451,21 @@ private:
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \param [out] pValue - read data.
|
/// \param [out] pValue - read data.
|
||||||
void XML_ReadNode_GetAttrVal_AsListB(const int pAttrIdx, std::list<bool>& pValue);
|
|
||||||
|
|
||||||
/// \overload void XML_ReadNode_GetAttrVal_AsListBool(const int pAttrIdx, std::list<bool>& pValue)
|
|
||||||
void XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector<bool>& pValue);
|
void XML_ReadNode_GetAttrVal_AsArrB(const int pAttrIdx, std::vector<bool>& pValue);
|
||||||
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \param [out] pValue - read data.
|
/// \param [out] pValue - read data.
|
||||||
void XML_ReadNode_GetAttrVal_AsListI32(const int pAttrIdx, std::list<int32_t>& pValue);
|
|
||||||
|
|
||||||
/// \overload void XML_ReadNode_GetAttrVal_AsListI32(const int pAttrIdx, std::list<int32_t>& pValue)
|
|
||||||
void XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector<int32_t>& pValue);
|
void XML_ReadNode_GetAttrVal_AsArrI32(const int pAttrIdx, std::vector<int32_t>& pValue);
|
||||||
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \param [out] pValue - read data.
|
/// \param [out] pValue - read data.
|
||||||
void XML_ReadNode_GetAttrVal_AsListF(const int pAttrIdx, std::list<float>& pValue);
|
|
||||||
|
|
||||||
/// \overload void XML_ReadNode_GetAttrVal_AsListF(const int pAttrIdx, std::list<float>& pValue)
|
|
||||||
void XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector<float>& pValue);
|
void XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector<float>& pValue);
|
||||||
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
|
||||||
/// \param [out] pValue - read data.
|
/// \param [out] pValue - read data.
|
||||||
void XML_ReadNode_GetAttrVal_AsListD(const int pAttrIdx, std::list<double>& pValue);
|
|
||||||
|
|
||||||
/// \overload void XML_ReadNode_GetAttrVal_AsListD(const int pAttrIdx, std::list<double>& pValue)
|
|
||||||
void XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector<double>& pValue);
|
void XML_ReadNode_GetAttrVal_AsArrD(const int pAttrIdx, std::vector<double>& pValue);
|
||||||
|
|
||||||
/// Read attribute value.
|
/// Read attribute value.
|
||||||
|
@ -554,7 +544,7 @@ private:
|
||||||
/// \param [in] pCoordIdx - vertices indices divided by delimiter "-1".
|
/// \param [in] pCoordIdx - vertices indices divided by delimiter "-1".
|
||||||
/// \param [in] pFaces - created faces array.
|
/// \param [in] pFaces - created faces array.
|
||||||
/// \param [in] pPrimitiveTypes - type of primitives in faces.
|
/// \param [in] pPrimitiveTypes - type of primitives in faces.
|
||||||
void GeometryHelper_CoordIdxStr2FacesArr(const std::list<int32_t>& pCoordIdx, std::vector<aiFace>& pFaces, unsigned int& pPrimitiveTypes) const;
|
void GeometryHelper_CoordIdxStr2FacesArr(const std::vector<int32_t>& pCoordIdx, std::vector<aiFace>& pFaces, unsigned int& pPrimitiveTypes) const;
|
||||||
|
|
||||||
/// Add colors to mesh.
|
/// Add colors to mesh.
|
||||||
/// a. If colorPerVertex is FALSE, colours are applied to each face, as follows:
|
/// a. If colorPerVertex is FALSE, colours are applied to each face, as follows:
|
||||||
|
@ -573,11 +563,11 @@ private:
|
||||||
/// then pColorIdx contain color indices for every faces and must not contain delimiter "-1".
|
/// then pColorIdx contain color indices for every faces and must not contain delimiter "-1".
|
||||||
/// \param [in] pColors - defined colors.
|
/// \param [in] pColors - defined colors.
|
||||||
/// \param [in] pColorPerVertex - if \ref pColorPerVertex is true then color in \ref pColors defined for every vertex, if false - for every face.
|
/// \param [in] pColorPerVertex - if \ref pColorPerVertex is true then color in \ref pColors defined for every vertex, if false - for every face.
|
||||||
void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx,
|
void MeshGeometry_AddColor(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pColorIdx,
|
||||||
const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const;
|
const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const;
|
||||||
|
|
||||||
/// \overload void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx, const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const;
|
/// \overload void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx, const std::list<aiColor4D>& pColors, const bool pColorPerVertex) const;
|
||||||
void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pColorIdx,
|
void MeshGeometry_AddColor(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pColorIdx,
|
||||||
const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const;
|
const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const;
|
||||||
|
|
||||||
/// Add colors to mesh.
|
/// Add colors to mesh.
|
||||||
|
@ -590,14 +580,14 @@ private:
|
||||||
void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const;
|
void MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor3D>& pColors, const bool pColorPerVertex) const;
|
||||||
|
|
||||||
/// Add normals to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
/// Add normals to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
||||||
void MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pNormalIdx,
|
void MeshGeometry_AddNormal(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pNormalIdx,
|
||||||
const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const;
|
const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const;
|
||||||
|
|
||||||
/// Add normals to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
/// Add normals to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
||||||
void MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const;
|
void MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<aiVector3D>& pNormals, const bool pNormalPerVertex) const;
|
||||||
|
|
||||||
/// Add texture coordinates to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
/// Add texture coordinates to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
||||||
void MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list<int32_t>& pCoordIdx, const std::list<int32_t>& pTexCoordIdx,
|
void MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::vector<int32_t>& pCoordIdx, const std::vector<int32_t>& pTexCoordIdx,
|
||||||
const std::list<aiVector2D>& pTexCoords) const;
|
const std::list<aiVector2D>& pTexCoords) const;
|
||||||
|
|
||||||
/// Add texture coordinates to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
/// Add texture coordinates to mesh. Function work similar to \ref MeshGeometry_AddColor;
|
||||||
|
@ -607,7 +597,7 @@ private:
|
||||||
/// \param [in] pCoordIdx - vertices indices divided by delimiter "-1".
|
/// \param [in] pCoordIdx - vertices indices divided by delimiter "-1".
|
||||||
/// \param [in] pVertices - vertices of mesh.
|
/// \param [in] pVertices - vertices of mesh.
|
||||||
/// \return created mesh.
|
/// \return created mesh.
|
||||||
aiMesh* GeometryHelper_MakeMesh(const std::list<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const;
|
aiMesh* GeometryHelper_MakeMesh(const std::vector<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const;
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/******** Functions: parse set private *********/
|
/******** Functions: parse set private *********/
|
||||||
|
@ -826,13 +816,15 @@ private:
|
||||||
/****************** Constants ******************/
|
/****************** Constants ******************/
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
static const aiImporterDesc Description;
|
static const aiImporterDesc Description;
|
||||||
static const std::string whitespace;
|
static const std::regex pattern_nws;
|
||||||
|
static const std::regex pattern_true;
|
||||||
|
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/****************** Variables ******************/
|
/****************** Variables ******************/
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
CX3DImporter_NodeElement* NodeElement_Cur;///< Current element.
|
CX3DImporter_NodeElement* NodeElement_Cur;///< Current element.
|
||||||
irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
|
std::unique_ptr<FIReader> mReader;///< Pointer to XML-reader object
|
||||||
IOSystem *mpIOHandler;
|
IOSystem *mpIOHandler;
|
||||||
};// class X3DImporter
|
};// class X3DImporter
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid()
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
float creaseAngle = 0;
|
float creaseAngle = 0;
|
||||||
std::list<float> height;
|
std::vector<float> height;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
int32_t xDimension = 0;
|
int32_t xDimension = 0;
|
||||||
|
@ -301,7 +301,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid()
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("creaseAngle", creaseAngle, XML_ReadNode_GetAttrVal_AsFloat);
|
MACRO_ATTRREAD_CHECK_RET("creaseAngle", creaseAngle, XML_ReadNode_GetAttrVal_AsFloat);
|
||||||
MACRO_ATTRREAD_CHECK_REF("height", height, XML_ReadNode_GetAttrVal_AsListF);
|
MACRO_ATTRREAD_CHECK_REF("height", height, XML_ReadNode_GetAttrVal_AsArrF);
|
||||||
MACRO_ATTRREAD_CHECK_RET("xDimension", xDimension, XML_ReadNode_GetAttrVal_AsI32);
|
MACRO_ATTRREAD_CHECK_RET("xDimension", xDimension, XML_ReadNode_GetAttrVal_AsI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("xSpacing", xSpacing, XML_ReadNode_GetAttrVal_AsFloat);
|
MACRO_ATTRREAD_CHECK_RET("xSpacing", xSpacing, XML_ReadNode_GetAttrVal_AsFloat);
|
||||||
MACRO_ATTRREAD_CHECK_RET("zDimension", zDimension, XML_ReadNode_GetAttrVal_AsI32);
|
MACRO_ATTRREAD_CHECK_RET("zDimension", zDimension, XML_ReadNode_GetAttrVal_AsI32);
|
||||||
|
@ -326,7 +326,7 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid()
|
||||||
CX3DImporter_NodeElement_ElevationGrid& grid_alias = *((CX3DImporter_NodeElement_ElevationGrid*)ne);// create alias for conveience
|
CX3DImporter_NodeElement_ElevationGrid& grid_alias = *((CX3DImporter_NodeElement_ElevationGrid*)ne);// create alias for conveience
|
||||||
|
|
||||||
{// create grid vertices list
|
{// create grid vertices list
|
||||||
std::list<float>::const_iterator he_it = height.begin();
|
std::vector<float>::const_iterator he_it = height.begin();
|
||||||
|
|
||||||
for(int32_t zi = 0; zi < zDimension; zi++)// rows
|
for(int32_t zi = 0; zi < zDimension; zi++)// rows
|
||||||
{
|
{
|
||||||
|
@ -863,29 +863,29 @@ void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet()
|
||||||
{
|
{
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
std::list<int32_t> colorIndex;
|
std::vector<int32_t> colorIndex;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
bool convex = true;
|
bool convex = true;
|
||||||
std::list<int32_t> coordIndex;
|
std::vector<int32_t> coordIndex;
|
||||||
float creaseAngle = 0;
|
float creaseAngle = 0;
|
||||||
std::list<int32_t> normalIndex;
|
std::vector<int32_t> normalIndex;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
std::list<int32_t> texCoordIndex;
|
std::vector<int32_t> texCoordIndex;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("colorIndex", colorIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("colorIndex", colorIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("convex", convex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("convex", convex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("coordIndex", coordIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("coordIndex", coordIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("creaseAngle", creaseAngle, XML_ReadNode_GetAttrVal_AsFloat);
|
MACRO_ATTRREAD_CHECK_RET("creaseAngle", creaseAngle, XML_ReadNode_GetAttrVal_AsFloat);
|
||||||
MACRO_ATTRREAD_CHECK_REF("normalIndex", normalIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("normalIndex", normalIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("texCoordIndex", texCoordIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("texCoordIndex", texCoordIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
// if "USE" defined then find already defined element.
|
// if "USE" defined then find already defined element.
|
||||||
|
|
|
@ -123,14 +123,14 @@ void X3DImporter::ParseNode_MetadataBoolean()
|
||||||
{
|
{
|
||||||
std::string def, use;
|
std::string def, use;
|
||||||
std::string name, reference;
|
std::string name, reference;
|
||||||
std::list<bool> value;
|
std::vector<bool> value;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListB);
|
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrB);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaBoolean, "MetadataBoolean", ENET_MetaBoolean);
|
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaBoolean, "MetadataBoolean", ENET_MetaBoolean);
|
||||||
|
@ -147,14 +147,14 @@ void X3DImporter::ParseNode_MetadataDouble()
|
||||||
{
|
{
|
||||||
std::string def, use;
|
std::string def, use;
|
||||||
std::string name, reference;
|
std::string name, reference;
|
||||||
std::list<double> value;
|
std::vector<double> value;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListD);
|
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrD);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaDouble, "MetadataDouble", ENET_MetaDouble);
|
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaDouble, "MetadataDouble", ENET_MetaDouble);
|
||||||
|
@ -171,14 +171,14 @@ void X3DImporter::ParseNode_MetadataFloat()
|
||||||
{
|
{
|
||||||
std::string def, use;
|
std::string def, use;
|
||||||
std::string name, reference;
|
std::string name, reference;
|
||||||
std::list<float> value;
|
std::vector<float> value;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListF);
|
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrF);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaFloat, "MetadataFloat", ENET_MetaFloat);
|
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaFloat, "MetadataFloat", ENET_MetaFloat);
|
||||||
|
@ -195,14 +195,14 @@ void X3DImporter::ParseNode_MetadataInteger()
|
||||||
{
|
{
|
||||||
std::string def, use;
|
std::string def, use;
|
||||||
std::string name, reference;
|
std::string name, reference;
|
||||||
std::list<int32_t> value;
|
std::vector<int32_t> value;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
|
||||||
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaInteger, "MetadataInteger", ENET_MetaInteger);
|
MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaInteger, "MetadataInteger", ENET_MetaInteger);
|
||||||
|
|
|
@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Header files, stdlib.
|
// Header files, stdlib.
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/// \class CX3DImporter_NodeElement
|
/// \class CX3DImporter_NodeElement
|
||||||
|
@ -264,7 +265,7 @@ public:
|
||||||
/// This struct describe metavalue of type boolean.
|
/// This struct describe metavalue of type boolean.
|
||||||
struct CX3DImporter_NodeElement_MetaBoolean : public CX3DImporter_NodeElement_Meta
|
struct CX3DImporter_NodeElement_MetaBoolean : public CX3DImporter_NodeElement_Meta
|
||||||
{
|
{
|
||||||
std::list<bool> Value;///< Stored value.
|
std::vector<bool> Value;///< Stored value.
|
||||||
|
|
||||||
/// \fn CX3DImporter_NodeElement_MetaBoolean(CX3DImporter_NodeElement* pParent)
|
/// \fn CX3DImporter_NodeElement_MetaBoolean(CX3DImporter_NodeElement* pParent)
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -279,7 +280,7 @@ struct CX3DImporter_NodeElement_MetaBoolean : public CX3DImporter_NodeElement_Me
|
||||||
/// This struct describe metavalue of type double.
|
/// This struct describe metavalue of type double.
|
||||||
struct CX3DImporter_NodeElement_MetaDouble : public CX3DImporter_NodeElement_Meta
|
struct CX3DImporter_NodeElement_MetaDouble : public CX3DImporter_NodeElement_Meta
|
||||||
{
|
{
|
||||||
std::list<double> Value;///< Stored value.
|
std::vector<double> Value;///< Stored value.
|
||||||
|
|
||||||
/// \fn CX3DImporter_NodeElement_MetaDouble(CX3DImporter_NodeElement* pParent)
|
/// \fn CX3DImporter_NodeElement_MetaDouble(CX3DImporter_NodeElement* pParent)
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -294,7 +295,7 @@ struct CX3DImporter_NodeElement_MetaDouble : public CX3DImporter_NodeElement_Met
|
||||||
/// This struct describe metavalue of type float.
|
/// This struct describe metavalue of type float.
|
||||||
struct CX3DImporter_NodeElement_MetaFloat : public CX3DImporter_NodeElement_Meta
|
struct CX3DImporter_NodeElement_MetaFloat : public CX3DImporter_NodeElement_Meta
|
||||||
{
|
{
|
||||||
std::list<float> Value;///< Stored value.
|
std::vector<float> Value;///< Stored value.
|
||||||
|
|
||||||
/// \fn CX3DImporter_NodeElement_MetaFloat(CX3DImporter_NodeElement* pParent)
|
/// \fn CX3DImporter_NodeElement_MetaFloat(CX3DImporter_NodeElement* pParent)
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -309,7 +310,7 @@ struct CX3DImporter_NodeElement_MetaFloat : public CX3DImporter_NodeElement_Meta
|
||||||
/// This struct describe metavalue of type integer.
|
/// This struct describe metavalue of type integer.
|
||||||
struct CX3DImporter_NodeElement_MetaInteger : public CX3DImporter_NodeElement_Meta
|
struct CX3DImporter_NodeElement_MetaInteger : public CX3DImporter_NodeElement_Meta
|
||||||
{
|
{
|
||||||
std::list<int32_t> Value;///< Stored value.
|
std::vector<int32_t> Value;///< Stored value.
|
||||||
|
|
||||||
/// \fn CX3DImporter_NodeElement_MetaInteger(CX3DImporter_NodeElement* pParent)
|
/// \fn CX3DImporter_NodeElement_MetaInteger(CX3DImporter_NodeElement* pParent)
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -508,7 +509,7 @@ public:
|
||||||
/// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are
|
/// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are
|
||||||
/// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced.
|
/// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced.
|
||||||
float CreaseAngle;
|
float CreaseAngle;
|
||||||
std::list<int32_t> CoordIdx;///< Coordinates list by faces. In X3D format: "-1" - delimiter for faces.
|
std::vector<int32_t> CoordIdx;///< Coordinates list by faces. In X3D format: "-1" - delimiter for faces.
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/****************** Functions ******************/
|
/****************** Functions ******************/
|
||||||
|
@ -554,21 +555,21 @@ public:
|
||||||
/// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the
|
/// direction. If normals are not generated but are supplied using a Normal node, and the orientation of the normals does not match the setting of the
|
||||||
/// ccw field, results are undefined.
|
/// ccw field, results are undefined.
|
||||||
bool CCW;
|
bool CCW;
|
||||||
std::list<int32_t> ColorIndex;///< Field to specify the polygonal faces by indexing into the <Color> or <ColorRGBA>.
|
std::vector<int32_t> ColorIndex;///< Field to specify the polygonal faces by indexing into the <Color> or <ColorRGBA>.
|
||||||
bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line).
|
bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line).
|
||||||
/// \var Convex
|
/// \var Convex
|
||||||
/// The convex field indicates whether all polygons in the shape are convex (TRUE). A polygon is convex if it is planar, does not intersect itself,
|
/// The convex field indicates whether all polygons in the shape are convex (TRUE). A polygon is convex if it is planar, does not intersect itself,
|
||||||
/// and all of the interior angles at its vertices are less than 180 degrees. Non planar and self intersecting polygons may produce undefined results
|
/// and all of the interior angles at its vertices are less than 180 degrees. Non planar and self intersecting polygons may produce undefined results
|
||||||
/// even if the convex field is FALSE.
|
/// even if the convex field is FALSE.
|
||||||
bool Convex;
|
bool Convex;
|
||||||
std::list<int32_t> CoordIndex;///< Field to specify the polygonal faces by indexing into the <Coordinate>.
|
std::vector<int32_t> CoordIndex;///< Field to specify the polygonal faces by indexing into the <Coordinate>.
|
||||||
/// \var CreaseAngle
|
/// \var CreaseAngle
|
||||||
/// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are
|
/// If the angle between the geometric normals of two adjacent faces is less than the crease angle, normals shall be calculated so that the faces are
|
||||||
/// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced.
|
/// shaded smoothly across the edge; otherwise, normals shall be calculated so that a lighting discontinuity across the edge is produced.
|
||||||
float CreaseAngle;
|
float CreaseAngle;
|
||||||
std::list<int32_t> NormalIndex;///< Field to specify the polygonal faces by indexing into the <Normal>.
|
std::vector<int32_t> NormalIndex;///< Field to specify the polygonal faces by indexing into the <Normal>.
|
||||||
bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line).
|
bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line).
|
||||||
std::list<int32_t> TexCoordIndex;///< Field to specify the polygonal faces by indexing into the <TextureCoordinate>.
|
std::vector<int32_t> TexCoordIndex;///< Field to specify the polygonal faces by indexing into the <TextureCoordinate>.
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/****************** Functions ******************/
|
/****************** Functions ******************/
|
||||||
|
@ -616,10 +617,10 @@ public:
|
||||||
bool CCW;
|
bool CCW;
|
||||||
bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line).
|
bool ColorPerVertex;///< If true then colors are defined for every vertex, else for every face(line).
|
||||||
bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line).
|
bool NormalPerVertex;///< If true then normals are defined for every vertex, else for every face(line).
|
||||||
std::list<int32_t> CoordIndex;///< Field to specify the polygonal faces by indexing into the <Coordinate>.
|
std::vector<int32_t> CoordIndex;///< Field to specify the polygonal faces by indexing into the <Coordinate>.
|
||||||
std::list<int32_t> NormalIndex;///< Field to specify the polygonal faces by indexing into the <Normal>.
|
std::vector<int32_t> NormalIndex;///< Field to specify the polygonal faces by indexing into the <Normal>.
|
||||||
std::list<int32_t> TexCoordIndex;///< Field to specify the polygonal faces by indexing into the <TextureCoordinate>.
|
std::vector<int32_t> TexCoordIndex;///< Field to specify the polygonal faces by indexing into the <TextureCoordinate>.
|
||||||
std::list<int32_t> VertexCount;///< Field describes how many vertices are to be used in each polyline(polygon) from the <Coordinate> field.
|
std::vector<int32_t> VertexCount;///< Field describes how many vertices are to be used in each polyline(polygon) from the <Coordinate> field.
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
/****************** Functions ******************/
|
/****************** Functions ******************/
|
||||||
|
|
|
@ -180,16 +180,16 @@ void X3DImporter::ParseNode_Rendering_Coordinate()
|
||||||
void X3DImporter::ParseNode_Rendering_IndexedLineSet()
|
void X3DImporter::ParseNode_Rendering_IndexedLineSet()
|
||||||
{
|
{
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
std::list<int32_t> colorIndex;
|
std::vector<int32_t> colorIndex;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> coordIndex;
|
std::vector<int32_t> coordIndex;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_REF("colorIndex", colorIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("colorIndex", colorIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("coordIndex", coordIndex, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("coordIndex", coordIndex, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
// if "USE" defined then find already defined element.
|
// if "USE" defined then find already defined element.
|
||||||
|
@ -256,7 +256,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet()
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> index;
|
std::vector<int32_t> index;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
@ -265,7 +265,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet()
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
@ -294,7 +294,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleFanSet()
|
||||||
ne_alias.CoordIndex.clear();
|
ne_alias.CoordIndex.clear();
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int32_t idx[3];
|
int32_t idx[3];
|
||||||
for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
for(std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
||||||
{
|
{
|
||||||
idx[2] = *idx_it;
|
idx[2] = *idx_it;
|
||||||
if (idx[2] < 0)
|
if (idx[2] < 0)
|
||||||
|
@ -374,7 +374,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet()
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> index;
|
std::vector<int32_t> index;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
@ -383,7 +383,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet()
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
@ -412,7 +412,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleSet()
|
||||||
ne_alias.CoordIndex.clear();
|
ne_alias.CoordIndex.clear();
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int32_t idx[3];
|
int32_t idx[3];
|
||||||
for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
for(std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
||||||
{
|
{
|
||||||
idx[counter++] = *idx_it;
|
idx[counter++] = *idx_it;
|
||||||
if (counter > 2)
|
if (counter > 2)
|
||||||
|
@ -480,7 +480,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet()
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> index;
|
std::vector<int32_t> index;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
@ -489,7 +489,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet()
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("index", index, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
@ -518,7 +518,7 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet()
|
||||||
ne_alias.CoordIndex.clear();
|
ne_alias.CoordIndex.clear();
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int32_t idx[3];
|
int32_t idx[3];
|
||||||
for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
for(std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); idx_it++)
|
||||||
{
|
{
|
||||||
idx[2] = *idx_it;
|
idx[2] = *idx_it;
|
||||||
if (idx[2] < 0)
|
if (idx[2] < 0)
|
||||||
|
@ -587,12 +587,12 @@ void X3DImporter::ParseNode_Rendering_IndexedTriangleStripSet()
|
||||||
void X3DImporter::ParseNode_Rendering_LineSet()
|
void X3DImporter::ParseNode_Rendering_LineSet()
|
||||||
{
|
{
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
std::list<int32_t> vertexCount;
|
std::vector<int32_t> vertexCount;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
|
||||||
MACRO_ATTRREAD_LOOPBEG;
|
MACRO_ATTRREAD_LOOPBEG;
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_REF("vertexCount", vertexCount, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("vertexCount", vertexCount, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
|
||||||
// if "USE" defined then find already defined element.
|
// if "USE" defined then find already defined element.
|
||||||
|
@ -616,7 +616,7 @@ void X3DImporter::ParseNode_Rendering_LineSet()
|
||||||
size_t coord_num = 0;
|
size_t coord_num = 0;
|
||||||
|
|
||||||
ne_alias.CoordIndex.clear();
|
ne_alias.CoordIndex.clear();
|
||||||
for(std::list<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
for(std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
||||||
{
|
{
|
||||||
if(*vc_it < 2) throw DeadlyImportError("LineSet. vertexCount shall be greater than or equal to two.");
|
if(*vc_it < 2) throw DeadlyImportError("LineSet. vertexCount shall be greater than or equal to two.");
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet()
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> fanCount;
|
std::vector<int32_t> fanCount;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
@ -731,7 +731,7 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet()
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("fanCount", fanCount, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("fanCount", fanCount, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
@ -764,7 +764,7 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet()
|
||||||
// assign indices for first triangle
|
// assign indices for first triangle
|
||||||
coord_num_first = 0;
|
coord_num_first = 0;
|
||||||
coord_num_prev = 1;
|
coord_num_prev = 1;
|
||||||
for(std::list<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
for(std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
||||||
{
|
{
|
||||||
if(*vc_it < 3) throw DeadlyImportError("TriangleFanSet. fanCount shall be greater than or equal to three.");
|
if(*vc_it < 3) throw DeadlyImportError("TriangleFanSet. fanCount shall be greater than or equal to three.");
|
||||||
|
|
||||||
|
@ -913,7 +913,7 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet()
|
||||||
std::string use, def;
|
std::string use, def;
|
||||||
bool ccw = true;
|
bool ccw = true;
|
||||||
bool colorPerVertex = true;
|
bool colorPerVertex = true;
|
||||||
std::list<int32_t> stripCount;
|
std::vector<int32_t> stripCount;
|
||||||
bool normalPerVertex = true;
|
bool normalPerVertex = true;
|
||||||
bool solid = true;
|
bool solid = true;
|
||||||
CX3DImporter_NodeElement* ne( nullptr );
|
CX3DImporter_NodeElement* ne( nullptr );
|
||||||
|
@ -922,7 +922,7 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet()
|
||||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
|
||||||
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("ccw", ccw, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("colorPerVertex", colorPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_REF("stripCount", stripCount, XML_ReadNode_GetAttrVal_AsListI32);
|
MACRO_ATTRREAD_CHECK_REF("stripCount", stripCount, XML_ReadNode_GetAttrVal_AsArrI32);
|
||||||
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("normalPerVertex", normalPerVertex, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
MACRO_ATTRREAD_CHECK_RET("solid", solid, XML_ReadNode_GetAttrVal_AsBool);
|
||||||
MACRO_ATTRREAD_LOOPEND;
|
MACRO_ATTRREAD_LOOPEND;
|
||||||
|
@ -955,7 +955,7 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet()
|
||||||
|
|
||||||
ne_alias.CoordIndex.clear();
|
ne_alias.CoordIndex.clear();
|
||||||
coord_num_sb = 0;
|
coord_num_sb = 0;
|
||||||
for(std::list<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
for(std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
|
||||||
{
|
{
|
||||||
if(*vc_it < 3) throw DeadlyImportError("TriangleStripSet. stripCount shall be greater than or equal to three.");
|
if(*vc_it < 3) throw DeadlyImportError("TriangleStripSet. stripCount shall be greater than or equal to three.");
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue