/** * Recalculates the borders of this entity container including * invisible entities. */ void RS_EntityContainer::forcedCalculateBorders() { //RS_DEBUG->print("RS_EntityContainer::calculateBorders"); resetBorders(); for (RS_Entity* e: entities){ //RS_Layer* layer = e->getLayer(); if (e->isContainer()) { ((RS_EntityContainer*)e)->forcedCalculateBorders(); } else { e->calculateBorders(); } adjustBorders(e); } // needed for correcting corrupt data (PLANS.dxf) if (minV.x>maxV.x || minV.x>RS_MAXDOUBLE || maxV.x>RS_MAXDOUBLE || minV.x<RS_MINDOUBLE || maxV.x<RS_MINDOUBLE) { minV.x = 0.0; maxV.x = 0.0; } if (minV.y>maxV.y || minV.y>RS_MAXDOUBLE || maxV.y>RS_MAXDOUBLE || minV.y<RS_MINDOUBLE || maxV.y<RS_MINDOUBLE) { minV.y = 0.0; maxV.y = 0.0; } //RS_DEBUG->print(" borders: %f/%f %f/%f", minV.x, minV.y, maxV.x, maxV.y); //printf("borders: %lf/%lf %lf/%lf\n", minV.x, minV.y, maxV.x, maxV.y); //RS_Entity::calculateBorders(); }
/** * Erases all entities in this container and resets the borders.. */ void RS_EntityContainer::clear() { if (autoDelete) { while (!entities.isEmpty()) delete entities.takeFirst(); } else entities.clear(); resetBorders(); }
/** * Updates the internal polygon of this spline. Called when the * spline or it's data, position, .. changes. */ void RS_Spline::update() { RS_DEBUG->print("RS_Spline::update"); clear(); if (isUndone()) { return; } if (data.degree<1 || data.degree>3) { RS_DEBUG->print("RS_Spline::update: invalid degree: %d", data.degree); return; } if (data.controlPoints.size() < data.degree+1) { RS_DEBUG->print("RS_Spline::update: not enough control points"); return; } resetBorders(); std::vector<RS_Vector> tControlPoints = data.controlPoints; if (data.closed) { for (size_t i=0; i<data.degree; ++i) { tControlPoints.push_back(data.controlPoints.at(i)); } } const size_t npts = tControlPoints.size(); // order: const size_t k = data.degree+1; // resolution: const size_t p1 = getGraphicVariableInt("$SPLINESEGS", 8) * npts; std::vector<double> h(npts+1, 1.); std::vector<RS_Vector> p(p1, {0., 0.}); if (data.closed) { rbsplinu(npts,k,p1,tControlPoints,h,p); } else { rbspline(npts,k,p1,tControlPoints,h,p); } RS_Vector prev{}; for (auto const& vp: p) { if (prev.valid) { RS_Line* line = new RS_Line{this, prev, vp}; line->setLayer(nullptr); line->setPen(RS2::FlagInvalid); addEntity(line); } prev = vp; minV = RS_Vector::minimum(prev, minV); maxV = RS_Vector::maximum(prev, maxV); } }
void RS_Solid::calculateBorders() { resetBorders(); for (int i=0; i<4; ++i) { if (data.corner[i].valid) { minV = RS_Vector::minimum(minV, data.corner[i]); maxV = RS_Vector::maximum(maxV, data.corner[i]); } } }
/** * Initialisation. Called from all constructors. */ void RS_Entity::init() { resetBorders(); setFlags(RS2::FlagVisible); // // updateEnabled = true; setLayerToActive(); initId(); }
/** * Initialisation. Called from all constructors. */ void RS_Entity::init() { resetBorders(); setFlag(RS2::FlagVisible); //layer = NULL; //pen = RS_Pen(); updateEnabled = true; setLayerToActive(); setPenToActive(); initId(); }
void RS_Solid::calculateBorders() { resetBorders(); for (int i = RS_SolidData::FirstCorner; i < RS_SolidData::MaxCorners; ++i) { if (data.corner[i].valid) { minV = RS_Vector::minimum( minV, data.corner[i]); maxV = RS_Vector::maximum( maxV, data.corner[i]); } } }
/** * Recalculates the borders of this entity container. */ void RS_EntityContainer::calculateBorders() { RS_DEBUG->print("RS_EntityContainer::calculateBorders"); resetBorders(); for (RS_Entity* e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone)) { RS_Layer* layer = e->getLayer(); RS_DEBUG->print("RS_EntityContainer::calculateBorders: " "isVisible: %d", (int)e->isVisible()); if (e->isVisible() && (layer==NULL || !layer->isFrozen())) { e->calculateBorders(); adjustBorders(e); } } RS_DEBUG->print("RS_EntityContainer::calculateBorders: size 1: %f,%f", getSize().x, getSize().y); // needed for correcting corrupt data (PLANS.dxf) if (minV.x>maxV.x || minV.x>RS_MAXDOUBLE || maxV.x>RS_MAXDOUBLE || minV.x<RS_MINDOUBLE || maxV.x<RS_MINDOUBLE) { minV.x = 0.0; maxV.x = 0.0; } if (minV.y>maxV.y || minV.y>RS_MAXDOUBLE || maxV.y>RS_MAXDOUBLE || minV.y<RS_MINDOUBLE || maxV.y<RS_MINDOUBLE) { minV.y = 0.0; maxV.y = 0.0; } RS_DEBUG->print("RS_EntityCotnainer::calculateBorders: size: %f,%f", getSize().x, getSize().y); //RS_DEBUG->print(" borders: %f/%f %f/%f", minV.x, minV.y, maxV.x, maxV.y); //printf("borders: %lf/%lf %lf/%lf\n", minV.x, minV.y, maxV.x, maxV.y); //RS_Entity::calculateBorders(); }
/** * Updates the internal polygon of this spline. Called when the * spline or it's data, position, .. changes. */ void RS_Spline::update() { RS_DEBUG->print("RS_Spline::update"); clear(); if (isUndone()) { return; } if (data.degree<1 || data.degree>3) { RS_DEBUG->print("RS_Spline::update: invalid degree: %d", data.degree); return; } if (data.controlPoints.size() < data.degree+1) { RS_DEBUG->print("RS_Spline::update: not enough control points"); return; } resetBorders(); std::vector<RS_Vector> tControlPoints = data.controlPoints; if (data.closed) { for (size_t i=0; i<data.degree; ++i) { tControlPoints.push_back(data.controlPoints.at(i)); } } size_t i; const size_t npts = tControlPoints.size(); // order: const size_t k = data.degree+1; // resolution: const size_t p1 = getGraphicVariableInt("$SPLINESEGS", 8) * npts; std::vector<double> b(npts*3+1, 0.); std::vector<double> h(npts+1, 1.); std::vector<double> p(3*p1, 0.); i = 1; for (size_t it = 0; it < tControlPoints.size(); ++it) { b[i] = tControlPoints.at(it).x; b[i+1] = tControlPoints.at(it).y; RS_DEBUG->print("RS_Spline::update: b[%d]: %f/%f", i, b[i], b[i+1]); i+=3; } if (data.closed) { rbsplinu(npts,k,p1,b,h,p); } else { rbspline(npts,k,p1,b,h,p); } RS_Vector prev(false); for (i = 1; i <= 3*p1; i += 3) { if (prev.valid) { RS_Line* line = new RS_Line(this, RS_LineData(prev, RS_Vector(p[i], p[i+1]))); line->setLayer(nullptr); line->setPen(RS_Pen(RS2::FlagInvalid)); addEntity(line); } prev = RS_Vector(p[i], p[i+1]); minV = RS_Vector::minimum(prev, minV); maxV = RS_Vector::maximum(prev, maxV); } }
/** * Updates the internal polygon of this spline. Called when the * spline or it's data, position, .. changes. */ void RS_Spline::update() { RS_DEBUG->print("RS_Spline::update"); clear(); if (isUndone()) { return; } if (data.degree<1 || data.degree>3) { RS_DEBUG->print("RS_Spline::update: invalid degree: %d", data.degree); return; } if (data.controlPoints.size() < data.degree+1) { RS_DEBUG->print("RS_Spline::update: not enough control points"); return; } resetBorders(); QList<RS_Vector> tControlPoints = data.controlPoints; if (data.closed) { for (int i=0; i<data.degree; ++i) { tControlPoints.append(data.controlPoints.at(i)); } } int i; int npts = tControlPoints.count(); // order: int k = data.degree+1; // resolution: int p1 = getGraphicVariableInt("$SPLINESEGS", 8) * npts; double* b = new double[npts*3+1]; double* h = new double[npts+1]; double* p = new double[p1*3+1]; i = 1; for (int it = 0; it < tControlPoints.size(); ++it) { b[i] = tControlPoints.at(it).x; b[i+1] = tControlPoints.at(it).y; b[i+2] = 0.0; RS_DEBUG->print("RS_Spline::update: b[%d]: %f/%f", i, b[i], b[i+1]); i+=3; } // set all homogeneous weighting factors to 1.0 for (i=1; i <= npts; i++) { h[i] = 1.0; } for (i = 1; i <= 3*p1; i++) { p[i] = 0.0; } if (data.closed) { rbsplinu(npts,k,p1,b,h,p); } else { rbspline(npts,k,p1,b,h,p); } RS_Vector prev(false); for (i = 1; i <= 3*p1; i=i+3) { if (prev.valid) { RS_Line* line = new RS_Line(this, RS_LineData(prev, RS_Vector(p[i], p[i+1]))); line->setLayer(NULL); line->setPen(RS_Pen(RS2::FlagInvalid)); addEntity(line); } prev = RS_Vector(p[i], p[i+1]); minV = RS_Vector::minimum(prev, minV); maxV = RS_Vector::maximum(prev, maxV); } delete[] b; delete[] h; delete[] p; }
/** * Erases all entities in this container and resets the borders.. */ void RS_EntityContainer::clear() { entities.clear(); resetBorders(); }