Skip to content

Commit

Permalink
Fix namespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Nov 12, 2023
1 parent 8cf2d6e commit 4535e37
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 98 deletions.
10 changes: 6 additions & 4 deletions code/AssetLib/3DS/3DSConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <memory>

using namespace Assimp;
namespace Assimp {

static const unsigned int NotSet = 0xcdcdcdcd;
static constexpr unsigned int NotSet = 0xcdcdcdcd;

// ------------------------------------------------------------------------------------------------
// Setup final material indices, generae a default material if necessary
Expand All @@ -68,7 +68,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
unsigned int idx(NotSet);
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
std::string s = mScene->mMaterials[i].mName;
for (char & it : s) {
for (char &it : s) {
it = static_cast<char>(::tolower(static_cast<unsigned char>(it)));
}

Expand Down Expand Up @@ -262,7 +262,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat,
unsigned int iWire = 1;
mat.AddProperty<int>((int *)&iWire, 1, AI_MATKEY_ENABLE_WIREFRAME);
}
[[fallthrough]];
[[fallthrough]];

case D3DS::Discreet3DS::Gouraud:
eShading = aiShadingMode_Gouraud;
Expand Down Expand Up @@ -805,4 +805,6 @@ void Discreet3DSImporter::ConvertScene(aiScene *pcOut) {
}
}

} // namespace Assimp

#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
6 changes: 2 additions & 4 deletions code/AssetLib/3DS/3DSExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
Expand Down Expand Up @@ -57,8 +56,7 @@ struct aiNode;
struct aiMaterial;
struct aiMesh;

