double Cube::value(const Vector3 &pos) const { // This is a really expensive operation and so should be avoided // Interpolate the value at the supplied vector - trilinear interpolation... Vector3 delta = pos - m_min; // Find the integer low and high corners Vector3i lC(static_cast<int>(delta.x() / m_spacing.x()), static_cast<int>(delta.y() / m_spacing.y()), static_cast<int>(delta.z() / m_spacing.z())); Vector3i hC(lC.x() + 1, lC.y() + 1, lC.z() + 1); // So there are six corners in total - work out the delta of the position // and the low corner Vector3 P((delta.x() - lC.x()*m_spacing.x()) / m_spacing.x(), (delta.y() - lC.y()*m_spacing.y()) / m_spacing.y(), (delta.z() - lC.z()*m_spacing.z()) / m_spacing.z()); Vector3 dP = Vector3(1.0, 1.0, 1.0) - P; // Now calculate and return the interpolated value return value(lC.x(), lC.y(), lC.z()) * dP.x() * dP.y() * dP.z() + value(hC.x(), lC.y(), lC.z()) * P.x() * dP.y() * dP.z() + value(lC.x(), hC.y(), lC.z()) * dP.x() * P.y() * dP.z() + value(lC.x(), lC.y(), hC.z()) * dP.x() * dP.y() * P.z() + value(hC.x(), lC.y(), hC.z()) * P.x() * dP.y() * P.z() + value(lC.x(), hC.y(), hC.z()) * dP.x() * P.y() * P.z() + value(hC.x(), hC.y(), lC.z()) * P.x() * P.y() * dP.z() + value(hC.x(), hC.y(), hC.z()) * P.x() * P.y() * P.z(); }
void TRoomModal::writeToForm(KAEntity *ent){ ClassRoom *cr=dynamic_cast<ClassRoom*>(ent); Edit1->Text=cr->name; Edit2->Text=IntToStr(cr->capacity); CheckBox1->Checked=cr->isactual; CheckBox2->Checked=cr->isrent; Specifics *specifics=App::db->getSpecifics(); std::sort(specifics->begin(), specifics->end()); std::sort(cr->specifics.begin(), cr->specifics.end()); std::vector<KAEntity*> lC(specifics->size()); std::vector<KAEntity*>::iterator it= std::set_difference(specifics->begin(), specifics->end(),cr->specifics.begin(), cr->specifics.end(),lC.begin()); lC.resize(it-lC.begin()); //std::sort(lC.begin(),lC.end(),specSort); ListBox1->Clear(); for(int i=0;i<lC.size();++i){ this->ListBox1->AddItem(dynamic_cast<Specific*>(lC[i])->name,reinterpret_cast<TObject*>(lC[i])); } //std::sort(cr->specifics.begin(), cr->specifics.end(),specSort); ListBox2->Clear(); for(int i=0;i<cr->specifics.size();++i){ this->ListBox2->AddItem(cr->specifics[i]->name,reinterpret_cast<TObject*>(cr->specifics[i])); } }