Skip to content

Commit

Permalink
ModelReaderNode100_Mesh reads volumeid
Browse files Browse the repository at this point in the history
3dJan committed Aug 21, 2024
1 parent ab579f4 commit 488aeb7
Showing 3 changed files with 42 additions and 14 deletions.
8 changes: 6 additions & 2 deletions Include/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.h
Original file line number Diff line number Diff line change
@@ -39,12 +39,13 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream.
#include "Model/Classes/NMR_ModelComponent.h"
#include "Model/Classes/NMR_ModelObject.h"
#include "Model/Classes/NMR_ModelVolumeData.h"
#include "Model/Classes/NMR_ModelMeshObject.h"

namespace NMR {

class CModelReaderNode100_Mesh : public CModelReaderNode {
private:
CMesh * m_pMesh;
PModelMeshObject m_pMesh;
CModel * m_pModel;

ModelResourceID m_nObjectLevelPropertyID;
@@ -56,12 +57,15 @@ namespace NMR {
ModelResourceID m_nClippingMeshID;
nfBool m_bHasRepresentationMeshID;
ModelResourceID m_nRepresentationMeshID;

nfBool m_bHasVolumeDataID = false;
ModelResourceID m_nVolumeDataID = 0;
protected:
virtual void OnAttribute(_In_z_ const nfChar * pAttributeName, _In_z_ const nfChar * pAttributeValue);
virtual void OnNSChildElement(_In_z_ const nfChar * pChildName, _In_z_ const nfChar * pNameSpace, _In_ CXmlReader * pXMLReader);
public:
CModelReaderNode100_Mesh() = delete;
CModelReaderNode100_Mesh(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings, _In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID m_pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex);
CModelReaderNode100_Mesh(_In_ CModel * pModel, PModelMeshObject pMesh, _In_ PModelWarnings pWarnings, _In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID m_pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex);

virtual void parseXML(_In_ CXmlReader * pXMLReader);
void retrieveClippingInfo(_Out_ eModelBeamLatticeClipMode &eClipMode, _Out_ nfBool & bHasClippingMode, _Out_ ModelResourceID & nClippingMeshID);
43 changes: 33 additions & 10 deletions Source/Model/Reader/v100/NMR_ModelReaderNode100_Mesh.cpp
Original file line number Diff line number Diff line change
@@ -45,24 +45,26 @@ A mesh reader model node is a parser for the mesh node of an XML Model Stream.

namespace NMR {

CModelReaderNode100_Mesh::CModelReaderNode100_Mesh(_In_ CModel * pModel, _In_ CMesh * pMesh, _In_ PModelWarnings pWarnings,
CModelReaderNode100_Mesh::CModelReaderNode100_Mesh(_In_ CModel * pModel, PModelMeshObject pMesh, _In_ PModelWarnings pWarnings,
_In_ PProgressMonitor pProgressMonitor, _In_ PPackageResourceID pObjectLevelPropertyID, _In_ ModelResourceIndex nDefaultPropertyIndex)
: CModelReaderNode(pWarnings, pProgressMonitor)
: CModelReaderNode(pWarnings, pProgressMonitor),
m_pModel(pModel),
m_pMesh(pMesh)
{
__NMRASSERT(pMesh);
__NMRASSERT(pModel);

m_pObjectLevelPropertyID = pObjectLevelPropertyID;
m_nObjectLevelPropertyIndex = nDefaultPropertyIndex;

m_pMesh = pMesh;
m_pModel = pModel;

m_bHasClippingMeshID = false;
m_nClippingMeshID = 0;
m_eClipMode = eModelBeamLatticeClipMode::MODELBEAMLATTICECLIPMODE_NONE;
m_bHasRepresentationMeshID = false;
m_nRepresentationMeshID = 0;

m_bHasVolumeDataID = false;
m_nVolumeDataID = 0;
}

void CModelReaderNode100_Mesh::parseXML(_In_ CXmlReader * pXMLReader)
@@ -75,6 +77,23 @@ namespace NMR {

// Parse Content
parseContent(pXMLReader);

if(m_bHasVolumeDataID)
{
PPackageResourceID volumePackageId =
m_pModel->findPackageResourceID(m_pModel->currentPath(),
m_nVolumeDataID);

if(!volumePackageId.get())
{
throw CNMRException(NMR_ERROR_UNKNOWNMODELRESOURCE);
}

auto pVolumeData = m_pModel->findVolumeData(
volumePackageId->getUniqueID());

m_pMesh->setVolumeData(pVolumeData);
}
}

void CModelReaderNode100_Mesh::retrieveClippingInfo(_Out_ eModelBeamLatticeClipMode &eClipMode, _Out_ nfBool & bHasClippingMode, _Out_ ModelResourceID & nClippingMeshID)
@@ -102,24 +121,28 @@ namespace NMR {
__NMRASSERT(pXMLReader);
__NMRASSERT(pNameSpace);


NMR::CMesh *mesh = m_pMesh->getMesh();

if (strcmp(pNameSpace, XML_3MF_NAMESPACE_CORESPEC100) == 0) {


if (strcmp(pChildName, XML_3MF_ELEMENT_VERTICES) == 0)
{
if (m_pMesh->getNodeCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) {
if (mesh->getNodeCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) {
m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_READMESH);
m_pProgressMonitor->ReportProgressAndQueryCancelled(true);
}
PModelReaderNode pXMLNode = std::make_shared<CModelReaderNode100_Vertices>(m_pMesh, m_pWarnings);
PModelReaderNode pXMLNode = std::make_shared<CModelReaderNode100_Vertices>(mesh, m_pWarnings);
pXMLNode->parseXML(pXMLReader);
}
else if (strcmp(pChildName, XML_3MF_ELEMENT_TRIANGLES) == 0)
{
if (m_pMesh->getFaceCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) {
if (mesh->getFaceCount() % PROGRESS_READUPDATE == PROGRESS_READUPDATE - 1) {
m_pProgressMonitor->SetProgressIdentifier(ProgressIdentifier::PROGRESS_READMESH);
m_pProgressMonitor->ReportProgressAndQueryCancelled(true);
}
PModelReaderNode100_Triangles pXMLNode = std::make_shared<CModelReaderNode100_Triangles>(m_pModel, m_pMesh, m_pWarnings,
PModelReaderNode100_Triangles pXMLNode = std::make_shared<CModelReaderNode100_Triangles>(m_pModel, mesh, m_pWarnings,
m_pObjectLevelPropertyID, m_nObjectLevelPropertyIndex);
pXMLNode->parseXML(pXMLReader);
if (m_pObjectLevelPropertyID && m_pObjectLevelPropertyID->getPackageModelPath() == 0) {
@@ -141,7 +164,7 @@ namespace NMR {
if (strcmp(pNameSpace, XML_3MF_NAMESPACE_BEAMLATTICESPEC) == 0) {
if (strcmp(pChildName, XML_3MF_ELEMENT_BEAMLATTICE) == 0)
{
PModelReaderNode_BeamLattice1702_BeamLattice pXMLNode = std::make_shared<CModelReaderNode_BeamLattice1702_BeamLattice>(m_pModel, m_pMesh, m_pWarnings);
PModelReaderNode_BeamLattice1702_BeamLattice pXMLNode = std::make_shared<CModelReaderNode_BeamLattice1702_BeamLattice>(m_pModel, mesh, m_pWarnings);
pXMLNode->parseXML(pXMLReader);

pXMLNode->retrieveClippingInfo(m_eClipMode, m_bHasClippingMeshID, m_nClippingMeshID);
5 changes: 3 additions & 2 deletions Source/Model/Reader/v100/NMR_ModelReaderNode100_Object.cpp
Original file line number Diff line number Diff line change
@@ -237,15 +237,16 @@ namespace NMR {
// Create Empty Mesh
PMesh pMesh = std::make_shared<CMesh>();
// Create Mesh Object
m_pObject = std::make_shared<CModelMeshObject>(m_nID, m_pModel, pMesh);
PModelMeshObject meshObject = std::make_shared<CModelMeshObject>(m_nID, m_pModel, pMesh);
m_pObject = meshObject;
// Set Object Type (might fail, if string is invalid)
if (m_bHasType) {
if (!m_pObject->setObjectTypeString(m_sType, false))
m_pWarnings->addWarning(NMR_ERROR_INVALIDMODELOBJECTTYPE, mrwInvalidOptionalValue);
}

// Read Mesh
PModelReaderNode100_Mesh pXMLNode = std::make_shared<CModelReaderNode100_Mesh>(m_pModel, pMesh.get(),
PModelReaderNode100_Mesh pXMLNode = std::make_shared<CModelReaderNode100_Mesh>(m_pModel, meshObject,
m_pWarnings, m_pProgressMonitor, m_pObjectLevelPropertyID, m_nObjectLevelPropertyIndex);
pXMLNode->parseXML(pXMLReader);

0 comments on commit 488aeb7

Please sign in to comment.