void AxisAlignedBox::merge(const AxisAlignedBox& rhs) { // Do nothing if rhs null, or this is infinite if ((rhs.mExtent == EXTENT_NULL) || (mExtent == EXTENT_INFINITE)) { return; } // Otherwise if rhs is infinite, make this infinite, too else if (rhs.mExtent == EXTENT_INFINITE) { mExtent = EXTENT_INFINITE; } // Otherwise if current null, just take rhs else if (mExtent == EXTENT_NULL) { setExtents(rhs.mMinimum, rhs.mMaximum); } // Otherwise merge else { Vector3 min = mMinimum; Vector3 max = mMaximum; max.makeCeil(rhs.mMaximum); min.makeFloor(rhs.mMinimum); setExtents(min, max); } }
int main() { dmcr::SceneFactory factory = [](const std::string& /*str*/) { auto scene = std::make_shared<dmcr::KDTreeScene>(); auto& c = scene->camera(); c.setPosition(dmcr::Vector3f(9, 3, 5)); c.setFov(M_PI / 2); c.setAspect(640.0 / 480.0); c.setLookAt(dmcr::Vector3f(6, 6, 0)); scene->beginAddObjects(); auto b = dmcr::make_unique<dmcr::Box>(); b->setPosition(dmcr::Vector3f(5, 0, 0)); b->setExtents(dmcr::Vector3f(10, 0.2, 10)); b->setColor({1, 1, 1}); b->setEmit(1); scene->addObject(std::move(b)); b = dmcr::make_unique<dmcr::Box>(); b->setPosition(dmcr::Vector3f(5, 11, 0)); b->setExtents(dmcr::Vector3f(10, 0.2, 10)); b->setColor({1, 1, 1}); scene->addObject(std::move(b)); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { auto a = dmcr::make_unique<dmcr::Sphere>(); a->setPosition(dmcr::Vector3f(i + 0.5, j + 0.5, 0.5)); a->setRadius(0.2); a->setColor({1.0, 1.0, 1.0}); a->setBlur(0.8); a->setOpacity(1.0); scene->addObject(std::move(a)); } } scene->endAddObjects(); std::cout << "Scene constructed." << std::endl; return scene; }; dmcr::TaskManager manager(factory); BenchmarkTaskProvider provider; manager.onNewTask(&provider, 1, 640, 480, 25, ""); for (;;) sleep(1); }
void bbox::merge(const bbox& b2) { vec3 mnn(mn), mxx(mx); mxx.ceil(b2.mx); mnn.floor(b2.mn); setExtents(mnn, mxx); }
Extents::Extents( double xMin, double xMax, double yMin, double yMax, double zMin, double zMax ) { setExtents( xMin, xMax, yMin, yMax, zMin, zMax); }
void AxisAlignedBox::scale(const Vector3& s) { // Do nothing if current null or infinite if (mExtent != EXTENT_FINITE) return; // NB assumes centered on origin Vector3 min = mMinimum * s; Vector3 max = mMaximum * s; setExtents(min, max); }
AABB::AABB(const CVector3& minPt, const CVector3& maxPt, bool minMaxRep) : mCenter(minPt), mHalfExtents(maxPt) { if( minMaxRep ) { //Generate vector, which will be the full extents. Half this. CVector3 h_extents = (maxPt - minPt) * 0.5f; CVector3 center = minPt + h_extents; setCenter(minPt); setExtents(h_extents); } }
WireCube::WireCube( double xMin, double xMax, double yMin, double yMax, double zMin, double zMax ) { setExtents( xMin, xMax, yMin, yMax, zMin, zMax); m_bShowAxes = false; m_WhichHilight = NoAxis; }
AABB AABB::convertToMinMaxPts() { //@TODO: 2 continue here. //Take center, and go back negative half extents. CVector3 minPt = mCenter - extents(); CVector3 maxPt = mCenter + extents(); CVector3 vec = maxPt; setCenter(minPt); //center acts as the miniumum CVector3 in the MinMax representation. setExtents(maxPt); // return AABB(); }
/** Generate an empty MDBox with 3 dimensions, split 10x5x2 !!! Box controller has to be deleted saparately to avoid memory leaks in tests !!!!**/ MDBox<MDLeanEvent<3>, 3> *makeMDBox3() { // Split at 5 events auto splitter = new BoxController(3); splitter->setSplitThreshold(5); // Splits into 10x5x2 boxes splitter->setSplitInto(10); splitter->setSplitInto(1, 5); splitter->setSplitInto(2, 2); // Set the size to 10.0 in all directions auto out = new MDBox<MDLeanEvent<3>, 3>(splitter); for (size_t d = 0; d < 3; ++d) { out->setExtents(d, 0.0, 10.0); } out->calcVolume(); return out; }
RectangleAnnotation::RectangleAnnotation(Component *pParent) : ShapeAnnotation(pParent) { // set the default values GraphicItem::setDefaults(); FilledShape::setDefaults(); ShapeAnnotation::setDefaults(); // create a grey rectangle setLineColor(QColor(0, 0, 0)); setFillColor(QColor(240, 240, 240)); setFillPattern(StringHandler::FillSolid); QList<QPointF> extents; extents << QPointF(-100, -100) << QPointF(100, 100); setExtents(extents); setPos(mOrigin); setRotation(mRotation); }
void AxisAlignedBox::merge(const Vector3& point) { switch (mExtent) { case EXTENT_NULL: // if null, use this point setExtents(point, point); return; case EXTENT_FINITE: mMaximum.makeCeil(point); mMinimum.makeFloor(point); return; case EXTENT_INFINITE: // if infinite, makes no difference return; } PE_ASSERT(false && "Never reached"); }
void AxisAlignedBox::transformAffine(const Matrix4& m) { PE_ASSERT(m.isAffine()); // Do nothing if current null or infinite if (mExtent != EXTENT_FINITE) return; Vector3 centre = getCenter(); Vector3 halfSize = getHalfSize(); Vector3 newCentre = m.transformAffine(centre); Vector3 newHalfSize( Math::Abs(m[0][0]) * halfSize.x + Math::Abs(m[0][1]) * halfSize.y + Math::Abs(m[0][2]) * halfSize.z, Math::Abs(m[1][0]) * halfSize.x + Math::Abs(m[1][1]) * halfSize.y + Math::Abs(m[1][2]) * halfSize.z, Math::Abs(m[2][0]) * halfSize.x + Math::Abs(m[2][1]) * halfSize.y + Math::Abs(m[2][2]) * halfSize.z); setExtents(newCentre - newHalfSize, newCentre + newHalfSize); }
void bbox::transform(const mtx& matrix) { vec3 min, max, temp; bool first = true; for(int i = 0 ; i < 8 ; ++i) { temp = matrix * corners[i]; if(first || temp.x > max.x) max.x = temp.x; if(first || temp.y > max.y) max.y = temp.y; if(first || temp.z > max.z) max.z = temp.z; if(first || temp.x < min.x) min.x = temp.x; if(first || temp.y < min.y) min.y = temp.y; if(first || temp.z < min.z) min.z = temp.z; first = false; } setExtents(min, max); }
/*! * \brief BitmapAnnotation::BitmapAnnotation * Used by OMSimulator FMU ModelWidget\n * We always make this shape as inherited shape since its not allowed to be modified. * \param classFileName * \param pGraphicsView */ BitmapAnnotation::BitmapAnnotation(QString classFileName, GraphicsView *pGraphicsView) : ShapeAnnotation(true, pGraphicsView, 0) { mpComponent = 0; mClassFileName = classFileName; // set the default values GraphicItem::setDefaults(); ShapeAnnotation::setDefaults(); // set users default value by reading the settings file. ShapeAnnotation::setUserDefaults(); QList<QPointF> extents; extents << QPointF(-100, -100) << QPointF(100, 100); setExtents(extents); setPos(mOrigin); setRotation(mRotation); setShapeFlags(true); setFileName(mClassFileName); if (!mFileName.isEmpty() && QFile::exists(mFileName)) { mImage.load(mFileName); } else { mImage = QImage(":/Resources/icons/bitmap-shape.svg"); } }
Extents::Extents() { setExtents(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5); }
/*! Scales this box by \a factor. The minimum() and maximum() extents are multiplied by \a factor. To scale a box about its center(), use the following: \code QVector3D c = box.center(); box.translate(-c); box.scale(factor); box.translate(c); \endcode \sa scaled(), translate(), transform() */ void QBox3D::scale(qreal factor) { if (boxtype == Finite) setExtents(mincorner * factor, maxcorner * factor); }
/*! Scales this box by the components of \a vector. The minimum() and maximum() extents are multiplied by \a vector. To scale a box about its center(), use the following: \code QVector3D c = box.center(); box.translate(-c); box.scale(vector); box.translate(c); \endcode \sa scaled(), translate(), transform() */ void QBox3D::scale(const QVector3D& vector) { if (boxtype == Finite) setExtents(mincorner * vector, maxcorner * vector); }
WireCube::WireCube() { setExtents(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5); m_bShowAxes = false; m_WhichHilight = NoAxis; }