/* * Copyright (c) 1991-2023 by STEP Tools Inc. * All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation is hereby granted, provided that this copyright * notice and license appear on all copies of the software. * * STEP TOOLS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. STEP TOOLS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. * * Author: Dave Loffredo (loffredo@steptools.com) */ #include #include // PRINT WALL PROPERTIES - This IFC program finds all of the IfcWall // instances in a file, then searches for all related property set // definitions and prints the property sets for each. The program // takes the filename from the command line so you can use it with // test files such as those on buildingSMART site or Univ Karlsruhe. // void printWallProps (IfcWall * wall); void printProperty (IfcProperty * prop); void printValue (IfcValue * val); int main(int argc, char* argv[]) { ifclib_init(); // force optimizing linkers to use all C++ classes // read file, change to your own as needed if (argc < 2) { printf ("No IFC file specified\n"); return 1; } RoseDesign * design = ROSE.findDesign(argv[1]); if (!design) { printf ("Could not open IFC file\n"); return 1; } // Compute backpointers for all objects for faster inverses rose_compute_backptrs(design); // Find the project and print all children RoseCursor objs; RoseObject * obj; objs.traverse(design); objs.domain(ROSE_DOMAIN(IfcWall)); while ((obj=objs.next()) != 0) { IfcWall * root = ROSE_CAST(IfcWall,obj); printWallProps (root); } return 0; } void printWallProps (IfcWall * wall) { unsigned i, j; if (!wall) { printf ("NULL OBJECT\n"); return; } printf ("Wall: %s #%lu, %s\n", wall->domain()->name(), wall->entity_id(), (wall-> Name()? wall-> Name(): "") ); // Iterate over all objects that point to this wall and select the // defines by properties. RoseBackptrs *bp = rose_get_backptrs(wall); for (i=0; isize(); i++) { RoseObject * obj = bp->get(i); if (!obj-> isa(ROSE_DOMAIN(IfcRelDefinesByProperties))) continue; // Only look at relations that connect a property set IfcRelDefinesByProperties * rel = ROSE_CAST(IfcRelDefinesByProperties,obj); RoseObject * psetd = rose_get_nested_object( rel->RelatingPropertyDefinition() // made a select in IFC4 ); if (!psetd-> isa(ROSE_DOMAIN(IfcPropertySet))) continue; IfcPropertySet * pset = ROSE_CAST (IfcPropertySet,psetd); printf (" rel: #%lu\n", rel->entity_id()); printf (" pset #%lu %s\n", pset->entity_id(), (pset-> Name()? pset-> Name(): "")); SetOfIfcProperty * props = pset-> HasProperties(); for (j=0; jsize(); j++) printProperty (props->get(j)); } } void printProperty (IfcProperty * prop) { if (!prop) { printf ("\tNULL PROP\n"); return; } printf ("\tprop: #%lu %s %s\n", prop-> entity_id(), (prop-> Name()? prop-> Name(): ""), prop-> domain()-> name()); if (prop-> isa(ROSE_DOMAIN(IfcPropertySingleValue))) { IfcPropertySingleValue * psv = ROSE_CAST(IfcPropertySingleValue,prop); IfcValue * val = psv->NominalValue(); printf("\tvalue="); printValue (val); printf("\n"); } else if (prop-> isa(ROSE_DOMAIN(IfcComplexProperty))) { IfcComplexProperty * cprop = ROSE_CAST(IfcComplexProperty,prop); SetOfIfcProperty * props = cprop-> HasProperties(); for (unsigned i=0; isize(); i++) printProperty(props->get(i)); } else { printf ("\tProperty type not implemented: %s\n", prop->domain()->name()); } } void printValue (IfcValue * val) { if (!val) printf(""); else if (val-> is_IfcMeasureValue()) { IfcMeasureValue * mv = val-> _IfcMeasureValue(); // The select can have contain many different types, but they // are almost all doubles, so we just print that. If you need // to know the exact type, you can call the test functions for // the types below. if (mv-> is_IfcDescriptiveMeasure()) printf ("%s (measure)", mv-> _IfcDescriptiveMeasure()); else { printf ("%g (measure)", mv-> getDouble()); } // IfcVolumeMeasure // IfcTimeMeasure // IfcThermodynamicTemperatureMeasure // IfcSolidAngleMeasure // IfcPositiveRatioMeasure // IfcRatioMeasure // IfcPositivePlaneAngleMeasure // IfcPlaneAngleMeasure // IfcParameterValue // IfcNumericMeasure // IfcMassMeasure // IfcPositiveLengthMeasure // IfcLengthMeasure // IfcElectricCurrentMeasure // IfcCountMeasure // IfcContextDependentMeasure // IfcAreaMeasure // IfcAmountOfSubstanceMeasure // IfcLuminousIntensityMeasure // IfcNormalisedRatioMeasure // IfcComplexNumber } else if (val-> is_IfcSimpleValue()) { IfcSimpleValue * sv = val-> _IfcSimpleValue(); if (sv-> is_IfcInteger()) printf ("%d (simple int)", sv-> _IfcInteger()); else if (sv-> is_IfcReal()) printf ("%g (simple real)", sv-> _IfcReal()); else if (sv-> is_IfcBoolean()) printf ("%s (simple bool)", (sv-> _IfcBoolean()? "TRUE": "FALSE")); else if (sv-> is_IfcIdentifier()) printf ("%s (simple ID)", sv-> _IfcIdentifier()); else if (sv-> is_IfcText()) printf ("%s (simple int)", sv-> _IfcText()); else if (sv-> is_IfcLabel()) printf ("%s (simple int)", sv-> _IfcLabel()); else if (sv-> is_IfcLogical()) switch (sv-> _IfcInteger()) { case ROSE_TRUE: printf ("TRUE (simple log)"); break; case ROSE_FALSE: printf ("FALSE (simple log)"); break; case ROSE_UNKNOWN: printf ("UNKNOWN (simple log)"); break; } } else if (val-> is_IfcDerivedMeasureValue()) { IfcDerivedMeasureValue * dmv = val-> _IfcDerivedMeasureValue(); // The select can have contain many different types, but they // are almost all doubles, so we just print that. If you need // to know the exact type, you can call the test functions for // the types below. printf ("%g (derived measure)", dmv-> getDouble()); // IfcVolumetricFlowRateMeasure // IfcTimeStamp // IfcThermalTransmittanceMeasure // IfcThermalResistanceMeasure // IfcThermalAdmittanceMeasure // IfcPressureMeasure // IfcPowerMeasure // IfcMassFlowRateMeasure // IfcMassDensityMeasure // IfcLinearVelocityMeasure // IfcKinematicViscosityMeasure // IfcIntegerCountRateMeasure // IfcHeatFluxDensityMeasure // IfcFrequencyMeasure // IfcEnergyMeasure // IfcElectricVoltageMeasure // IfcDynamicViscosityMeasure // IfcCompoundPlaneAngleMeasure // IfcAngularVelocityMeasure // IfcThermalConductivityMeasure // IfcMolecularWeightMeasure // IfcVaporPermeabilityMeasure // IfcMoistureDiffusivityMeasure // IfcIsothermalMoistureCapacityMeasure // IfcSpecificHeatCapacityMeasure // IfcMonetaryMeasure // IfcMagneticFluxDensityMeasure // IfcMagneticFluxMeasure // IfcLuminousFluxMeasure // IfcForceMeasure // IfcInductanceMeasure // IfcIlluminanceMeasure // IfcElectricResistanceMeasure // IfcElectricConductanceMeasure // IfcElectricChargeMeasure // IfcDoseEquivalentMeasure // IfcElectricCapacitanceMeasure // IfcAbsorbedDoseMeasure // IfcRadioActivityMeasure // IfcRotationalFrequencyMeasure // IfcTorqueMeasure // IfcAccelerationMeasure // IfcLinearForceMeasure // IfcLinearStiffnessMeasure // IfcModulusOfSubgradeReactionMeasure // IfcModulusOfElasticityMeasure // IfcMomentOfInertiaMeasure // IfcPlanarForceMeasure // IfcRotationalStiffnessMeasure // IfcShearModulusMeasure // IfcLinearMomentMeasure // IfcLuminousIntensityDistributionMeasure // IfcCurvatureMeasure // IfcMassPerLengthMeasure // IfcModulusOfLinearSubgradeReactionMeasure // IfcModulusOfRotationalSubgradeReactionMeasure // IfcRotationalMassMeasure // IfcSectionalAreaIntegralMeasure // IfcSectionModulusMeasure // IfcTemperatureGradientMeasure // IfcThermalExpansionCoefficientMeasure // IfcWarpingConstantMeasure // IfcWarpingMomentMeasure // IfcSoundPowerMeasure // IfcSoundPressureMeasure // IfcHeatingValueMeasure // IfcPHMeasure // IfcIonConcentrationMeasure } }