Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
beachtom committed Nov 12, 2024
1 parent a762005 commit c324c85
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/cpp/web-ifc-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ bool WriteSet(uint32_t modelID, emscripten::val& val)
{
emscripten::val child = val[std::to_string(i)];
if (child.isNull()) loader->Push<uint8_t>(webifc::parsing::IfcTokenType::EMPTY);
else if (child.isUndefined()) loader->Push<uint8_t>(webifc::parsing::IfcTokenType::EMPTY);
else if (child.isUndefined()) loader->Push<uint8_t>(webifc::parsing::IfcTokenType::UNKNOWN);
else if (child.isArray()) WriteSet(modelID,child);
else if (child["value"].isArray())
{
Expand Down
2 changes: 1 addition & 1 deletion src/schema-generator/gen_functional_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ for (var i = 0; i < files.length; i++) {

//generate ToRawLineData
tsSchema.push(`ToRawLineData[${i}]={`)
for (var x=0; x < entities.length; x++) tsSchema.push(`${crc32(entities[x].name.toUpperCase(),crcTable)}:(${entities[x].derivedProps.length==0?'_:any': `i:${schemaNameClean}.${entities[x].name}`}):unknown[]=>[${entities[x].derivedProps.map((p) => generateTapeAssignment(p,types)).join(", ")}],`);
for (var x=0; x < entities.length; x++) tsSchema.push(`${crc32(entities[x].name.toUpperCase(),crcTable)}:(${entities[x].derivedProps.length==0?'_:any': `i:${schemaNameClean}.${entities[x].name}`}):unknown[]=>[${entities[x].derivedProps.map((p) => generateTapeAssignment(p,entities[x].ifcDerivedProps,types)).join(", ")}],`);
tsSchema.push('}');

//initialisers
Expand Down
8 changes: 6 additions & 2 deletions src/schema-generator/gen_functional_types_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ export function sortEntities(entities: Array<Entity>) {
return sortedEntities;
}

export function generateTapeAssignment(p: Prop, types:Type[])
export function generateTapeAssignment(p: Prop, ifcDerivedProps: string[],types:Type[])
{
let type = types.find( (x:Type) => x.name == p.type);
if (p.set && type?.isSelect)
if (ifcDerivedProps.includes(p.name))
{
return "undefined";
}
else if (p.set && type?.isSelect)
{
let isEntitySelect = type?.values.some(refType => types.findIndex( t => t.name==refType)==-1);
if (isEntitySelect) return `i.${p.name}`;
Expand Down
22 changes: 11 additions & 11 deletions src/ts/ifc-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ ToRawLineData[1]={
1660063152:(i:IFC2X3.IfcRepresentationMap):unknown[]=>[i.MappingOrigin, i.MappedRepresentation],
3679540991:(i:IFC2X3.IfcRibPlateProfileProperties):unknown[]=>[i.ProfileName, i.ProfileDefinition, i.Thickness, i.RibHeight, i.RibWidth, i.RibSpacing, i.Direction],
2341007311:(i:IFC2X3.IfcRoot):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
448429030:(i:IFC2X3.IfcSIUnit):unknown[]=>[i.Dimensions, i.UnitType, i.Prefix, i.Name],
448429030:(i:IFC2X3.IfcSIUnit):unknown[]=>[undefined, i.UnitType, i.Prefix, i.Name],
2042790032:(i:IFC2X3.IfcSectionProperties):unknown[]=>[i.SectionType, i.StartProfile, i.EndProfile],
4165799628:(i:IFC2X3.IfcSectionReinforcementProperties):unknown[]=>[i.LongitudinalStartPosition, i.LongitudinalEndPosition, i.TransversePosition, i.ReinforcementRole, i.SectionDefinition, i.CrossSectionReinforcementDefinitions],
867548509:(i:IFC2X3.IfcShapeAspect):unknown[]=>[i.ShapeRepresentations, i.Name, i.Description, i.ProductDefinitional, i.PartOfProductDefinitionShape],
Expand Down Expand Up @@ -3292,7 +3292,7 @@ ToRawLineData[1]={
1446786286:(i:IFC2X3.IfcGeneralProfileProperties):unknown[]=>[i.ProfileName, i.ProfileDefinition, i.PhysicalWeight, i.Perimeter, i.MinimumPlateThickness, i.MaximumPlateThickness, i.CrossSectionArea],
3448662350:(i:IFC2X3.IfcGeometricRepresentationContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth],
2453401579:(_:any):unknown[]=>[],
4142052618:(i:IFC2X3.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
4142052618:(i:IFC2X3.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, undefined, undefined, undefined, undefined, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
3590301190:(i:IFC2X3.IfcGeometricSet):unknown[]=>[i.Elements],
178086475:(i:IFC2X3.IfcGridPlacement):unknown[]=>[i.PlacementLocation, i.PlacementRefDirection],
812098782:(i:IFC2X3.IfcHalfSpaceSolid):unknown[]=>[i.BaseSurface, i.AgreementFlag],
Expand All @@ -3313,7 +3313,7 @@ ToRawLineData[1]={
219451334:(i:IFC2X3.IfcObjectDefinition):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
2833995503:(i:IFC2X3.IfcOneDirectionRepeatFactor):unknown[]=>[i.RepeatFactor],
2665983363:(i:IFC2X3.IfcOpenShell):unknown[]=>[i.CfsFaces],
1029017970:(i:IFC2X3.IfcOrientedEdge):unknown[]=>[i.EdgeStart, i.EdgeEnd, i.EdgeElement, i.Orientation],
1029017970:(i:IFC2X3.IfcOrientedEdge):unknown[]=>[undefined, undefined, i.EdgeElement, i.Orientation],
2529465313:(i:IFC2X3.IfcParameterizedProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.Position],
2519244187:(i:IFC2X3.IfcPath):unknown[]=>[i.EdgeList],
3021840470:(i:IFC2X3.IfcPhysicalComplexQuantity):unknown[]=>[i.Name, i.Description, i.HasQuantities, i.Discrimination, i.Quality, i.Usage],
Expand Down Expand Up @@ -11917,7 +11917,7 @@ ToRawLineData[2]={
1660063152:(i:IFC4.IfcRepresentationMap):unknown[]=>[i.MappingOrigin, i.MappedRepresentation],
2439245199:(i:IFC4.IfcResourceLevelRelationship):unknown[]=>[i.Name, i.Description],
2341007311:(i:IFC4.IfcRoot):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
448429030:(i:IFC4.IfcSIUnit):unknown[]=>[i.Dimensions, i.UnitType, i.Prefix, i.Name],
448429030:(i:IFC4.IfcSIUnit):unknown[]=>[undefined, i.UnitType, i.Prefix, i.Name],
1054537805:(i:IFC4.IfcSchedulingTime):unknown[]=>[i.Name, i.DataOrigin, i.UserDefinedDataOrigin],
867548509:(i:IFC4.IfcShapeAspect):unknown[]=>[i.ShapeRepresentations, i.Name, i.Description, {type:3,value:BooleanConvert(i.ProductDefinitional.value)}, i.PartOfProductDefinitionShape],
3982875396:(i:IFC4.IfcShapeModel):unknown[]=>[i.ContextOfItems, i.RepresentationIdentifier, i.RepresentationType, i.Items],
Expand Down Expand Up @@ -12001,7 +12001,7 @@ ToRawLineData[2]={
738692330:(i:IFC4.IfcFillAreaStyle):unknown[]=>[i.Name, i.FillStyles, i.ModelorDraughting == null ? null : {type:3,value:BooleanConvert(i.ModelorDraughting.value)}],
3448662350:(i:IFC4.IfcGeometricRepresentationContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth],
2453401579:(_:any):unknown[]=>[],
4142052618:(i:IFC4.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
4142052618:(i:IFC4.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, undefined, undefined, undefined, undefined, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
3590301190:(i:IFC4.IfcGeometricSet):unknown[]=>[i.Elements],
178086475:(i:IFC4.IfcGridPlacement):unknown[]=>[i.PlacementLocation, i.PlacementRefDirection],
812098782:(i:IFC4.IfcHalfSpaceSolid):unknown[]=>[i.BaseSurface, {type:3,value:BooleanConvert(i.AgreementFlag.value)}],
Expand Down Expand Up @@ -12029,11 +12029,11 @@ ToRawLineData[2]={
3404854881:(i:IFC4.IfcMaterialProfileSetUsageTapering):unknown[]=>[i.ForProfileSet, i.CardinalPoint, i.ReferenceExtent, i.ForProfileEndSet, i.CardinalEndPoint],
3265635763:(i:IFC4.IfcMaterialProperties):unknown[]=>[i.Name, i.Description, i.Properties, i.Material],
853536259:(i:IFC4.IfcMaterialRelationship):unknown[]=>[i.Name, i.Description, i.RelatingMaterial, i.RelatedMaterials, i.Expression],
2998442950:(i:IFC4.IfcMirroredProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.ParentProfile, i.Operator, i.Label],
2998442950:(i:IFC4.IfcMirroredProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.ParentProfile, undefined, i.Label],
219451334:(i:IFC4.IfcObjectDefinition):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
2665983363:(i:IFC4.IfcOpenShell):unknown[]=>[i.CfsFaces],
1411181986:(i:IFC4.IfcOrganizationRelationship):unknown[]=>[i.Name, i.Description, i.RelatingOrganization, i.RelatedOrganizations],
1029017970:(i:IFC4.IfcOrientedEdge):unknown[]=>[i.EdgeStart, i.EdgeEnd, i.EdgeElement, {type:3,value:BooleanConvert(i.Orientation.value)}],
1029017970:(i:IFC4.IfcOrientedEdge):unknown[]=>[undefined, undefined, i.EdgeElement, {type:3,value:BooleanConvert(i.Orientation.value)}],
2529465313:(i:IFC4.IfcParameterizedProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.Position],
2519244187:(i:IFC4.IfcPath):unknown[]=>[i.EdgeList],
3021840470:(i:IFC4.IfcPhysicalComplexQuantity):unknown[]=>[i.Name, i.Description, i.HasQuantities, i.Discrimination, i.Quality, i.Usage],
Expand Down Expand Up @@ -22102,7 +22102,7 @@ ToRawLineData[3]={
1660063152:(i:IFC4X3.IfcRepresentationMap):unknown[]=>[i.MappingOrigin, i.MappedRepresentation],
2439245199:(i:IFC4X3.IfcResourceLevelRelationship):unknown[]=>[i.Name, i.Description],
2341007311:(i:IFC4X3.IfcRoot):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
448429030:(i:IFC4X3.IfcSIUnit):unknown[]=>[i.Dimensions, i.UnitType, i.Prefix, i.Name],
448429030:(i:IFC4X3.IfcSIUnit):unknown[]=>[undefined, i.UnitType, i.Prefix, i.Name],
1054537805:(i:IFC4X3.IfcSchedulingTime):unknown[]=>[i.Name, i.DataOrigin, i.UserDefinedDataOrigin],
867548509:(i:IFC4X3.IfcShapeAspect):unknown[]=>[i.ShapeRepresentations, i.Name, i.Description, {type:3,value:BooleanConvert(i.ProductDefinitional.value)}, i.PartOfProductDefinitionShape],
3982875396:(i:IFC4X3.IfcShapeModel):unknown[]=>[i.ContextOfItems, i.RepresentationIdentifier, i.RepresentationType, i.Items],
Expand Down Expand Up @@ -22190,7 +22190,7 @@ ToRawLineData[3]={
738692330:(i:IFC4X3.IfcFillAreaStyle):unknown[]=>[i.Name, i.FillStyles, i.ModelOrDraughting == null ? null : {type:3,value:BooleanConvert(i.ModelOrDraughting.value)}],
3448662350:(i:IFC4X3.IfcGeometricRepresentationContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth],
2453401579:(_:any):unknown[]=>[],
4142052618:(i:IFC4X3.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, i.CoordinateSpaceDimension, i.Precision, i.WorldCoordinateSystem, i.TrueNorth, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
4142052618:(i:IFC4X3.IfcGeometricRepresentationSubContext):unknown[]=>[i.ContextIdentifier, i.ContextType, undefined, undefined, undefined, undefined, i.ParentContext, i.TargetScale, i.TargetView, i.UserDefinedTargetView],
3590301190:(i:IFC4X3.IfcGeometricSet):unknown[]=>[i.Elements],
178086475:(i:IFC4X3.IfcGridPlacement):unknown[]=>[i.PlacementRelTo, i.PlacementLocation, i.PlacementRefDirection],
812098782:(i:IFC4X3.IfcHalfSpaceSolid):unknown[]=>[i.BaseSurface, {type:3,value:BooleanConvert(i.AgreementFlag.value)}],
Expand Down Expand Up @@ -22219,12 +22219,12 @@ ToRawLineData[3]={
3404854881:(i:IFC4X3.IfcMaterialProfileSetUsageTapering):unknown[]=>[i.ForProfileSet, i.CardinalPoint, i.ReferenceExtent, i.ForProfileEndSet, i.CardinalEndPoint],
3265635763:(i:IFC4X3.IfcMaterialProperties):unknown[]=>[i.Name, i.Description, i.Properties, i.Material],
853536259:(i:IFC4X3.IfcMaterialRelationship):unknown[]=>[i.Name, i.Description, i.RelatingMaterial, i.RelatedMaterials, i.MaterialExpression],
2998442950:(i:IFC4X3.IfcMirroredProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.ParentProfile, i.Operator, i.Label],
2998442950:(i:IFC4X3.IfcMirroredProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.ParentProfile, undefined, i.Label],
219451334:(i:IFC4X3.IfcObjectDefinition):unknown[]=>[i.GlobalId, i.OwnerHistory, i.Name, i.Description],
182550632:(i:IFC4X3.IfcOpenCrossProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, {type:3,value:BooleanConvert(i.HorizontalWidths.value)}, i.Widths, i.Slopes, i.Tags, i.OffsetPoint],
2665983363:(i:IFC4X3.IfcOpenShell):unknown[]=>[i.CfsFaces],
1411181986:(i:IFC4X3.IfcOrganizationRelationship):unknown[]=>[i.Name, i.Description, i.RelatingOrganization, i.RelatedOrganizations],
1029017970:(i:IFC4X3.IfcOrientedEdge):unknown[]=>[i.EdgeStart, i.EdgeEnd, i.EdgeElement, {type:3,value:BooleanConvert(i.Orientation.value)}],
1029017970:(i:IFC4X3.IfcOrientedEdge):unknown[]=>[undefined, undefined, i.EdgeElement, {type:3,value:BooleanConvert(i.Orientation.value)}],
2529465313:(i:IFC4X3.IfcParameterizedProfileDef):unknown[]=>[i.ProfileType, i.ProfileName, i.Position],
2519244187:(i:IFC4X3.IfcPath):unknown[]=>[i.EdgeList],
3021840470:(i:IFC4X3.IfcPhysicalComplexQuantity):unknown[]=>[i.Name, i.Description, i.HasQuantities, i.Discrimination, i.Quality, i.Usage],
Expand Down
20 changes: 12 additions & 8 deletions src/ts/web-ifc-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ declare var __WASM_PATH__:string;

let WebIFCWasm: any;

if (typeof self !== 'undefined' && self.crossOriginIsolated) {
try {
WebIFCWasm = require("./web-ifc-mt");
} catch (ex){
WebIFCWasm = require(__WASM_PATH__);
}
} else WebIFCWasm = require(__WASM_PATH__);


export * from "./ifc-schema";
import { Properties } from "./helpers/properties";
Expand Down Expand Up @@ -180,7 +174,17 @@ export class IfcAPI {
* @param customLocateFileHandler An optional locateFile function that let's
* you override the path from which the wasm module is loaded.
*/
async Init(customLocateFileHandler?: LocateFileHandlerFn) {
async Init(customLocateFileHandler?: LocateFileHandlerFn, forceSingleThread: boolean = false) {
if (!WebIFCWasm) {
if (typeof self !== 'undefined' && self.crossOriginIsolated && !forceSingleThread) {
try {
WebIFCWasm = require("./web-ifc-mt");
} catch (ex){
WebIFCWasm = require(__WASM_PATH__);
}
} else WebIFCWasm = require(__WASM_PATH__);
}

if (WebIFCWasm && this.wasmModule == undefined) {
let locateFileHandler: LocateFileHandlerFn = (path, prefix) => {
// when the wasm module requests the wasm file, we redirect to include the user specified path
Expand Down
46 changes: 46 additions & 0 deletions test.ifc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ISO-10303-21;
HEADER;
/******************************************************
* STEP Physical File produced by: That Open Engine WebIfc 0.0.62
* Module: web-ifc/IfcLoader
* Version: 0.0.62
* Source: https://github.com/ThatOpen/engine_web-ifc
* Issues: https://github.com/ThatOpen/engine_web-ifc/issues
******************************************************/
FILE_DESCRIPTION(('1','2'),'2;1');
FILE_NAME('test.ifc','2024-11-12T08:27:57',('3','4'),('5','6'),'thatopen/web-ifc-api','thatopen/web-ifc-api','78');
FILE_SCHEMA(('IFC2X3'));
ENDSEC;
DATA;
#1=IFCCARTESIANPOINT((1.,2.,3.));
#2=IFCCARTESIANPOINT((4.,5.,6.));
#3=IFCCARTESIANPOINT((7.,8.,9.));
#4=IFCPOLYLOOP((#1,#2,#3));
#5=IFCFACEOUTERBOUND(#4,.T.);
#6=IFCFACE((#5));
ENDSEC;
END-ISO-10303-21;
---------------------
ISO-10303-21;
HEADER;
/******************************************************
* STEP Physical File produced by: That Open Engine WebIfc 0.0.62
* Module: web-ifc/IfcLoader
* Version: 0.0.62
* Source: https://github.com/ThatOpen/engine_web-ifc
* Issues: https://github.com/ThatOpen/engine_web-ifc/issues
******************************************************/
FILE_DESCRIPTION(('1','2'),'2;1');
FILE_NAME('test.ifc','2024-11-12T08:27:57',('3','4'),('5','6'),'thatopen/web-ifc-api','thatopen/web-ifc-api','78');
FILE_SCHEMA(('IFC2X3'));
ENDSEC;
DATA;
#7=IFCCARTESIANPOINT((1.,2.,3.));
#8=IFCCARTESIANPOINT((4.,5.,6.));
#9=IFCCARTESIANPOINT((7.,8.,9.));
#10=IFCPOLYLOOP((#7,#8,#9));
#11=IFCFACEOUTERBOUND(#10,.T.);
#12=IFCFACE((#11));
ENDSEC;
END-ISO-10303-21;
---------------------

0 comments on commit c324c85

Please sign in to comment.