Files
2025-12-15 23:22:33 +08:00

60 lines
2.0 KiB
C++

/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#include "model_file.h"
#include "part.h"
#include "product_occurrence.h"
namespace he
{
namespace structure
{
ModelFile::ModelFile(A3DAsmModelFile* mdlFile)
{
A3D_INITIALIZE_DATA(A3DAsmModelFileData, data);
status = A3DAsmModelFileGet(mdlFile, &data);
if (status != A3D_SUCCESS)
return;
status = A3DMiscCascadedAttributesCreate(&attributes);
}
ModelFile::~ModelFile()
{
A3DAsmModelFileGet(nullptr, &data);
}
int ModelFile::collect(std::vector<Part>& parts)
{
if (status)
return 1;
A3DMiscCascadedAttributes* mdl_attribs = nullptr;
A3DMiscCascadedAttributesCreate(&mdl_attribs);
for (const auto po_entity : sub_levels())
{
A3DMiscCascadedAttributes* new_attributes = nullptr;
if (create_cascaded_attributes(po_entity, mdl_attribs, new_attributes) != 0)
return 1;
if (A3DMiscCascadedAttributesEntityReferencePush(new_attributes, po_entity, nullptr) != 0)
continue;
ProductOccurrence po(po_entity, new_attributes);
po.collect(parts, nullptr);
}
return 0;
}
std::vector<A3DEntity*> ModelFile::sub_levels() const
{
return std::vector<A3DEntity*>(data.m_ppPOccurrences, data.m_ppPOccurrences + data.m_uiPOccurrencesSize);
}
}
}