该类是Revit中表示平面拓扑结构的数据类型之一。该类存储平面几何形体在平面拓扑结构中的关系和拓扑结构信息。拓扑结构指平面几何形体(例如直线、多边形等)之间的关系,这些关系指的是相邻、相交、共线、共面等。
PlanTopology planTopology = new PlanTopology();
Curve curve1 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(10, 0, 0));
Curve curve2 = Line.CreateBound(new XYZ(10, 0, 0), new XYZ(10, 10, 0));
Curve curve3 = Line.CreateBound(new XYZ(10, 10, 0), new XYZ(0, 10, 0));
Curve curve4 = Line.CreateBound(new XYZ(0, 10, 0), new XYZ(0, 0, 0));
List<Curve> curves = new List<Curve> { curve1, curve2, curve3, curve4 };
PlanarCurveStorage storage = new PlanarCurveStorage(curves);
planTopology.SetFromCurves(storage, new View());
//闭合环
planTopology.CloseLoop();
//切割
List<Curve> cutterCurves = new List<Curve> { Line.CreateBound(new XYZ(5, 0, 0), new XYZ(5, 10, 0)) };
PlanarCurveStorage cutterStorage = new PlanarCurveStorage(cutterCurves);
PlanTopology[] cutResults = planTopology.Cut(cutterStorage);
//连接
PlanTopology topology2 = new PlanTopology();
Curve curve5 = Line.CreateBound(new XYZ(0, 5, 0), new XYZ(5, 5, 0));
Curve curve6 = Line.CreateBound(new XYZ(5, 5, 0), new XYZ(10, 5, 0));
List<Curve> curves2 = new List<Curve> { curve5, curve6 };
PlanarCurveStorage storage2 = new PlanarCurveStorage(curves2);
topology2.SetFromCurves(storage2, new View());
PlanTopology[] joinResult = PlanTopology.Join(planTopology, topology2);
//判断点是否在拓扑结构内
XYZ point = new XYZ(5, 5, 0);
bool isPointInTopology = planTopology.PointInTopology(point);