/*********************************************************************************************************************** * * 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 #include #include "Viewer.h" static A3DUns32 NumberOfSections = 0; //###################################################################################################################### // create RISet with the planar section A3DRiSet* stCreateRISet(A3DRiSet * pRISectionElements) { A3DRiSet* pp = nullptr; A3DRiSetData sData; A3D_INITIALIZE_DATA(A3DRiSetData, sData); A3DRiSetData sSectionData; A3D_INITIALIZE_DATA(A3DRiSetData, sSectionData); A3DRiSetGet(pRISectionElements, &sSectionData); sData.m_uiRepItemsSize = sSectionData.m_uiRepItemsSize; sData.m_ppRepItems = new A3DRiRepresentationItem*[sSectionData.m_uiRepItemsSize]; for(A3DUns32 ui = 0; ui < sSectionData.m_uiRepItemsSize; ++ui) { sData.m_ppRepItems[ui] = sSectionData.m_ppRepItems[ui]; } A3DRiSetCreate(&sData, &pp); A3DRiSetGet(nullptr, &sSectionData); delete [] sData.m_ppRepItems; return pp; } //###################################################################################################################### // create part definition A3DAsmPartDefinition* stCreatePart(A3DRiSet** pRISectionElements) { A3DAsmPartDefinition* pp = nullptr; A3DAsmPartDefinitionData sData; A3D_INITIALIZE_DATA(A3DAsmPartDefinitionData, sData); sData.m_uiRepItemsSize = NumberOfSections; sData.m_ppRepItems = new A3DRiRepresentationItem*[sData.m_uiRepItemsSize]; for(A3DUns32 iSet = 0; iSet < NumberOfSections; ++iSet) { A3DRiSet* p = nullptr; p = stCreateRISet(pRISectionElements[iSet]); if(p != nullptr) sData.m_ppRepItems[iSet] = p; } A3DAsmPartDefinitionCreate(&sData, &pp); delete [] sData.m_ppRepItems; return pp; } //###################################################################################################################### // create product occurence A3DAsmProductOccurrence* stCreateOccurrence(A3DRiSet** pRISectionElements) { A3DAsmProductOccurrence* pp = nullptr; A3DAsmPartDefinition* p = stCreatePart(pRISectionElements); if(p != nullptr) { A3DAsmProductOccurrenceData sData; A3D_INITIALIZE_DATA(A3DAsmProductOccurrenceData, sData); sData.m_pPart = p; A3DAsmProductOccurrenceCreate(&sData, &pp); } return pp; } //###################################################################################################################### // create model file A3DAsmModelFile* stCreateModel(A3DRiSet** pRISectionElements) { A3DAsmModelFile* pp = nullptr; A3DAsmProductOccurrence* p = stCreateOccurrence(pRISectionElements); if(p != nullptr) { A3DAsmModelFileData sData; A3D_INITIALIZE_DATA(A3DAsmModelFileData, sData); sData.m_uiPOccurrencesSize = 1; sData.m_dUnit = 1.0; sData.m_ppPOccurrences = &p; A3DAsmModelFileCreate(&sData, &pp); } return pp; } //###################################################################################################################### // create an empty model file containing the section of the previous model file A3DAsmModelFile* ComputeSection(A3DAsmModelFile* pModelFile, A3DPlanarSectionData sSectionParametersData) { A3DAsmModelFile* pSectionnedModelFile = nullptr; A3DRiSet** ppRISectionElements = nullptr; A3DStatus iRet = A3DComputePlanarSectionOnModelFile(pModelFile, &sSectionParametersData, &NumberOfSections, &ppRISectionElements); if (iRet == A3D_SUCCESS) { pSectionnedModelFile = stCreateModel(ppRISectionElements); A3DComputePlanarSectionOnModelFile(nullptr, &sSectionParametersData, &NumberOfSections, &ppRISectionElements); } return pSectionnedModelFile; }