use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class ModelHelper method copyDecomposes.
@SuppressWarnings("unchecked")
public void copyDecomposes(IdEObject ifcObjectDefinition, IdEObject ownerHistory) throws IfcModelInterfaceException, ObjectAlreadyExistsException {
IdEObject newObjectDefinition = copy(ifcObjectDefinition, false, skipRepresentation);
EStructuralFeature decomposesFeature = newObjectDefinition.eClass().getEStructuralFeature("Decomposes");
for (IdEObject ifcRelDecomposes : (List<IdEObject>) ifcObjectDefinition.eGet(decomposesFeature)) {
copy(ifcRelDecomposes, false, skipRepresentation);
EStructuralFeature relatingObjectFeature = ifcRelDecomposes.eClass().getEStructuralFeature("RelatingObject");
IdEObject relatingObject = (IdEObject) ifcRelDecomposes.eGet(relatingObjectFeature);
if (relatingObject != null) {
copyDecomposes(relatingObject, ownerHistory);
}
}
if (ifcObjectDefinition.eClass().getEPackage().getEClassifier("IfcElement").isInstance(ifcObjectDefinition)) {
EStructuralFeature containedInStructureFeature = ifcObjectDefinition.eClass().getEStructuralFeature("ContainedInStructure");
for (IdEObject containedInStructure : (List<IdEObject>) ifcObjectDefinition.eGet(containedInStructureFeature)) {
IdEObject newContainedInSpatialStructure = getTargetModel().create(containedInStructure.eClass());
newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("GlobalId"), GuidCompressor.getNewIfcGloballyUniqueId());
newContainedInSpatialStructure.eSet(newContainedInSpatialStructure.eClass().getEStructuralFeature("OwnerHistory"), ownerHistory);
EStructuralFeature relatedElementsFeature = newContainedInSpatialStructure.eClass().getEStructuralFeature("RelatedElements");
((List<IdEObject>) newContainedInSpatialStructure.eGet(relatedElementsFeature)).add(newObjectDefinition);
EStructuralFeature relatingStructureFeature = containedInStructure.eClass().getEStructuralFeature("RelatingStructure");
IdEObject newRelatingStructre = copy(((IdEObject) containedInStructure.eGet(relatingStructureFeature)), false, skipRepresentation);
newContainedInSpatialStructure.eSet(relatingStructureFeature, newRelatingStructre);
getTargetModel().add(oidProvider.newOid(newContainedInSpatialStructure.eClass()), newContainedInSpatialStructure);
copyDecomposes((IdEObject) containedInStructure.eGet(relatingStructureFeature), ownerHistory);
}
}
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class ModelHelper method copyBasicObjects.
public IdEObject copyBasicObjects(IfcModelInterface model, Map<IdEObject, IdEObject> bigMap) throws IfcModelInterfaceException {
PackageMetaData packageMetaData = model.getPackageMetaData();
IdEObject newProject = null;
for (IdEObject idEObject : model.getAllWithSubTypes(packageMetaData.getEClass("IfcProject"))) {
newProject = copy(idEObject, false, skipRepresentation);
bigMap.put(newProject, idEObject);
}
IdEObject newOwnerHistory = null;
for (IdEObject idEObject : model.getAllWithSubTypes(packageMetaData.getEClass("IfcOwnerHistory"))) {
newOwnerHistory = copy(idEObject, false, skipRepresentation);
bigMap.put(newOwnerHistory, idEObject);
}
for (IdEObject idEObject : model.getAllWithSubTypes(packageMetaData.getEClass("IfcUnit"))) {
bigMap.put(copy(idEObject, false, skipRepresentation), idEObject);
}
for (IdEObject idEObject : model.getAllWithSubTypes(packageMetaData.getEClass("IfcUnitAssignment"))) {
bigMap.put(copy(idEObject, false, skipRepresentation), idEObject);
}
return newOwnerHistory;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class ModelHelper method copy.
@SuppressWarnings({ "unchecked", "rawtypes" })
private IdEObject copy(EClass originalEClass, IdEObject original, boolean setOid, ObjectIDM objectIDM) throws IfcModelInterfaceException {
if (!((IdEObjectImpl) original).isLoadedOrLoading()) {
return null;
}
if (converted.containsKey(original)) {
return converted.get(original);
}
IdEObject newObject = (IdEObject) objectFactory.create(original.eClass());
((IdEObjectImpl) newObject).setPid(original.getPid());
((IdEObjectImpl) newObject).setLoadingState(State.LOADED);
long oid = -1;
if (keepOriginalOids) {
oid = original.getOid();
((IdEObjectImpl) newObject).setOid(oid);
} else {
if (newObject.getOid() == -1) {
if (oidProvider != null) {
oid = oidProvider.newOid(newObject.eClass());
} else {
oid = original.getOid();
}
}
}
if (setOid && newObject.getOid() == -1) {
((IdEObjectImpl) newObject).setOid(oid);
}
converted.put(original, newObject);
if (newObject.eClass().getEAnnotation("wrapped") == null) {
targetModel.add(newObject.getOid(), newObject);
}
if (inverseFixes.containsKey(original.getOid())) {
InverseFix inverseFix = inverseFixes.get(original.getOid());
inverseFix.apply(newObject);
}
for (EStructuralFeature eStructuralFeature : original.eClass().getEAllStructuralFeatures()) {
boolean canFollow = objectIDM == null || objectIDM.shouldFollowReference(originalEClass, original.eClass(), eStructuralFeature);
Object get = original.eGet(eStructuralFeature);
if (eStructuralFeature instanceof EAttribute) {
if (get instanceof List) {
List list = (List) get;
List targetList = (List) newObject.eGet(eStructuralFeature);
for (Object o : list) {
targetList.add(o);
}
} else {
newObject.eSet(eStructuralFeature, get);
}
} else if (eStructuralFeature instanceof EReference) {
if (!canFollow) {
continue;
}
if (get == null) {
} else {
if (eStructuralFeature.isMany()) {
EList<EObject> list = (EList<EObject>) get;
AbstractEList<EObject> toList = (AbstractEList<EObject>) newObject.eGet(eStructuralFeature);
for (Object o : list) {
if (converted.containsKey(o)) {
toList.addUnique(converted.get(o));
} else {
if (canFollow) {
IdEObject result = copy(originalEClass, (IdEObject) o, setOid, objectIDM);
if (result != null) {
toList.addUnique(result);
}
} else {
// Findbugs says canFollow is always true at this point and it's right, TODO
if (eStructuralFeature.getName().equals("RelatedElements")) {
inverseFixes.put(((IdEObject) o).getOid(), new InverseFix(Ifc2x3tc1Package.eINSTANCE.getIfcRelContainedInSpatialStructure_RelatedElements(), newObject));
}
}
}
}
} else {
if (converted.containsKey(get)) {
newObject.eSet(eStructuralFeature, converted.get(get));
} else {
if (canFollow) {
newObject.eSet(eStructuralFeature, copy(originalEClass, (IdEObject) get, setOid, objectIDM));
}
}
}
}
}
}
return newObject;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class ReferenceCounter method removeInternal.
@SuppressWarnings("rawtypes")
public int removeInternal(IdEObject idEObject) {
int totalRemoved = 1;
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
if (eReference.isMany()) {
List list = (List) idEObject.eGet(eReference);
for (Object o : list) {
IdEObject refObject = (IdEObject) o;
references.get(refObject).remove(idEObject);
if (references.get(refObject).size() == 0) {
totalRemoved += removeInternal(refObject);
}
}
} else {
IdEObject refObject = (IdEObject) idEObject.eGet(eReference);
if (references.containsKey(refObject)) {
references.get(refObject).remove(idEObject);
if (references.get(refObject).size() == 0) {
totalRemoved += removeInternal(refObject);
}
}
}
}
return totalRemoved;
}
use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.
the class Scaler method scale.
public void scale(float scale) {
if (scale != 1.0f) {
for (long key : ifcModel.keySet()) {
IdEObject idEObject = (IdEObject) ifcModel.get(key);
if (idEObject instanceof IfcAsymmetricIShapeProfileDef) {
setIfcAsymmetricIShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcBlock) {
setIfcBlock(idEObject, scale);
} else if (idEObject instanceof IfcBoundingBox) {
setIfcBoundingBox(idEObject, scale);
} else if (idEObject instanceof IfcBuilding) {
setIfcBuilding(idEObject, scale);
} else if (idEObject instanceof IfcBuildingStorey) {
setIfcBuildingStorey(idEObject, scale);
} else if (idEObject instanceof IfcCartesianPoint) {
setIfcCartesianPoint(idEObject, scale);
} else if (idEObject instanceof IfcCenterLineProfileDef) {
setIfcCenterLineProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcChamferEdgeFeature) {
setIfcChamferEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcCircle) {
setIfcCircle(idEObject, scale);
} else if (idEObject instanceof IfcCircleHollowProfileDef) {
setIfcCircleHollowProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCircleProfileDef) {
setIfcCircleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCraneRailAShapeProfileDef) {
setIfcCraneRailAShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCraneRailFShapeProfileDef) {
setIfcCraneRailFShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcConnectionPointEccentricity) {
setIfcConnectionPointEccentricity(idEObject, scale);
} else if (idEObject instanceof IfcCShapeProfileDef) {
setIfcCShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCurveStyleFontPattern) {
setIfcCurveStyleFontPattern(idEObject, scale);
} else if (idEObject instanceof IfcDoor) {
setIfcDoor(idEObject, scale);
} else if (idEObject instanceof IfcDoorLiningProperties) {
setIfcDoorLiningProperties(idEObject, scale);
} else if (idEObject instanceof IfcDoorPanelProperties) {
setIfcDoorPanelProperties(idEObject, scale);
} else if (idEObject instanceof IfcEdgeFeature) {
setIfcEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcEllipse) {
setIfcEllipse(idEObject, scale);
} else if (idEObject instanceof IfcEllipseProfileDef) {
setIfcEllipseProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcExtrudedAreaSolid) {
setIfcExtrudedAreaSolid(idEObject, scale);
} else if (idEObject instanceof IfcGeneralProfileProperties) {
setIfcGeneralProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcIShapeProfileDef) {
setIfcIShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcLightSourcePositional) {
setIfcLightSourcePositional(idEObject, scale);
} else if (idEObject instanceof IfcLShapeProfileDef) {
setIfcLShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcMaterialLayer) {
setIfcMaterialLayer(idEObject, scale);
} else if (idEObject instanceof IfcMaterialLayerSetUsage) {
setIfcMaterialLayerSetUsage(idEObject, scale);
} else if (idEObject instanceof IfcMechanicalConcreteMaterialProperties) {
setIfcMechanicalConcreteMaterialProperties(idEObject, scale);
} else if (idEObject instanceof IfcMechanicalFastener) {
setIfcMechanicalFastener(idEObject, scale);
} else if (idEObject instanceof IfcOffsetCurve2D) {
setIfcOffsetCurve2D(idEObject, scale);
} else if (idEObject instanceof IfcOffsetCurve3D) {
setIfcOffsetCurve3D(idEObject, scale);
} else if (idEObject instanceof IfcPermeableCoveringProperties) {
setIfcPermeableCoveringProperties(idEObject, scale);
} else if (idEObject instanceof IfcPlanarExtent) {
setIfcPlanarExtent(idEObject, scale);
} else if (idEObject instanceof IfcQuantityLength) {
setIfcQuantityLength(idEObject, scale);
} else if (idEObject instanceof IfcRectangleHollowProfileDef) {
setIfcRectangleHollowProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcRectangleProfileDef) {
setIfcRectangleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcRectangularPyramid) {
setIfcRectangularPyramid(idEObject, scale);
} else if (idEObject instanceof IfcReinforcementBarProperties) {
setIfcReinforcementBarProperties(idEObject, scale);
} else if (idEObject instanceof IfcReinforcingBar) {
setIfcReinforcingBar(idEObject, scale);
} else if (idEObject instanceof IfcReinforcingMesh) {
setIfcReinforcingMesh(idEObject, scale);
} else if (idEObject instanceof IfcRelConnectsStructuralMember) {
setIfcRelConnectsStructuralMember(idEObject, scale);
} else if (idEObject instanceof IfcRibPlateProfileProperties) {
setIfcRibPlateProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcRightCircularCone) {
setIfcRightCircularCone(idEObject, scale);
} else if (idEObject instanceof IfcRightCircularCylinder) {
setIfcRightCircularCylinder(idEObject, scale);
} else if (idEObject instanceof IfcRoundedEdgeFeature) {
setIfcRoundedEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcRoundedRectangleProfileDef) {
setIfcRoundedRectangleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcSectionReinforcementProperties) {
setIfcSectionReinforcementProperties(idEObject, scale);
} else if (idEObject instanceof IfcSite) {
setIfcSite(idEObject, scale);
} else if (idEObject instanceof IfcSlippageConnectionCondition) {
setIfcSlippageConnectionCondition(idEObject, scale);
} else if (idEObject instanceof IfcSpace) {
setIfcSpace(idEObject, scale);
} else if (idEObject instanceof IfcSphere) {
setIfcSphere(idEObject, scale);
} else if (idEObject instanceof IfcStairFlight) {
setIfcStairFlight(idEObject, scale);
} else if (idEObject instanceof IfcStructuralLoadSingleDisplacement) {
setIfcStructuralLoadSingleDisplacement(idEObject, scale);
} else if (idEObject instanceof IfcStructuralProfileProperties) {
setIfcStructuralProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcStructuralSurfaceMember) {
setIfcStructuralSurfaceMember(idEObject, scale);
} else if (idEObject instanceof IfcStructuralSurfaceMemberVarying) {
setIfcStructuralSurfaceMemberVarying(idEObject, scale);
} else if (idEObject instanceof IfcSurfaceOfLinearExtrusion) {
setIfcSurfaceOfLinearExtrusion(idEObject, scale);
} else if (idEObject instanceof IfcSweptDiskSolid) {
setIfcSweptDiskSolid(idEObject, scale);
} else if (idEObject instanceof IfcTendon) {
setIfcTendon(idEObject, scale);
} else if (idEObject instanceof IfcTextStyleWithBoxCharacteristics) {
setIfcTextStyleWithBoxCharacteristics(idEObject, scale);
} else if (idEObject instanceof IfcTrapeziumProfileDef) {
setIfcTrapeziumProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcTShapeProfileDef) {
setIfcTShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcUShapeProfileDef) {
setIfcUShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcVector) {
setIfcVector(idEObject, scale);
} else if (idEObject instanceof IfcVirtualGridIntersection) {
setIfcVirtualGridIntersection(idEObject, scale);
} else if (idEObject instanceof IfcWindow) {
setIfcWindow(idEObject, scale);
} else if (idEObject instanceof IfcWindowLiningProperties) {
setIfcWindowLiningProperties(idEObject, scale);
} else if (idEObject instanceof IfcWindowPanelProperties) {
setIfcWindowPanelProperties(idEObject, scale);
} else if (idEObject instanceof IfcZShapeProfileDef) {
setIfcZShapeProfileDef(idEObject, scale);
}
setDoubleAsStringValues(idEObject);
}
}
}
Aggregations