Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated references using RichIfcModel #907

Closed
gbonnardelOL opened this issue Jan 22, 2019 · 1 comment
Closed

Duplicated references using RichIfcModel #907

gbonnardelOL opened this issue Jan 22, 2019 · 1 comment
Labels

Comments

@gbonnardelOL
Copy link

gbonnardelOL commented Jan 22, 2019

Hi,

I'm using RichIfcModel class in order to generate some objects (IfcBuilding, IfcSpace, ..) like you did in the org.bimserver.tests.emf.TestBigModelEmf class.

Ifc objects are created as expected but when I look on my new project from the bimviewer webpage, it seems that all my objects are duplicated.
image

Here is the code I'm using:

public Test() {

	try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8082")) {

		// create a client
		BimServerClientInterface bimServerClient = factory
				.create(new UsernamePasswordAuthenticationInfo("email", "mail"));

		// create a new project
		SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");

		// create a model
		IfcModelInterface model = bimServerClient.newModel(newProject, true);

		// from Model object, create a Rich client
		RichIfcModel richIfcModel = new RichIfcModel(model);

		IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure();

		// Create IfcBuildingStorey & Ifcspace
		IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
		buildingAggregation.setRelatingObject(ifcBuilding);
		for (int i = 1; i <= 10; i++) {
			IfcBuildingStorey ifcBuildingStorey = richIfcModel.create(IfcBuildingStorey.class);
			ifcBuildingStorey.setName("Storey " + i);
			ifcBuildingStorey.setCompositionType(IfcElementCompositionEnum.ELEMENT);
			ifcBuildingStorey.setElevation(3000 * i);

			IfcLocalPlacement storeyPlacement = richIfcModel.create(IfcLocalPlacement.class);
			storeyPlacement.setRelativePlacement(richIfcModel.createBasicPosition(0, 0, i * 3000));
			ifcBuildingStorey.setObjectPlacement(storeyPlacement);

			buildingAggregation.getRelatedObjects().add(ifcBuildingStorey);

			IfcRelAggregates storeyAggregation = richIfcModel.create(IfcRelAggregates.class);
			storeyAggregation.setRelatingObject(ifcBuildingStorey);

			for (int x = 1; x <= 1; x++) {
				for (int y = 1; y <= 1; y++) {
					createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement,
							storeyAggregation, x, y, true);
				}
			}
		}

		// commit
		long roid = model.commit("Initial model");

	} catch (Throwable e) {
		e.printStackTrace();
		if (e instanceof AssertionError) {
			throw (AssertionError) e;
		}
		fail(e.getMessage());
	}

}

private void createSpace(RichIfcModel richIfcModel, IfcRepresentationContext representationContext,
		IfcLocalPlacement storeyPlacement, IfcRelAggregates storeyAggregation, int x, int y, boolean doreuse)
		throws IfcModelInterfaceException {
	IfcSpace ifcSpace = richIfcModel.create(IfcSpace.class);
	ifcSpace.setName("Space " + ((y * 10) + x));
	ifcSpace.setCompositionType(IfcElementCompositionEnum.ELEMENT);
	ifcSpace.setInteriorOrExteriorSpace(IfcInternalOrExternalEnum.INTERNAL);

	IfcLocalPlacement spacePlacement = richIfcModel.create(IfcLocalPlacement.class);
	spacePlacement.setPlacementRelTo(storeyPlacement);
	spacePlacement.setRelativePlacement(richIfcModel.createBasicPosition(x * 6000, y * 6000, 0));
	ifcSpace.setObjectPlacement(spacePlacement);

	storeyAggregation.getRelatedObjects().add(ifcSpace);

	IfcProductRepresentation rep = null;
	rep = richIfcModel.createRectangularExtrusionProductRepresentation(5000, 5000, 2000);
	ifcSpace.setRepresentation(rep);

	createFurnishing(richIfcModel, representationContext, y, ifcSpace, spacePlacement, doreuse);
}

private void createFurnishing(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, int number,
		IfcSpace ifcSpace, IfcLocalPlacement spacePlacement, boolean doreuse) throws IfcModelInterfaceException {
	IfcFurnishingElement furnishing = richIfcModel.create(IfcFurnishingElement.class);
	furnishing.setName("Furnishing " + number);

	IfcLocalPlacement furnishingPlacement = richIfcModel.create(IfcLocalPlacement.class);
	furnishingPlacement.setPlacementRelTo(spacePlacement);
	IfcAxis2Placement3D furnitureAxisPlacement = richIfcModel.create(IfcAxis2Placement3D.class);
	furnitureAxisPlacement.setLocation(richIfcModel.createIfcCartesianPoint(500, 500, 2));
	furnishingPlacement.setRelativePlacement(furnitureAxisPlacement);

	furnishing.setObjectPlacement(furnishingPlacement);
	IfcProductRepresentation rep = null;
	rep = richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200);
	furnishing.setRepresentation(rep);

	richIfcModel.addContains(ifcSpace, furnishing);
}

public static void main(String[] args) {
	new Test();
}

}

I'm not totally sure but this issue might be related with issue #688.

Do you have any idea how I could avoid this duplicate ?

Thank you

Gregory

@hlg hlg added the bug label Mar 29, 2021
@hlg
Copy link
Member

hlg commented Oct 23, 2024

Pretty sure this is a duplicate of #1224 and #1115 and thus solved in the meantime.

@hlg hlg closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants