Hello,
It seems that “Rhino.Geometry.HiddenLineDrawingSegment.Visibility.Clipped” type is currently not supported.
Whenever I define a clipping plane and Compute, only visible and hidden segments are returned, but never clipped segments.
@DavidRutten also excluded the clipped curves as outputs of the “Make2D” grasshopper component.
Does that mean that “Clipped” segments are currently not supported by “HiddenLineDrawingSegment” class?
@djordje what do you need the HiddenLineDrawingSegment.Visibility.Clipped segments for?
Are you trying to find ClippingPlane intersections with your geometry?
Hi @rajaa,
Yes. I have an object in the perspective view, and I would like to “identify” the clipping plane Make2D lines. But the “HiddenLineDrawingSegment.Visibility.Clipped” seens to not work.
Ok, I’ll put together a sample for you to extract intersection curves with the clipping plane.
1 Like
This code will select objects and use active clipping plane to output Make2D curves.
Is that what you are looking for?
var _go = new GetObject();
_go.SetCommandPrompt("Select objects to test Make2D");
_go.GeometryFilter = ObjectType.Point | ObjectType.Surface | ObjectType.PolysrfFilter;
_go.GroupSelect = true;
_go.GetMultiple(1, 0);
if (_go.CommandResult() != Result.Success)
return _go.CommandResult();
var _obj_refs = _go.Objects();
var _view = doc.Views.ActiveView;
//Set Make2D Parameters
var _hld_params = new HiddenLineDrawingParameters
{
AbsoluteTolerance = doc.ModelAbsoluteTolerance,
IncludeTangentEdges = false,
IncludeHiddenCurves = true
};
_hld_params.SetViewport(_view.ActiveViewport);
//add objects to hld_param
foreach (var obj_ref in _obj_refs)
{
if (null == obj_ref)
continue;
var obj = obj_ref.Object();
if (null == obj)
continue;
_hld_params.AddGeometry(obj.Geometry, Transform.Identity, obj.Id);
}
//Add active clipping planes
var clipping_planes = doc.Objects.GetObjectsByType<ClippingPlaneObject>().ToArray();
foreach (var clipping_plane in clipping_planes)
{
if (clipping_plane.ClippingPlaneGeometry.ViewportIds().Contains(_view.ActiveViewport.Id))
{
var plane = clipping_plane.ClippingPlaneGeometry.Plane;
plane.Flip();
_hld_params.AddClippingPlane(plane);
}
}
//perform HLD calculation
var _hld = HiddenLineDrawing.Compute(_hld_params, true);
if (_hld != null)
{
//transform and add to doc
var flatten = Transform.PlanarProjection(Plane.WorldXY);
BoundingBox page_box = _hld.BoundingBox(true);
var delta2D = new Vector2d(0, 0);
delta2D = delta2D - new Vector2d(page_box.Min.X, page_box.Min.Y);
var delta3D = Transform.Translation(new Vector3d(delta2D.X, delta2D.Y, 0.0));
flatten = delta3D * flatten;
//add curves to doc
var h_attribs = new ObjectAttributes();
h_attribs.Name = "H";
h_attribs.ColorSource = ObjectColorSource.ColorFromObject;
h_attribs.ObjectColor = System.Drawing.Color.Cyan;
var v_attribs = new ObjectAttributes();
v_attribs.Name = "V";
var cv_attribs = new ObjectAttributes();
cv_attribs.Name = "CutV";
cv_attribs.ColorSource = ObjectColorSource.ColorFromObject;
cv_attribs.ObjectColor = System.Drawing.Color.Red;
var ch_attribs = new ObjectAttributes();
ch_attribs.Name = "CutH";
ch_attribs.ColorSource = ObjectColorSource.ColorFromObject;
ch_attribs.ObjectColor = System.Drawing.Color.Pink;
foreach (HiddenLineDrawingSegment hld_curve in _hld.Segments)
{
if (hld_curve == null || hld_curve.ParentCurve == null || hld_curve.ParentCurve.SilhouetteType == SilhouetteType.None)
continue;
var crv = hld_curve.CurveGeometry.DuplicateCurve();
if (crv != null)
{
crv.Transform(flatten);
if (hld_curve.SegmentVisibility == HiddenLineDrawingSegment.Visibility.Visible)
{
if (hld_curve.ParentCurve.SilhouetteType == SilhouetteType.SectionCut)
doc.Objects.AddCurve(crv, cv_attribs);
else
doc.Objects.AddCurve(crv, v_attribs);
}
else if (hld_curve.SegmentVisibility == HiddenLineDrawingSegment.Visibility.Hidden)
{
if (hld_curve.ParentCurve.SilhouetteType == SilhouetteType.SectionCut)
doc.Objects.AddCurve(crv, ch_attribs);
else
doc.Objects.AddCurve(crv, h_attribs);
}
}
}
//add points to doc
foreach (HiddenLineDrawingPoint hld_pt in _hld.Points)
{
if (hld_pt == null)
continue;
var pt = hld_pt.Location;
if (pt != null)
{
pt.Transform(flatten);
if (hld_pt.PointVisibility == HiddenLineDrawingPoint.Visibility.Visible)
doc.Objects.AddPoint(pt, v_attribs);
else if (hld_pt.PointVisibility == HiddenLineDrawingPoint.Visibility.Hidden)
doc.Objects.AddPoint(pt, h_attribs);
}
}
}
1 Like