Class AbstractComponent
- All Implemented Interfaces:
- Component,- Transformable,- Showable
- Direct Known Subclasses:
- ConcaveComponent,- PrismaticComponent
Component interface to minimize the effort
 required to implement a Component.
 
 To implement a Component, the programmer needs only to extend this
 class and provide implementations for the
 Component.getType() and
 Component.getLength() methods.
 
 Initially, the Component will contain no volume points, lines, or
 faces and the Shape3D will be empty, so volume points, lines, and
 faces must be added to the Component after
 AbstractComponent's constructor has been invoked via the  addVolumePoint(org.jlab.geom.prim.Point3D),
 addVolumeEdge(int, int), and addVolumeTriangleFace(int, int, int)
 methods.
 
 To set the midpoint, use getMidpoint() to retrieve the point and
 modify it accordingly.
 If the subtyped Component contains additional geometry data, then, to
 ensure that the additional geometry is properly rotated and translated with
 the Component, the programmer must also override onTranslateXYZ(double, double, double),
 onRotateX(double), onRotateY(double), and
 onRotateZ(double), which are invoked after the
 AbstractComponent implementations of the
 Transformable methods are invoked.
- Author:
- jhankins
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractComponent(int componentId) Initializes an empty AbstractComponent with the given id.
- 
Method SummaryModifier and TypeMethodDescriptionprotected final voidaddVolumeEdge(int pointIndex0, int pointIndex1) Adds an edge from the point at the first index to the point at the second.protected final voidaddVolumePoint(Point3D point) Adds points to the component's volume.protected final voidaddVolumeTriangleFace(int pointIndex0, int pointIndex1, int pointIndex2) Adds aTriangle3Dface to the volume shape such that the shape is composed of the points corresponding to the three given point indexes.final intReturns the component's id number.final Point3DReturns the midpoint of this component.final intReturns the number of edges between the points that define thevolume.final intReturns the number of points that define thevolume.getVolumeCrossSection(Transformation3D transformation) Returns the cross section of a plane through the the component'svolumeas a list of lines in the xy-plane.final Line3DgetVolumeEdge(int edgeIndex) Returns the edge on thevolumewith the specified index.final Point3DgetVolumePoint(int pointIndex) Returns the point on thevolumewith the specified index.final Shape3DReturns the volume of the component.protected voidonRotateX(double angle) Classes extending AbstractComponent should implement onRotateX so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateX method is invoke.protected voidonRotateY(double angle) Classes extending AbstractComponent should implement onRotateY so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateY method is invoke.protected voidonRotateZ(double angle) Classes extending AbstractComponent should implement onRotateZ so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateZ method is invoke.protected voidonTranslateXYZ(double dx, double dy, double dz) Classes extending AbstractComponent should implement onTranslateXYZ so that any additional geometric data they contain is translated appropriately when AbstractComponent's translateXYZ method is invoked.final voidrotateX(double angle) Rotates this object clockwise around the x axis.final voidrotateY(double angle) Rotates this object clockwise around the y axis.final voidrotateZ(double angle) Rotates this object clockwise around the z axis.voidshow()InvokesSystem.out.println(this).toString()final voidtranslateXYZ(double dx, double dy, double dz) Translates this object linearly by the amounts specified.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jlab.geom.base.ComponentgetLength, getType, getVolumeIntersection
- 
Constructor Details- 
AbstractComponentprotected AbstractComponent(int componentId) Initializes an empty AbstractComponent with the given id.- Parameters:
- componentId- the id of this component
 
 
- 
- 
Method Details- 
getComponentIdpublic final int getComponentId()Description copied from interface:ComponentReturns the component's id number.- Specified by:
- getComponentIdin interface- Component
- Returns:
- the id
 
- 
getNumVolumePointspublic final int getNumVolumePoints()Description copied from interface:ComponentReturns the number of points that define thevolume.- Specified by:
- getNumVolumePointsin interface- Component
- Returns:
- the number of volume points
 
- 
getVolumePointDescription copied from interface:ComponentReturns the point on thevolumewith the specified index.- Specified by:
- getVolumePointin interface- Component
- Parameters:
- pointIndex- the index of the point
- Returns:
- the point on the volume
 
- 
addVolumePointAdds points to the component's volume.Intended for use by constructors of classes extending AbstractComponent. - Parameters:
- point- the point to add
- See Also:
 
- 
getNumVolumeEdgespublic final int getNumVolumeEdges()Description copied from interface:ComponentReturns the number of edges between the points that define thevolume.- Specified by:
- getNumVolumeEdgesin interface- Component
- Returns:
- the number of volume edges
 
