Include file: entity.h
CAMgeometric entity is the base class for all geometric entities. The functions listed below are those member functions that are shared by all classes derived from the CAMgometricEntity class. By programming using these member functions one can develop procedures which are independent of any particular type of geometric entity.
Chris Anderson © UCLA 6/27/97
CAMgeometricEntity() CAMgeometricEntity(const CAMgeometricEntity)
ostream& operator <<(ostream& out_stream, const CAMgeometricEntity& A) void output(ostream& O) istream& operator >>(istream& in_stream, CAMgeometricEntity& A) void input(istream& I)
void scaleBy(double alpha) void rotateBy(double theta) void translateBy(double xInc, double yInc) void translateTo(double xPos, double yPos)
double getMinX() double getMaxX() double getMinY() double getMaxY()double getTotalArcLength() int getParametricCoordinate(double& s, double x, double y) int getParametricCoordinate(double& s, double s1, double s2, double x, double y) double getXcoordinate(double s) double getYcoordinate(double s) void getUnitNormal(double s, double& nX, double& nY) void getUnitTangent(double s, double& tX, double& tY)
int getInteriorPoint(double& x, double& y)
int interiorExteriorTest(double x, double y) int boundaryTest(double x, double y) int boundaryTest(double s1, double s2, double x, double y) int getSegmentIntersection(double& s, double xA, double yA, double xB, double yB) int getSegmentIntersection(double& s, double s1, double s2, double xA, double yA, double xB, double yB)
void initialize() void initialize(const CAMgeometricEntity& E)
int operator ==(const CAMgeometricEntity& E) int operator !=(const CAMgeometricEntity& E)
ostream& operator <<(ostream& out_stream, const CAMgeometricEntity& A)
This operator outputs a text description of the entity. It is the "inverse" operation to the >> operator. This routine simply calls the output member function. (This is done so that the << operator applied to a derived class calls that class's output function).
This operator outputs a text description of the entity to the output stream O. It is the "inverse" of the input operator.
istream& operator >>(istream& in_stream, CAMgeometricEntity& A)
This operator inputs a text description of the entity. It is the "inverse" operation to the << operator. This routine simply calls the input member function. (This is done so that the >> operator applied to a derived class calls that class's input function).
void input(istream& I)This operator inputs a text description of the entity to the input stream I. It is the "inverse" of the output function.
Scales the entity by the factor alpha.
Rotates the entity by the factor theta. For some geometric entities, such as CAMxyRectangle, the rotations are restricted.
void translateBy(double xInc, double yInc)
The entity is translated by the vector (xInc, yInc).
void translateTo(double xPos, double yPos)
The entity is translated to the position (xPos, yPos).
This routine returns a pointer to a null terminated string containing the entity class name (= type).
Returns the minimial x coordinate of the entity.
Returns the maximial x coordinate of the entity.
Returns the minimial y coordinate of the entity.
Returns the maximial y coordinate of the entity.
double getTotalArcLength()
Returns the total arc length of the boundary of the entity.
int getParametricCoordinate(double& s, double x, double y)
This routine gets the parametric coordinate of the point (x,y). If the point is not on the curve the routine returns 0, otherwise the routine returns a value of 1, and the variable s is assigned the parametric coordinate value.
int getParametricCoordinate(double& s, double s1, double s2, double x, double y)
This routine gets the parametric coordinate of the point (x,y) when the corresponding parametric coordinate of the point is between s1 and s2. If the point is not on the curve within the parametric coordinate range [s1,s2] the routine returns 0, otherwise the routine returns a value of 1, and the variable s is assigned to the parametric coordinate value.
double getXcoordinate(double s)
Given a point on on the boundary of an entity with parametric coordinate value s, this routine returns the x coordinate of that point.
double getYcoordinate(double s)
Given a point on on the boundary of an entity with parametric coordinate value s, this routine returns the y coordinate of that point.
void getUnitNormal(double, double& nX, double& nY)
Given a point on on the boundary of an entity with parametric coordinate value s, this routine sets nX and nY to be the components of the unit outward normal. (If the orientation of the entity is 1, then the entity is parameterized "counter-clockwise"). For entities with corners, then entity specific decisions are made about what constitutes the unit normal.
void getUnitTangent(double, double& tX, double& tY)
Given a point on on the boundary of an entity with parametric coordinate value s, this routine sets tX and tY to be the components of the unit tangent. . (If the orientation of the entity is 1, then the entity is parameterized "counter-clockwise"). For entities with corners, then entity specific decisions are made about what constitutes the unit normal.
int getInteriorPoint(double& x, double& y)Sets the values of x and y to be a point inside the entity. If a value is not set, the function returns 0, otherwise the function returns 1.
int interiorExteriorTest(double x, double y)
Returns +1 if the test point (x, y) is interior to the entity, -1 if point is exterior to the entity and returns 0 if the point is on the boundary of the entity.
int boundaryTest(double x, double y)
Returns 1 if the point (x, y) is on the boundary of the entity otherwise returns 0.
int boundaryTest(double s1, double s2, double x, double y)
Returns 1 if the point (x, y) is on the boundary of the entity and has a parametric coordinate in the range [s1, s2], otherwise returns 0.
int getSegmentIntersection(double& intersectPoint, double x_a, double y_a, double x_b, double y_b)
This routine sets the value of intersectPoint to be the parametric coordinate of the intersection of the boundary of the entity with the directed line segment from (x_a, y_a) to (x_b, y_b). If the segment intersects the entity more than once, then intersectPoint is set to that point which is closest to (x_a, y_a). The function returns 1 if an intersection point is found, and 0 if an intersection point is not found.
int getSegmentIntersection(double& intersectPoint, double s1, double s2, double x_a, double y_a, double x_b, double y_b)
This routine sets the value of intersectPoint to be the parametric coordinate of the intersection of the boundary of the entity with the directed line segment from (x_a, y_a) to (x_b, y_b). The range of parametric coordinates considered is from s1 to s2. If the segment intersects the entity more than once, then intersectPoint is set to that point which is closest to (x_a, y_a). The function returns 1 if an intersection point is found, and 0 if an intersection point is not found. Because there is a restricted range of parametric coordinate values considered, for some types of entities this routine is considerable faster than the same function in which the parametric range is unrestricted.
Equivalent to the null constructor for the entity. Included so that existing instances of classes can "call" the constructor for the class.
void initialize(const CAMgeometricEntity& E)
Equivalent to the copy constructor for the entity. Included so that existing instances of classes can "call" the copy constructor for the class.
int operator ==(const CAMgeometricEntity& E)
Returns 1 if the constructor data defining the two geometric entities is the same. Returns 0 otherwise.
int operator !=(const CAMgeometricEntity& E)
Returns 0 if the constructor data defining the two geometric entities is the same. Returns 1 otherwise.