ArcEngine开发判断3D模型之间的关系
1、可以通过IRelationalOperator3D接口的Disjoint3D方法查看两个模型是否有相交的地方,C#示例代码如下
publicstatic void TestIntersection()
{
IGeometry polylineGeometry= GetPolylineGeometry();
IGeometry polygonGeometry =GetPolygonGeometry();
IRelationalOperator3DrelationalOperator3D = polylineGeometryasIRelationalOperator3D;
bool intersect =!(relationalOperator3D.Disjoint3D(polygonGeometry));
//intersect = true
}
新的IRelationalOperator3D2接口增加了IsNear3D方法,可以判断模型一定距离之内是否有其他的模型;
2、判断两个模型之间的距离可以通过IProximityOperator3D接口实现,C#示例代码返回最近的点
publicstatic void ReturnNearestPoint3D()
{
IGeometry pointGeometry= GetPointGeometry();
IGeometry envelopeGeometry =GetEnvelopeGeometry();
IProximityOperator3D proximityOperator3D = envelopeGeometry asIProximityOperator3D;
IPoint nearestPoint3D=proximityOperator3D.ReturnNearestPoint3D(pointGeometry as IPoint,esriSegmentExtension.esriNoExtension);
//nearestPoint3D = (5.393, -0.583, -6.043)
}
publicstatic void QueryNearestPoint3D()
{
IGeometrypointGeometry = GetPointGeometry();
IGeometry envelopeGeometry = GetEnvelopeGeometry();
IProximityOperator3DÂ proximityOperator3D = envelopeGeometry asIProximityOperator3D;
IPoint nearestPoint3D = new PointClass();
proximityOperator3D.QueryNearestPoint3D(pointGeometry as IPoint,esriSegmentExtension.esriNoExtension, nearestPoint3D);
//nearestPoint3D =Â (5.393, -0.583, -6.043)
}
C#示例返回最近距离
publicstatic void ReturnDistance3D()
{
IGeometry pointGeometry= GetPointGeometry();
IGeometry envelopeGeometry =GetEnvelopeGeometry();
IProximityOperator3D proximityOperator3D = envelopeGeometry asIProximityOperator3D;
double distance3D = proximityOperator3D.ReturnDistance3D(pointGeometry);
//distance3D = 13.971
}
3、获取3D模型直接相交或者合并的部分可以通过IEnvelope3D实现;该接口实现的只是相交或合并的最大和最小范围;
C#中相交代码如下
publicstaticvoidTestIntersect3D()
{
IGeometryenvelopeGeometry1 = GetEnvelopeGeometry1();
IGeometryenvelopeGeometry2 = GetEnvelopeGeometry2();
IEnvelope3Denvelope3D = envelopeGeometry1 asIEnvelope3D;
envelope3D.Intersect3D(envelopeGeometry2asIEnvelope);
}
C#中合并代码如下
publicstaticvoidTestUnion3D()
{
IGeometryenvelopeGeometry1 = GetEnvelopeGeometry1();
IGeometryenvelopeGeometry2 = GetEnvelopeGeometry2();
IEnvelope3Denvelope3D = envelopeGeometry1 asIEnvelope3D;
envelope3D.Union3D(envelopeGeometry2asIEnvelope);
}