码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-11-26 19:49:42      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:profile   etc   closed   name   ring   java   不规则   sed   int   

不规则形状的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+"\t");
                        }
                        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+"\t");
                                }
                                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构件顶点坐标获取

标签:profile   etc   closed   name   ring   java   不规则   sed   int   

原文地址:https://www.cnblogs.com/herd/p/11937659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!