/*********************************************************************************************************************** * * 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 "part.h" #include #include namespace he { namespace structure { Part::Part(const Part& other) : Entity(other) { this->entity = other.entity; this->contexts = other.contexts; } Part& Part::operator=(const Part& other) { if (this != &other) { this->entity = other.entity; this->contexts = other.contexts; } return *this; } Part::Part(Part&& other) noexcept { this->entity = other.entity; this->contexts = std::move(other.contexts); } Part& Part::operator=(Part&& other) noexcept { if (this != &other) { this->entity = other.entity; this->contexts = std::move(other.contexts); } return *this; } Part::Part(A3DAsmPartDefinition* part, const A3DMiscCascadedAttributes* attributes, const glm::mat4& parentPosition) : entity(part) { A3DMiscCascadedAttributesData graphics_data; A3D_INITIALIZE_DATA(A3DMiscCascadedAttributesData, graphics_data); status = A3DMiscCascadedAttributesGet(attributes, &graphics_data); contexts.push_back({ attributes, graphics_data, {parentPosition} }); } const A3DAsmPartDefinition* Part::get_entity() const { return entity; } const std::vector& Part::get_contexts() const { return contexts; } std::vector& Part::grab_contexts() { return contexts; } bool Part::isSame(const A3DAsmPartDefinition* part_def, const A3DMiscCascadedAttributes* graphics, glm::mat4&& position) { if (this->entity != part_def) return false; A3DMiscCascadedAttributesData graphics_data; A3D_INITIALIZE_DATA(A3DMiscCascadedAttributesData, graphics_data); status = A3DMiscCascadedAttributesGet(graphics, &graphics_data); if (status != A3D_SUCCESS) return false; auto it = std::find_if( contexts.begin(), contexts.end(), [&] (Context& context) { const auto& gpx = std::get<1>(context); auto& positions = std::get<2>(context); if (graphics_data.m_sStyle.m_dWidth != gpx.m_sStyle.m_dWidth || graphics_data.m_sStyle.m_bVPicture != gpx.m_sStyle.m_bVPicture || graphics_data.m_sStyle.m_uiLinePatternIndex != gpx.m_sStyle.m_uiLinePatternIndex || graphics_data.m_sStyle.m_bMaterial != gpx.m_sStyle.m_bMaterial || graphics_data.m_sStyle.m_uiRgbColorIndex != gpx.m_sStyle.m_uiRgbColorIndex || graphics_data.m_sStyle.m_bIsTransparencyDefined != gpx.m_sStyle.m_bIsTransparencyDefined || graphics_data.m_sStyle.m_ucTransparency != gpx.m_sStyle.m_ucTransparency || graphics_data.m_sStyle.m_bSpecialCulling != gpx.m_sStyle.m_bSpecialCulling || graphics_data.m_sStyle.m_bFrontCulling != gpx.m_sStyle.m_bFrontCulling || graphics_data.m_sStyle.m_bBackCulling != gpx.m_sStyle.m_bBackCulling || graphics_data.m_sStyle.m_bNoLight != gpx.m_sStyle.m_bNoLight || graphics_data.m_sStyle.m_eRenderingMode != gpx.m_sStyle.m_eRenderingMode // || graphics_data.m_usLayer != gpx.m_usLayer ) { contexts.push_back({ graphics, graphics_data, {position} }); return true; } positions.push_back(position); return true; }); if (it == contexts.end()) contexts.push_back({ graphics, graphics_data, {position} }); return true; } void traverse_ri(A3DRiRepresentationItem* ri, std::vector& ri_list) { A3DEEntityType type = kA3DTypeUnknown; A3DEntityGetType(ri, &type); if (type == kA3DTypeRiSet) { A3DRiSetData data; A3D_INITIALIZE_DATA(A3DRiSetData, data); if (A3D_SUCCESS != A3DRiSetGet(ri, &data)) return; for (A3DUns32 i = 0; i < data.m_uiRepItemsSize; i++) traverse_ri(data.m_ppRepItems[i], ri_list); } else if(type != kA3DTypeRiPlane) ri_list.push_back(ri); }; void Part::ri_list(std::vector& ri_list) const { A3DAsmPartDefinitionData data; A3D_INITIALIZE_DATA(A3DAsmPartDefinitionData, data); if (A3D_SUCCESS != A3DAsmPartDefinitionGet(entity, &data) || data.m_uiRepItemsSize == 0) return; for (A3DUns32 i = 0; i < data.m_uiRepItemsSize; i++) traverse_ri(data.m_ppRepItems[i], ri_list); A3DAsmPartDefinitionGet(nullptr, &data); } } }