void SBConvolve::SBConvolveImpl::add(const SBProfile& rhs) { dbg<<"Start SBConvolveImpl::add. Adding item # "<<_plist.size()+1<<std::endl; // Add new terms(s) to the _plist: assert(GetImpl(rhs)); const SBProfileImpl* p = GetImpl(rhs); const SBConvolveImpl* sbc = dynamic_cast<const SBConvolveImpl*>(p); const SBAutoConvolve::SBAutoConvolveImpl* sbc2 = dynamic_cast<const SBAutoConvolve::SBAutoConvolveImpl*>(p); const SBAutoCorrelate::SBAutoCorrelateImpl* sbc3 = dynamic_cast<const SBAutoCorrelate::SBAutoCorrelateImpl*>(p); if (sbc) { dbg<<" (Item is really "<<sbc->_plist.size()<<" items.)"<<std::endl; // If rhs is an SBConvolve, copy its list here for (ConstIter pptr = sbc->_plist.begin(); pptr!=sbc->_plist.end(); ++pptr) { if (!pptr->isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!pptr->isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(*pptr); } } else if (sbc2) { dbg<<" (Item is really AutoConvolve.)"<<std::endl; // If rhs is an SBAutoConvolve, put two of its item here: const SBProfile& obj = sbc2->getAdaptee(); if (!obj.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!obj.isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(obj); _plist.push_back(obj); } else if (sbc3) { dbg<<" (Item is really AutoCorrelate items.)"<<std::endl; // If rhs is an SBAutoCorrelate, put its item and 180 degree rotated verion here: const SBProfile& obj = sbc3->getAdaptee(); if (!obj.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!obj.isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(obj); SBProfile temp = obj; temp.applyRotation(180. * degrees); _plist.push_back(temp); } else { if (!rhs.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!rhs.isAnalyticX() && _real_space) throw SBError("Real-space SBConvolve requires members to be analytic in x"); _plist.push_back(rhs); } }
void SBConvolve::SBConvolveImpl::add(const SBProfile& sbp) { dbg<<"Start SBConvolveImpl::add. Adding item # "<<_plist.size()+1<<std::endl; // Add new terms(s) to the _plist: assert(GetImpl(sbp)); const SBProfileImpl* p = GetImpl(sbp); const SBConvolveImpl* sbc = dynamic_cast<const SBConvolveImpl*>(p); const SBAutoConvolve::SBAutoConvolveImpl* sbc2 = dynamic_cast<const SBAutoConvolve::SBAutoConvolveImpl*>(p); const SBAutoCorrelate::SBAutoCorrelateImpl* sbc3 = dynamic_cast<const SBAutoCorrelate::SBAutoCorrelateImpl*>(p); if (sbc) { dbg<<" (Item is really "<<sbc->_plist.size()<<" items.)"<<std::endl; // If sbp is an SBConvolve, copy its list here for (ConstIter pptr = sbc->_plist.begin(); pptr!=sbc->_plist.end(); ++pptr) add(*pptr); } else if (sbc2) { dbg<<" (Item is really AutoConvolve.)"<<std::endl; // If sbp is an SBAutoConvolve, put two of its item here: const SBProfile& obj = sbc2->getAdaptee(); add(obj); add(obj); } else if (sbc3) { dbg<<" (Item is really AutoCorrelate items.)"<<std::endl; // If sbp is an SBAutoCorrelate, put its item and 180 degree rotated verion here: const SBProfile& obj = sbc3->getAdaptee(); add(obj); SBProfile temp = obj.rotate(180. * degrees); add(temp); } else { if (!sbp.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!sbp.isAnalyticX() && _real_space) throw SBError("Real-space SBConvolve requires members to be analytic in x"); _plist.push_back(sbp); } _x0 += sbp.centroid().x; _y0 += sbp.centroid().y; _isStillAxisymmetric = _isStillAxisymmetric && sbp.isAxisymmetric(); _fluxProduct *= sbp.getFlux(); }