* entities. Usually that's an Drawing entity but
* it can also be a polyline, text, ...
*/
-RS_Information::RS_Information(RS_EntityContainer& container)
+Information::Information(EntityContainer& container)
{
this->container = &container;
}
* @return true: if the entity is a dimensioning enity.
* false: otherwise
*/
-bool RS_Information::isDimension(RS2::EntityType type)
+bool Information::isDimension(RS2::EntityType type)
{
if (type == RS2::EntityDimAligned || type == RS2::EntityDimLinear
|| type == RS2::EntityDimRadial || type == RS2::EntityDimDiametric
* @retval true the entity can be trimmed.
* i.e. it is in a graphic or in a polyline.
*/
-bool RS_Information::isTrimmable(RS_Entity * e)
+bool Information::isTrimmable(Entity * e)
{
if (e)
{
* @retval true the two entities can be trimmed to each other;
* i.e. they are in a graphic or in the same polyline.
*/
-bool RS_Information::isTrimmable(RS_Entity * e1, RS_Entity * e2)
+bool Information::isTrimmable(Entity * e1, Entity * e2)
{
if (e1 && e2)
{
&& e1->getParent()==e2->getParent())
{
// in the same polyline
- RS_EntityContainer * pl = e1->getParent();
+ EntityContainer * pl = e1->getParent();
int idx1 = pl->findEntity(e1);
int idx2 = pl->findEntity(e2);
- RS_DEBUG->print("RS_Information::isTrimmable: idx1: %d, idx2: %d", idx1, idx2);
+ DEBUG->print("Information::isTrimmable: idx1: %d, idx2: %d", idx1, idx2);
if (abs(idx1 - idx2) == 1 || abs(idx1 - idx2) == pl->count() - 1)
{
* if there are no elements at all in this graphics
* container.
*/
-Vector RS_Information::getNearestEndpoint(const Vector & coord, double * dist) const
+Vector Information::getNearestEndpoint(const Vector & coord, double * dist) const
{
return container->getNearestEndpoint(coord, dist);
}
* if there are no elements at all in this graphics
* container.
*/
-Vector RS_Information::getNearestPointOnEntity(const Vector & coord,
- bool onEntity, double * dist, RS_Entity ** entity) const
+Vector Information::getNearestPointOnEntity(const Vector & coord,
+ bool onEntity, double * dist, Entity ** entity) const
{
return container->getNearestPointOnEntity(coord, onEntity, dist, entity);
}
* @return the entity found or NULL if there are no elements
* at all in this graphics container.
*/
-RS_Entity * RS_Information::getNearestEntity(const Vector & coord,
+Entity * Information::getNearestEntity(const Vector & coord,
double * dist, RS2::ResolveLevel level) const
{
return container->getNearestEntity(coord, dist, level);
* @return All intersections of the two entities. The tangent flag in
* VectorSolutions is set if one intersection is a tangent point.
*/
-VectorSolutions RS_Information::getIntersection(RS_Entity * e1,
- RS_Entity * e2, bool onEntities)
+VectorSolutions Information::getIntersection(Entity * e1,
+ Entity * e2, bool onEntities)
{
VectorSolutions ret;
double tol = 1.0e-4;
{
if (e2->rtti() == RS2::EntityEllipse)
{
- RS_Entity * tmp = e1;
+ Entity * tmp = e1;
e1 = e2;
e2 = tmp;
}
if (e2->rtti() == RS2::EntityLine)
{
- RS_Ellipse * ellipse = (RS_Ellipse *)e1;
- ret = getIntersectionLineEllipse((RS_Line *)e2, ellipse);
+ Ellipse * ellipse = (Ellipse *)e1;
+ ret = getIntersectionLineEllipse((Line *)e2, ellipse);
tol = 1.0e-1;
}
// ellipse / arc, ellipse / ellipse: not supported:
}
else
{
- RS_Entity * te1 = e1;
- RS_Entity * te2 = e2;
+ Entity * te1 = e1;
+ Entity * te2 = e2;
// entity copies - so we only have to deal with lines and arcs
- RS_Line l1(NULL, RS_LineData(Vector(0.0, 0.0), Vector(0.0, 0.0)));
- RS_Line l2(NULL, RS_LineData(Vector(0.0, 0.0), Vector(0.0, 0.0)));
+ Line l1(NULL, LineData(Vector(0.0, 0.0), Vector(0.0, 0.0)));
+ Line l2(NULL, LineData(Vector(0.0, 0.0), Vector(0.0, 0.0)));
- RS_Arc a1(NULL, RS_ArcData(Vector(0.0, 0.0), 1.0, 0.0, 2 * M_PI, false));
- RS_Arc a2(NULL, RS_ArcData(Vector(0.0, 0.0), 1.0, 0.0, 2 * M_PI, false));
+ Arc a1(NULL, ArcData(Vector(0.0, 0.0), 1.0, 0.0, 2 * M_PI, false));
+ Arc a2(NULL, ArcData(Vector(0.0, 0.0), 1.0, 0.0, 2 * M_PI, false));
// convert construction lines to lines:
if (e1->rtti() == RS2::EntityConstructionLine)
{
- RS_ConstructionLine * cl = (RS_ConstructionLine *)e1;
+ ConstructionLine * cl = (ConstructionLine *)e1;
l1.setStartpoint(cl->getPoint1());
l1.setEndpoint(cl->getPoint2());
te1 = &l1;
if (e2->rtti() == RS2::EntityConstructionLine)
{
- RS_ConstructionLine * cl = (RS_ConstructionLine *)e2;
+ ConstructionLine * cl = (ConstructionLine *)e2;
l2.setStartpoint(cl->getPoint1());
l2.setEndpoint(cl->getPoint2());
te2 = &l2;
// convert circles to arcs:
if (e1->rtti() == RS2::EntityCircle)
{
- RS_Circle * c = (RS_Circle *)e1;
- RS_ArcData data(c->getCenter(), c->getRadius(), 0.0, 2 * M_PI, false);
+ Circle * c = (Circle *)e1;
+ ArcData data(c->getCenter(), c->getRadius(), 0.0, 2 * M_PI, false);
a1.setData(data);
te1 = &a1;
}
if (e2->rtti() == RS2::EntityCircle)
{
- RS_Circle * c = (RS_Circle *)e2;
- RS_ArcData data(c->getCenter(), c->getRadius(), 0.0, 2 * M_PI, false);
+ Circle * c = (Circle *)e2;
+ ArcData data(c->getCenter(), c->getRadius(), 0.0, 2 * M_PI, false);
a2.setData(data);
te2 = &a2;
}
//else
if (te1->rtti() == RS2::EntityLine && te2->rtti() == RS2::EntityLine)
{
- RS_Line * line1 = (RS_Line *)te1;
- RS_Line * line2 = (RS_Line *)te2;
+ Line * line1 = (Line *)te1;
+ Line * line2 = (Line *)te2;
ret = getIntersectionLineLine(line1, line2);
}
// line / arc:
//
else if (te1->rtti() == RS2::EntityLine && te2->rtti() == RS2::EntityArc)
{
- RS_Line * line = (RS_Line *)te1;
- RS_Arc * arc = (RS_Arc *)te2;
+ Line * line = (Line *)te1;
+ Arc * arc = (Arc *)te2;
ret = getIntersectionLineArc(line, arc);
}
// arc / line:
//
else if (te1->rtti() == RS2::EntityArc && te2->rtti() == RS2::EntityLine)
{
- RS_Arc * arc = (RS_Arc *)te1;
- RS_Line * line = (RS_Line *)te2;
+ Arc * arc = (Arc *)te1;
+ Line * line = (Line *)te2;
ret = getIntersectionLineArc(line, arc);
}
// arc / arc:
//
else if (te1->rtti() == RS2::EntityArc && te2->rtti() == RS2::EntityArc)
{
- RS_Arc * arc1 = (RS_Arc *)te1;
- RS_Arc * arc2 = (RS_Arc *)te2;
+ Arc * arc1 = (Arc *)te1;
+ Arc * arc2 = (Arc *)te2;
ret = getIntersectionArcArc(arc1, arc2);
}
else
{
- RS_DEBUG->print("RS_Information::getIntersection:: Unsupported entity type.");
+ DEBUG->print("Information::getIntersection:: Unsupported entity type.");
}
}
/**
* @return Intersection between two lines.
*/
-VectorSolutions RS_Information::getIntersectionLineLine(RS_Line * e1, RS_Line * e2)
+VectorSolutions Information::getIntersectionLineLine(Line * e1, Line * e2)
{
VectorSolutions ret;
/**
* @return One or two intersection points between given entities.
*/
-VectorSolutions RS_Information::getIntersectionLineArc(RS_Line * line, RS_Arc * arc)
+VectorSolutions Information::getIntersectionLineArc(Line * line, Arc * arc)
{
VectorSolutions ret;
Vector delta = p - c;
// root term:
- double term = RS_Math::pow(Vector::dotP(d, delta), 2.0)
- - RS_Math::pow(d.magnitude(), 2.0)
- * (RS_Math::pow(delta.magnitude(), 2.0) - RS_Math::pow(r, 2.0));
+ double term = Math::pow(Vector::dotP(d, delta), 2.0)
+ - Math::pow(d.magnitude(), 2.0)
+ * (Math::pow(delta.magnitude(), 2.0) - Math::pow(r, 2.0));
// no intersection:
if (term<0.0) {
// one or two intersections:
else {
double t1 = (- Vector::dotP(d, delta) + sqrt(term))
- / RS_Math::pow(d.magnitude(), 2.0);
+ / Math::pow(d.magnitude(), 2.0);
double t2;
bool tangent = false;
// two intersections
else {
t2 = (-Vector::dotP(d, delta) - sqrt(term))
- / RS_Math::pow(d.magnitude(), 2.0);
+ / Math::pow(d.magnitude(), 2.0);
}
Vector sol1;
/**
* @return One or two intersection points between given entities.
*/
-VectorSolutions RS_Information::getIntersectionArcArc(RS_Arc * e1, RS_Arc * e2)
+VectorSolutions Information::getIntersectionArcArc(Arc * e1, Arc * e2)
{
VectorSolutions ret;
double s, t1, t2, term;
- s = 1.0/2.0 * ((r1*r1 - r2*r2)/(RS_Math::pow(u.magnitude(), 2.0)) + 1.0);
+ s = 1.0/2.0 * ((r1*r1 - r2*r2)/(Math::pow(u.magnitude(), 2.0)) + 1.0);
- term = (r1*r1)/(RS_Math::pow(u.magnitude(), 2.0)) - s*s;
+ term = (r1*r1)/(Math::pow(u.magnitude(), 2.0)) - s*s;
// no intersection:
if (term<0.0) {
/**
* @return One or two intersection points between given entities.
*/
-VectorSolutions RS_Information::getIntersectionLineEllipse(RS_Line * line, RS_Ellipse * ellipse)
+VectorSolutions Information::getIntersectionLineEllipse(Line * line, Ellipse * ellipse)
{
VectorSolutions ret;
double d = b*b - a*c;
if (d < 0) {
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 0");
+ DEBUG->print("Information::getIntersectionLineEllipse: outside 0");
} else if ( d > 0 ) {
double root = sqrt(d);
double t_a = (-b - root) / a;
/*if ( (t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b) ) {
if ( (t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1) ) {
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 1");
+ DEBUG->print("Information::getIntersectionLineEllipse: outside 1");
}
else {
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: inside 1");
+ DEBUG->print("Information::getIntersectionLineEllipse: inside 1");
}
} else {*/
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 1");
+ DEBUG->print("Information::getIntersectionLineEllipse: intersection 1");
Vector ret1(false);
Vector ret2(false);
//if ( 0 <= t_a && t_a <= 1 ) {
- //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_a<=1");
+ //DEBUG->print("Information::getIntersectionLineEllipse: 0<=t_a<=1");
ret1 = a1.lerp(a2, t_a);
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret1.x, ret1.y);
+ DEBUG->print("Information::getIntersectionLineEllipse: ret1: %f/%f", ret1.x, ret1.y);
//}
//if ( 0 <= t_b && t_b <= 1 ) {
- //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_b<=1");
+ //DEBUG->print("Information::getIntersectionLineEllipse: 0<=t_b<=1");
ret2 = a1.lerp(a2, t_b);
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret2: %f/%f", ret2.x, ret2.y);
+ DEBUG->print("Information::getIntersectionLineEllipse: ret2: %f/%f", ret2.x, ret2.y);
//}
if (ret1.valid && ret2.valid) {
ret = VectorSolutions(ret1, ret2);
} else {
double t = -b/a;
if ( 0 <= t && t <= 1 ) {
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t<=1");
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 2");
+ DEBUG->print("Information::getIntersectionLineEllipse: 0<=t<=1");
+ DEBUG->print("Information::getIntersectionLineEllipse: intersection 2");
ret = VectorSolutions(a1.lerp(a2, t));
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret.get(0).x, ret.get(0).y);
+ DEBUG->print("Information::getIntersectionLineEllipse: ret1: %f/%f", ret.get(0).x, ret.get(0).y);
} else {
- RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 2");
+ DEBUG->print("Information::getIntersectionLineEllipse: outside 2");
}
}
/*
- RS_Arc* arc = new RS_Arc(NULL,
- RS_ArcData(ellipse->getCenter(),
+ Arc* arc = new Arc(NULL,
+ ArcData(ellipse->getCenter(),
ellipse->getMajorRadius(),
ellipse->getAngle1(),
ellipse->getAngle2(),
false));
- RS_Line* other = (RS_Line*)line->clone();
+ Line* other = (Line*)line->clone();
double angle = ellipse->getAngle();
//double ratio = ellipse->getRatio();
* @param onContour Will be set to true if the given point it exactly
* on the contour.
*/
-bool RS_Information::isPointInsideContour(const Vector & point,
- RS_EntityContainer * contour, bool * onContour)
+bool Information::isPointInsideContour(const Vector & point,
+ EntityContainer * contour, bool * onContour)
{
if (contour==NULL) {
- RS_DEBUG->print(RS_Debug::D_WARNING,
- "RS_Information::isPointInsideContour: contour is NULL");
+ DEBUG->print(Debug::D_WARNING,
+ "Information::isPointInsideContour: contour is NULL");
return false;
}
// create ray:
Vector v;
v.setPolar(width*10.0, rayAngle);
- RS_Line ray(NULL, RS_LineData(point, point+v));
+ Line ray(NULL, LineData(point, point+v));
counter = 0;
VectorSolutions sol;
if (onContour)
*onContour = false;
- for(RS_Entity * e=contour->firstEntity(RS2::ResolveAll); e!=NULL;
+ for(Entity * e=contour->firstEntity(RS2::ResolveAll); e!=NULL;
e=contour->nextEntity(RS2::ResolveAll))
{
// intersection(s) from ray with contour entity:
- sol = RS_Information::getIntersection(&ray, e, true);
+ sol = Information::getIntersection(&ray, e, true);
for(int i=0; i<=1; ++i)
{
{
if (e->rtti() == RS2::EntityLine)
{
- RS_Line * line = (RS_Line *)e;
+ Line * line = (Line *)e;
// ray goes through startpoint of line:
if (p.distanceTo(line->getStartpoint()) < 1.0e-4)
{
- if (RS_Math::correctAngle(line->getAngle1()) < M_PI)
+ if (Math::correctAngle(line->getAngle1()) < M_PI)
{
counter++;
sure = false;
// ray goes through endpoint of line:
else if (p.distanceTo(line->getEndpoint()) < 1.0e-4)
{
- if (RS_Math::correctAngle(line->getAngle2()) < M_PI)
+ if (Math::correctAngle(line->getAngle2()) < M_PI)
{
counter++;
sure = false;
}
else if (e->rtti() == RS2::EntityArc)
{
- RS_Arc * arc = (RS_Arc *)e;
+ Arc * arc = (Arc *)e;
if (p.distanceTo(arc->getStartpoint()) < 1.0e-4)
{