Class Face
A face is a bounded portion of a single geometric surface, the two-dimensional analog of a body. The boundary is represented by one or more loops or edges. Each face is simply connected, implying that one can traverse from any point on the interior of the face to any other point on the interior of the face without crossing the boundary of the face. In general, it is not meaningful to distinguish exterior and interior loops of edges, though for certain surface types this may be possible and some algorithms may do so.
Implements
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
public sealed class Face : ProjectObject, IGeometryObject, IHasGeometry, IGfxObject
Remarks
The Face object is generated on demand and is not stored in the station file; therefore Attributes cannot be used to persist attributes.
Properties
Body
Declaration
public Body Body { get; }
Property Value
Type | Description |
---|---|
Body |
Examples
Get Body.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Color
Gets or sets color of the face in the graphics.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color |
Examples
Get/Set Color.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FaceType
Returns the type of the face.
Declaration
public FaceType FaceType { get; }
Property Value
Type | Description |
---|---|
FaceType |
Loops
Gets the LoopCollection of the Face.
Declaration
public LoopCollection Loops { get; }
Property Value
Type | Description |
---|---|
LoopCollection |
Examples
Get LoopCollection.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Opacity
Gets or sets the opacity of the face.
Declaration
public double Opacity { get; set; }
Property Value
Type | Description |
---|---|
Double |
Remarks
Valid values are 0.0 (fully transparent) through 1.0 (fully opaque).
Visible
Gets or sets whether the face is visible or not in the graphics.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Get/Set Visible.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Methods
Connected(Face[])
Checks whether a set of faces are connected, e.g. form a continous surface.
Declaration
public static bool Connected(Face[] faces)
Parameters
Type | Name | Description |
---|---|---|
Face[] | faces | Faces to check. |
Returns
Type | Description |
---|---|
Boolean | True if all faces are connected. |
Remarks
Two faces are considered connected if they share at least one Edge.
FindClosestVertex(Vector3)
Declaration
public Vertex FindClosestVertex(Vector3 testPoint)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | testPoint | The point which to find the closest vertex to. |
Returns
Type | Description |
---|---|
Vertex | The closest Vertex. |
Examples
Find closest Vertex.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
GetBoundingBox(Boolean)
Computes the (axis-aligned) bounding box for this object.
Declaration
public BoundingBox GetBoundingBox(bool global)
Parameters
Type | Name | Description |
---|---|---|
Boolean | global | Specifies that the bounding box should be in the global (world) coordinate system rather than in this object's local coordinate system. |
Returns
Type | Description |
---|---|
BoundingBox |
GetBoundingBox(Boolean, out Vector3, out Vector3)
Computes the (axis-aligned) bounding box for this object.
Declaration
olete("Use GetBoundingBox(bool global) instead", true)]
public void GetBoundingBox(bool global, out Vector3 min, out Vector3 max)
Parameters
Type | Name | Description |
---|---|---|
Boolean | global | Specifies that the bounding box should be in the global (world) coordinate system rather than in this object's local coordinate system. |
Vector3 | min | The first corner of the bounding box. |
Vector3 | max | The second corner of the bounding box. |
Remarks
The Face must containing a station.
GetCenterPoint(out Vector3)
Returns the center point of a planar surface.
Declaration
public bool GetCenterPoint(out Vector3 centerPoint)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | centerPoint |
Returns
Type | Description |
---|---|
Boolean | True if the face is planar, false otherwise. |
GetEdges()
Returns an array containing the edges of this face.
Declaration
public Edge[] GetEdges()
Returns
Type | Description |
---|---|
Edge[] |
GetMaterial()
Returns the material used to render this face
Declaration
public Material GetMaterial()
Returns
Type | Description |
---|---|
Material |
GetNormalToSurface(Vector3, out Vector3, out Vector3)
Calculates the closest point and the corresponding normal.
Declaration
public bool GetNormalToSurface(Vector3 testPoint, out Vector3 hitPoint, out Vector3 hitPointNormal)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | testPoint | The test point. |
Vector3 | hitPoint | The closest point. |
Vector3 | hitPointNormal | Normal to the closest point. |
Returns
Type | Description |
---|---|
Boolean | True if successful. |
Remarks
All parameters are in world coordinates.
Examples
GetNormalToSurface.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
GetURange(out ParameterRange)
Returns the parameter range of a surface in the u-parameter direction.
Declaration
public bool GetURange(out ParameterRange uRange)
Parameters
Type | Name | Description |
---|---|---|
ParameterRange | uRange | Parameter range. |
Returns
Type | Description |
---|---|
Boolean | False if the range is unbounded. |
GetVertices()
Returns an array containing the vertices of this face.
Declaration
public Vertex[] GetVertices()
Returns
Type | Description |
---|---|
Vertex[] |
GetVRange(out ParameterRange)
Returns the parameter range of a surface in the v-parameter direction.
Declaration
public bool GetVRange(out ParameterRange vRange)
Parameters
Type | Name | Description |
---|---|---|
ParameterRange | vRange | Parameter range. |
Returns
Type | Description |
---|---|
Boolean | False if the range is unbounded. |
NormalizeTextureCoordinates(Boolean, Boolean)
Declaration
public void NormalizeTextureCoordinates(bool u, bool v)
Parameters
Type | Name | Description |
---|---|---|
Boolean | u | |
Boolean | v |
ReverseNormal()
Reverses the sense of a face; i.e., makes the face material void (flips the normal). Also, alters the senses of the coedges to avoid changing the shape of the face.
Declaration
public bool ReverseNormal()
Returns
Type | Description |
---|---|
Boolean | True if successful. |
Remarks
This method does not check to see if the face belongs to a solid, nor does it compensate for side effects caused by reversal of the face. The user must ensure that this method is called only for independent faces.
Examples
Reverse Normal.
Project.UndoContext.BeginUndoStep("FaceProperties");
try
{
Station station = Station.ActiveStation;
// Create a box.
Part myPart = new Part();
myPart.Name = "MyPart";
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box.Name = "MyBox";
myPart.Bodies.Add(box);
// Get a face from the box.
Face myFace = box.Shells[0].Faces[0];
// Make sure the face is visible.
myFace.Visible = true;
// Make the the face yellow.
myFace.Color = Color.Yellow;
// Output the name of the body of the face.
Logger.AddMessage(new LogMessage("The body of the face is: " + myFace.Body.Name));
// Traverse the loops of the face and output the number of coedges each has.
int i = 1;
foreach (Loop l in myFace.Loops)
{
Logger.AddMessage(new LogMessage("Loop number '" + i + "' has '" + l.Coedges.Count + "' coedges"));
i++;
}
// Find the vertex closest to a point.
Vector3 point = new Vector3(0.6, 0.6, 0.6);
Vertex closestVert = myFace.FindClosestVertex(point);
Logger.AddMessage(new LogMessage("The closest vertex to point is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() +
", " + closestVert.Position.x.ToString() + ")"));
// Create a surface circle.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body circle = Body.CreateSurfaceCircle(matrix_origo, 0.5);
circle.Name = "Surface circle";
myPart.Bodies.Add(circle);
if (circle.Shells[0].Faces[0].ReverseNormal())
{
Logger.AddMessage(new LogMessage("Face of surface circle succesfully reversed!"));
}
else
{
Logger.AddMessage(new LogMessage("Reversal of face of surface circle failed!"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SetMaterial(Material)
Sets the material of the face.
Declaration
public void SetMaterial(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | Material to use when rendering this face. |
SetMaterial(Material, Boolean)
Sets the material of the face.
Declaration
public void SetMaterial(Material material, bool preserveOpacity)
Parameters
Type | Name | Description |
---|---|---|
Material | material | |
Boolean | preserveOpacity |
SetMaterial(Material, SizeF)
Sets the material of the face and re-scales the texture cooordinates.
Declaration
olete("Use Material.TextureSize instead")]
public void SetMaterial(Material material, SizeF scale)
Parameters
Type | Name | Description |
---|---|---|
Material | material | Material to use when rendering this face. |
SizeF | scale | Scale factor for u and v texture coordinates. Range from 0 to 1. |