Hi,
Can someone could explain a bit how Silhouette.Compute is working?
Even by changing the ‘SilhouetteType’ parameters, the output seems to be always the same. Is this a bug? Why even expose this parameter if the output isn’t influenced by it anyway?
Thanks in advance
dale
(Dale Fugier)
August 22, 2022, 9:06pm
2
Hi @jeffoulet ,
Can you post some code and geometry, along with any required instructions, that doesn’t seem to be working for you?
Thanks,
– Dale
Hi @dale ,
Please consider the code example below:
public class dlSilhouetteTypeResults : Command
{
public dlSilhouetteTypeResults()
{
Instance = this;
}
///<summary>The only instance of the MyCommand command.</summary>
public static dlSilhouetteTypeResults Instance { get; private set; }
public override string EnglishName => "dlSilhouetteTypeResults";
private List<SilhouetteType> _silhouettesTypes = new List<SilhouetteType>() {
SilhouetteType.None,
SilhouetteType.Projecting,
SilhouetteType.TangentProjects,
SilhouetteType.Tangent,
SilhouetteType.Crease,
SilhouetteType.Boundary,
SilhouetteType.NonSilhouetteCrease,
SilhouetteType.NonSilhouetteTangent,
SilhouetteType.NonSilhouetteSeam,
SilhouetteType.SectionCut,
SilhouetteType.MiscellaneousFeature,
SilhouetteType.DraftCurve};
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var res = RhinoGet.GetOneObject("Select brep", false, ObjectType.Brep, out ObjRef objRef);
if (res != Result.Success)
return res;
var brep = objRef.Brep();
if (brep == null)
return Result.Failure;
var viewport = doc.Views.ActiveView.ActiveViewport;
foreach (var silhouetteType in _silhouettesTypes)
{
var layer = doc.Layers.Add(silhouetteType.ToString(), Color.Red);
var attributes = doc.CreateDefaultAttributes();
attributes.LayerIndex = layer;
var silhouettes = Silhouette.Compute(
brep,
silhouetteType,
new ViewportInfo(viewport),
doc.ModelAbsoluteTolerance,
doc.ModelAngleToleranceRadians);
foreach (var silhouette in silhouettes)
{
ClassifySilhouette(silhouette, attributes);
doc.Objects.AddCurve(silhouette.Curve, attributes);
}
}
doc.Views.Redraw();
return Result.Success;
}
private void ClassifySilhouette(Silhouette silhouette, ObjectAttributes attributes)
{
var type = silhouette.SilhouetteType;
if (type.HasFlag(SilhouetteType.Projecting))
attributes.SetUserString("SilhouetteType.Projecting", "true");
if (type.HasFlag(SilhouetteType.TangentProjects))
attributes.SetUserString("SilhouetteType.TangentProjects", "true");
if (type.HasFlag(SilhouetteType.Tangent))
attributes.SetUserString("SilhouetteType.Tangent", "true");
if (type.HasFlag(SilhouetteType.Crease))
attributes.SetUserString("SilhouetteType.Crease", "true");
if (type.HasFlag(SilhouetteType.Boundary))
attributes.SetUserString("SilhouetteType.Boundary", "true");
if (type.HasFlag(SilhouetteType.NonSilhouetteCrease))
attributes.SetUserString("SilhouetteType.NonSilhouetteCrease", "true");
if (type.HasFlag(SilhouetteType.NonSilhouetteTangent))
attributes.SetUserString("SilhouetteType.NonSilhouetteTangent", "true");
if (type.HasFlag(SilhouetteType.NonSilhouetteSeam))
attributes.SetUserString("SilhouetteType.NonSilhouetteSeam", "true");
if (type.HasFlag(SilhouetteType.SectionCut))
attributes.SetUserString("SilhouetteType.SectionCut", "true");
if (type.HasFlag(SilhouetteType.MiscellaneousFeature))
attributes.SetUserString("SilhouetteType.MiscellaneousFeature", "true");
if (type.HasFlag(SilhouetteType.DraftCurve))
attributes.SetUserString("SilhouetteType.DraftCurve", "true");
}
}
Here are the results when ran on a simple box with parallel projection:
A few points that make little sense to me:
when selecting all the result curves, they only have the tag ‘Silhouette.Crease’, there is no distinction made between the results:
Some curves should be labelled as NonSilhouetteCrease or am I wrong?
why some SilhouetteTypes produce a result anyway? Considering Silhouette.Compute with SilhouetteType.SectionCut as parameter, shouldn’t the result be empty? Similar with Silhouette.DraftCurve. The results here are obviously creases and not draft or section curves.
when the command is executed with a Top view, all the edges are outputted by the command: is this really the way it is expected to work?
Here is the file:
SilhouetteResults.3dm (183.0 KB)
Tom_P
October 22, 2024, 9:21pm
4
@jeffoulet
did you figure out any nice example with Silhouette.Compute ?
I did not.
The documentation for SilhouetteTypes is hard to understand.
Ended up feeling stupid and used Mesh.GetOutlines()
thanks for an update. - kind regards -tom
Hi @Tom_P ,
Unfortunately I let this topic aside for a while and did not dig further… I did not came to a satisfying result so far. From what I can recall, I also ended by using Mesh.GetOutlines…
But I agree with you, the ‘SilhouetteTypes’ documentation is rather cryptic. A verbose description + some examples would be really welcome.
1 Like
Tom_P
October 29, 2024, 2:28pm
6
@dale or @stevebaer
would it be possible to get any help on this ?
or at least an example or hint - how to get a Silhouette in shape of an Outline ?
THANKS
dale
(Dale Fugier)
October 29, 2024, 3:42pm
7
Hi @Tom_P ,
If you want an outline, just specify a SilhouetteType.Boundary
type.
TestSilhouette.cs (1.9 KB)
– Dale
1 Like
Tom_P
October 29, 2024, 4:17pm
8
Dear @dale thanks a lot for the fast reply.
silhouetteTest_tom_p_00.3dm (3.2 MB)
… a sphere seams a nice test object to see the direction…
but - the sheared board with an inner opening does not get the curve I expeced ?
as far as I see in the old documentation the silhouetteType is a flag-style enum.
Do I need to set / disable more flags ?
thanks - tom