本文整理汇总了C++中Interpolator类的典型用法代码示例。如果您正苦于以下问题:C++ Interpolator类的具体用法?C++ Interpolator怎么用?C++ Interpolator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetItemText
void KeyListCtrl::OnDurationText(wxCommandEvent& event)
{
if (m_editing_item == -1)
return;
wxString str = GetItemText(m_editing_item);
long id;
str.ToLong(&id);
VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (!vr_frame)
return;
Interpolator* interpolator = vr_frame->GetInterpolator();
if (!interpolator)
return;
int index = interpolator->GetKeyIndex(int(id));
str = m_duration_text->GetValue();
double duration;
if (str.ToDouble(&duration))
{
interpolator->ChangeDuration(index, duration);
SetText(m_editing_item, 2, str);
}
}
示例2: GetNextItem
void KeyListCtrl::OnAct(wxListEvent &event)
{
long item = GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if (item == -1)
return;
wxString str = GetItemText(item);
long id;
str.ToLong(&id);
VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (!vr_frame)
return;
Interpolator* interpolator = vr_frame->GetInterpolator();
if (!interpolator)
return;
int index = interpolator->GetKeyIndex(int(id));
double time = interpolator->GetKeyTime(index);
VRenderView* view = vr_frame->GetRecorderDlg()->GetView();
if (!view)
view = vr_frame->GetView(0);
if (view)
{
view->m_glview->SetParams(time);
view->RefreshGL();
}
}
示例3: resized_image
void ImageBase::resizeImage( const size_t width, const size_t height, ImageDataType* image )
{
// Resized image.
ImageDataType resized_image( width, height );
// Interpolator.
Interpolator interpolator;
interpolator.attach( image );
const double ratio_width = m_width / static_cast<double>( width );
const double ratio_height = m_height / static_cast<double>( height );
for( size_t j = 0; j < height; j++ )
{
const double v = j * ratio_height;
interpolator.setV( v );
for( size_t i = 0; i < width; i++ )
{
const double u = i * ratio_width;
interpolator.setU( u );
typename ImageDataType::PixelType pixel = interpolator();
resized_image.setPixel( i, j, pixel );
}
}
*image = resized_image;
}
示例4: HitTest
void KeyListCtrl::OnDragging(wxMouseEvent& event)
{
wxPoint pos = event.GetPosition();
int flags = wxLIST_HITTEST_ONITEM;
long index = HitTest(pos, flags, NULL); // got to use it at last
if (index >=0 && index != m_editing_item && index != m_dragging_to_item)
{
VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (!vr_frame)
return;
Interpolator* interpolator = vr_frame->GetInterpolator();
if (!interpolator)
return;
m_dragging_to_item = index;
//change the content in the interpolator
if (m_editing_item > m_dragging_to_item)
interpolator->MoveKeyBefore(m_editing_item, m_dragging_to_item);
else
interpolator->MoveKeyAfter(m_editing_item, m_dragging_to_item);
DeleteItem(m_editing_item);
InsertItem(m_dragging_to_item, "", 0);
UpdateText();
m_editing_item = m_dragging_to_item;
SetItemState(m_editing_item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
}
示例5: OnInsKey
void RecorderDlg::OnInsKey(wxCommandEvent &event)
{
wxString str;
VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (!vr_frame)
return;
Interpolator* interpolator = vr_frame->GetInterpolator();
if (!interpolator)
return;
long item = m_keylist->GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
int index = -1;
if (item != -1)
{
str = m_keylist->GetItemText(item);
long id;
str.ToLong(&id);
index = interpolator->GetKeyIndex(id);
}
str = m_duration_text->GetValue();
double duration;
str.ToDouble(&duration);
int interpolation = m_interpolation_cmb->GetSelection();
InsertKey(index, duration, interpolation);
m_keylist->Update();
m_keylist->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
示例6: DeleteAll
void KeyListCtrl::DeleteAll()
{
VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
if (!vr_frame)
return;
Interpolator* interpolator = vr_frame->GetInterpolator();
if (!interpolator)
return;
interpolator->Clear();
Update();
}
示例7: GetMaxDuration
// static
bool Animation::GetMaxDuration(Interpolator const & interpolator, double & maxDuration)
{
if (interpolator.IsActive())
{
double const duration = interpolator.GetMaxDuration();
if (duration >= 0.0)
maxDuration = maxDuration >= 0.0 ? std::max(duration, maxDuration) : duration;
else
return false;
}
return true;
}
示例8: main
int main(int argc, char* argv[])
{
if(argc != 2)
{
std::cerr << "Usage: " << argv[0]
<< " VOLTAGE" << std::endl <<
" VOLTAGE should be a voltage that a Sharp rangefinder can produce." << std::endl <<
" Your program will then print out the corresponding distance as per the rangefinder's datasheet."<< std::endl;
exit(0);
}
Interpolator myInterpolator;
//TODO1:
//Insert your datapoints here like this:
//myInterpolator.insertDataPoint(someVoltage1, someDistance1);
//myInterpolator.insertDataPoint(someVoltage2, someDistance2);
//myInterpolator.insertDataPoint(someVoltage3, someDistance3);
//etc...
myInterpolator.insertDataPoint(2.00, 30);
myInterpolator.insertDataPoint(1.55, 40);
myInterpolator.insertDataPoint(1.25, 50);
myInterpolator.insertDataPoint(1.07, 60);
myInterpolator.insertDataPoint(0.90, 70);
myInterpolator.insertDataPoint(0.80, 80);
myInterpolator.insertDataPoint(0.70, 90);
myInterpolator.insertDataPoint(0.65, 100);
myInterpolator.insertDataPoint(0.60, 110);
myInterpolator.insertDataPoint(0.50, 130);
// This output is done for you - don't modify it!
std::cout << myInterpolator.getDistance(atof(argv[1]))<< std::endl;
return 0;
}
示例9: LSInterpolator
Interpolator * Interpolator::getAnyInterpolatorFromFile(std::ifstream *in) {
long placeInFile = in->tellg();
Interpolator *interpolator;
interpolator = static_cast<Interpolator *>(new LSInterpolator());
if(interpolator->initFromStream(in)) {
return interpolator;
}
delete interpolator;
in->seekg(placeInFile);
std::cout << "Could not get any interpolator from file\n";
throw 1;
};
示例10: setNodeEndBehaviour
void NodeUtil::setNodeEndBehaviour( sg::Node* node, Interpolator::BehaviourType behaviour )
{
Interpolator* intp = dynamic_cast<Interpolator*>( node->positionController() );
if ( intp )
intp->setEndBehaviour( behaviour );
intp = dynamic_cast<Interpolator*>( node->rotationController() );
if ( intp )
intp->setEndBehaviour( behaviour );
intp = dynamic_cast<Interpolator*>( node->scaleController() );
if ( intp )
intp->setEndBehaviour( behaviour );
}
示例11: process
void MeshProcessor::process(ObjectData* object) {
//Statusinformationen ausgeben
cout << "calculating temperature distribution for \"" << object->getName()
<< "\"..." << endl;
//Für alle Materialien...
for (unsigned int i = 0; i < object->getMaterials()->size(); i++) {
ObjectData::MaterialData* mat = &object->getMaterials()->at(i);
tetgenio* io = mat->tetgenoutput;
//ist es nötig, die Punktattributliste freizugeben?
if (mat->tetgenoutput->numberofpointattributes != 0) {
delete mat->tetgenoutput->pointattributelist;
}
//ist es nötig, die Extrapolationsstatusliste freizugeben?
if (mat->extrapolated != NULL) {
delete[] mat->extrapolated;
}
//Extrapolationsstatusliste neu erstellen
mat->extrapolated = new bool[mat->tetgenoutput->numberofpoints];
//Punktattributliste neu erstellen
mat->tetgenoutput->numberofpointattributes = NUMBEROFSENSORATTRIBUTES;
mat->tetgenoutput->pointattributelist =
new REAL[NUMBEROFSENSORATTRIBUTES
* mat->tetgenoutput->numberofpoints];
Interpolator interpolator;
interpolator.setMode(mat->interpolation_mode);
//Ermitteln der Werte für alle Punkte...
for (int j = 0; j < io->numberofpoints; j++) {
//Statusinformationen ausgeben
cout << "\rmaterial " << i + 1 << ": " << j + 1 << "/"
<< io->numberofpoints << endl;
SensorData* sd = &object->getSensorDataList()->at(
object->getCurrentSensorIndex());
interpolatePoint(mat, &sd->data.at(sd->current_time_index), j,
&interpolator);
}
cout << endl;
}
}
示例12: SmileSection
InterpolatedSmileSection<Interpolator>::InterpolatedSmileSection(
const Date& d,
const std::vector<Rate>& strikes,
const std::vector<Real>& stdDevs,
Real atmLevel,
const DayCounter& dc,
const Interpolator& interpolator,
const Date& referenceDate,
const Real shift)
: SmileSection(d, dc, referenceDate, ShiftedLognormal, shift),
exerciseTimeSquareRoot_(std::sqrt(exerciseTime())), strikes_(strikes),
stdDevHandles_(stdDevs.size()), vols_(stdDevs.size())
{
//fill dummy handles to allow generic handle-based
// computations later on
for (Size i=0; i<stdDevs.size(); ++i)
stdDevHandles_[i] = Handle<Quote>(boost::shared_ptr<Quote>(new
SimpleQuote(stdDevs[i])));
atmLevel_ = Handle<Quote>
(boost::shared_ptr<Quote>(new SimpleQuote(atmLevel)));
// check strikes!!!!!!!!!!!!!!!!!!!!
interpolation_ = interpolator.interpolate(strikes_.begin(),
strikes_.end(),
vols_.begin());
}
示例13: setInterpolation
void setInterpolation(const Interpolator& i = Interpolator()) {
varianceSurface_ =
i.interpolate(times_.begin(), times_.end(),
strikes_.begin(), strikes_.end(),
variances_);
notifyObservers();
}
示例14: setInterpolation
void setInterpolation(const Interpolator& i = Interpolator()) {
for (Size j=0; j < times_.size(); ++j) {
localVolInterpol_[j] = i.interpolate(
strikes_[j]->begin(), strikes_[j]->end(),
localVolMatrix_->column_begin(j));
}
notifyObservers();
}
示例15: main
int main ()
{
Region reg;
Constants con;
Exodus_file exo;
Driver drv;
Model_file mod;
Utilities utl;
Discontinuity dis;
std::cout << "Begin model building." << std::endl;
// Read parameter file.
drv.initialize ( mod, dis, utl, exo, reg );
drv.checkUsage ( mod, "INTERPOLATE" );
std::cout << "\n----- Interpolating -----\n";
std::cout << "\n";
dis.createKDTreePacked ( );
for ( std::vector < Exodus_file > ::
iterator exoFile=reg.regionsExo.begin();
exoFile!=reg.regionsExo.end(); ++exoFile )
{
std::cout << "\n";
Mesh msh;
Interpolator ipl;
exoFile -> openFile ( exoFile -> fname );
msh.getInfo ( exoFile -> idexo );
mod.createKDTreeUnpacked ( msh );
ipl.interpolate ( msh, mod, dis );
exoFile -> writeParams ( msh );
exoFile -> closeFile ( );
msh.deallocateMesh ( mod );
mod.deallocate ( );
}
drv.report ( mod );
return 0;
}