- 
getVolumeEdgeDescription copied from interface:ComponentReturns the edge on thevolumewith the specified index.Though edges are returned as Line3Dobjects and a majority components have edges which are all straight line segments, edges are not required to be straight lines. The edge may, in reality, be curved, in which case the returnedLine3Dis merely storing the two points bounding a curved path segment. Thus, special care must be taken to ensure that the edge is in fact a straight line segment if one intends to use it as such.- Specified by:
- getVolumeEdgein interface- Component
- Parameters:
- edgeIndex- the index of the edge
- Returns:
- the edge on the volume
 
- 
addVolumeEdgeprotected final void addVolumeEdge(int pointIndex0, int pointIndex1) Adds an edge from the point at the first index to the point at the second.Intended for use by constructors of classes extending AbstractComponent. - Parameters:
- pointIndex0- the first point index
- pointIndex1- the second point index
- See Also:
 
- 
getVolumeShapeDescription copied from interface:ComponentReturns the volume of the component.A volume is represented by a Shape3Dobject which contains a list of triangularFace3Dobjects. This these triangles bound a closed closed volume.- Specified by:
- getVolumeShapein interface- Component
- Returns:
- the volume
 
- 
addVolumeTriangleFaceprotected final void addVolumeTriangleFace(int pointIndex0, int pointIndex1, int pointIndex2) Adds aTriangle3Dface to the volume shape such that the shape is composed of the points corresponding to the three given point indexes.Intended for use by constructors of classes extending AbstractComponent. Though not required, by convention the points defining a face should be given in counterclockwise order from th perspective of an observer outside the volume. This allows 3D-rendering applications to use back-face culling to increase performance. - Parameters:
- pointIndex0- the first point index
- pointIndex1- the second point index
- pointIndex2- the third point index
- See Also:
 
- 
getVolumeCrossSectionDescription copied from interface:ComponentReturns the cross section of a plane through the the component'svolumeas a list of lines in the xy-plane.This method takes a Transformation3D object as an argument, then constructs a new Plane3Dobject in the xy-plane and applies the transformation to the plane. The intersection of the volume's shape with the transformed plane is then calculated and stored in a list of lines. The inverse of the transformation is then applied to each line in the list ensuring that each line in the returned list is in the xy-plane.- Specified by:
- getVolumeCrossSectionin interface- Component
- Parameters:
- transformation- the transformation to apply to the plane
- Returns:
- a list of lines in the xy-plane representing the cross section
 
- 
getMidpointDescription copied from interface:ComponentReturns the midpoint of this component. By convention, the midpoint of a component is normally the geometric center of the component's volume but the definition of midpoint may vary by component type.- Specified by:
- getMidpointin interface- Component
- Returns:
- the midpoint
 
- 
translateXYZpublic final void translateXYZ(double dx, double dy, double dz) Description copied from interface:TransformableTranslates this object linearly by the amounts specified.- Specified by:
- translateXYZin interface- Transformable
- Parameters:
- dx- amount to translate along the x axis
- dy- amount to translate along the y axis
- dz- amount to translate along the z axis
 
- 
rotateXpublic final void rotateX(double angle) Description copied from interface:TransformableRotates this object clockwise around the x axis.- Specified by:
- rotateXin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateYpublic final void rotateY(double angle) Description copied from interface:TransformableRotates this object clockwise around the y axis.- Specified by:
- rotateYin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateZpublic final void rotateZ(double angle) Description copied from interface:TransformableRotates this object clockwise around the z axis.- Specified by:
- rotateZin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
onTranslateXYZprotected void onTranslateXYZ(double dx, double dy, double dz) Classes extending AbstractComponent should implement onTranslateXYZ so that any additional geometric data they contain is translated appropriately when AbstractComponent's translateXYZ method is invoked. This method is called at the end of AbstractComponent's translateXYZ method.- Parameters:
- dx- amount to translate along the x axis
- dy- amount to translate along the y axis
- dz- amount to translate along the z axis
- See Also:
 
- 
onRotateXprotected void onRotateX(double angle) Classes extending AbstractComponent should implement onRotateX so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateX method is invoke. This method is called at the end of AbstractComponent's rotateX method.- Parameters:
- angle- rotation angle in radians
- See Also:
 
- 
onRotateYprotected void onRotateY(double angle) Classes extending AbstractComponent should implement onRotateY so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateY method is invoke. This method is called at the end of AbstractComponent's rotateY method.- Parameters:
- angle- rotation angle in radians
- See Also:
 
- 
onRotateZprotected void onRotateZ(double angle) Classes extending AbstractComponent should implement onRotateZ so that any additional geometric data they contain is rotated appropriately when AbstractComponent's rotateZ method is invoke. This method is called at the end of AbstractComponent's rotateZ method.- Parameters:
- angle- rotation angle in radians
- See Also:
 
- 
showpublic void show()Description copied from interface:ComponentInvokesSystem.out.println(this).
- 
toString
 
-