Skip to content

Commit

Permalink
Fixing warnings and errors from gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
3dJan committed Oct 20, 2023
1 parent 649c738 commit a8f8c30
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Include/API/lib3mf_volumedata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class CVolumeData : public virtual IVolumeData, public virtual CBase {
/**
* Put private members here.
*/
NMR::PModelVolumeData m_pVolumeData;
NMR::PModelMeshObject m_pMeshObject; // questionable
NMR::PModelVolumeData m_pVolumeData;

protected:

Expand Down
7 changes: 7 additions & 0 deletions Include/Model/Classes/NMR_ImplicitNodeTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ namespace NMR

struct InputOutputRule
{
InputOutputRule(Lib3MF::eImplicitNodeConfiguration const& configuration,
In const& inputs,
Out const& outputs)
: configuration(configuration), inputs(inputs), outputs(outputs)
{
}

Lib3MF::eImplicitNodeConfiguration configuration = Lib3MF::eImplicitNodeConfiguration::Default;
In inputs;
Out outputs;
Expand Down
2 changes: 1 addition & 1 deletion Include/Model/Classes/NMR_KeyStoreCEKParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace NMR {

class CKeyStoreCEKParams {
protected:
eKeyStoreEncryptAlgorithm m_eAlgorithm;
nfBool m_bCompression;
eKeyStoreEncryptAlgorithm m_eAlgorithm;
std::vector<nfByte> m_rgIv, m_rgTag, m_rgAad;
nfUint64 m_nDescriptor;
public:
Expand Down
4 changes: 2 additions & 2 deletions Include/Model/Classes/NMR_ModelImplicitNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace NMR
class CModelImplicitNode
{
private:
Lib3MF::eImplicitNodeType m_type;
ImplicitIdentifier m_identifier;
std::string m_displayname;
std::string m_tag;
Lib3MF::eImplicitNodeType m_type;


PPorts m_inputs;
PPorts m_outputs;

Expand Down
6 changes: 2 additions & 4 deletions Include/Model/Classes/NMR_ModelImplicitPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ namespace NMR
class CModelImplicitPort
{
private:
CModelImplicitNode * m_parent = nullptr;
ImplicitIdentifier m_identifier;
std::string m_displayname;
Lib3MF::eImplicitPortType m_type = Lib3MF::eImplicitPortType::Scalar;
ImplicitIdentifier m_reference;
CModelImplicitNode * m_parent = nullptr;

void throwIfNotAnInstance() const;


public:
CModelImplicitPort(CModelImplicitNode * parent,
ImplicitIdentifier const & identifier,
Expand Down
2 changes: 1 addition & 1 deletion Include/Model/Reader/NMR_ModelReaderNode_KeyStoreBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace NMR {

class CModelReaderNode_KeyStoreBase : public CModelReaderNode {
protected:
CKeyStore * const m_pKeyStore;
CModel * const m_pModel;
CKeyStore * const m_pKeyStore;

public:
CModelReaderNode_KeyStoreBase() = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ namespace NMR
std::string m_identifier;
std::string m_displayName;
std::string m_reference;
ImplicitPortInOut m_inOut;
Lib3MF::eImplicitPortType m_portType;
ImplicitPortInOut m_inOut;


public:
CModelReaderNode_Implicit_Port() = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace NMR {
private:
protected:

CModelImageStack* m_pImageStack;
CModel* m_pModel;
CModel* m_pModel = nullptr;
CModelImageStack* m_pImageStack = nullptr;

nfUint32 m_nRowCount;
nfUint32 m_nColumnCount;
Expand Down
4 changes: 2 additions & 2 deletions Source/API/lib3mf_beamlattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ sLib3MFBall CBeamLattice::GetBall (const Lib3MF_uint32 nIndex)
return ball;
}
else if (ballMode == eBeamLatticeBallMode::All) {
Lib3MF_uint32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index;
Lib3MF_int32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index;

Lib3MF_uint32 meshBallCount = m_mesh.getBallCount();
for (Lib3MF_uint32 iBall = 0; iBall < meshBallCount; iBall++) {
Expand Down Expand Up @@ -377,7 +377,7 @@ void CBeamLattice::SetBall (const Lib3MF_uint32 nIndex, const sLib3MFBall BallIn
meshBall->m_radius = BallInfo.m_Radius;
}
else if (ballMode == eBeamLatticeBallMode::All) {
Lib3MF_uint32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index;
Lib3MF_int32 ballNodeIndex = m_mesh.getOccupiedNode(nIndex)->m_index;
Lib3MF_uint32 meshBallCount = m_mesh.getBallCount();
for (Lib3MF_uint32 iBall = 0; iBall < meshBallCount; iBall++) {
NMR::MESHBALL * meshBall = m_mesh.getBall(iBall);
Expand Down
7 changes: 5 additions & 2 deletions Source/API/lib3mf_functionfromimage3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ NMR::CModelFunctionFromImage3D * Lib3MF::Impl::CFunctionFromImage3D::functionfro
{
auto pFunctionFromImage3D = std::dynamic_pointer_cast<NMR::CModelFunctionFromImage3D>(resource());

if(!pFunctionFromImage3D)
if(!pFunctionFromImage3D)
{
throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDOBJECT);
}

return pFunctionFromImage3D.get();
}
Expand All @@ -71,8 +73,9 @@ Lib3MF::Impl::CFunctionFromImage3D::CFunctionFromImage3D(NMR::PModelResource pRe
void CFunctionFromImage3D::SetImage3D(IImage3D * pImage3D)
{
if (pImage3D == nullptr)
{
throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM);

}
functionfromimage3d()->setImage3DUniqueResourceID(pImage3D->GetUniqueResourceID());
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Common/Mesh/NMR_Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ namespace NMR {
try {
addBall(getNode(ballData[iBall].m_nodeindex), ballData[iBall].m_radius);
}
catch (CNMRException) {}
catch (CNMRException &) {}
}

delete [] ballData;
Expand Down
21 changes: 11 additions & 10 deletions Source/Common/MeshImport/NMR_MeshImporter_STL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace NMR {

std::array<nfByte, 80> aSTLHeader;
nfUint32 nFaceCount = 0;
nfUint32 nGlobalColor = 0xffffffff;
// nfUint32 nGlobalColor = 0xffffffff;

pStream->readIntoBuffer(&aSTLHeader[0], 80, true);
pStream->readIntoBuffer((nfByte*)&nFaceCount, sizeof(nFaceCount), true);
Expand All @@ -138,14 +138,14 @@ namespace NMR {
if (nFaceCount > NMR_MESH_MAXFACECOUNT)
throw CNMRException(NMR_ERROR_INVALIDFACECOUNT);

std::string sHeaderString(std::begin(aSTLHeader), std::end(aSTLHeader));
std::size_t nFound = sHeaderString.find("COLOR=");
if (nFound != std::string::npos) {
if (nFound <= 76) {
nGlobalColor = ((nfUint32)aSTLHeader[nFound + 6]) + (((nfUint32)aSTLHeader[nFound + 7]) << 8) + (((nfUint32)aSTLHeader[nFound + 8]) << 16) +
(((nfUint32)aSTLHeader[nFound + 9]) << 24);
}
}
// std::string sHeaderString(std::begin(aSTLHeader), std::end(aSTLHeader));
// std::size_t nFound = sHeaderString.find("COLOR=");
// if (nFound != std::string::npos) {
// if (nFound <= 76) {
// nGlobalColor = ((nfUint32)aSTLHeader[nFound + 6]) + (((nfUint32)aSTLHeader[nFound + 7]) << 8) + (((nfUint32)aSTLHeader[nFound + 8]) << 16) +
// (((nfUint32)aSTLHeader[nFound + 9]) << 24);
// }
// }

nfUint32 nNodeIdx;
MESHNODE * pNodes[3];
Expand Down Expand Up @@ -193,7 +193,8 @@ namespace NMR {
throw CNMRException(NMR_ERROR_INVALIDCOORDINATES);

if (bIsValid) {
MESHFACE * pFace = pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]);
pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]);
// MESHFACE * pFace = pMesh->addFace(pNodes[0], pNodes[1], pNodes[2]);
//if (pProperties) {
// nfUint32 nRed = (nfUint32) ((nfFloat) (Facet.m_attribute & 0x1f) / (255.0f / 31.0f));
// nfUint32 nGreen = (nfUint32)((nfFloat)((Facet.m_attribute >> 5) & 0x1f) / (255.0f / 31.0f));
Expand Down
17 changes: 0 additions & 17 deletions Source/Model/Classes/NMR_ModelImplicitPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,64 +60,47 @@ namespace NMR

ImplicitIdentifier const& CModelImplicitPort::getIdentifier() const
{
throwIfNotAnInstance();
return m_identifier;
}

std::string const& CModelImplicitPort::getDisplayName() const
{
throwIfNotAnInstance();
return m_displayname;
}

void CModelImplicitPort::setIdentifier(std::string const& identifier)
{
throwIfNotAnInstance();
m_identifier = identifier;
}

void CModelImplicitPort::setDisplayName(std::string const& displayname)
{
throwIfNotAnInstance();
m_displayname = displayname;
}

Lib3MF::eImplicitPortType CModelImplicitPort::getType() const
{
throwIfNotAnInstance();
return m_type;
}

void CModelImplicitPort::setType(Lib3MF::eImplicitPortType type)
{
throwIfNotAnInstance();
m_type = type;
}

ImplicitIdentifier const& NMR::CModelImplicitPort::getReference() const
{
throwIfNotAnInstance();
return m_reference;
}

void NMR::CModelImplicitPort::setReference(
ImplicitIdentifier const& reference)
{
throwIfNotAnInstance();
m_reference = reference;
}

CModelImplicitNode* NMR::CModelImplicitPort::getParent() const
{
throwIfNotAnInstance();
return m_parent;
}

void CModelImplicitPort::throwIfNotAnInstance() const
{
if(!this)
{
throw CNMRException(NMR_ERROR_IMPLICIT_PORT_DOES_NOT_EXIST);
}
}
} // namespace NMR
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace NMR {
eModelBlendMethod method = MODELBLENDMETHOD_MIX;
try {
method = CModelMultiPropertyGroupResource::stringToBlendMethod(blendMethodString);
} catch (CNMRException e) {
} catch (CNMRException& e) {
m_pWarnings->addException(e, mrwInvalidMandatoryValue);
}
m_pBlendMethods->push_back(method);
Expand Down
2 changes: 1 addition & 1 deletion Source/Model/Writer/NMR_KeyStoreOpcPackageWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace NMR {
ctx.m_sKekDecryptData.m_pAccessRight = ar;
std::vector<nfByte> closedKey;
//give consumer a chance to (re)encrypt this key
nfUint64 wrapped = ctx.m_fnWrap(key, closedKey, ctx.m_sKekDecryptData);
ctx.m_fnWrap(key, closedKey, ctx.m_sKekDecryptData);
ar->setCipherValue(closedKey);
} catch (CNMRException const & e) {
if (ar->isNew()) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/CPP_Bindings/Include/UnitTest_Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct PositionedVector
static void writeCallback(Lib3MF_uint64 nByteData, Lib3MF_uint64 nNumBytes, Lib3MF_pvoid pUserData) {
PositionedVector<T>* buffer = reinterpret_cast<PositionedVector<T>*> ((void*)(pUserData));
T* pData = (T*)(nByteData);
for (int i = 0; i < nNumBytes; i++) {
for (Lib3MF_uint64 i = 0; i < nNumBytes; i++) {
if (buffer->pos == buffer->vec.size()) {
buffer->vec.push_back(*pData);
}
Expand All @@ -165,7 +165,7 @@ struct PositionedVector
static void readCallback(Lib3MF_uint64 nByteData, Lib3MF_uint64 nNumBytes, Lib3MF_pvoid pUserData) {
PositionedVector<T>* buffer = reinterpret_cast<PositionedVector<T>*> ((void*)(pUserData));
T* pData = (T*)(nByteData);
for (int i = 0; i < nNumBytes; i++) {
for (Lib3MF_uint64 i = 0u; i < nNumBytes; i++) {
if (buffer->pos < buffer->vec.size()) {
*pData = buffer->vec[(size_t)buffer->pos];
}
Expand Down
20 changes: 10 additions & 10 deletions Tests/CPP_Bindings/Source/BeamLattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace Lib3MF
beamLattice->AddBeam(beam);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}

Expand All @@ -291,15 +291,15 @@ namespace Lib3MF
beamLattice->SetBeam(0, beam);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}

//Invalid ball options, should fail
try {
beamLattice->SetBallOptions(eBeamLatticeBallMode::All, 0.0);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}

Expand All @@ -316,7 +316,7 @@ namespace Lib3MF
beamLattice->SetBall(0, ball);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}

Expand All @@ -326,7 +326,7 @@ namespace Lib3MF
beamLattice->AddBall(ball);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}
}
Expand Down Expand Up @@ -420,7 +420,7 @@ namespace Lib3MF
beamLattice->SetBeams(beams);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}

Expand Down Expand Up @@ -463,7 +463,7 @@ namespace Lib3MF
beamLattice->SetBalls(balls);
ASSERT_FALSE(true);
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}
}
Expand Down Expand Up @@ -501,14 +501,14 @@ namespace Lib3MF
mesh->SetType(eObjectType::Support);
ASSERT_FALSE(true) << "Could set eObjectTypeSupport";
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}
try {
mesh->SetType(eObjectType::Other);
ASSERT_FALSE(true) << "Could set eObjectTypeOther";
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}
}
Expand All @@ -530,7 +530,7 @@ namespace Lib3MF
beamLattice->AddBeam(beam);
ASSERT_FALSE(true) << "Could add beam on eObjectTypeSupport";
}
catch (ELib3MFException) {
catch (ELib3MFException&) {
ASSERT_TRUE(true);
}
}
Expand Down
Loading

0 comments on commit a8f8c30

Please sign in to comment.