/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "RxObjectImpl.h" #include "daiValidationCommon.h" #include "daiSet.h" #include "IfcFile.h" #include "daiStepFile.h" #include "IfcShapeRepresentationTask.h" #define INCORRECT_IDENTIFIER " identifier does not exist" #define INCORRECT_TYPE " type does not exist" using namespace OdDAI; using namespace OdIfc; ODRX_VALIDATION_CONS_DEFINE_MEMBERS(ShapeRepresentationTask, ExtentValidationTask, RXIMPL_CONSTR); using IdentifiersMap = std::map >; static IdentifiersMap ids = { {"IFC4X3", { "cog", "box", "annotation", "axis", "footprint", "profile", "surface", "reference", "body", "body-fallback", "clearance", "lighting" } }, {"IFC4", { "box", "annotation", "axis", "footprint", "profile", "surface", "reference", "body", "body-fallback", "clearance", "lighting" } }, {"IFC2X3", { "box", "annotation", "axis", "footprint", "profile", "surface", "reference", "body", "body-fallback", "clearance", "lighting" } } }; static IdentifiersMap types = { {"IFC4X3", { "point", "pointcloud", "curve", "curve2d", "curve3d", "segment", "surface", "surface2d", "surface3d", "sectionedsurface", "fillarea", "text", "advancedsurface", "annotation2d", "geometricset", "geometriccurveset", "tessellation", "surfaceorsolidmodel", "surfacemodel", "solidmodel", "sweptsolid", "advancedsweptsolid", "csg", "clipping", "brep", "advancedbrep", "boundingbox", "sectionedspine", "lightsource", "mappedrepresentation" } }, {"IFC4", { "point", "pointcloud", "curve", "curve2d", "curve3d", "surface", "surface2d", "surface3d", "fillarea", "text", "advancedsurface", "geometricset", "geometriccurveset", "annotation2d", "surfacemodel", "tessellation", "solidmodel", "sweptsolid", "advancedsweptsolid", "brep", "advancedbrep", "csg", "clipping", "boundingbox", "sectionedspine", "lightsource", "mappedrepresentation" } }, {"IFC2X3", { "curve2d", "geometricset", "geometriccurveset", "surfacemodel", "solidmodel", "sweptsolid", "brep", "csg", "clipping", "advancedsweptsolid", "boundingbox", "sectionedspine", "mappedrepresentation" } } }; ShapeRepresentationTask::ShapeRepresentationTask() { m_extentName = "ifcshaperepresentation"; } OdDAI::Logical ShapeRepresentationTask::validate(OdDAI::InstanceValidationContext* instanceCtx, OdSharedPtr& invalidParams) { //OdIfcInstanceValidationContext* pIfcCtx = dynamic_cast(instanceCtx); //if (pIfcCtx == nullptr) //{ // return OdDAI::Logical::False; //} invalidParams = new InvalidRxArrayValidationParams; InvalidRxArrayValidationParams* pInvalidIds = reinterpret_cast(invalidParams.get()); OdAnsiString schemaName = instanceCtx->pFile->getModel()->underlyingSchemaName(); // IFC4X3_RCx schemas have the same identifiers and representation types as IFC4X3 // IFC4X1, IFC4X2 schemas have the same identifiers and representation types as IFC4 // IFC2XFINAL - IFC2X3 schemas have the same identifiers and representation types as IFC2X3 if (schemaName.find("IFC4X3") != -1) schemaName = "IFC4X3"; else if (schemaName.find("IFC4") != -1) schemaName = "IFC4"; else if (schemaName.find("IFC2") != -1) schemaName = "IFC2X3"; OdAnsiString identifier; if (instanceCtx->pInstance->getAttr("representationidentifier") >> identifier) { identifier.makeLower(); const auto idsSet = ids.find(schemaName); if (idsSet != ids.cend()) if (idsSet->second.find(identifier) == idsSet->second.cend()) pInvalidIds->addData(InvalidRxObjectsValidationParams({ instanceCtx->pInstance }, identifier + INCORRECT_IDENTIFIER, OdDAI::Logical::False)); } OdAnsiString reprType; if (instanceCtx->pInstance->getAttr("representationtype") >> reprType) { reprType.makeLower(); const auto typesSet = types.find(schemaName); if (typesSet != types.cend()) if (typesSet->second.find(reprType) == typesSet->second.cend()) pInvalidIds->addData(InvalidRxObjectsValidationParams({ instanceCtx->pInstance }, reprType + INCORRECT_TYPE, OdDAI::Logical::False)); } return invalidParams->invalidItemsCount() ? OdDAI::Logical::False : OdDAI::Logical::True; } OdAnsiString ShapeRepresentationTask::description() const { return "IfcShapeRepresentation identifier and type validation"; }