<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/pattern.xsl"?>
<pattern id="">
  <name>
    Reporter
  </name>
  <relatedPatterns>
    <relatedPattern ref="">
	  <patternLink>Selector</patternLink>
    </relatedPattern>
    <relatedPattern ref="">
	  <patternLink>Controller</patternLink>
    </relatedPattern>
    <relatedPattern ref="">
	  <patternLink>Projection</patternLink>
    </relatedPattern>
    <relatedPattern ref=""/>
  </relatedPatterns>
  <diagram>
  <web>
      <img src="DiagramRepo.gif" width="400"/>
  </web>
    <latex>
    <img src="DiagramRepo.png" width="400"/>
	</latex>
  </diagram>
  <what>
    <paragraph>
      Re-present (abstract or transform) information from a model.
    </paragraph>
  </what>
  <when>
    <paragraph>
      Models can be complex. Finding and using the relevant parts of a
      model can be tedious and error-prone. Further, "parts" of a
      model may only be implied---computation may be needed to
      construct them from primary model data. Use this pattern when
      you need to use some aspect of a model in another process or
      another part of the model.
    </paragraph>
  </when>
  <why>
    <paragraph>
      Models can be arbitrarily complex and therefore hard to
      understand. Further, they can imply far more information than
      they directly express. Such information is typically uncovered
      through functions<latex>\index{function}</latex> applied to the model.  Using a
      <patternName>Reporter</patternName> allows you to present only
      the information you need to another part of the model. This
      makes your model structure more clear and helps you communicate
      with other people who may use your model.
    </paragraph>
    <paragraph>
      <patternName>Reporters</patternName> may abstract (simplify) or
      transform (re-present). They report a design or its parts from a
      different point of view.  In analogy to a relational database,
      the <patternName>Reporter</patternName> pattern is akin to a
      view table extracted from a database.
    </paragraph>
  </why>
  <how>




    <paragraph>
       Data from a <patternName>Reporter</patternName> must be
       conceived, extracted and envisioned. Deciding what to report
       can be non-trivial, for example, when reporting planarity in
       facade elements, the most appropriate report may, or may not,
       be the minimal vertex movement that restores
       planarity. Extracting the data may involve a substantial
       algorithm<latex>\index{algorithm}</latex>, for example, a convex hull<latex>\index{convex hull}</latex> of a set of
       points. Envisioning that data so that it makes sense to the
       person receiving it has been the subject of entire books
       <latex>\cite{Tufte1986}, \cite{Tufte1990},
       \cite{Tufte1997}</latex> -- it is likely that a simple, textual
       list will not best. Of course, if the purpose of the
       <patternName>Reporter</patternName> is to provide data to
       another program, a textual or numeric list might be exactly
       right.
    </paragraph>
    <paragraph>
      You can use the <patternName>Reporter</patternName>
      pattern in many different ways. 
      <ol>
	<li>Displaying properties of an object. For example, the
	coordinates of a collection of points might be displayed
	numerically in a table, or their minima and maxima might be
	instanced as two points.</li>
	
	<li>Defining an element in a different way. For example, a
	point defined in one coordinate system can be reported in
	another.</li>
	
	<li>Conditionally selecting parts from your model. In this
	use, a <patternName>Reporter</patternName> is very similar to
	a <patternLink>Selector</patternLink>. For example,
	a roof surface comprising polygons might be reported by the
	degree of non-planarity in each.</li>


         <li>Creating new objects from the reported objects. In this case
         of indirection, a property of an object is used to define
         another object. For example, a <patternName>Reporter</patternName> on line
         segments might comprise new segments coincident with the
         orginals' central third. Another <patternName>Reporter</patternName>
         example produces a 	<em>dual</em> polygon mesh (the
         mesh generated by replacing centroids with vertices, and
         edges between vertices with edges between centroids).</li>

	<li>Sampling a model and then reporting this
	simplified version somewhere else and with different
	conditions to create a more complex model.</li>
	
	<li>Copying. Generally, copying is reporting the model as many
	times as needed in different places, therefore features such
	as copy, mirror, clone and rotate are all kinds of
	reporting.</li>
      </ol>		

      The <patternName>Reporter</patternName> pattern typically
      combines with other patterns to make a complete task.
      This pattern feeds information to downstream objects or directly
      to the designer. In many ways, it is a normal part of parametric
      modeling in that models are defined in terms of other
      models. The difference is that a
      <patternName>Reporter</patternName> is often not a part of the
      design, but rather a view on the design or an intermediary in
      the model construction process.
    </paragraph>
    <paragraph>
      In some sense, the <patternName>Reporter</patternName> pattern
      is an anti-<patternLink>Controller</patternLink> pattern. In a
      <patternName>Controller</patternName>, information flows from the control to the target --
      typically from a simple model to a complex one.  In a <patternName>Reporter</patternName>
      information flows the other way -- it typically is an
      abstraction of a larger model.
    </paragraph>
  </how>
  <samples>
    <sample id="SubtendedAngle">
      <name>Subtended Angle</name>
      <when>
	<paragraph>
	  Envision information from the model as text.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  In a circle<latex>\index{circle}</latex>, any inscribed angle subtended by a chord of a
	  given length is constant. A good demonstration is to
	  justapose as text multiple angles<latex>\index{angle}</latex> subtended by a common
	  chord. This model comprises a circle and two pairs of lines
	  that represent two angles and share a common subtending
	  chord.  Showing both of those angles together demonstrates
	  this simple geometric theorem. Text is perhaps the most
	  simple <patternName>Reporter</patternName>. Sometimes it is
	  actually effective.
	</paragraph>
      </how>
      <diagram>
	<img src="Samples/RepoSubtendedAngle/RepoSubtendedAngleDiag.pdf" width="600"/>
      </diagram>
      <a href="Samples/RepoSubtendedAngle/RepoSubtendedAngle.gct">Click to download RepoSubtendedAngle.gct</a>
      <animation src="Samples/RepoSubtendedAngle/AnimationSubtendedAngle.swf"/>
    </sample>
    <sample id="ArrayDepth">
      <name>Array Depth</name>
      <when>
	<paragraph>
	  Extract properties of a collection of points organized as an array.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Collections of objects such as points<latex>\index{point}</latex> imply many properties,
	  some pertaining the points themselves and some to their
	  organization in a collection. Examples include the extrema
	  coordinates of the points, the longest path in the
	  collection (the array depth) and the number of elements in
	  the collection. In this example, the
	  <patternName>Reporter</patternName> pattern extracts such
	  data from the model. In this sample, a function iterates over
	  each element in a collection, accumulating the desired
	  measures as it proceeds.
	</paragraph>
      </how>
      <diagram>
	<img src="Samples/RepoArrayDepth/RepoArrayDepthDiag.png" width="300"/>
      </diagram>

      <a href="Samples/RepoArrayDepth/RepoArrayDepth.gct">Click to download RepoArrayDepth.gct</a>
      <animation src="Samples/RepoArrayDepth/AnimationArrayDepth.swf"/>
    </sample>
    <sample id="Fabrication">
      <name>Fabrication</name>
      <when>
	<paragraph>
	  Transform design data for fabrication.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Slicing a solid with planes gives a set of closed curves. A
	  common fabrication technique is to use such curves to cut
	  <em>stations</em> out of a sheet material and use the
	  stations as internal formwork that is covered with other
	  sheet or strip material. The curves<latex>\index{curve}</latex> forming the stations can
	  be reported in variety of ways, in both 2D and 3D and
	  through mediating transformations<latex>\index{transformation}</latex>. In this sample, one
	  report is a scaled 3D version and
	  the other is a 2D layout suitable
	  (to a first approximation) as a cutting plan from sheet
	  material.
	</paragraph>
      </how>
		<paragraph>
	  <latex>
 \begin{bodyNote}
               \pbOneCol
                 {\input{\GCFigsPath/Patterns/ReporterFabricationExplain0.tex}}
             \end{bodyNote}
      </latex>
	</paragraph>
      <a href="Samples/RepoFabrication/RepoFabrication.gct">Click to
      download RepoFabrication.gct</a>
      <animation src="Samples/RepoFabrication/AnimationFabrication.swf"/>
    </sample>
    <sample id="Mirror">
      <name>Mirror</name>
      <when>
	<paragraph>
	  Mirror a curve<latex>\index{curve}</latex> through an axis.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Define a curve based on a point collection, and a line to
	  use as a mirror. In 3D the line would be a plane. Now
	  project poles to the axis (perpendicular to the line) and
	  then create points on the other side of the axis at the same
	  distance as between the original points and their
	  projections. Finally create a curve from the new poles on
	  the other side of the axis, this curve is a mirror of the
	  first curve. In general, it will be an
	  <em>enantiomorph</em>, that is, identical except for
	  handedness.
	</paragraph>
      </how>
      <paragraph>
	
      </paragraph>
      <diagram>
	<img src="Samples/RepoMirror/RepoMirrorDiag.pdf" width="450"/>
      </diagram>
      <paragraph>
      </paragraph>
      <a href="Samples/RepoMirror/RepoMirror.gct">Click to download
      RepoMirror.gct</a>
      <animation src="Samples/RepoMirror/AnimationMirror.swf"/>
    </sample>
    <sample id="Out of Plane">
      <name>Out of Plane</name>
      <when>
	<paragraph>
	  Report the out-of-plane polygons of a surface both by color and text.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Create a surface<latex>\index{surface}</latex> with curvature<latex>\index{surface!curvature}</latex> and then subdivide the
	  surface with polygons or create an array of polygons on the
	  surface. When the surface has curvature, some of the
	  polygons may be non-planar. The degree of non-planarity
	  depends on the local curvature of the surface. Using a
	  function that iterates over the collection, extract the
	  polygons that exceed a threshold out-of-plane
	  measure. Visualize the resulting polygons<latex>\index{polygon}</latex> both
	  <em>in-situ</em> with colour and in a tabular report.
	</paragraph>
	<paragraph>
		
	  <latex>
 \begin{bodyNote}
               \pbOneCol
                 {\input{\GCFigsPath/Patterns/ReporterOutofPlaneExplain0.tex}}
             \end{bodyNote}
      </latex>
	
	</paragraph>
      </how>
      <a href="Samples/RepoOutOfPlane/RepoOutOfPlane.gct">Click to download RepoOutOfPlane.gct</a>
      <animation src="Samples/RepoOutOfPlane/AnimationOutOfPlane.swf"/>
    </sample>
    <sample id="Snapper">
      <name>Snapper</name>
      <when>
	<paragraph>
	  Report a triangle snapped onto a grid.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  Parametric "sketches" (yes, a parametric model can be
	  sketch-like!) are continuous. They may be abstracted into a
	  discrete system, such as a grid. This
	  <patternName>Reporter</patternName> maintains the original
	  model and ability to smoothly interact with it and reports
	  the model as it would appear were it snapped onto a
	  specified grid. The reporting occurs in two steps. First,
	  report the position of the original triangle in a new
	  coordinate system. Second, select and report the nearest
	  point on the grid to each triangle<latex>\index{triangle}</latex> vertex. Construct the
	  reported triangle on these abstracted points<latex>\index{point}</latex>.
	</paragraph>
	<paragraph>
	  <diagram>
	<img src="Samples/RepoSnapper/ReporterSnapperDiagram.pdf" width="450"/>
      </diagram>
	</paragraph>
      </how>
      <a href="Samples/RepoSnapper/RepoSnapper.gct">Click to download RepoSnapper.gct</a>
      <animation src="Samples/RepoSnapper/AnimationSnapper.swf"/>
    </sample>
    <sample id="Triangle">
      <name>Triangle</name>
      <when>
	<paragraph>
	  Rotate and scale a triangle<latex>\index{triangle}</latex>.
	</paragraph>
      </when>
      <how>
	<paragraph>
	  This sample separates the shape of an object from the space
	  in which it is embedded, giving independent control of each.
	  It reports a triangle developed in one coordinate system (the <arg>baseCS</arg>) in
	  another system (the <arg>reporterCS</arg>) and provides rotation<latex>\index{frame!rotation}</latex> and scaling<latex>\index{frame!scaling}</latex> controls
	  for that new coordinate system. 
	</paragraph>
	<paragraph>
	  Ironically, this <patternName>Reporter</patternName> uses a
	  <patternName>Reporter</patternName> internally. In order to
	  compute the rotation of the <arg>reporterCS</arg> system, a
	  point is defined in the <arg>baseCS</arg> system at the
	  origin of the <arg>reporterCS</arg> system, but one unit
	  along the <math latex="x">x</math>-axis of the
	  <arg>baseCS</arg> system. Reporting this point in the
	  <arg>reporterCS</arg> system provides the arguments needed
	  for the function <arg>Atan2</arg> to correctly compute the
	  rotation angle.
	</paragraph>
	<paragraph>
      <diagram>
	<img src="Samples/RepoTriangle/ReporterTriangleDiagram.pdf" width="300"/>
</diagram>
	</paragraph>
      </how>
      <a href="Samples/RepoTriangle/RepoTriangle.gct">Click to download RepoTriangle.gct</a>
      <animation src="Samples/RepoTriangle/AnimationTriangle.swf"/>
    </sample>
  </samples>
</pattern>

