Skip to content

Commit

Permalink
added GetTriangleList api to CTriangleSet
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJohnMcLean authored and gangatp committed Dec 17, 2024
1 parent 3991d0f commit f6266a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion AutomaticComponentToolkit/lib3mf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@
<method name="GetTriangleList" description="Retrieves all the triangles in the TriangleSet">
<param name="TriangleIndices" type="basicarray" class="uint32" pass="out" description="retrieves the indices of the triangles in this TriangleSet"/>
</method>

<method name="AddTriangleList" description="Adds multiple triangles in the list. Duplicates will be merged.">
<param name="TriangleIndices" type="basicarray" class="uint32" pass="in" description="Triangle indices to add. Every element MUST be between 0 and TriangleCount - 1."/>
</method>
Expand Down
2 changes: 2 additions & 0 deletions Include/API/lib3mf_triangleset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class CTriangleSet : public virtual ITriangleSet, public virtual CBase {

void SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override;

void GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer) override;

void AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer) override;

void Merge(ITriangleSet* pOtherTriangleSet, const bool bDeleteOther) override;
Expand Down
18 changes: 18 additions & 0 deletions Source/API/lib3mf_triangleset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ void CTriangleSet::SetTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSiz
}
}

void CTriangleSet::GetTriangleList(Lib3MF_uint64 nTriangleIndicesBufferSize, Lib3MF_uint64 * pTriangleIndicesNeededCount, Lib3MF_uint32 * pTriangleIndicesBuffer)
{
auto triangleIndicesSet = m_pTriangleSet->getTriangles();
Lib3MF_uint32 count = (Lib3MF_uint32)triangleIndicesSet.size();
if (pTriangleIndicesNeededCount)
*pTriangleIndicesNeededCount = count;

if (nTriangleIndicesBufferSize >= count && pTriangleIndicesBuffer)
{
Lib3MF_uint32* pIndex = pTriangleIndicesBuffer;
for (auto index : triangleIndicesSet)
{
*pIndex = index;
pIndex++;
}
}
}

void CTriangleSet::AddTriangleList(const Lib3MF_uint64 nTriangleIndicesBufferSize, const Lib3MF_uint32* pTriangleIndicesBuffer)
{
if (pTriangleIndicesBuffer) {
Expand Down

0 comments on commit f6266a5

Please sign in to comment.