不规则形状的Ifc构件顶点坐标获取

Posted herd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不规则形状的Ifc构件顶点坐标获取相关的知识,希望对你有一定的参考价值。

不规则形状的Ifc构件顶点坐标获取

今天有人问我,ifc构件的顶点坐标怎么获取,自己前年的时候写过类似的程序,但有点记不清了,最近一直用C++解析ifc,慎重起见,还是重新再写一次,java版本的获取方式如下,有空了再尝试一下C#版本的怎么写。

public static void getVertex(IfcProduct ifcProductParam) {
        IfcProductRepresentation productRepresentation =ifcProductParam.getRepresentation();
        LIST<IfcRepresentation> listRepresentation =productRepresentation.getRepresentations();
        for(int k=0;k<listRepresentation.size();k++)
        {
            IfcShapeRepresentation shapeRepresentation=(IfcShapeRepresentation) listRepresentation.get(k);
            SET<IfcRepresentationItem> ifcRepresentationItemSet = shapeRepresentation.getItems();
            
            for(IfcRepresentationItem ifcRepresentationItemObj:ifcRepresentationItemSet) {
                String className1 = ifcRepresentationItemObj.getClass().getName();
                //System.out.println(className1+"  "+ifcRepresentationItemSet.size());
                if(className1.contains("IfcPolyline")) {
                    IfcPolyline ifcPolylineObj = (IfcPolyline) ifcRepresentationItemObj;
                    LIST<IfcCartesianPoint> ifcCartesianPointList = ifcPolylineObj.getPoints();
                    for(IfcCartesianPoint ifcCartesianPointObj:ifcCartesianPointList) {
                        LIST<IfcLengthMeasure> ifcLengthMeasureList=ifcCartesianPointObj.getCoordinates();
                        for(IfcLengthMeasure ifcLengthMeasureObj:ifcLengthMeasureList) {
                            System.out.print(ifcLengthMeasureObj+" ");
                        }
                        System.out.println("");
                    }
                }else if(className1.contains("IfcExtrudedAreaSolid")) {
                    IfcExtrudedAreaSolid ifcExtrudedAreaSolidObj = (IfcExtrudedAreaSolid) ifcRepresentationItemObj;
                    IfcProfileDef ifcProfileDef=ifcExtrudedAreaSolidObj.getSweptArea();
                    //IfcArbitraryClosedProfileDef IfcArbitraryClosedProfileDef=(IfcArbitraryClosedProfileDef) ifcExtrudedAreaSolidObj.getSweptArea();
                    String profileDefClassName = ifcProfileDef.getClass().getName();
                    //System.out.println("=="+profileDefClassName);
                    
                    //常规轮廓
                    if(profileDefClassName.contains("IfcRectangleProfileDef")) {
                        IfcRectangleProfileDef ifcRectangleProfileDef = (IfcRectangleProfileDef) ifcProfileDef;
                        
                        //中心点
                        IfcAxis2Placement2D ifcAxis2Placement2D = ifcRectangleProfileDef.getPosition();
                        IfcCartesianPoint ifcCartesianPoint = ifcAxis2Placement2D.getLocation();
                        LIST<IfcLengthMeasure> ifcLengthMeasureList= ifcCartesianPoint.getCoordinates();
                        
                        System.out.println("Coordinates:");
                        for(IfcLengthMeasure ifcLengthMeasureObj:ifcLengthMeasureList) {
                            System.out.print(ifcLengthMeasureObj+"	");
                        }
                        System.out.println("");
                        
                        //
                        IfcPositiveLengthMeasure ifcPositiveLengthMeasureX =ifcRectangleProfileDef.getXDim();
                        System.out.println("XDim:"+ifcPositiveLengthMeasureX);
                        
                        //
                        IfcPositiveLengthMeasure ifcPositiveLengthMeasureY =ifcRectangleProfileDef.getYDim();
                        System.out.println("YDim:"+ifcPositiveLengthMeasureY);
                        
                    }
                    //不规则轮廓
                    else if(profileDefClassName.contains("IfcArbitraryClosedProfileDef")) {
                        IfcArbitraryClosedProfileDef ifcArbitraryClosedProfileDef = (IfcArbitraryClosedProfileDef) ifcProfileDef;
                        IfcCurve ifcCurve = ifcArbitraryClosedProfileDef.getOuterCurve();
                        String ifcCurveClassName = ifcCurve.getClass().getName();
                        //System.out.println("==="+ifcCurveClassName);
                        if(ifcCurveClassName.contains("IfcPolyline")) {
                            IfcPolyline ifcPolyline = (IfcPolyline) ifcCurve;
                            LIST<IfcCartesianPoint>  ifcCartesianPointList=ifcPolyline.getPoints();
                            for(IfcCartesianPoint ifcCartesianPointObj:ifcCartesianPointList) {
                                LIST<IfcLengthMeasure> ifcLengthMeasureList=ifcCartesianPointObj.getCoordinates();
                                //两个坐标值分开存储的,需要遍历才能获得
                                for(IfcLengthMeasure ifcLengthMeasureObj:ifcLengthMeasureList) {
                                    System.out.print(ifcLengthMeasureObj+"	");
                                }
                                System.out.println("");
                            }
                        }
                    }
                }
            }
        }
        
        
    }
    

--------------IfcWallStandardCase
0.0 0.0
12240.0 0.0
Coordinates:
6120.0 3.90798504668055E-13
XDim:12240.0
YDim:239.999999999997
--------------IfcWallStandardCase
0.0 0.0
4400.0 -0.0
Coordinates:
2200.0 -7.105427357601E-15
XDim:4400.0
YDim:240.0
--------------IfcWallStandardCase
0.0 0.0
12637.650181761 -0.0
12637.650181761 -120.0
11122.349818239 120.0
0.0 120.0
0.0 -120.0
12637.650181761 -120.0
--------------IfcWallStandardCase
0.0 0.0
7222.81601221758 -0.0
7222.81601221758 -120.0
7144.83528512168 120.0
1515.30036352204 120.0
0.0 -120.0
6970.46507840039 -120.0
7222.81601221758 -120.0
--------------IfcWallStandardCase
0.0 0.0
1532.81489663935 0.0
1532.81489663935 -120.0
1532.81489663935 120.0
77.9807270958989 120.0
0.0 -120.0
1292.81489663935 -120.0
1532.81489663935 -120.0
--------------IfcWallStandardCase
0.0 0.0
1991.65605265947 0.0
Coordinates:
995.828026329733 0.0
XDim:1991.65605265947
YDim:239.999999999997
--------------IfcWallStandardCase
0.0 0.0
1000.0 0.0
Coordinates:
500.000000000001 -6.3948846218409E-14
XDim:1000.0
YDim:240.0
--------------IfcWallStandardCase
0.0 0.0
4000.0 0.0
Coordinates:
2000.0 0.0
XDim:4000.0
YDim:239.999999999997
--------------IfcWallStandardCase
0.0 0.0
1713.19293543784 -0.0
Coordinates:
856.596467718918 -1.98951966012828E-13
XDim:1713.19293543784
YDim:240.0

 

以上是关于不规则形状的Ifc构件顶点坐标获取的主要内容,如果未能解决你的问题,请参考以下文章

传递给片段着色器的纹理坐标全部为 0

如何获取 IFC 对象的绝对坐标?

拖动 QML 形状的坐标

根据顶点世界位置Y坐标修改Metal片段着色

通过顶点属性指针将颜色坐标传递到顶点着色器

IfcAxis2Placement3D IFC构件的位置和方向