Rhinocommon Transform Method
This commit is contained in:
Родитель
1f16953eed
Коммит
5b1b0af536
|
@ -286,8 +286,6 @@ namespace GeometryGym.Ifc
|
|||
private IfcObjectPlacement mPlacementRelTo = null;// : OPTIONAL IfcObjectPlacement;
|
||||
private IfcAxis2Placement mRelativePlacement = null;// : IfcAxis2Placement;
|
||||
|
||||
private bool mCalculated = false;
|
||||
|
||||
public IfcObjectPlacement PlacementRelTo
|
||||
{
|
||||
get { return mPlacementRelTo; }
|
||||
|
@ -303,7 +301,7 @@ namespace GeometryGym.Ifc
|
|||
public IfcAxis2Placement RelativePlacement
|
||||
{
|
||||
get { return mRelativePlacement; }
|
||||
set { mRelativePlacement = value; mCalculated = false; }
|
||||
set { mRelativePlacement = value; }
|
||||
}
|
||||
|
||||
internal IfcLocalPlacement() : base() { }
|
||||
|
|
|
@ -49,6 +49,6 @@ namespace GeometryGym.Ifc
|
|||
}
|
||||
public partial class IfcGridPlacement : IfcObjectPlacement
|
||||
{
|
||||
public override Transform Transform { get { return Transform.ChangeBasis(PlacementLocation.LocationPlane, Plane.WorldXY); } }
|
||||
public override Transform Transform() { return Rhino.Geometry.Transform.ChangeBasis(PlacementLocation.LocationPlane, Plane.WorldXY); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,33 +38,32 @@ namespace GeometryGym.Ifc
|
|||
}
|
||||
public partial class IfcLocalPlacement : IfcObjectPlacement
|
||||
{
|
||||
private Transform mtransform = Transform.Unset;
|
||||
public override Transform Transform
|
||||
public override Transform Transform()
|
||||
{
|
||||
get
|
||||
IfcObjectPlacement placementRelTo = PlacementRelTo;
|
||||
IfcAxis2Placement relativePlacement = RelativePlacement;
|
||||
bool identityRelative = relativePlacement == null;
|
||||
if(relativePlacement != null)
|
||||
{
|
||||
if (!mCalculated)
|
||||
if (mDatabase != null && relativePlacement.Plane.IsValid)
|
||||
{
|
||||
mCalculated = true;
|
||||
IfcObjectPlacement placementRelTo = PlacementRelTo;
|
||||
IfcAxis2Placement relativePlacement = RelativePlacement;
|
||||
if (placementRelTo == null || placementRelTo.isXYPlane)
|
||||
{
|
||||
if (relativePlacement == null || relativePlacement.IsXYPlane)
|
||||
mtransform = Transform.Identity;
|
||||
else
|
||||
mtransform = Transform.ChangeBasis(relativePlacement.Plane,Plane.WorldXY);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (relativePlacement == null || relativePlacement.IsXYPlane)
|
||||
mtransform = placementRelTo.Transform;
|
||||
else
|
||||
mtransform = placementRelTo.Transform * Transform.ChangeBasis(relativePlacement.Plane, Plane.WorldXY);
|
||||
}
|
||||
Plane plane = relativePlacement.Plane;
|
||||
if (plane.Origin.DistanceTo(Point3d.Origin) < mDatabase.Tolerance && plane.XAxis.IsParallelTo(Vector3d.XAxis) == 1 && plane.YAxis.IsParallelTo(Vector3d.YAxis) == 1)
|
||||
identityRelative = true;
|
||||
}
|
||||
return mtransform;
|
||||
else
|
||||
identityRelative = relativePlacement.IsXYPlane;
|
||||
}
|
||||
if (placementRelTo == null || placementRelTo.isXYPlane)
|
||||
{
|
||||
if (identityRelative)
|
||||
return Rhino.Geometry.Transform.Identity;
|
||||
else
|
||||
return Rhino.Geometry.Transform.ChangeBasis(relativePlacement.Plane,Plane.WorldXY);
|
||||
}
|
||||
if (identityRelative)
|
||||
return placementRelTo.Transform();
|
||||
return placementRelTo.Transform() * Rhino.Geometry.Transform.ChangeBasis(relativePlacement.Plane, Plane.WorldXY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ namespace GeometryGym.Ifc
|
|||
get
|
||||
{
|
||||
Point3d o = new Point3d(), x = new Point3d(1, 0, 0), y = new Point3d(0, 1, 0);
|
||||
Transform tr = Transform;
|
||||
Transform tr = Transform();
|
||||
o.Transform(tr);
|
||||
x.Transform(tr);
|
||||
y.Transform(tr);
|
||||
return new Plane(o, x, y);
|
||||
}
|
||||
}
|
||||
public abstract Transform Transform { get; }
|
||||
public abstract Transform Transform();
|
||||
}
|
||||
|
||||
public partial class IfcOffsetCurve2D : IfcOffsetCurve
|
||||
|
|
|
@ -85,7 +85,9 @@ namespace GeometryGym.Ifc
|
|||
get
|
||||
{
|
||||
IfcObjectPlacement p = ObjectPlacement;
|
||||
return (p == null ? Transform.Identity : p.Transform);
|
||||
if (p == null)
|
||||
return Transform.Identity;
|
||||
return p.Transform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче