本文整理汇总了C#中Transform.OfPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.OfPoint方法的具体用法?C# Transform.OfPoint怎么用?C# Transform.OfPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.OfPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddGeometry
public void AddGeometry(IList<XYZ> inVertices, IList<PolymeshFacet> inIndices, IList<XYZ> inNormals, Transform inTransform)
{
List<Vector3> _lVertices = new List<Vector3>(inVertices.Count);
foreach (XYZ _vert in inVertices)
{
XYZ _newVert = inTransform.OfPoint(_vert);//_ofVert -_ofZero;
_lVertices.Add(new Vector3(_newVert.X, _newVert.Y, _newVert.Z));
}
List<int> _lIndices = new List<int>(inIndices.Count * 3);
foreach (PolymeshFacet _ind in inIndices)
{
_lIndices.Add(_ind.V1);
_lIndices.Add(_ind.V2);
_lIndices.Add(_ind.V3);
}
List<Vector3> _lNormals = new List<Vector3>(inNormals.Count);
foreach (XYZ _norm in inNormals)
{
_lNormals.Add(new Vector3(_norm.X, _norm.Y, _norm.Z));
}
m_pCurrentMesh.AddGeometry(_lVertices, _lIndices, _lNormals);
}
示例2: TransformVertexList
private static IList<XYZ> TransformVertexList(IList<XYZ> vertices, Transform trf)
{
IList<XYZ> transformedVertices = new List<XYZ>();
foreach (XYZ vertex in vertices)
transformedVertices.Add(trf.OfPoint(vertex));
return transformedVertices;
}
示例3: GetComponentDataJson
/// <summary>
/// Retrieve the family instance data to store in
/// the external database for the given component
/// and return it as a dictionary in a JSON
/// formatted string.
/// Obsolete, replaced by GetInstanceData method.
/// </summary>
string GetComponentDataJson(
FamilyInstance a,
Transform geoTransform)
{
Document doc = a.Document;
FamilySymbol symbol = a.Symbol;
XYZ location = Util.GetLocation( a );
XYZ geolocation = geoTransform.OfPoint(
location );
string properties = Util.GetPropertiesJson(
a.GetOrderedParameters() );
// /a/src/web/CompHoundWeb/model/instance.js
// _id : UniqueId // suppress automatic generation
// project : String
// path : String
// family : String
// symbol : String
// level : String
// x : Number
// y : Number
// z : Number
// easting : Number // Geo2d?
// northing : Number
// properties : String // json dictionary of instance properties and values
string s = string.Format(
"\"_id\": \"{0}\", "
+ "\"project\": \"{1}\", "
+ "\"path\": \"{2}\", "
+ "\"family\": \"{3}\", "
+ "\"symbol\": \"{4}\", "
+ "\"level\": \"{5}\", "
+ "\"x\": \"{6}\", "
+ "\"y\": \"{7}\", "
+ "\"z\": \"{8}\", "
+ "\"easting\": \"{9}\", "
+ "\"northing\": \"{10}\", "
+ "\"properties\": \"{11}\"",
a.UniqueId, doc.Title, doc.PathName,
symbol.FamilyName, symbol.Name,
doc.GetElement( a.LevelId ).Name,
Util.RealString( location.X ),
Util.RealString( location.Y ),
Util.RealString( location.Z ),
Util.RealString( geolocation.X ),
Util.RealString( geolocation.Y ),
properties );
return "{" + s + "}";
}
示例4: CalculateDoorWindowInformation
private void CalculateDoorWindowInformation(ExporterIFC exporterIFC, FamilyInstance famInst,
ElementId overrideLevelId, Transform trf)
{
IFCFile file = exporterIFC.GetFile();
if (ExportingDoor)
{
string doorOperationType = null;
Element doorType = famInst.Document.GetElement(famInst.GetTypeId());
if (doorType != null)
ParameterUtil.GetStringValueFromElement(doorType, BuiltInParameter.DOOR_OPERATION_TYPE, out doorOperationType);
DoorOperationTypeString = "NOTDEFINED";
if (!string.IsNullOrWhiteSpace(doorOperationType))
{
Type enumType = null;
if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
enumType = typeof(Toolkit.IFC4.IFCDoorStyleOperation);
else
enumType = typeof(Toolkit.IFCDoorStyleOperation);
foreach (Enum ifcDoorStyleOperation in Enum.GetValues(enumType))
{
string enumAsString = ifcDoorStyleOperation.ToString();
if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(enumAsString, doorOperationType))
{
DoorOperationTypeString = enumAsString;
break;
}
}
}
if (DoorOperationTypeString == "NOTDEFINED")
{
// We are going to try to guess the hinge placement.
DoorOperationTypeString = CalculateDoorOperationStyle(famInst);
}
if (FlippedX ^ FlippedY)
DoorOperationTypeString = ReverseDoorStyleOperation(DoorOperationTypeString);
if (String.Compare(DoorOperationTypeString, "USERDEFINED", true) == 0)
{
string userDefinedOperationType;
ParameterUtil.GetStringValueFromElementOrSymbol(doorType, "UserDefinedOperationType", out userDefinedOperationType);
if (!string.IsNullOrEmpty(userDefinedOperationType))
UserDefinedOperationType = userDefinedOperationType;
else
DoorOperationTypeString = "NOTDEFINED"; //re-set to NotDefined if operation type is set to UserDefined but the userDefinedOperationType parameter is empty!
}
}
if (HasRealWallHost)
{
// do hingeside calculation
Wall wall = HostObject as Wall;
PosHingeSide = true;
BoundingBoxXYZ famBBox = null;
Options options = GeometryUtil.GetIFCExportGeometryOptions();
GeometryElement geomElement = famInst.GetOriginalGeometry(options);
if (geomElement != null)
famBBox = geomElement.GetBoundingBox();
if (famBBox != null)
{
XYZ bboxCtr = trf.OfPoint((famBBox.Min + famBBox.Max) / 2.0);
Curve curve = WallExporter.GetWallAxis(wall);
XYZ wallZDir = WallExporter.GetWallHeightDirection(wall);
// famInst.HostParameter will fail if FamilyPlacementType is WorkPlaneBased, regardless of whether or not the reported host is a Wall.
// In this case, just use the start parameter of the curve.
bool hasHostParameter = famInst.Symbol.Family.FamilyPlacementType != FamilyPlacementType.WorkPlaneBased;
double param = hasHostParameter ? famInst.HostParameter : curve.GetEndParameter(0);
Transform wallTrf = curve.ComputeDerivatives(param, false);
XYZ wallOrig = wallTrf.Origin;
XYZ wallXDir = wallTrf.BasisX;
XYZ wallYDir = wallZDir.CrossProduct(wallXDir);
double eps = MathUtil.Eps();
bboxCtr -= wallOrig;
PosHingeSide = (bboxCtr.DotProduct(wallYDir) > -eps);
XYZ famInstYDir = trf.BasisY;
FlippedSymbol = (PosHingeSide != (wallYDir.DotProduct(famInstYDir) > -eps));
}
}
}
示例5: TriangulateFace
public void TriangulateFace(Autodesk.Revit.DB.Face vFace, Transform instTransform)
{
try
{
//setup utility class
LuxExporter.UnitConverter Converter = new UnitConverter();
//process face
Mesh vMesh = vFace.Triangulate();
//check if we have a quad mesh (4 edges to a face)
if (vMesh.Vertices.Count == 4)
{
//increase face counter
iNumberOfFaces++;
//found quad
Data.NumberOfVerticesinFace = 4;
//loop through all vertices and add
foreach (XYZ ii in vMesh.Vertices)
{
XYZ point = ii;
XYZ transformedPoint;
//transform geometry (only required in nested families / or elements like baluster
if (instTransform == null)
{
transformedPoint = point;
}
else
{
transformedPoint = instTransform.OfPoint(point);
}
//get the normal
XYZ NormalAtPoint;
IntersectionResult IntResult= vFace.Project(ii);
if (IntResult != null)
{
UV UVatPoint = IntResult.UVPoint;
NormalAtPoint = new XYZ(vFace.ComputeNormal(UVatPoint).X, vFace.ComputeNormal(UVatPoint).Y, vFace.ComputeNormal(UVatPoint).Z);
}
else
{
//this needs fixing!!!
NormalAtPoint = new XYZ(0, 0, 0);
}
//convert to meter
transformedPoint = Converter.ConvertPointCoordToMeter(transformedPoint);
//NormalAtPoint = Converter.ConvertPointCoordToMeter(NormalAtPoint);
//add to ply class
Data.AddVertice(transformedPoint,NormalAtPoint);
}
}
else
{
// set pointer
Data.NumberOfVerticesinFace = 3;
//export all triangles in face
for (int i = 0; i < vMesh.NumTriangles; i++)
{
//increase face counter
iNumberOfFaces++;
MeshTriangle objTriangular = vMesh.get_Triangle(i);
for (int iPointsCounter = 0; iPointsCounter < 3; iPointsCounter++)
{
XYZ point = objTriangular.get_Vertex(iPointsCounter);
XYZ transformedPoint;
//transform geometry (only required in nested families / or elements like baluster
if (instTransform == null)
{
transformedPoint = point;
}
else
{
transformedPoint = instTransform.OfPoint(point);
}
XYZ NormalAtPoint;
//get the normal
IntersectionResult IntResult = vFace.Project(point);
if (IntResult!=null)
{
UV UVatPoint = IntResult.UVPoint;
NormalAtPoint = new XYZ(vFace.ComputeNormal(UVatPoint).X,vFace.ComputeNormal(UVatPoint).Y,vFace.ComputeNormal(UVatPoint).Z);
}
else
{
//this needs fixing
NormalAtPoint = new XYZ(0, 0, 0);
//.........这里部分代码省略.........
示例6: Update
/// <summary>
/// Update the edge's geometry according to the transformation.
/// </summary>
/// <param name="rotation">Rotation transform</param>
/// <param name="translation">Translation transform</param>
/// <param name="scale">Scale transform</param>
public void Update(Transform rotation, XYZ translation, double scale)
{
rotation = rotation.Inverse;
PointF[] points = new PointF[m_points.Count];
for (int i = 0; i < m_points.Count; i++)
{
XYZ tmpPt = m_points[i];
tmpPt = rotation.OfPoint((tmpPt + translation) * scale);
points[i] = new PointF((float)tmpPt.X, (float)tmpPt.Y);
}
if (m_gdiEdge != null) m_gdiEdge.Dispose();
m_gdiEdge = new GraphicsPath();
m_gdiEdge.AddLines(points);
if (m_region != null) m_region.Dispose();
m_region = null;
}
示例7: GetSurface
/// <summary>
/// Returns the surface which defines the internal shape of the face
/// </summary>
/// <param name="lcs">The local coordinate system for the surface. Can be null.</param>
/// <returns>The surface which defines the internal shape of the face</returns>
public override Surface GetSurface(Transform lcs)
{
if (lcs == null || Plane == null)
return Plane;
// Make a new copy of the plane.
return new Plane(lcs.OfVector(Plane.Normal), lcs.OfPoint(Plane.Origin));
}
示例8: CreateShapeInternal
/// <summary>
/// Create geometry for a particular representation item.
/// </summary>
/// <param name="shapeEditScope">The geometry creation scope.</param>
/// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
/// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
/// <param name="guid">The guid of an element for which represntation is being created.</param>
protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
{
TessellatedShapeBuilderScope tsBuilderScope = shapeEditScope.BuilderScope as TessellatedShapeBuilderScope;
if (tsBuilderScope == null)
throw new InvalidOperationException("BuilderScope has not been initialised");
base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid);
Bound.CreateShape(shapeEditScope, lcs, scaledLcs, guid);
IList<XYZ> loopVertices = Bound.LoopVertices;
int count = 0;
if (loopVertices == null || ((count = loopVertices.Count) == 0))
throw new InvalidOperationException("#" + Id + ": missing loop vertices, ignoring.");
if (count < 3)
throw new InvalidOperationException("#" + Id + ": too few loop vertices (" + count + "), ignoring.");
if (!Orientation)
loopVertices.Reverse();
// Apply the transform
IList<XYZ> transformedVertices = new List<XYZ>();
foreach (XYZ vertex in loopVertices)
{
transformedVertices.Add(scaledLcs.OfPoint(vertex));
}
// Check that the loop vertices don't contain points that are very close to one another;
// if so, throw the point away and hope that the TessellatedShapeBuilder can repair the result.
// Warn in this case. If the entire boundary is bad, report an error and don't add the loop vertices.
IList<XYZ> validVertices;
IFCGeometryUtil.CheckAnyDistanceVerticesWithinTolerance(Id, shapeEditScope, transformedVertices, out validVertices);
// We are going to catch any exceptions if the loop is invalid.
// We are going to hope that we can heal the parent object in the TessellatedShapeBuilder.
bool bPotentiallyAbortFace = false;
count = validVertices.Count;
if (validVertices.Count < 3)
{
Importer.TheLog.LogComment(Id, "Too few distinct loop vertices (" + count + "), ignoring.", false);
bPotentiallyAbortFace = true;
}
else
{
try
{
tsBuilderScope.AddLoopVertices(Id, validVertices);
}
catch (InvalidOperationException ex)
{
Importer.TheLog.LogComment(Id, ex.Message, false);
bPotentiallyAbortFace = true;
}
}
if (bPotentiallyAbortFace && IsOuter)
tsBuilderScope.AbortCurrentFace();
}
示例9: ApplyTransform
List<XYZ> ApplyTransform(
List<XYZ> polygon,
Transform t)
{
int n = polygon.Count;
List<XYZ> polygonTransformed
= new List<XYZ>( n );
foreach( XYZ p in polygon )
{
polygonTransformed.Add( t.OfPoint( p ) );
}
return polygonTransformed;
}
示例10: AddTransform
public void AddTransform(Transform inTrans)
{
//m_pCurrentTransform = inTrans;
XYZ _rot = inTrans.OfVector(XYZ.Zero);
XYZ _pos = inTrans.OfPoint(_rot);
double _scale = inTrans.Scale;
m_pCurrentMesh.Position = new Vector3(_pos.X, _pos.Y, _pos.Z);
m_pCurrentMesh.Rotation = new Vector3(_rot.X, _rot.Y, _rot.Z);
m_pCurrentMesh.Scale = _scale;
}
示例11: GetInstanceData
/// <summary>
/// Retrieve the family instance data to store in
/// the external database for the given component
/// and return it as a dictionary-like object.
/// Obsolete, replaced by InstanceData class.
/// </summary>
object GetInstanceData(
FamilyInstance a,
Transform geoTransform)
{
Document doc = a.Document;
FamilySymbol symbol = a.Symbol;
Category cat = a.Category;
Debug.Assert( null != cat,
"expected valid category" );
string levelName = ElementId.InvalidElementId == a.LevelId
? "-1"
: doc.GetElement( a.LevelId ).Name;
XYZ location = Util.GetLocation( a );
Debug.Assert( null != location,
"expected valid location" );
XYZ geolocation = geoTransform.OfPoint(
location );
string properties = Util.GetPropertiesJson(
a.GetOrderedParameters() );
// /a/src/web/CompHoundWeb/model/instance.js
// _id : UniqueId // suppress automatic generation
// project : String
// path : String
// family : String
// symbol : String
// category : String
// level : String
// x : Number
// y : Number
// z : Number
// easting : Number // Geo2d?
// northing : Number
// properties : String // json dictionary of instance properties and values
object data = new
{
_id = a.UniqueId,
project = doc.Title,
path = doc.PathName,
family = symbol.FamilyName,
symbol = symbol.Name,
category = cat.Name,
level = levelName,
x = location.X,
y = location.Y,
z = location.Z,
easting = geolocation.X,
northing = geolocation.Y,
properties = properties
};
return data;
}
示例12: CreateShapeInternal
protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
{
using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.TessellatedShapeBuilder))
{
base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid);
TessellatedShapeBuilderScope tsBuilderScope = bs as TessellatedShapeBuilderScope;
tsBuilderScope.StartCollectingFaceSet();
// Create triangle face set from CoordIndex. We do not support the Normals yet at this point
foreach (List<int> triIndex in CoordIndex)
{
// This is a defensive check in an unlikely situation that the index is larger than the data
if (triIndex[0] > Coordinates.CoordList.Count || triIndex[1] > Coordinates.CoordList.Count || triIndex[2] > Coordinates.CoordList.Count)
{
continue;
}
tsBuilderScope.StartCollectingFace(GetMaterialElementId(shapeEditScope));
IList<XYZ> loopVertices = new List<XYZ>();
IList<double> v1 = Coordinates.CoordList[triIndex[0] - 1];
IList<double> v2 = Coordinates.CoordList[triIndex[1] - 1];
IList<double> v3 = Coordinates.CoordList[triIndex[2] - 1];
loopVertices.Add(new XYZ(v1[0], v1[1], v1[2]));
loopVertices.Add(new XYZ(v2[0], v2[1], v2[2]));
loopVertices.Add(new XYZ(v3[0], v3[1], v3[2]));
IList<XYZ> transformedVertices = new List<XYZ>();
foreach (XYZ vertex in loopVertices)
{
// Need to apply the project unit scaling here
XYZ scaledVertex = applyProjectUnitScaleVertex(vertex);
transformedVertices.Add(scaledLcs.OfPoint(scaledVertex));
}
// Check triangle that is too narrow (2 vertices are within the tolerance
IList<XYZ> validVertices;
IFCGeometryUtil.CheckAnyDistanceVerticesWithinTolerance(Id, shapeEditScope, transformedVertices, out validVertices);
// We are going to catch any exceptions if the loop is invalid.
// We are going to hope that we can heal the parent object in the TessellatedShapeBuilder.
bool bPotentiallyAbortFace = false;
int count = validVertices.Count;
if (validVertices.Count < 3)
{
Importer.TheLog.LogComment(Id, "Too few distinct loop vertices (" + count + "), ignoring.", false);
bPotentiallyAbortFace = true;
}
else
{
if (!tsBuilderScope.AddLoopVertices(Id, validVertices))
bPotentiallyAbortFace = true;
}
if (bPotentiallyAbortFace)
tsBuilderScope.AbortCurrentFace();
else
tsBuilderScope.StopCollectingFace();
}
IList<GeometryObject> createdGeometries = tsBuilderScope.CreateGeometry(guid);
if (createdGeometries != null)
{
foreach (GeometryObject createdGeometry in createdGeometries)
{
shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, createdGeometry));
}
}
}
}
示例13: GetTriangular
/// <summary>
/// Get triangles in a solid with transform.
/// </summary>
/// <param name="solid">The solid contains triangulars</param>
/// <param name="transform">The transformation.</param>
private void GetTriangular(Document document, Solid solid, Transform transform)
{
// a solid has many faces
FaceArray faces = solid.Faces;
bool hasTransform = (null != transform);
if (0 == faces.Size)
{
return;
}
foreach (Face face in faces)
{
if (face.Visibility != Visibility.Visible)
{
continue;
}
Mesh mesh = face.Triangulate();
if (null == mesh)
{
continue;
}
m_TriangularNumber += mesh.NumTriangles;
PlanarFace planarFace = face as PlanarFace;
// write face to stl file
// a face has a mesh, all meshes are made of triangles
for (int ii = 0; ii < mesh.NumTriangles; ii++)
{
MeshTriangle triangular = mesh.get_Triangle(ii);
double[] xyz = new double[9];
Autodesk.Revit.DB.XYZ normal = new Autodesk.Revit.DB.XYZ();
try
{
Autodesk.Revit.DB.XYZ[] triPnts = new Autodesk.Revit.DB.XYZ[3];
for (int n = 0; n < 3; ++n)
{
double x, y, z;
Autodesk.Revit.DB.XYZ point = triangular.get_Vertex(n);
if (hasTransform)
{
point = transform.OfPoint(point);
}
if (m_Settings.ExportSharedCoordinates)
{
ProjectPosition ps = document.ActiveProjectLocation.get_ProjectPosition(point);
x = ps.EastWest;
y = ps.NorthSouth;
z = ps.Elevation;
}
else
{
x = point.X;
y = point.Y;
z = point.Z;
}
if (m_Settings.Units != DisplayUnitType.DUT_UNDEFINED)
{
xyz[3 * n] = UnitUtils.ConvertFromInternalUnits(x, m_Settings.Units);
xyz[3 * n + 1] = UnitUtils.ConvertFromInternalUnits(y, m_Settings.Units);
xyz[3 * n + 2] = UnitUtils.ConvertFromInternalUnits(z, m_Settings.Units);
}
else
{
xyz[3 * n] = x;
xyz[3 * n + 1] = y;
xyz[3 * n + 2] = z;
}
triPnts[n] = point;
}
Autodesk.Revit.DB.XYZ pnt1 = triPnts[1] - triPnts[0];
normal = pnt1.CrossProduct(triPnts[2] - triPnts[1]);
}
catch (Exception ex)
{
m_TriangularNumber--;
STLDialogManager.ShowDebug(ex.Message);
continue;
}
if (m_Writer is SaveDataAsBinary && m_Settings.ExportColor)
{
Material material = document.GetElement(face.MaterialElementId) as Material;
if(material!=null)
((SaveDataAsBinary)m_Writer).Color = material.Color;
}
m_Writer.WriteSection(normal, xyz);
}
}
}
示例14: CreateGeometryInternal
/// <summary>
/// Create geometry for an IfcHalfSpaceSolid.
/// </summary>
/// <param name="shapeEditScope">The shape edit scope.</param>
/// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
/// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
/// <param name="guid">The guid of an element for which represntation is being created.</param>
/// <returns>A list containing one geometry for the IfcHalfSpaceSolid.</returns>
protected virtual IList<GeometryObject> CreateGeometryInternal(
IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
{
IFCPlane ifcPlane = BaseSurface as IFCPlane;
Plane plane = ifcPlane.Plane;
XYZ origin = plane.Origin;
XYZ xVec = plane.XVec;
XYZ yVec = plane.YVec;
// Set some huge boundaries for now.
const double largeCoordinateValue = 100000;
XYZ[] corners = new XYZ[4] {
lcs.OfPoint((xVec * -largeCoordinateValue) + (yVec * -largeCoordinateValue) + origin),
lcs.OfPoint((xVec * largeCoordinateValue) + (yVec * -largeCoordinateValue) + origin),
lcs.OfPoint((xVec * largeCoordinateValue) + (yVec * largeCoordinateValue) + origin),
lcs.OfPoint((xVec * -largeCoordinateValue) + (yVec * largeCoordinateValue) + origin)
};
IList<CurveLoop> loops = new List<CurveLoop>();
CurveLoop loop = new CurveLoop();
for (int ii = 0; ii < 4; ii++)
{
if (AgreementFlag)
loop.Append(Line.CreateBound(corners[(5 - ii) % 4], corners[(4 - ii) % 4]));
else
loop.Append(Line.CreateBound(corners[ii], corners[(ii + 1) % 4]));
}
loops.Add(loop);
XYZ normal = lcs.OfVector(AgreementFlag ? -plane.Normal : plane.Normal);
SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId);
Solid baseSolid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, normal, largeCoordinateValue, solidOptions);
if (BaseBoundingCurve != null)
{
CurveLoop polygonalBoundary = BaseBoundingCurve.CurveLoop;
Transform totalTransform = lcs.Multiply(BaseBoundingCurveTransform);
// Make sure this bounding polygon extends below base of half-space soild.
Transform moveBaseTransform = Transform.Identity;
moveBaseTransform.Origin = new XYZ(0, 0, -largeCoordinateValue);
totalTransform = totalTransform.Multiply(moveBaseTransform);
CurveLoop transformedPolygonalBoundary = IFCGeometryUtil.CreateTransformed(polygonalBoundary, totalTransform);
IList<CurveLoop> boundingLoops = new List<CurveLoop>();
boundingLoops.Add(transformedPolygonalBoundary);
Solid boundingSolid = GeometryCreationUtilities.CreateExtrusionGeometry(boundingLoops, totalTransform.BasisZ, 2.0 * largeCoordinateValue,
solidOptions);
baseSolid = IFCGeometryUtil.ExecuteSafeBooleanOperation(Id, BaseBoundingCurve.Id, baseSolid, boundingSolid, BooleanOperationsType.Intersect, null);
}
IList<GeometryObject> returnList = new List<GeometryObject>();
returnList.Add(baseSolid);
return returnList;
}
示例15: CreateShapeInternal
/// <summary>
/// Create geometry for a particular representation item.
/// </summary>
/// <param name="shapeEditScope">The geometry creation scope.</param>
/// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
/// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
/// <param name="guid">The guid of an element for which represntation is being created.</param>
protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
{
base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid);
IList<XYZ> loopVertices = Bound.LoopVertices;
int count = 0;
if (loopVertices == null || ((count = loopVertices.Count) == 0))
throw new InvalidOperationException("#" + Id + ": missing loop vertices, ignoring.");
if (count < 3)
throw new InvalidOperationException("#" + Id + ": too few loop vertices (" + count + "), ignoring.");
if (!Orientation)
loopVertices.Reverse();
// Apply the transform
IList<XYZ> transformedVertices = new List<XYZ>();
foreach (XYZ vertex in loopVertices)
{
transformedVertices.Add(scaledLcs.OfPoint(vertex));
}
// The tolerance we use to determine if loop vertices are too close to one another is based on what type of data
// we are trying to create. If we are trying to create a Solid, then we must have vertices that are further apart than ShortCurveTolerance.
// If we are trying to cerate a Mesh, then the smaller VertexTolerance is acceptable.
double shortSegmentTolerance = shapeEditScope.TryToCreateSolid() ?
shapeEditScope.Document.Application.ShortCurveTolerance :
shapeEditScope.Document.Application.VertexTolerance;
// Check that the loop vertices don't contain points that are very close to one another;
// if so, throw the point away and hope that the TessellatedShapeBuilder can repair the result.
// Warn in this case. If the entire boundary is bad, report an error and don't add the loop vertices.
IList<XYZ> validVertices = new List<XYZ>();
int lastVertex = 0;
for (int ii = 1; ii <= count; ii++)
{
int currIdx = (ii % count);
double dist = transformedVertices[lastVertex].DistanceTo(transformedVertices[currIdx]);
if (dist >= shortSegmentTolerance)
{
validVertices.Add(transformedVertices[lastVertex]);
lastVertex = currIdx;
}
else
{
string warningString = GenerateShortDistanceCommentString(dist, shortSegmentTolerance, lastVertex, currIdx, shapeEditScope.TryToCreateSolid());
IFCImportFile.TheLog.LogComment(Id, warningString, false);
}
}
// We are going to catch any exceptions if the loop is invalid.
// We are going to hope that we can heal the parent object in the TessellatedShapeBuilder.
bool bPotentiallyAbortFace = false;
count = validVertices.Count;
if (validVertices.Count < 3)
{
IFCImportFile.TheLog.LogComment(Id, "Too few distinct loop vertices (" + count + "), ignoring.", false);
bPotentiallyAbortFace = true;
}
else
{
try
{
shapeEditScope.AddLoopVertices(validVertices);
}
catch (InvalidOperationException ex)
{
IFCImportFile.TheLog.LogComment(Id, ex.Message, false);
bPotentiallyAbortFace = true;
}
}
if (bPotentiallyAbortFace && IsOuter)
shapeEditScope.AbortCurrentFace();
}