'SilhouetteType' does not seem to change anything in Silhouette.Compute

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

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:

  1. 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?

  2. 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.

  3. 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)