namespace Assimp
{
namespace Assimp {

// ------------------------------------------------------------------------------------------------
/**
Expand Down Expand Up @@ -88,7 +86,7 @@ class Discreet3DSExporter {

std::map<const aiNode*, aiMatrix4x4> trafos;

typedef std::multimap<const aiNode*, unsigned int> MeshesByNodeMap;
using MeshesByNodeMap = std::multimap<const aiNode*, unsigned int>;
MeshesByNodeMap meshes;

};
Expand Down
4 changes: 3 additions & 1 deletion code/AssetLib/3DS/3DSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>

using namespace Assimp;
namespace Assimp {

static constexpr aiImporterDesc desc = {
"Discreet 3DS Importer",
Expand Down Expand Up @@ -1335,4 +1335,6 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) {
(void)bGamma;
}

} // namespace Assimp

#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
4 changes: 0 additions & 4 deletions code/AssetLib/3MF/D3MFImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ static constexpr aiImporterDesc desc = {
"3mf"
};

D3MFImporter::D3MFImporter() = default;

D3MFImporter::~D3MFImporter() = default;

bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const {
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions code/AssetLib/3MF/D3MFImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ namespace Assimp {
class D3MFImporter : public BaseImporter {
public:
/// @brief The default class constructor.
D3MFImporter();
D3MFImporter() = default;

/// @brief The class destructor.
~D3MFImporter() override;
~D3MFImporter() override = default;

/// @brief Performs the data format detection.
/// @param pFile The filename to check.
Expand Down
10 changes: 5 additions & 5 deletions code/AssetLib/3MF/D3MFOpcPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ using OpcPackageRelationshipPtr = std::shared_ptr<OpcPackageRelationship>;
class OpcPackageRelationshipReader {
public:
OpcPackageRelationshipReader(XmlParser &parser) :
m_relationShips() {
mRelations() {
XmlNode root = parser.getRootNode();
ParseRootNode(root);
}
Expand Down Expand Up @@ -108,13 +108,13 @@ class OpcPackageRelationshipReader {
relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string();
relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string();
if (validateRels(relPtr)) {
m_relationShips.push_back(relPtr);
mRelations.push_back(relPtr);
}
}
}
}

std::vector<OpcPackageRelationshipPtr> m_relationShips;
std::vector<OpcPackageRelationshipPtr> mRelations;
};

static bool IsEmbeddedTexture( const std::string &filename ) {
Expand Down Expand Up @@ -217,11 +217,11 @@ std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {

OpcPackageRelationshipReader reader(xmlParser);

auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) {
auto itr = std::find_if(reader.mRelations.begin(), reader.mRelations.end(), [](const OpcPackageRelationshipPtr &rel) {
return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
});

if (itr == reader.m_relationShips.end()) {
if (itr == reader.mRelations.end()) {
throw DeadlyImportError("Cannot find ", XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE);
}

Expand Down
6 changes: 3 additions & 3 deletions code/AssetLib/3MF/XmlSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace D3MF {

static const int IdNotSet = -1;
static constexpr int IdNotSet = -1;

namespace {

static const size_t ColRGBA_Len = 9;
static const size_t ColRGB_Len = 7;
static constexpr size_t ColRGBA_Len = 9;
static constexpr size_t ColRGB_Len = 7;

// format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
bool validateColorString(const char *color) {
Expand Down
4 changes: 3 additions & 1 deletion code/AssetLib/AC/ACLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp>
#include <memory>

using namespace Assimp;
namespace Assimp {

static constexpr aiImporterDesc desc = {
"AC3D Importer",
Expand Down Expand Up @@ -862,4 +862,6 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
}
}

} // namespace Assimp

#endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER
4 changes: 3 additions & 1 deletion code/AssetLib/ASE/ASELoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// utilities
#include <assimp/fast_atof.h>

using namespace Assimp;
namespace Assimp {
using namespace Assimp::ASE;

static constexpr aiImporterDesc desc = {
Expand Down Expand Up @@ -1262,6 +1262,8 @@ bool ASEImporter::GenerateNormals(ASE::Mesh &mesh) {
return false;
}

}

#endif // ASSIMP_BUILD_NO_3DS_IMPORTER

#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER
4 changes: 3 additions & 1 deletion code/AssetLib/ASE/ASEParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/fast_atof.h>
#include <assimp/DefaultLogger.hpp>

using namespace Assimp;
namespace Assimp {
using namespace Assimp::ASE;

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1864,6 +1864,8 @@ void Parser::ParseLV4MeshLong(unsigned int &iOut) {
iOut = strtoul10(filePtr, &filePtr);
}

}

#endif // ASSIMP_BUILD_NO_3DS_IMPORTER

#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER
20 changes: 11 additions & 9 deletions code/AssetLib/B3D/B3DImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <memory>

using namespace Assimp;
namespace Assimp {
using namespace std;

static constexpr aiImporterDesc desc = {
Expand All @@ -79,9 +79,9 @@ static constexpr aiImporterDesc desc = {
#pragma warning(disable : 4018)
#endif

//#define DEBUG_B3D
// #define DEBUG_B3D

template<typename T>
template <typename T>
void DeleteAllBarePointers(std::vector<T> &x) {
for (auto p : x) {
delete p;
Expand Down Expand Up @@ -329,7 +329,7 @@ void B3DImporter::ReadBRUS() {
mat->AddProperty(&i, 1, AI_MATKEY_TWOSIDED);
}

//Textures
// Textures
for (int i = 0; i < n_texs; ++i) {
int texid = ReadInt();
if (texid < -1 || (texid >= 0 && texid >= static_cast<int>(_textures.size()))) {
Expand Down Expand Up @@ -372,7 +372,7 @@ void B3DImporter::ReadVRTS() {
}

if (_vflags & 2) {
ReadQuat(); //skip v 4bytes...
ReadQuat(); // skip v 4bytes...
}

for (int j = 0; j < _tcsets; ++j) {
Expand Down Expand Up @@ -704,22 +704,22 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
}
}

//nodes
// nodes
scene->mRootNode = _nodes[0];
_nodes.clear(); // node ownership now belongs to scene

//material
// material
if (!_materials.size()) {
_materials.emplace_back(std::unique_ptr<aiMaterial>(new aiMaterial));
}
scene->mNumMaterials = static_cast<unsigned int>(_materials.size());
scene->mMaterials = unique_to_array(_materials);

//meshes
// meshes
scene->mNumMeshes = static_cast<unsigned int>(_meshes.size());
scene->mMeshes = unique_to_array(_meshes);

//animations
// animations
if (_animations.size() == 1 && _nodeAnims.size()) {

aiAnimation *anim = _animations.back().get();
Expand All @@ -738,4 +738,6 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
flip.Execute(scene);
}

} // namespace Assimp

#endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER
48 changes: 24 additions & 24 deletions code/AssetLib/BVH/BVHLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
#include <memory>

using namespace Assimp;
namespace Assimp {

using namespace Assimp::Formatter;

static constexpr aiImporterDesc desc = {
Expand All @@ -73,8 +74,8 @@ static constexpr aiImporterDesc desc = {

// ------------------------------------------------------------------------------------------------
// Aborts the file reading with an exception
template<typename... T>
AI_WONT_RETURN void BVHLoader::ThrowException(T&&... args) {
template <typename... T>
AI_WONT_RETURN void BVHLoader::ThrowException(T &&...args) {
throw DeadlyImportError(mFileName, ":", mLine, " - ", args...);
}

Expand Down Expand Up @@ -426,7 +427,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
nodeAnim->mNodeName.Set(nodeName);
std::map<BVHLoader::ChannelType, int> channelMap;

//Build map of channels
// Build map of channels
for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) {
channelMap[node.mChannels[channel]] = channel;
}
Expand All @@ -441,7 +442,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {

// Now compute all translations
for (BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel + 1)) {
//Find channel in node
// Find channel in node
std::map<BVHLoader::ChannelType, int>::iterator mapIter = channelMap.find(channel);

if (mapIter == channelMap.end())
Expand Down Expand Up @@ -485,30 +486,27 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) {
aiMatrix4x4 temp;
aiMatrix3x3 rotMatrix;
for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) {
switch (node.mChannels[channelIdx]) {
case Channel_RotationX:
{
for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++channelIdx) {
switch (node.mChannels[channelIdx]) {
case Channel_RotationX: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp);
}
break;
case Channel_RotationY:
{
aiMatrix4x4::RotationX(angle, temp);
rotMatrix *= aiMatrix3x3(temp);
} break;
case Channel_RotationY: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp);
}
break;
case Channel_RotationZ:
{
aiMatrix4x4::RotationY(angle, temp);
rotMatrix *= aiMatrix3x3(temp);
} break;
case Channel_RotationZ: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp);
}
break;
aiMatrix4x4::RotationZ(angle, temp);
rotMatrix *= aiMatrix3x3(temp);
} break;
default:
break;
}
}
}
}
rotkey->mTime = double(fr);
rotkey->mValue = aiQuaternion(rotMatrix);
++rotkey;
Expand All @@ -525,4 +523,6 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
}
}

} // namespace Assimp

#endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER
4 changes: 3 additions & 1 deletion code/AssetLib/COB/COBLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <memory>

using namespace Assimp;
namespace Assimp {
using namespace Assimp::COB;
using namespace Assimp::Formatter;

Expand Down Expand Up @@ -1164,4 +1164,6 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
}

}

#endif // ASSIMP_BUILD_NO_COB_IMPORTER
Loading

0 comments on commit 4535e37

Please sign in to comment.