Skip to content

Commit

Permalink
32bit fixes (#251)
Browse files Browse the repository at this point in the history
* Added 32 bit exceeding error code

* Added size_t checks for API objects

* Made Tests compile on 32bit

* safe 32bit fixes

* 32 bit compile fix

Co-authored-by: Alexander Oster <[email protected]>
  • Loading branch information
martinweismann and netfabb authored Feb 18, 2021
1 parent ae5faf3 commit 8b5aa63
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 55 deletions.
3 changes: 2 additions & 1 deletion AutomaticComponentToolkit/lib3mf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
<error name="INVALIDATTACHMENTSTREAM" code="131" description="An attachment stream is invalid"/>
<error name="INVALIDPROPERTYCOUNT" code="132" description="Invalid property count."/>
<error name="UNKOWNPROGRESSIDENTIFIER" code="140" description="A progress identifier is unknown"/>
<error name="BEAMLATTICE_INVALID_OBJECTTYPE" code="2000" description="This object type is not valid for beamlattices"/>
<error name="ELEMENTCOUNTEXCEEDSLIMIT" code="141" description="An element buffer exceeds its spec limit"/>
<error name="BEAMLATTICE_INVALID_OBJECTTYPE" code="2000" description="This object type is not valid for beamlattices"/>
<error name="INVALIDKEYSTORE" code="3000" description="The keystore object is invalid"/>
<error name="INVALIDKEYSTORECONSUMER" code="3001" description="The consumer keystore object is invalid"/>
<error name="KEYSTORECONSUMERNOTFOUND" code="3002" description="A consumer has not been found"/>
Expand Down
1 change: 1 addition & 0 deletions Include/API/lib3mf_beamset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Abstract: This is the class declaration of CBeamSet
namespace Lib3MF {
namespace Impl {

#define LIB3MF_MAXBEAMCOUNT (1UL << 31)

/*************************************************************************************************************************
Class declaration of CBeamSet
Expand Down
2 changes: 2 additions & 0 deletions Include/API/lib3mf_compositematerials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Abstract: This is the class declaration of CCompositeMaterials
// Include custom headers here.
#include "Model/Classes/NMR_ModelCompositeMaterials.h"

#define LIB3MF_MAXCOMPOSITEMATERIALS (1UL << 31)

namespace Lib3MF {
namespace Impl {

Expand Down
1 change: 1 addition & 0 deletions Include/API/lib3mf_multipropertygroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Abstract: This is the class declaration of CMultiPropertyGroup
// Include custom headers here.
#include "Model/Classes/NMR_ModelMultiPropertyGroup.h"

#define LIB3MF_MAXMULTIPROPERTIES (1UL << 31)

namespace Lib3MF {
namespace Impl {
Expand Down
14 changes: 10 additions & 4 deletions Source/API/lib3mf_beamset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ Lib3MF_uint32 CBeamSet::GetReferenceCount()

void CBeamSet::SetReferences(const Lib3MF_uint64 nReferencesBufferSize, const Lib3MF_uint32 * pReferencesBuffer)
{
m_pBeamSet->m_Refs.resize(nReferencesBufferSize);
if (nReferencesBufferSize > LIB3MF_MAXBEAMCOUNT)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

m_pBeamSet->m_Refs.resize((size_t) nReferencesBufferSize);
const Lib3MF_uint32 beamCount = m_mesh.getBeamCount();
for (Lib3MF_uint64 i = 0; i < nReferencesBufferSize; i++) {
for (size_t i = 0; i < (size_t)nReferencesBufferSize; i++) {
if (beamCount <= pReferencesBuffer[i])
throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM);
m_pBeamSet->m_Refs[i] = Lib3MF_uint32(pReferencesBuffer[i]);
Expand Down Expand Up @@ -115,9 +118,12 @@ Lib3MF_uint32 CBeamSet::GetBallReferenceCount()

void CBeamSet::SetBallReferences(const Lib3MF_uint64 nBallReferencesBufferSize, const Lib3MF_uint32* pBallReferencesBuffer)
{
m_pBeamSet->m_BallRefs.resize(nBallReferencesBufferSize);
if (nBallReferencesBufferSize > LIB3MF_MAXBEAMCOUNT)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

m_pBeamSet->m_BallRefs.resize((size_t)nBallReferencesBufferSize);
const Lib3MF_uint32 ballCount = m_mesh.getBallCount();
for (Lib3MF_uint64 i = 0; i < nBallReferencesBufferSize; i++) {
for (size_t i = 0; i < (size_t)nBallReferencesBufferSize; i++) {
if (ballCount <= pBallReferencesBuffer[i])
throw ELib3MFInterfaceException(LIB3MF_ERROR_INVALIDPARAM);
m_pBeamSet->m_BallRefs[i] = Lib3MF_uint32(pBallReferencesBuffer[i]);
Expand Down
13 changes: 10 additions & 3 deletions Source/API/lib3mf_compositematerials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ IBaseMaterialGroup * CCompositeMaterials::GetBaseMaterialGroup ()

Lib3MF_uint32 CCompositeMaterials::AddComposite(const Lib3MF_uint64 nCompositeBufferSize, const sLib3MFCompositeConstituent * pCompositeBuffer)
{
if (nCompositeBufferSize > LIB3MF_MAXCOMPOSITEMATERIALS)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

NMR::PModelComposite constituents = std::make_shared<NMR::CModelComposite>();
constituents->resize(nCompositeBufferSize);
for (Lib3MF_uint64 i = 0; i < nCompositeBufferSize; i++) {
constituents->resize((size_t)nCompositeBufferSize);
for (size_t i = 0; i < (size_t)nCompositeBufferSize; i++) {
(*constituents)[i].m_dMixingRatio = pCompositeBuffer[i].m_MixingRatio;
(*constituents)[i].m_nPropertyID = pCompositeBuffer[i].m_PropertyID;
}
Expand All @@ -108,14 +111,18 @@ void CCompositeMaterials::RemoveComposite (const Lib3MF_uint32 nPropertyID)

void CCompositeMaterials::GetComposite(const Lib3MF_uint32 nPropertyID, Lib3MF_uint64 nCompositeBufferSize, Lib3MF_uint64* pCompositeNeededCount, sLib3MFCompositeConstituent * pCompositeBuffer)
{

if (nCompositeBufferSize > LIB3MF_MAXCOMPOSITEMATERIALS)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

NMR::PModelComposite constituents = compositeMaterials().getComposite(nPropertyID);

if (pCompositeNeededCount) {
*pCompositeNeededCount = constituents->size();
}

if (pCompositeBuffer && nCompositeBufferSize >= constituents->size()) {
for (Lib3MF_uint64 i = 0; i < nCompositeBufferSize; i++) {
for (size_t i = 0; i < (size_t) nCompositeBufferSize; i++) {
pCompositeBuffer[i].m_MixingRatio = (*constituents)[i].m_dMixingRatio;
pCompositeBuffer[i].m_PropertyID = (*constituents)[i].m_nPropertyID;
}
Expand Down
20 changes: 15 additions & 5 deletions Source/API/lib3mf_multipropertygroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,25 @@ void CMultiPropertyGroup::GetAllPropertyIDs (Lib3MF_uint64 nPropertyIDsBufferSiz

Lib3MF_uint32 CMultiPropertyGroup::AddMultiProperty (const Lib3MF_uint64 nPropertyIDsBufferSize, const Lib3MF_uint32 * pPropertyIDsBuffer)
{
if (nPropertyIDsBufferSize > LIB3MF_MAXMULTIPROPERTIES)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

NMR::PModelMultiProperty multiProperty = std::make_shared<NMR::CModelMultiProperty>();
multiProperty->resize(nPropertyIDsBufferSize);
for (Lib3MF_uint64 i = 0; i < nPropertyIDsBufferSize; i++) {
multiProperty->resize((size_t)nPropertyIDsBufferSize);
for (size_t i = 0; i < (size_t) nPropertyIDsBufferSize; i++) {
(*multiProperty)[i] = pPropertyIDsBuffer[i];
}
return multiPropertyGroup().addMultiProperty(multiProperty);
}

void CMultiPropertyGroup::SetMultiProperty (const Lib3MF_uint32 nPropertyID, const Lib3MF_uint64 nPropertyIDsBufferSize, const Lib3MF_uint32 * pPropertyIDsBuffer)
{
if (nPropertyIDsBufferSize > LIB3MF_MAXMULTIPROPERTIES)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

NMR::PModelMultiProperty multiProperty = std::make_shared<NMR::CModelMultiProperty>();
multiProperty->resize(nPropertyIDsBufferSize);
for (Lib3MF_uint64 i = 0; i < nPropertyIDsBufferSize; i++) {
multiProperty->resize((size_t)nPropertyIDsBufferSize);
for (size_t i = 0; i < (size_t)nPropertyIDsBufferSize; i++) {
(*multiProperty)[i] = pPropertyIDsBuffer[i];
}
multiPropertyGroup().setMultiProperty(nPropertyID, multiProperty);
Expand All @@ -113,7 +119,11 @@ void CMultiPropertyGroup::GetMultiProperty (const Lib3MF_uint32 nPropertyID, Lib
}

if (pPropertyIDsBuffer && nPropertyIDsBufferSize >= multiProperty->size()) {
for (Lib3MF_uint64 i = 0; i < nPropertyIDsBufferSize; i++) {

if (nPropertyIDsBufferSize > LIB3MF_MAXMULTIPROPERTIES)
throw ELib3MFInterfaceException(LIB3MF_ERROR_ELEMENTCOUNTEXCEEDSLIMIT);

for (size_t i = 0; i < (size_t)nPropertyIDsBufferSize; i++) {
pPropertyIDsBuffer[i] = (*multiProperty)[i];
}
}
Expand Down
7 changes: 6 additions & 1 deletion Source/Common/Platform/NMR_ImportStream_Unique_Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ namespace NMR {
}

__NMR_INLINE const nfByte * CImportStream_Unique_Memory::getAt(nfUint64 nPosition) {
return &m_Buffer[nPosition];

if (nPosition >= (uint64_t) m_Buffer.size())
throw CNMRException(NMR_ERROR_COULDNOTREADSTREAM);

// On 32 bit system, nPosition is definitely a 32bit value, because m_Buffer.size () is a size_t
return &m_Buffer[(size_t) nPosition];
}

}
6 changes: 3 additions & 3 deletions Source/Model/Classes/NMR_KeyStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace NMR {
{
if (index >= m_Consumers.size())
throw CNMRException(NMR_ERROR_INVALIDINDEX);
return m_Consumers[index];
return m_Consumers[(size_t)index];
}

PKeyStoreConsumer CKeyStore::findConsumerById(std::string id)
Expand Down Expand Up @@ -114,7 +114,7 @@ namespace NMR {

PKeyStoreResourceDataGroup CKeyStore::getResourceDataGroup(nfUint64 index) const {
if (index < m_ResourceDataGroups.size())
return m_ResourceDataGroups[index];
return m_ResourceDataGroups[(size_t)index];
throw CNMRException(NMR_ERROR_INVALIDINDEX);
}

Expand Down Expand Up @@ -177,7 +177,7 @@ namespace NMR {

PKeyStoreResourceData CKeyStore::getResourceData(nfUint64 index) const {
if (index < m_ResourceDatas.size())
return m_ResourceDatas[index];
return m_ResourceDatas[(size_t)index];
throw CNMRException(NMR_ERROR_INVALIDINDEX);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Model/Classes/NMR_KeyStoreResourceDataGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace NMR {
{
if (index >= m_AccessRights.size())
throw CNMRException(NMR_ERROR_INVALIDPARAM);
return m_AccessRights[index];
return m_AccessRights[(size_t)index];
}

PKeyStoreAccessRight CKeyStoreResourceDataGroup::findAccessRightByConsumerID(std::string const & consumerId) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ namespace NMR {

if (m_pMatIndices) {
pBaseMaterial->buildResourceIndexMap();

if (m_pMatIndices->size() > XML_3MF_MAXRESOURCECOUNT)
throw CNMRException(NMR_ERROR_INVALIDBUFFERSIZE);


m_vctMaterialPropertyIDs.resize(m_pMatIndices->size());
for (int i = 0; i < m_vctMaterialPropertyIDs.size(); i++) {
for (size_t i = 0; i < m_vctMaterialPropertyIDs.size(); i++) {
ModelPropertyID nPropertyID;
if (!pBaseMaterial->mapResourceIndexToPropertyID(i, nPropertyID)) {
if (!pBaseMaterial->mapResourceIndexToPropertyID((ModelResourceIndex)i, nPropertyID)) {
throw CNMRException(NMR_ERROR_INVALIDBASEMATERIAL);
}
m_vctMaterialPropertyIDs[i] = nPropertyID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace NMR {
m_pWarnings->addException(CNMRException(NMR_ERROR_MULTIPROPERTIES_DIFFERNT_NUMBER_OF_BLENDMETHODS_AND_PIDS), mrwInvalidMandatoryValue);
}

for (int i = 0; i < m_pPIDs->size(); i++) {
for (size_t i = 0; i < m_pPIDs->size(); i++) {
PPackageResourceID pID = m_pModel->findPackageResourceID(m_pModel->currentPath(), (*m_pPIDs)[i]);
if (!pID)
throw CNMRException(NMR_ERROR_RESOURCENOTFOUND);
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 @@ -118,7 +118,7 @@ struct PositionedVector
buffer->vec.push_back(*pData);
}
else if (buffer->pos < buffer->vec.size()) {
buffer->vec[buffer->pos] = *pData;
buffer->vec[(size_t)buffer->pos] = *pData;
}
else {
ASSERT_TRUE(false);
Expand All @@ -133,7 +133,7 @@ struct PositionedVector
T* pData = (T*)(nByteData);
for (int i = 0; i < nNumBytes; i++) {
if (buffer->pos < buffer->vec.size()) {
*pData = buffer->vec[buffer->pos];
*pData = buffer->vec[(size_t)buffer->pos];
}
else {
ASSERT_TRUE(false);
Expand Down
4 changes: 2 additions & 2 deletions Tests/CPP_Bindings/Source/CompositeMaterials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace Lib3MF
Lib3MF_uint32 propertyID2 = compositeMaterial->AddComposite(constituents2);

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = compositeMaterial->GetResourceID();
for (int k = 0; k < 3; k++) {
properties[i].m_PropertyIDs[k] = ((i + k) % 2) ? propertyID1 : propertyID2;
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace Lib3MF

std::vector<sTriangleProperties> obtainedProperties;
mesh->GetAllTriangleProperties(obtainedProperties);
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
EXPECT_EQ(obtainedProperties[i].m_ResourceID, properties[i].m_ResourceID);
for (Lib3MF_uint64 j = 0; j < 3; j++) {
EXPECT_EQ(obtainedProperties[i].m_PropertyIDs[j], properties[i].m_PropertyIDs[j]);
Expand Down
4 changes: 2 additions & 2 deletions Tests/CPP_Bindings/Source/MultiProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace Lib3MF
std::vector<sTex2Coord> coords(0);
texture2DGroup = model->AddTexture2DGroup(texture2D.get());
std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = texture2DGroup->GetResourceID();

coords.push_back({ 1.0*i / mesh->GetTriangleCount(), 1.0 - 1.0*i / mesh->GetTriangleCount() });
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace Lib3MF
{
std::vector<Lib3MF_uint32> vctPropertyIDs;
multiPropertyGroup->GetAllPropertyIDs(vctPropertyIDs);
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = multiPropertyGroup->GetResourceID();
for (Lib3MF_uint64 k = 0; k < 3; k++) {
properties[i].m_PropertyIDs[k] = vctPropertyIDs[(i + k) % vctPropertyIDs.size()];
Expand Down
30 changes: 15 additions & 15 deletions Tests/CPP_Bindings/Source/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Lib3MF
std::vector<sTriangleProperties> properties;
mesh->GetAllTriangleProperties(properties);

for (Lib3MF_uint64 i=0; i < mesh->GetTriangleCount(); i++) {
for (size_t i=0; i < mesh->GetTriangleCount(); i++) {
EXPECT_EQ(properties[i].m_ResourceID, 0);
for (Lib3MF_uint64 j = 0; j < 3; j++) {
EXPECT_EQ(properties[i].m_PropertyIDs[j], 0);
Expand All @@ -84,7 +84,7 @@ namespace Lib3MF
auto anotherMaterial = baseMaterialGroup->AddMaterial("AnotherMaterial", wrapper->RGBAToColor(100, 200, 150, 255));

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = baseMaterialGroup->GetResourceID();
for (int j = 0; j < 3; j++) {
properties[i].m_PropertyIDs[j] = (i % (2 + j)) ? anotherMaterial : someMaterial;
Expand All @@ -94,9 +94,9 @@ namespace Lib3MF

mesh->ClearAllProperties();
mesh->GetAllTriangleProperties(properties);
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
EXPECT_EQ(properties[i].m_ResourceID, 0);
for (Lib3MF_uint64 j = 0; j < 3; j++) {
for (size_t j = 0; j < 3; j++) {
EXPECT_EQ(properties[i].m_PropertyIDs[j], 0);
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ namespace Lib3MF
auto anotherMaterial = baseMaterialGroup->AddMaterial("AnotherMaterial", wrapper->RGBAToColor(100, 200, 150, 255));

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = baseMaterialGroup->GetResourceID();
for (int j = 0; j < 3; j++) {
properties[i].m_PropertyIDs[j] = ( i % (2+j) ) ? someMaterial : anotherMaterial;
Expand All @@ -149,7 +149,7 @@ namespace Lib3MF
readMesh->GetAllTriangleProperties(readProperties);

ASSERT_EQ(readMesh->GetTriangleCount(), mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < readMesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < readMesh->GetTriangleCount(); i++) {
auto readBaseMaterialGroup = readModel->GetBaseMaterialGroupByID(readProperties[i].m_ResourceID);
for (int j = 0; j < 3; j++) {
CompareColors(baseMaterialGroup->GetDisplayColor(properties[i].m_PropertyIDs[j]), baseMaterialGroup->GetDisplayColor(readProperties[i].m_PropertyIDs[j]));
Expand All @@ -175,7 +175,7 @@ namespace Lib3MF
auto anotherMaterial = baseMaterialGroup->AddMaterial("AnotherMaterial", wrapper->RGBAToColor(100, 200, 150, 255));

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = baseMaterialGroup->GetResourceID();
for (int j = 0; j < 3; j++) {
properties[i].m_PropertyIDs[j] = (i % (2 + j)) ? someMaterial : anotherMaterial;
Expand All @@ -199,7 +199,7 @@ namespace Lib3MF
readMesh->GetAllTriangleProperties(readProperties);

ASSERT_EQ(readMesh->GetTriangleCount(), mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < readMesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < readMesh->GetTriangleCount(); i++) {
auto readBaseMaterialGroup = readModel->GetBaseMaterialGroupByID(readProperties[i].m_ResourceID);
for (int j = 0; j < 3; j++) {
CompareColors(baseMaterialGroup->GetDisplayColor(properties[i].m_PropertyIDs[j]), baseMaterialGroup->GetDisplayColor(readProperties[i].m_PropertyIDs[j]));
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace Lib3MF
auto anotherMaterial = baseMaterialGroup->AddMaterial("AnotherMaterial", wrapper->RGBAToColor(100, 200, 150, 255));

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = baseMaterialGroup->GetResourceID();
auto material = someMaterial;
if (i % 2 == 0) {
Expand All @@ -277,16 +277,16 @@ namespace Lib3MF

std::vector<sTriangleProperties> gottenProperties;
mesh->GetAllTriangleProperties(gottenProperties);
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
EXPECT_EQ(gottenProperties[i].m_ResourceID, properties[i].m_ResourceID);
for (Lib3MF_uint64 j = 0; j < 3; j++) {
for (size_t j = 0; j < 3; j++) {
EXPECT_EQ(gottenProperties[i].m_PropertyIDs[j], properties[i].m_PropertyIDs[j]);
}

sTriangleProperties currentProperty;
mesh->GetTriangleProperties(Lib3MF_uint32(i), currentProperty);
EXPECT_EQ(currentProperty.m_ResourceID, properties[i].m_ResourceID);
for (Lib3MF_uint64 j = 0; j < 3; j++) {
for (size_t j = 0; j < 3; j++) {
EXPECT_EQ(currentProperty.m_PropertyIDs[j], properties[i].m_PropertyIDs[j]);
}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ namespace Lib3MF
auto anotherMaterial = baseMaterialGroup->AddMaterial("AnotherMaterial", wrapper->RGBAToColor(100, 200, 150, 255));

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = baseMaterialGroup->GetResourceID();
auto material = someMaterial;
if (i % 2 == 0) {
Expand Down Expand Up @@ -411,7 +411,7 @@ namespace Lib3MF
auto anotherColor = colorGroup->AddColor(cAnotherColor);

std::vector<sTriangleProperties> properties(mesh->GetTriangleCount());
for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
properties[i].m_ResourceID = colorGroup->GetResourceID();
auto color = someColor;
if (i % 2 == 0) {
Expand Down Expand Up @@ -459,7 +459,7 @@ namespace Lib3MF
std::vector<sTriangleProperties> properties;
mesh->GetAllTriangleProperties(properties);

for (Lib3MF_uint64 i = 0; i < mesh->GetTriangleCount(); i++) {
for (size_t i = 0; i < mesh->GetTriangleCount(); i++) {
auto colorGroup = readModel->GetColorGroupByID(properties[i].m_ResourceID);
auto color = cSomeColor;
if (i % 2 == 0) {
Expand Down
Loading

0 comments on commit 8b5aa63

Please sign in to comment.