How do you add an extra shape?
Define the dependency that says which data is needed for your shape:
public class LineDependency : DependencyBase
{
public LineDependency() : base("Line")
{
AddAttributeType(1, "Geometry");
AddAttributeType(2, "Geometry");
}
}
This class say that a line will need two geometry points, defined as children 1 and 2.
The OpenCascade function that defines your shape is the following:
public class LineFunction : FunctionBase
{
public LineFunction() : base("Line")
{
Dependency = DependencyFactory.Instance.GetDependency
}
public override int Execute()
{
// Get the values of dimension and position attributes
OCgp_Pnt firstPoint = Dependency.Child(1).Geometry;
OCgp_Pnt secondPoint = Dependency.Child(2).Geometry;
OCTopoDS_Edge aEdge = new OCBRepBuilderAPI_MakeEdge(firstPoint, secondPoint).Edge();
var shape = new OCBRepBuilderAPI_MakeWire(aEdge).Wire();
var shapeInterpreter = Parent.UpdateInterpreter
shapeInterpreter.Shape = shape;
return 0;
}
}
And before using any of them, register them to be known globally:
DependencyFactory.Register
FunctionFactory.Register
No comments:
Post a Comment