<commit_before>/*******************************************************************************
* ALMA - Atacama Large Millimiter Array
* (c) European Southern Observatory, 2011
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*
* "@(#) $Id: bulkDataNTDDS.cpp,v 1.14 2012/01/20 08:49:27 bjeram Exp $"
*
* who       when      what
* --------  --------  ----------------------------------------------
* bjeram  2011-04-19  created
*/
#include "bulkDataNTDDS.h"
#include <iostream>

using namespace AcsBulkdata;
using namespace std;
using namespace ACSErrTypeCommon;
using namespace ACS_DDS_Errors;

BulkDataNTDDS::BulkDataNTDDS(DDS::DomainParticipant* participant, const DDSConfiguration &ddsCfg) :
	participant_m(participant),
	ddsCfg_m(ddsCfg)
{
	AUTO_TRACE("BulkDataNTDDS::BulkDataNTDDS");
	if (participant==0)
	{
		NullPointerExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setVariable("participant");
		throw ex;
	}//if
}//BulkDataNTDDS

BulkDataNTDDS::~BulkDataNTDDS()
{
	participant_m = 0;
}//~BulkDataNTDDS

DDS::Topic* BulkDataNTDDS::createDDSTopic(const char* topicName)
{
	AUTO_TRACE(__PRETTY_FUNCTION__);
	DDS::ReturnCode_t ret;

	topicName_m = topicName;
	//TBD: check if topic already exists find_topic ??
	//TBD: type name could be a parameter of the method or class member

	/* Register the type before creating the topic */
	const char* type_name = ACSBulkData::BulkDataNTFrameTypeSupport::get_type_name();
	ret = ACSBulkData::BulkDataNTFrameTypeSupport::register_type(participant_m, type_name);
	if (ret != DDS::RETCODE_OK)
	{
		DDSRegisterTypeProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setDDSTypeCode(ret);
		ex.setTypeName(type_name);
		throw ex;
	}

	DDS::Topic *topic =  participant_m->create_topic_with_profile(topicName_m,
			type_name,
			ddsCfg_m.libraryQos.c_str(), ddsCfg_m.profileQos.c_str(),
			NULL,
			DDS::STATUS_MASK_NONE
	);
	if (topic==0)
	{
		DDSTopicCreateProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setTopic(topicName_m);
		throw ex;
	}//if

	ret = topic->enable();
	if ( ret != DDS::RETCODE_OK )
	{
		DDSTopicEnableProblemExImpl ex(__FILE__, __LINE__, __FUNCTION__);
		ex.setDDSTypeCode(ret);
		throw ex;
	}

	ACS_SHORT_LOG((LM_DEBUG, "Created DDS topic: %s", topicName_m));
	return topic;
}//createDDSTopic

/*___oOo___*/

<commit_msg>when createDDSTopic is called is set topicName_m<commit_after>/*******************************************************************************
* ALMA - Atacama Large Millimiter Array
* (c) European Southern Observatory, 2011
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*
* "@(#) $Id: bulkDataNTDDS.cpp,v 1.15 2012/01/20 09:00:26 bjeram Exp $"
*
* who       when      what
* --------  --------  ----------------------------------------------
* bjeram  2011-04-19  created
*/
#include "bulkDataNTDDS.h"
#include <iostream>

using namespace AcsBulkdata;
using namespace std;
using namespace ACSErrTypeCommon;
using namespace ACS_DDS_Errors;

BulkDataNTDDS::BulkDataNTDDS(DDS::DomainParticipant* participant, const DDSConfiguration &ddsCfg) :
	participant_m(participant),
	ddsCfg_m(ddsCfg)
{
	AUTO_TRACE("BulkDataNTDDS::BulkDataNTDDS");
	if (participant==0)
	{
		NullPointerExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setVariable("participant");
		throw ex;
	}//if
}//BulkDataNTDDS

BulkDataNTDDS::~BulkDataNTDDS()
{
	participant_m = 0;
}//~BulkDataNTDDS

DDS::Topic* BulkDataNTDDS::createDDSTopic(const char* topicName)
{
	AUTO_TRACE(__PRETTY_FUNCTION__);
	DDS::ReturnCode_t ret;

	topicName_m = topicName;
	//TBD: check if topic already exists find_topic ??
	//TBD: type name could be a parameter of the method or class member

	/* Register the type before creating the topic */
	const char* type_name = ACSBulkData::BulkDataNTFrameTypeSupport::get_type_name();
	ret = ACSBulkData::BulkDataNTFrameTypeSupport::register_type(participant_m, type_name);
	if (ret != DDS::RETCODE_OK)
	{
		DDSRegisterTypeProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setDDSTypeCode(ret);
		ex.setTypeName(type_name);
		throw ex;
	}

	DDS::Topic *topic =  participant_m->create_topic_with_profile(topicName_m.c_str(),
			type_name,
			ddsCfg_m.libraryQos.c_str(), ddsCfg_m.profileQos.c_str(),
			NULL,
			DDS::STATUS_MASK_NONE
	);
	if (topic==0)
	{
		DDSTopicCreateProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__);
		ex.setTopic(topicName_m.c_str());
		throw ex;
	}//if

	ret = topic->enable();
	if ( ret != DDS::RETCODE_OK )
	{
		DDSTopicEnableProblemExImpl ex(__FILE__, __LINE__, __FUNCTION__);
		ex.setDDSTypeCode(ret);
		throw ex;
	}

	ACS_SHORT_LOG((LM_DEBUG, "Created DDS topic: %s", topicName_m.c_str()));
	return topic;
}//createDDSTopic

/*___oOo___*/

<|endoftext|>


<commit_before>#include "Lxy_weight_calculator.h"

using namespace std;

// Defien the constants for the Lxy1 and Lxy2 binning
const int n_bins = 100; // 100 bins
const double lxy_min = 0.0; // lxy minimum in meters
const double lxy_max = 5.0; // lxy maximum in meters

//
// Calcualte the weight histogram
// Note: In Run1 this was done during the actual running on MC that generates this ntuple. But by doing it here
//       we better keep cuts consistent by keeping them close to each other.
Lxy_weight_calculator::Lxy_weight_calculator(const muon_tree_processor &reader)
{
	// Events where they were generated and where they passed the analysis selection
	unique_ptr<TH2D> generated(new TH2D("generated", "generated", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedA(new TH2D("passedA", "passedA", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedB(new TH2D("passedB", "passedB", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedC(new TH2D("passedC", "passedC", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedD(new TH2D("passedD", "passedD", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	generated->Sumw2();
	passedA->Sumw2();
	passedB->Sumw2();
	passedC->Sumw2();
	passedD->Sumw2();

	reader.process_all_entries([&generated, &passedA, &passedB, &passedC, &passedD](const muon_tree_processor::eventInfo &entry) {
		generated->Fill(entry.vpi1_Lxy/1000.0, entry.vpi2_Lxy/1000.0);
		if (entry.RegionA) {
			passedA->Fill(entry.vpi1_Lxy/1000.0, entry.vpi2_Lxy/1000.0);
		}
		if (entry.RegionB) {
			passedB->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0);
		}
		if (entry.RegionC) {
			passedC->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0);
		}
		if (entry.RegionD) {
			passedD->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0);
		}
	});

	// The key is the ratio.
	// We can't use ROOT sumw2 errors because they assume independent histograms. So we use
	// binomial errors (the "B" option).
	_pass_weight[0] = unique_ptr<TH2D>(new TH2D("_pass_weightA", "_pass_weightA", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[0]->Divide(passedA.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[1] = unique_ptr<TH2D>(new TH2D("_pass_weightB", "_pass_weightB", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[1]->Divide(passedB.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[2] = unique_ptr<TH2D>(new TH2D("_pass_weightC", "_pass_weightC", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[2]->Divide(passedC.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[3] = unique_ptr<TH2D>(new TH2D("_pass_weightD", "_pass_weightD", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[3]->Divide(passedD.get(), generated.get(), 1.0, 1.0, "B");
}

Lxy_weight_calculator::~Lxy_weight_calculator()
{
}

// Do the lookup to make the calculation
double Lxy_weight_calculator::operator()(int region, double lxy1, double lxy2) const
{
	if (region < 0 || region > 3) {
		throw runtime_error("Illegal region in operator()");
	}
	int xbin = _pass_weight[region]->FindBin(lxy1, lxy2);
	return _pass_weight[region]->GetBinContent(xbin);
}
<commit_msg>Weight the Lxy histograms by the event weight (which will include pileup reweighting).<commit_after>#include "Lxy_weight_calculator.h"

using namespace std;

// Defien the constants for the Lxy1 and Lxy2 binning
const int n_bins = 100; // 100 bins
const double lxy_min = 0.0; // lxy minimum in meters
const double lxy_max = 5.0; // lxy maximum in meters

//
// Calcualte the weight histogram
// Note: In Run1 this was done during the actual running on MC that generates this ntuple. But by doing it here
//       we better keep cuts consistent by keeping them close to each other.
// Note: this is not weighted, but the beta shape is (so we don't do weights twice).
Lxy_weight_calculator::Lxy_weight_calculator(const muon_tree_processor &reader)
{
	// Events where they were generated and where they passed the analysis selection
	unique_ptr<TH2D> generated(new TH2D("generated", "generated", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedA(new TH2D("passedA", "passedA", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedB(new TH2D("passedB", "passedB", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedC(new TH2D("passedC", "passedC", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	unique_ptr<TH2D> passedD(new TH2D("passedD", "passedD", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	generated->Sumw2();
	passedA->Sumw2();
	passedB->Sumw2();
	passedC->Sumw2();
	passedD->Sumw2();

	reader.process_all_entries([&generated, &passedA, &passedB, &passedC, &passedD](const muon_tree_processor::eventInfo &entry) {
		generated->Fill(entry.vpi1_Lxy/1000.0, entry.vpi2_Lxy/1000.0, entry.weight);
		if (entry.RegionA) {
			passedA->Fill(entry.vpi1_Lxy/1000.0, entry.vpi2_Lxy/1000.0, entry.weight);
		}
		if (entry.RegionB) {
			passedB->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0, entry.weight);
		}
		if (entry.RegionC) {
			passedC->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0, entry.weight);
		}
		if (entry.RegionD) {
			passedD->Fill(entry.vpi1_Lxy / 1000.0, entry.vpi2_Lxy / 1000.0, entry.weight);
		}
	});

	// The key is the ratio.
	// We can't use ROOT sumw2 errors because they assume independent histograms. So we use
	// binomial errors (the "B" option).
	_pass_weight[0] = unique_ptr<TH2D>(new TH2D("_pass_weightA", "_pass_weightA", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[0]->Divide(passedA.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[1] = unique_ptr<TH2D>(new TH2D("_pass_weightB", "_pass_weightB", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[1]->Divide(passedB.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[2] = unique_ptr<TH2D>(new TH2D("_pass_weightC", "_pass_weightC", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[2]->Divide(passedC.get(), generated.get(), 1.0, 1.0, "B");
	_pass_weight[3] = unique_ptr<TH2D>(new TH2D("_pass_weightD", "_pass_weightD", n_bins, lxy_min, lxy_max, n_bins, lxy_min, lxy_max));
	_pass_weight[3]->Divide(passedD.get(), generated.get(), 1.0, 1.0, "B");
}

Lxy_weight_calculator::~Lxy_weight_calculator()
{
}

// Do the lookup to make the calculation
double Lxy_weight_calculator::operator()(int region, double lxy1, double lxy2) const
{
	if (region < 0 || region > 3) {
		throw runtime_error("Illegal region in operator()");
	}
	int xbin = _pass_weight[region]->FindBin(lxy1, lxy2);
	return _pass_weight[region]->GetBinContent(xbin);
}
<|endoftext|>


<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkGenericMovieWriter.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkGenericMovieWriter.h"

#include "vtkImageData.h"

vtkCxxRevisionMacro(vtkGenericMovieWriter, "1.1");

//---------------------------------------------------------------------------
vtkGenericMovieWriter::vtkGenericMovieWriter()
{
  this->FileName = NULL;
  this->Error = 0;
}

//---------------------------------------------------------------------------
vtkGenericMovieWriter::~vtkGenericMovieWriter()
{
  this->SetFileName(0);
}

//----------------------------------------------------------------------------
void vtkGenericMovieWriter::SetInput(vtkImageData *input)
{
  this->vtkProcessObject::SetNthInput(0, input);
}

//----------------------------------------------------------------------------
vtkImageData *vtkGenericMovieWriter::GetInput()
{
  if (this->NumberOfInputs < 1)
    {
    return NULL;
    }

  return (vtkImageData *)(this->Inputs[0]);
}

//----------------------------------------------------------------------------
void vtkGenericMovieWriter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);

  os << indent << "FileName: " << this->FileName << endl;
  os << indent << "Error: " << this->Error << endl;
}

<commit_msg>BUG: Fix NULL pointer dereference in PrintSelf; eliminates otherPrint test failure on dashboards<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkGenericMovieWriter.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkGenericMovieWriter.h"

#include "vtkImageData.h"

vtkCxxRevisionMacro(vtkGenericMovieWriter, "1.2");

//---------------------------------------------------------------------------
vtkGenericMovieWriter::vtkGenericMovieWriter()
{
  this->FileName = NULL;
  this->Error = 0;
}

//---------------------------------------------------------------------------
vtkGenericMovieWriter::~vtkGenericMovieWriter()
{
  this->SetFileName(0);
}

//----------------------------------------------------------------------------
void vtkGenericMovieWriter::SetInput(vtkImageData *input)
{
  this->vtkProcessObject::SetNthInput(0, input);
}

//----------------------------------------------------------------------------
vtkImageData *vtkGenericMovieWriter::GetInput()
{
  if (this->NumberOfInputs < 1)
    {
    return NULL;
    }

  return (vtkImageData *)(this->Inputs[0]);
}

//----------------------------------------------------------------------------
void vtkGenericMovieWriter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);

  os << indent << "FileName: "
     << (this->FileName ? this->FileName : "(none)") << endl;
  os << indent << "Error: " << this->Error << endl;
}
<|endoftext|>


<commit_before>#pragma once

#define COMPILE_PARAM_LOGGING false

#define COMPETITION_DEPLOY false

#define ARM_MATH_CM3

// ** DEBUGGING OPTIONS ** ============================= **
/*
    This will enable/disable a `Log File` that is created at the mbed's startup.
   The file is written
    to the mbed's onboard flash memory and can be opened for debugging purposes
   if it is enabled.
    Note that you may have to disconnect and reconnect the mbed's USB connection
   for the file to show up
    if it is plugged into a computer during the startup process.
*/
#define RJ_BOOT_LOG false

#define RJ_FPGA_ENABLE true

// ** ENABLE / DISABLE INTERFACES ** ============================= **

// Enable/Disable the Radio Transceiver (915MHz band)
#define RJ_CC1201
//#define RJ_CC1101

// Enable/Disable the Accel/Gyro (MPU-6050)
#define RJ_MPU_EN true

#define RJ_WATCHDOG_TIMER_EN false

// The `Watchdog Timer` timeout value. The mbed will reset if the timer is not
// reset after the number of seconds defined here
#define RJ_WATCHDOG_TIMER_VALUE 2  // seconds

// The number of ms the flashing status light waits between flashes.
#define RJ_LIFELIGHT_TIMEOUT_MS 1400

// The amount of time (in ms) that all LEDs stay lit during startup
#define RJ_STARTUP_LED_TIMEOUT_MS 500
<commit_msg>cleaning up config file<commit_after>#pragma once

#define COMPILE_PARAM_LOGGING false

#define COMPETITION_DEPLOY false

#define ARM_MATH_CM3

// ** DEBUGGING OPTIONS ** ============================= **
/*
    This will enable/disable a `Log File` that is created at the mbed's startup.
   The file is written
    to the mbed's onboard flash memory and can be opened for debugging purposes
   if it is enabled.
    Note that you may have to disconnect and reconnect the mbed's USB connection
   for the file to show up
    if it is plugged into a computer during the startup process.
*/
#define RJ_BOOT_LOG false

// ** ENABLE / DISABLE INTERFACES ** ============================= **

// Enable/Disable the Radio Transceiver (915MHz band)
#define RJ_CC1201
//#define RJ_CC1101

// The `Watchdog Timer` timeout value. The mbed will reset if the timer is not
// reset after the number of seconds defined here
#define RJ_WATCHDOG_TIMER_VALUE 2  // seconds

// The number of ms the flashing status light waits between flashes.
#define RJ_LIFELIGHT_TIMEOUT_MS 1400

// The amount of time (in ms) that all LEDs stay lit during startup
#define RJ_STARTUP_LED_TIMEOUT_MS 500
<|endoftext|>


<commit_before>// SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2020 Arm Limited
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at:
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// ----------------------------------------------------------------------------

/**
 * @brief Fuzz target for physical_to_symbolic().
 *
 * This function is the first entrypoint for decompressing a 16 byte block of
 * input ASTC data from disk. The 16 bytes can contain arbitrary data; they
 * are read from an external source, but the block size used must be a valid
 * ASTC block footprint.
 */

#include "astcenc_internal.h"

#include <fuzzer/FuzzedDataProvider.h>
#include <array>
#include <vector>

struct BlockSizes {
	int x;
	int y;
	int z;
};

std::array<BlockSizes, 3> testSz {{
	{ 4,  4, 1}, // Highest bitrate
	{12, 12, 1}, // Largest 2D block
	{6,  6,  6}  // Largest 3D block
}};

std::array<block_size_descriptor, 3> testBSD;

/**
 * @brief Utility function to create all of the block size descriptors needed.
 *
 * This is triggered once via a static initializer.
 *
 * Triggering once is important so that we only create a single BSD per block
 * size we need, rather than one per fuzzer iteration (it's expensive). This
 * improves fuzzer throughput by ~ 1000x!
 *
 * Triggering via a static initializer, rather than a lazy init in the fuzzer
 * function, is important because is means that the BSD is allocated before
 * fuzzing starts. This means that leaksanitizer will ignore the fact that we
 * "leak" the dynamic allocations inside the BSD (we never call term()).
 */
bool bsd_initializer()
{
	for (int i = 0; i < testSz.size(); i++)
	{
		init_block_size_descriptor(
		    testSz[i].x,
		    testSz[i].y,
		    testSz[i].z,
		    false,
		    1.0f,
		    &(testBSD[i]));
	}

	return true;
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	// Preinitialize the block size descriptors we need
	static bool init = bsd_initializer();

	// Must have 4 (select block size) and 16 (payload) bytes
	if (size < 4 + 16)
	{
		return 0;
	}

	FuzzedDataProvider stream(data, size);

	// Select a block size to test
	int i = stream.ConsumeIntegralInRange<int>(0, testSz.size() - 1);

	// Populate the physical block
	physical_compressed_block pcb;
	std::vector<uint8_t> buffer = stream.ConsumeBytes<uint8_t>(16);
	std::memcpy(&pcb, buffer.data(), 16);

	// Call the function under test
	symbolic_compressed_block scb;
	physical_to_symbolic(testBSD[i], pcb, scb);

	return 0;
}
<commit_msg>Update oss-fuzz test to new API.<commit_after>// SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2020-2021 Arm Limited
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at:
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// ----------------------------------------------------------------------------

/**
 * @brief Fuzz target for physical_to_symbolic().
 *
 * This function is the first entrypoint for decompressing a 16 byte block of
 * input ASTC data from disk. The 16 bytes can contain arbitrary data; they
 * are read from an external source, but the block size used must be a valid
 * ASTC block footprint.
 */

#include "astcenc_internal.h"

#include <fuzzer/FuzzedDataProvider.h>
#include <array>
#include <vector>

struct BlockSizes {
	int x;
	int y;
	int z;
};

std::array<BlockSizes, 3> testSz {{
	{ 4,  4, 1}, // Highest bitrate
	{12, 12, 1}, // Largest 2D block
	{6,  6,  6}  // Largest 3D block
}};

std::array<block_size_descriptor, 3> testBSD;

/**
 * @brief Utility function to create all of the block size descriptors needed.
 *
 * This is triggered once via a static initializer.
 *
 * Triggering once is important so that we only create a single BSD per block
 * size we need, rather than one per fuzzer iteration (it's expensive). This
 * improves fuzzer throughput by ~ 1000x!
 *
 * Triggering via a static initializer, rather than a lazy init in the fuzzer
 * function, is important because is means that the BSD is allocated before
 * fuzzing starts. This means that leaksanitizer will ignore the fact that we
 * "leak" the dynamic allocations inside the BSD (we never call term()).
 */
bool bsd_initializer()
{
	for (int i = 0; i < testSz.size(); i++)
	{
		init_block_size_descriptor(
		    testSz[i].x,
		    testSz[i].y,
		    testSz[i].z,
		    false,
		    1.0f,
		    testBSD[i]);
	}

	return true;
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	// Preinitialize the block size descriptors we need
	static bool init = bsd_initializer();

	// Must have 4 (select block size) and 16 (payload) bytes
	if (size < 4 + 16)
	{
		return 0;
	}

	FuzzedDataProvider stream(data, size);

	// Select a block size to test
	int i = stream.ConsumeIntegralInRange<int>(0, testSz.size() - 1);

	// Populate the physical block
	physical_compressed_block pcb;
	std::vector<uint8_t> buffer = stream.ConsumeBytes<uint8_t>(16);
	std::memcpy(&pcb, buffer.data(), 16);

	// Call the function under test
	symbolic_compressed_block scb;
	physical_to_symbolic(testBSD[i], pcb, scb);

	return 0;
}
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2018, Ford Motor Company
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the Ford Motor Company nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include "application_manager/application.h"
#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application.h"
#include "application_manager/commands/commands_test.h"
#include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"

using ::testing::_;
using ::testing::Return;
using ::testing::NiceMock;
using ::testing::SaveArg;
using ::testing::Mock;
using application_manager::ApplicationSet;
using application_manager::commands::MessageSharedPtr;
using test::components::application_manager_test::MockApplication;
using test::components::application_manager_test::MockApplicationManager;
using test::components::commands_test::CommandsTest;
using test::components::commands_test::CommandsTestMocks;

namespace {
const uint32_t kAppId = 0u;
const uint32_t kConnectionKey = 1u;
const std::string kPolicyAppId = "Test";
}

namespace rc_rpc_plugin_test {
using namespace rc_rpc_plugin;
using application_manager::ApplicationSet;

class RCOnRemoteControlSettingsNotificationTest
    : public CommandsTest<CommandsTestMocks::kIsNice> {
 public:
  RCOnRemoteControlSettingsNotificationTest()
      : mock_app_(std::make_shared<NiceMock<MockApplication> >()) {}
  MessageSharedPtr CreateBasicMessage() {
    MessageSharedPtr message = CreateMessage();
    (*message)[application_manager::strings::params]
              [application_manager::strings::function_id] =
                  mobile_apis::FunctionID::SetInteriorVehicleDataID;
    (*message)[application_manager::strings::params]
              [application_manager::strings::connection_key] = kConnectionKey;
    (*message)[application_manager::strings::params]
              [application_manager::strings::connection_key] = kAppId;
    smart_objects::SmartObject& msg_param =
        (*message)[application_manager::strings::msg_params];
    msg_param[message_params::kModuleType] = enums_value::kClimate;

    return message;
  }

  template <class Command>
  std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
    InitCommand(kDefaultTimeout_);
    RCCommandParams params{app_mngr_,
                           mock_rpc_service_,
                           mock_hmi_capabilities_,
                           mock_policy_handler_,
                           mock_allocation_manager_,
                           mock_interior_data_cache_,
                           mock_interior_data_manager_};
    return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
  }

 protected:
  std::shared_ptr<MockApplication> mock_app_;
  testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
      mock_allocation_manager_;
  testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
      mock_interior_data_cache_;
  testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
      mock_interior_data_manager_;
};

TEST_F(RCOnRemoteControlSettingsNotificationTest,
       Run_Allowed_SetAccessMode) {  // Arrange
  MessageSharedPtr mobile_message = CreateBasicMessage();
  (*mobile_message)[application_manager::strings::msg_params]
                   [message_params::kAllowed] = true;

  // Expectations

  ON_CALL(mock_allocation_manager_, GetAccessMode())
      .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER));

  EXPECT_CALL(mock_allocation_manager_,
              SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER));
  // Act
  std::shared_ptr<
      rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command =
      CreateRCCommand<
          rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>(
          mobile_message);

  command->Run();
}

TEST_F(RCOnRemoteControlSettingsNotificationTest,
       Run_NotAllowed_ResetAllAllocations) {
  // Arrange
  MessageSharedPtr mobile_message = CreateBasicMessage();
  (*mobile_message)[application_manager::strings::msg_params]
                   [message_params::kAllowed] = false;

  ApplicationSet app_set = {mock_app_};

  std::shared_ptr<sync_primitives::Lock> apps_lock =
      std::make_shared<sync_primitives::Lock>();
  DataAccessor<ApplicationSet> accessor(app_set, apps_lock);
  // Expectations
  EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));

  RCAppExtensionPtr rc_extention_ptr =
      std::make_shared<RCAppExtension>(application_manager::AppExtensionUID(
          rc_rpc_plugin::RCRPCPlugin::kRCPluginID));
  rc_extention_ptr->SubscribeToInteriorVehicleData(enums_value::kClimate);
  ON_CALL(*mock_app_, QueryInterface(_))
      .WillByDefault(Return(rc_extention_ptr));

  EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations());

  // Act
  std::shared_ptr<
      rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command =
      CreateRCCommand<
          rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>(
          mobile_message);

  command->Run();
  Mock::VerifyAndClearExpectations(&app_mngr_);
}

}  // namespace rc_rpc_plugin_test
<commit_msg>Fix unit tests<commit_after>/*
 * Copyright (c) 2018, Ford Motor Company
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the Ford Motor Company nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include "application_manager/application.h"
#include "application_manager/commands/command_request_test.h"
#include "application_manager/mock_application.h"
#include "application_manager/commands/commands_test.h"
#include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"

using ::testing::_;
using ::testing::Return;
using ::testing::NiceMock;
using ::testing::SaveArg;
using ::testing::Mock;
using application_manager::ApplicationSet;
using application_manager::commands::MessageSharedPtr;
using test::components::application_manager_test::MockApplication;
using test::components::application_manager_test::MockApplicationManager;
using test::components::commands_test::CommandsTest;
using test::components::commands_test::CommandsTestMocks;

namespace {
const uint32_t kAppId = 0u;
const uint32_t kConnectionKey = 1u;
const std::string kPolicyAppId = "Test";
}

namespace rc_rpc_plugin_test {
using namespace rc_rpc_plugin;
using application_manager::ApplicationSet;

class RCOnRemoteControlSettingsNotificationTest
    : public CommandsTest<CommandsTestMocks::kIsNice> {
 public:
  RCOnRemoteControlSettingsNotificationTest()
      : mock_app_(std::make_shared<NiceMock<MockApplication> >()) {}
  MessageSharedPtr CreateBasicMessage() {
    MessageSharedPtr message = CreateMessage();
    (*message)[application_manager::strings::params]
              [application_manager::strings::function_id] =
                  mobile_apis::FunctionID::SetInteriorVehicleDataID;
    (*message)[application_manager::strings::params]
              [application_manager::strings::connection_key] = kConnectionKey;
    (*message)[application_manager::strings::params]
              [application_manager::strings::connection_key] = kAppId;
    smart_objects::SmartObject& msg_param =
        (*message)[application_manager::strings::msg_params];
    msg_param[message_params::kModuleType] = enums_value::kClimate;

    return message;
  }

  template <class Command>
  std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
    InitCommand(kDefaultTimeout_);
    RCCommandParams params{app_mngr_,
                           mock_rpc_service_,
                           mock_hmi_capabilities_,
                           mock_policy_handler_,
                           mock_allocation_manager_,
                           mock_interior_data_cache_,
                           mock_interior_data_manager_};
    return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
  }

 protected:
  std::shared_ptr<MockApplication> mock_app_;
  testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
      mock_allocation_manager_;
  testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
      mock_interior_data_cache_;
  testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
      mock_interior_data_manager_;
};

TEST_F(RCOnRemoteControlSettingsNotificationTest,
       Run_Allowed_SetAccessMode) {  // Arrange
  MessageSharedPtr mobile_message = CreateBasicMessage();
  (*mobile_message)[application_manager::strings::msg_params]
                   [message_params::kAllowed] = true;

  // Expectations

  ON_CALL(mock_allocation_manager_, GetAccessMode())
      .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER));

  EXPECT_CALL(mock_allocation_manager_,
              SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER));
  // Act
  std::shared_ptr<
      rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command =
      CreateRCCommand<
          rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>(
          mobile_message);

  command->Run();
}

TEST_F(RCOnRemoteControlSettingsNotificationTest,
       Run_NotAllowed_ResetAllAllocations) {
  // Arrange
  MessageSharedPtr mobile_message = CreateBasicMessage();
  (*mobile_message)[application_manager::strings::msg_params]
                   [message_params::kAllowed] = false;

  EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations());
  EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC());

  // Act
  std::shared_ptr<
      rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command =
      CreateRCCommand<
          rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>(
          mobile_message);

  command->Run();
  Mock::VerifyAndClearExpectations(&app_mngr_);
}

}  // namespace rc_rpc_plugin_test
<|endoftext|>


<commit_before>/**************************************************************************************/
/*                                                                                */
/*  Visualization Library                                                             */
/*  http://www.visualizationlibrary.com                                               */
/*                                                                                */
/*  Copyright (c) 2005-2010, Michele Bosi                                             */
/*  All rights reserved.                                                              */
/*                                                                                */
/*  Redistribution and use in source and binary forms, with or without modification,  */
/*  are permitted provided that the following conditions are met:                     */
/*                                                                                */
/*  - Redistributions of source code must retain the above copyright notice, this     */
/*  list of conditions and the following disclaimer.                                  */
/*                                                                                */
/*  - Redistributions in binary form must reproduce the above copyright notice, this  */
/*  list of conditions and the following disclaimer in the documentation and/or       */
/*  other materials provided with the distribution.                                   */
/*                                                                                */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
/*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
/*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
/*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
/*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
/*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
/*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
/*                                                                                */
/**************************************************************************************/

#ifndef MDIWindow_INCLUDE_ONCE
#define MDIWindow_INCLUDE_ONCE

#include <vlGraphics/OpenGLContext.hpp>
#include <vlWin32/Win32Context.hpp>

namespace vlMFC
{
//-----------------------------------------------------------------------------
// MDIWindow
//-----------------------------------------------------------------------------
  /**
   * The MDIWindow class is an MFC CView with the functionalities of a Win32Context.
   */
  class MDIWindow: public CView, public vlWin32::Win32Context /* the order is important! */
  {
  public:
    MDIWindow() {}

    virtual ~MDIWindow();

    //! Creates the window and initializes the OpenGL rendering context
    bool initOpenGLContext(HGLRC share_context, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x=0, int y=0, int width=640, int height=480);

    //! calls destroyWindow() and dispatches the destroy event to the UIEventListener objects
    virtual void destroy();

    //! Destroyes the window and the OpenGL rendering context
    void destroyWindow();

    //! Returns the Win32 window handle
    HWND hwnd() const { return m_hWnd; }

  public:
	  //{{AFX_MSG(MFCContext
    /*afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);*/
	  /*afx_msg void OnDraw(CDC *pDC);*/
    afx_msg void OnPaint();
    afx_msg void OnClose();
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
    afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    afx_msg void OnDropFiles(HDROP hDropInfo);
	  //}}AFX_MSG

  protected:
    void CountAndCapture();
    void CountAndRelease();

  protected:
    int mMouseDownCount;
    static CString mClassName;

    DECLARE_MESSAGE_MAP()
  };
}

#endif
<commit_msg>Default empty implementation of OnDraw().<commit_after>/**************************************************************************************/
/*                                                                                */
/*  Visualization Library                                                             */
/*  http://www.visualizationlibrary.com                                               */
/*                                                                                */
/*  Copyright (c) 2005-2010, Michele Bosi                                             */
/*  All rights reserved.                                                              */
/*                                                                                */
/*  Redistribution and use in source and binary forms, with or without modification,  */
/*  are permitted provided that the following conditions are met:                     */
/*                                                                                */
/*  - Redistributions of source code must retain the above copyright notice, this     */
/*  list of conditions and the following disclaimer.                                  */
/*                                                                                */
/*  - Redistributions in binary form must reproduce the above copyright notice, this  */
/*  list of conditions and the following disclaimer in the documentation and/or       */
/*  other materials provided with the distribution.                                   */
/*                                                                                */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
/*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
/*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
/*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
/*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
/*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
/*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
/*                                                                                */
/**************************************************************************************/

#ifndef MDIWindow_INCLUDE_ONCE
#define MDIWindow_INCLUDE_ONCE

#include <vlGraphics/OpenGLContext.hpp>
#include <vlWin32/Win32Context.hpp>

namespace vlMFC
{
//-----------------------------------------------------------------------------
// MDIWindow
//-----------------------------------------------------------------------------
  /**
   * The MDIWindow class is an MFC CView with the functionalities of a Win32Context (experimental).
   * \remarks Don't forget to reimplement the OnDraw() method.
   */
  class MDIWindow: public CView, public vlWin32::Win32Context /* the order is important! */
  {
  public:
    MDIWindow() {}

    virtual ~MDIWindow();

    //! Creates the window and initializes the OpenGL rendering context
    bool initOpenGLContext(HGLRC share_context, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x=0, int y=0, int width=640, int height=480);

    //! calls destroyWindow() and dispatches the destroy event to the UIEventListener objects
    virtual void destroy();

    //! Destroyes the window and the OpenGL rendering context
    void destroyWindow();

    //! Returns the Win32 window handle
    HWND hwnd() const { return m_hWnd; }

    //! Don't forget to reimplement this!
    void OnDraw(CDC *) {}

  public:
	  //{{AFX_MSG(MFCContext
    /*afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);*/
	  /*afx_msg void OnDraw(CDC *pDC);*/
    afx_msg void OnPaint();
    afx_msg void OnClose();
    afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
    afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    afx_msg void OnDropFiles(HDROP hDropInfo);
	  //}}AFX_MSG

  protected:
    void CountAndCapture();
    void CountAndRelease();

  protected:
    int mMouseDownCount;
    static CString mClassName;

    DECLARE_MESSAGE_MAP()
  };
}

#endif
<|endoftext|>


<commit_before>// $Id: assign_typenames_from_rules.C,v 1.1 2003/03/05 16:17:29 anker Exp $

#include <BALL/common.h>
#include <BALL/FORMAT/INIFile.h>
#include <BALL/FORMAT/HINFile.h>
#include <BALL/SYSTEM/path.h>
#include <BALL/MOLMEC/COMMON/typenameRuleProcessor.h>

using namespace BALL;

int main(int argc, char** argv)
{
	Path path;
	String filename = path.find(argv[1]);
	if (filename == "")
	{
		Log.warn() << "Could not find rule file " << argv[1] << std::endl;
		return(1);
	}
	INIFile typename_rules(filename);
	typename_rules.read();
	TypenameRuleProcessor proc(typename_rules, "TypenameRules");

	HINFile infile(argv[2]);
	System system;
	infile >> system;
	infile.close();

	system.apply(proc);

	HINFile outfile(argv[3], std::ios::out);
	outfile << system;
	outfile.close();
}

<commit_msg>added: shortest usage information ever<commit_after>// $Id: assign_typenames_from_rules.C,v 1.2 2003/03/28 14:41:40 anker Exp $

#include <BALL/common.h>
#include <BALL/FORMAT/INIFile.h>
#include <BALL/FORMAT/HINFile.h>
#include <BALL/SYSTEM/path.h>
#include <BALL/MOLMEC/COMMON/typenameRuleProcessor.h>

using namespace BALL;
using namespace std;

int main(int argc, char** argv)
{
	if (argc != 4)
	{
		cout << "Need 3 arguments: INIFile input.hin output.hin" << endl;
		return(1);
	}

	Path path;
	String filename = path.find(argv[1]);
	if (filename == "")
	{
		cerr << "Could not find rule file " << argv[1] << std::endl;
		return(1);
	}

	INIFile typename_rules(filename);
	typename_rules.read();
	TypenameRuleProcessor proc(typename_rules, "TypenameRules");

	HINFile infile(argv[2]);
	System system;
	infile >> system;
	infile.close();

	system.apply(proc);

	HINFile outfile(argv[3], std::ios::out);
	outfile << system;
	outfile.close();
}

<|endoftext|>


<commit_before>#if defined(TARGET_HAS_ThirdPartyEIGEN)

#include "ovpCAlgorithmSingleTrialPhaseLockingValue.h"
#include <cmath>
#include <complex>
#include <Eigen/Dense>
#include <unsupported/Eigen/FFT>

using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;

using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;

using namespace Eigen;
using namespace std;

boolean CAlgorithmSingleTrialPhaseLockingValue::initialize(void)
{

	ip_pSignal1.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_InputMatrix1));
	ip_pSignal2.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_InputMatrix2));

	ip_pChannelPairs.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_LookupMatrix));
	op_pMatrix.initialize(this->getOutputParameter(OVP_Algorithm_Connectivity_OutputParameterId_OutputMatrix));

	// Create algorithm instance of Hilbert transform
	m_pHilbertTransform = &this->getAlgorithmManager().getAlgorithm(this->getAlgorithmManager().createAlgorithm(OVP_ClassId_Algorithm_HilbertTransform));
	m_pHilbertTransform->initialize();

	ip_pHilbertInput.initialize(m_pHilbertTransform->getInputParameter(OVP_Algorithm_HilbertTransform_InputParameterId_Matrix));
	op_pInstantaneousPhase.initialize(m_pHilbertTransform->getOutputParameter(OVP_Algorithm_HilbertTransform_OutputParameterId_PhaseMatrix));

	return true;
}

boolean CAlgorithmSingleTrialPhaseLockingValue::uninitialize(void) {

	ip_pSignal1.uninitialize();
	ip_pSignal2.uninitialize();

	ip_pHilbertInput.uninitialize();
	op_pInstantaneousPhase.uninitialize();

	ip_pChannelPairs.uninitialize();
	op_pMatrix.uninitialize();

	m_pHilbertTransform->uninitialize();
	this->getAlgorithmManager().releaseAlgorithm(*m_pHilbertTransform);

	return true;
}

boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
{
		const std::complex <double> iComplex(0.0,1.0);

		IMatrix* l_pInputMatrix1 = ip_pSignal1;
		IMatrix* l_pInputMatrix2 = ip_pSignal2;

		IMatrix* l_pChannelPairs = ip_pChannelPairs;
		IMatrix* l_pOutputMatrix = op_pMatrix;

		uint32 l_ui32ChannelCount1 = l_pInputMatrix1->getDimensionSize(0);
		uint32 l_ui32SamplesPerChannel1 = l_pInputMatrix1->getDimensionSize(1);

		uint32 l_ui32ChannelCount2 = l_pInputMatrix2->getDimensionSize(0);
		uint32 l_ui32SamplesPerChannel2 = l_pInputMatrix2->getDimensionSize(1);

		uint32 l_ui32PairsCount = ip_pChannelPairs->getDimensionSize(0)/2;

		MatrixXd l_pChannelToCompare = MatrixXd::Zero(ip_pChannelPairs->getDimensionSize(0),l_ui32SamplesPerChannel1);

		float64* l_ipMatrixBuffer1 = l_pInputMatrix1->getBuffer();
		float64* l_ipMatrixBuffer2 = l_pInputMatrix2->getBuffer();
		float64* l_opMatrixBuffer = l_pOutputMatrix->getBuffer();

		float64* l_pHilberInputBuffer = ip_pHilbertInput->getBuffer();
		float64* l_pInstPhaseBuffer = op_pInstantaneousPhase->getBuffer();

		if(this->isInputTriggerActive(OVP_Algorithm_Connectivity_InputTriggerId_Initialize))
		{

			if(l_ui32SamplesPerChannel1 != l_ui32SamplesPerChannel2)
			{
				this->getLogManager() << LogLevel_Error << "Can't compute S-PLV on two signals with different lengths";
				return false;
			}

			if(l_ui32SamplesPerChannel1==0||l_ui32SamplesPerChannel2==0)
			{
				this->getLogManager() << LogLevel_Error << "Can't compute S-PLV, input signal size = 0";
				return false;
			}

			// Setting size of output
			l_pOutputMatrix->setDimensionCount(2); // the output matrix will have 2 dimensions
			l_pOutputMatrix->setDimensionSize(0,l_ui32PairsCount); //
			l_pOutputMatrix->setDimensionSize(1,1);//

			// Setting name of output channels for visualization
			CString l_name1, l_name2, l_name;
			uint32 l_ui32Index;
			for(uint32 i=0;i<l_ui32PairsCount;i++)
			{
				l_ui32Index=2*i;
				l_name1 = l_pInputMatrix1->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index]);
				l_name2 = l_pInputMatrix2->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index+1]);
				l_name = l_name1+l_name2;
				l_pOutputMatrix->setDimensionLabel(0,i,l_name);
			}

			//
			ip_pHilbertInput->setDimensionCount(2);
			ip_pHilbertInput->setDimensionSize(0,1);
			ip_pHilbertInput->setDimensionSize(1,l_ui32SamplesPerChannel1);

		}

		if(this->isInputTriggerActive(OVP_Algorithm_Connectivity_InputTriggerId_Process))
		{
			VectorXd l_vecXdChannelToCompare1;
			VectorXd l_vecXdChannelToCompare2;
			VectorXd l_vecXdPhase1;
			VectorXd l_vecXdPhase2;

			std::complex <double> l_sum(0.0,0.0);

			//_______________________________________________________________________________________
			//
			// Compute S-PLV for each pairs
			//_______________________________________________________________________________________
			//

			for(uint32 channel = 0; channel < l_ui32PairsCount; channel++)
			{
				l_vecXdChannelToCompare1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
				l_vecXdChannelToCompare2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
				l_vecXdPhase1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
				l_vecXdPhase2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
				l_sum = (0.0,0.0);

				uint32 l_channelIndex = 2*channel; //Index on single channel

				//_______________________________________________________________________________________
				//
				// Form pairs with the lookup matrix given
				//_______________________________________________________________________________________
				//

				for(uint32 sample = 0; sample < l_ui32SamplesPerChannel1; sample++)
				{
					if(l_pChannelPairs->getBuffer()[sample] < l_ui32ChannelCount1)
					{
						l_pChannelToCompare(l_channelIndex,sample) = l_ipMatrixBuffer1[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex]*l_ui32SamplesPerChannel1];
						l_pChannelToCompare(l_channelIndex+1,sample) = l_ipMatrixBuffer2[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex+1]*l_ui32SamplesPerChannel2];
					}
				}

				// Retrieve the 2 channel to compare
				l_vecXdChannelToCompare1 = l_pChannelToCompare.row(l_channelIndex);
				l_vecXdChannelToCompare2 = l_pChannelToCompare.row(l_channelIndex+1);

				// Apply Hilbert transform to each channel to compute instantaneous phase
					// Channel 1
				for(uint32 sample = 0; sample<l_ui32SamplesPerChannel1; sample++)
				{
					l_pHilberInputBuffer[sample] = l_vecXdChannelToCompare1(sample);
				}

				m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize);
				m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);

					// Channel 2
				for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
				{
					l_vecXdPhase1(i) = op_pInstantaneousPhase->getBuffer()[i];
					l_pHilberInputBuffer[i] = l_vecXdChannelToCompare2(i);
				}

				m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize);
				m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);

				// Compute S-PLV and store it in l_opMatrixBuffer for each pair

				for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
				{
					l_vecXdPhase2(i) = op_pInstantaneousPhase->getBuffer()[i];

					l_sum += exp(iComplex*(l_vecXdPhase1(i)-l_vecXdPhase2(i)));
				}

				l_opMatrixBuffer[channel] = abs(l_sum)/l_ui32SamplesPerChannel1;

			}

			this->activateOutputTrigger(OVP_Algorithm_Connectivity_OutputTriggerId_ProcessDone, true);
		}

	return true;
}

#endif //TARGET_HAS_ThirdPartyEIGEN
<commit_msg>Clean up PLV algorithm code and correct bug<commit_after>#if defined(TARGET_HAS_ThirdPartyEIGEN)

#include "ovpCAlgorithmSingleTrialPhaseLockingValue.h"
#include <cmath>
#include <complex>
#include <Eigen/Dense>
#include <unsupported/Eigen/FFT>

using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;

using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;

using namespace Eigen;
using namespace std;

boolean CAlgorithmSingleTrialPhaseLockingValue::initialize(void)
{

	ip_pSignal1.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_InputMatrix1));
	ip_pSignal2.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_InputMatrix2));

	ip_pChannelPairs.initialize(this->getInputParameter(OVP_Algorithm_Connectivity_InputParameterId_LookupMatrix));
	op_pMatrix.initialize(this->getOutputParameter(OVP_Algorithm_Connectivity_OutputParameterId_OutputMatrix));

	// Create algorithm instance of Hilbert transform
	m_pHilbertTransform = &this->getAlgorithmManager().getAlgorithm(this->getAlgorithmManager().createAlgorithm(OVP_ClassId_Algorithm_HilbertTransform));
	m_pHilbertTransform->initialize();

	ip_pHilbertInput.initialize(m_pHilbertTransform->getInputParameter(OVP_Algorithm_HilbertTransform_InputParameterId_Matrix));
	op_pInstantaneousPhase.initialize(m_pHilbertTransform->getOutputParameter(OVP_Algorithm_HilbertTransform_OutputParameterId_PhaseMatrix));

	return true;
}

boolean CAlgorithmSingleTrialPhaseLockingValue::uninitialize(void) {

	ip_pSignal1.uninitialize();
	ip_pSignal2.uninitialize();

	ip_pHilbertInput.uninitialize();
	op_pInstantaneousPhase.uninitialize();

	ip_pChannelPairs.uninitialize();
	op_pMatrix.uninitialize();

	m_pHilbertTransform->uninitialize();
	this->getAlgorithmManager().releaseAlgorithm(*m_pHilbertTransform);

	return true;
}

boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
{
		const std::complex <double> iComplex(0.0,1.0);

		IMatrix* l_pInputMatrix1 = ip_pSignal1;
		IMatrix* l_pInputMatrix2 = ip_pSignal2;

		IMatrix* l_pChannelPairs = ip_pChannelPairs;
		IMatrix* l_pOutputMatrix = op_pMatrix;

		uint32 l_ui32ChannelCount1 = l_pInputMatrix1->getDimensionSize(0);
		uint32 l_ui32SamplesPerChannel1 = l_pInputMatrix1->getDimensionSize(1);

		uint32 l_ui32SamplesPerChannel2 = l_pInputMatrix2->getDimensionSize(1);

		uint32 l_ui32PairsCount = ip_pChannelPairs->getDimensionSize(0)/2;

		MatrixXd l_pChannelToCompare = MatrixXd::Zero(ip_pChannelPairs->getDimensionSize(0),l_ui32SamplesPerChannel1);

		float64* l_ipMatrixBuffer1 = l_pInputMatrix1->getBuffer();
		float64* l_ipMatrixBuffer2 = l_pInputMatrix2->getBuffer();
		float64* l_opMatrixBuffer = l_pOutputMatrix->getBuffer();

		float64* l_pHilberInputBuffer = ip_pHilbertInput->getBuffer();

		if(this->isInputTriggerActive(OVP_Algorithm_Connectivity_InputTriggerId_Initialize))
		{

			if(l_ui32SamplesPerChannel1 != l_ui32SamplesPerChannel2)
			{
				this->getLogManager() << LogLevel_Error << "Can't compute S-PLV on two signals with different lengths";
				return false;
			}

			if(l_ui32SamplesPerChannel1<2||l_ui32SamplesPerChannel2<2)
			{
				uint32 l_size = l_ui32SamplesPerChannel1<=l_ui32SamplesPerChannel2?l_ui32SamplesPerChannel1:l_ui32SamplesPerChannel2;
				this->getLogManager() << LogLevel_Error << "Can't compute S-PLV, input signal size = "<<l_size<<"\n";
				return false;
			}

			// Setting size of output
			l_pOutputMatrix->setDimensionCount(2); // the output matrix will have 2 dimensions
			l_pOutputMatrix->setDimensionSize(0,l_ui32PairsCount); //
			l_pOutputMatrix->setDimensionSize(1,1);//

			// Setting name of output channels for visualization
			CString l_name1, l_name2, l_name;
			uint32 l_ui32Index;
			for(uint32 i=0;i<l_ui32PairsCount;i++)
			{
				l_ui32Index=2*i;
				l_name1 = l_pInputMatrix1->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index]);
				l_name2 = l_pInputMatrix2->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index+1]);
				l_name = l_name1+l_name2;
				l_pOutputMatrix->setDimensionLabel(0,i,l_name);
			}

			//
			ip_pHilbertInput->setDimensionCount(2);
			ip_pHilbertInput->setDimensionSize(0,1);
			ip_pHilbertInput->setDimensionSize(1,l_ui32SamplesPerChannel1);

		}

		if(this->isInputTriggerActive(OVP_Algorithm_Connectivity_InputTriggerId_Process))
		{

			VectorXd l_vecXdChannelToCompare1;
			VectorXd l_vecXdChannelToCompare2;
			VectorXd l_vecXdPhase1;
			VectorXd l_vecXdPhase2;

			std::complex <double> l_sum(0.0,0.0);

			//_______________________________________________________________________________________
			//
			// Compute S-PLV for each pairs
			//_______________________________________________________________________________________
			//

			for(uint32 channel = 0; channel < l_ui32PairsCount; channel++)
			{
				l_vecXdChannelToCompare1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
				l_vecXdChannelToCompare2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
				l_vecXdPhase1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
				l_vecXdPhase2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
				l_sum = (0.0,0.0);

				uint32 l_channelIndex = 2*channel; //Index on single channel

				//_______________________________________________________________________________________
				//
				// Form pairs with the lookup matrix given
				//_______________________________________________________________________________________
				//

				for(uint32 sample = 0; sample < l_ui32SamplesPerChannel1; sample++)
				{
					if(l_pChannelPairs->getBuffer()[sample] < l_ui32ChannelCount1)
					{
						l_pChannelToCompare(l_channelIndex,sample) = l_ipMatrixBuffer1[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex]*l_ui32SamplesPerChannel1];
						l_pChannelToCompare(l_channelIndex+1,sample) = l_ipMatrixBuffer2[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex+1]*l_ui32SamplesPerChannel2];
					}
				}

				// Retrieve the 2 channel to compare
				l_vecXdChannelToCompare1 = l_pChannelToCompare.row(l_channelIndex);
				l_vecXdChannelToCompare2 = l_pChannelToCompare.row(l_channelIndex+1);

				// Apply Hilbert transform to each channel to compute instantaneous phase
					// Channel 1
				for(uint32 sample = 0; sample<l_ui32SamplesPerChannel1; sample++)
				{
					l_pHilberInputBuffer[sample] = l_vecXdChannelToCompare1(sample); // Pass channel 1 as input for the Hilbert transform algorithm
				}

				if(m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize)) // Check initialization before doing the process on channel 1
				{
					m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);

					// Channel 2
					for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
					{
						l_vecXdPhase1(i) = op_pInstantaneousPhase->getBuffer()[i]; // Store instantaneous phase given by Hilbert algorithm
						l_pHilberInputBuffer[i] = l_vecXdChannelToCompare2(i); // Pass channel 2 as input for the Hilbert transform algorithm
					}

					if(m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize)) // Check initialization before doing the process on channel 2
					{
						m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);

						// Compute S-PLV and store it in l_opMatrixBuffer for each pair

						for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
						{
							l_vecXdPhase2(i) = op_pInstantaneousPhase->getBuffer()[i]; // Store instantaneous phase given by Hilbert algorithm

							l_sum += exp(iComplex*(l_vecXdPhase1(i)-l_vecXdPhase2(i)));
						}

						l_opMatrixBuffer[channel] = abs(l_sum)/l_ui32SamplesPerChannel1;
					}

				}

				else // Display error if initialization of Hilbert transform was unsuccessful
				{
					this->getLogManager() << LogLevel_Error << "Hilbert transform initialization returned bad status\n";
				}

			}

			this->activateOutputTrigger(OVP_Algorithm_Connectivity_OutputTriggerId_ProcessDone, true);
		}

	return true;
}

#endif //TARGET_HAS_ThirdPartyEIGEN
<|endoftext|>


<commit_before>#pragma once

#include <string_view>

#include "Runtime/GCNTypes.hpp"
#include "Runtime/World/CActor.hpp"
#include "Runtime/World/CDamageVulnerability.hpp"
#include "Runtime/World/CFluidPlaneDoor.hpp"
#include "Runtime/World/CHealthInfo.hpp"

#include <zeus/CAABox.hpp>
#include <zeus/CFrustum.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector3f.hpp>

namespace urde {
class CVisorParameters;

class CScriptDamageableTrigger : public CActor {
private:
  zeus::CFrustum xe8_frustum;
  zeus::CAABox x14c_bounds;
  CHealthInfo x164_origHInfo;
  CHealthInfo x16c_hInfo;
  CDamageVulnerability x174_dVuln;
  u32 x1dc_faceFlag;
  float x1e0_alpha = 1.f;
  zeus::CTransform x1e4_faceDir;
  zeus::CTransform x214_faceDirInv;
  zeus::CVector3f x244_faceTranslate;
  float x250_alphaTimer = 0.f;
  mutable CFluidPlaneDoor x254_fluidPlane;
  union {
    struct {
      bool x300_24_notOccluded : 1;
      bool x300_25_alphaOut : 1;
      bool x300_26_outOfFrustum : 1;
      bool x300_27_invulnerable : 1;
      bool x300_28_canOrbit : 1;
    };
    u32 _dummy = 0;
  };
  void SetLinkedObjectAlpha(float a, CStateManager& mgr);
  float GetPuddleAlphaScale() const;

public:
  enum class ECanOrbit {
    NoOrbit,
    Orbit,
  };

  CScriptDamageableTrigger(TUniqueId uid, std::string_view name, const CEntityInfo& info,
                           const zeus::CVector3f& position, const zeus::CVector3f& extent, const CHealthInfo& hInfo,
                           const CDamageVulnerability& dVuln, u32 faceFlag, CAssetId patternTex1, CAssetId patternTex2,
                           CAssetId colorTex, ECanOrbit canOrbit, bool active, const CVisorParameters& vParams);

  void Accept(IVisitor& visitor) override;
  void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
  EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
                                                         const CWeaponMode&, EProjectileAttrib) const override;
  void Render(CStateManager& mgr) override;
  void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
  void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
  const CDamageVulnerability* GetDamageVulnerability() const override { return &x174_dVuln; }
  CHealthInfo* HealthInfo(CStateManager&) override { return &x16c_hInfo; }
  void Think(float, CStateManager&) override;
  std::optional<zeus::CAABox> GetTouchBounds() const override;
};
} // namespace urde
<commit_msg>CScriptDamageableTrigger: Remove mutable specifier on x254_fluidPlane<commit_after>#pragma once

#include <string_view>

#include "Runtime/GCNTypes.hpp"
#include "Runtime/World/CActor.hpp"
#include "Runtime/World/CDamageVulnerability.hpp"
#include "Runtime/World/CFluidPlaneDoor.hpp"
#include "Runtime/World/CHealthInfo.hpp"

#include <zeus/CAABox.hpp>
#include <zeus/CFrustum.hpp>
#include <zeus/CTransform.hpp>
#include <zeus/CVector3f.hpp>

namespace urde {
class CVisorParameters;

class CScriptDamageableTrigger : public CActor {
private:
  zeus::CFrustum xe8_frustum;
  zeus::CAABox x14c_bounds;
  CHealthInfo x164_origHInfo;
  CHealthInfo x16c_hInfo;
  CDamageVulnerability x174_dVuln;
  u32 x1dc_faceFlag;
  float x1e0_alpha = 1.f;
  zeus::CTransform x1e4_faceDir;
  zeus::CTransform x214_faceDirInv;
  zeus::CVector3f x244_faceTranslate;
  float x250_alphaTimer = 0.f;
  CFluidPlaneDoor x254_fluidPlane;
  union {
    struct {
      bool x300_24_notOccluded : 1;
      bool x300_25_alphaOut : 1;
      bool x300_26_outOfFrustum : 1;
      bool x300_27_invulnerable : 1;
      bool x300_28_canOrbit : 1;
    };
    u32 _dummy = 0;
  };
  void SetLinkedObjectAlpha(float a, CStateManager& mgr);
  float GetPuddleAlphaScale() const;

public:
  enum class ECanOrbit {
    NoOrbit,
    Orbit,
  };

  CScriptDamageableTrigger(TUniqueId uid, std::string_view name, const CEntityInfo& info,
                           const zeus::CVector3f& position, const zeus::CVector3f& extent, const CHealthInfo& hInfo,
                           const CDamageVulnerability& dVuln, u32 faceFlag, CAssetId patternTex1, CAssetId patternTex2,
                           CAssetId colorTex, ECanOrbit canOrbit, bool active, const CVisorParameters& vParams);

  void Accept(IVisitor& visitor) override;
  void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
  EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
                                                         const CWeaponMode&, EProjectileAttrib) const override;
  void Render(CStateManager& mgr) override;
  void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
  void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
  const CDamageVulnerability* GetDamageVulnerability() const override { return &x174_dVuln; }
  CHealthInfo* HealthInfo(CStateManager&) override { return &x16c_hInfo; }
  void Think(float, CStateManager&) override;
  std::optional<zeus::CAABox> GetTouchBounds() const override;
};
} // namespace urde
<|endoftext|>


<commit_before>// ----------------------------------------------------------------------------
// PSP Player Emulation Suite
// Copyright (C) 2006 Ben Vanik (noxa)
// Licensed under the LGPL - see License.txt in the project root for details
// ----------------------------------------------------------------------------

#include "StdAfx.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "R4000Cpu.h"
#include "R4000BiosStubs.h"
#include "R4000Generator.h"

using namespace System;
using namespace Noxa::Emulation::Psp::Bios;
using namespace Noxa::Emulation::Psp::Cpu;

#pragma unmanaged

// sceRtc ----------------------------------------------
int sceRtcGetTickResolution();
void sceRtcGetCurrentTick( LARGE_INTEGER* address );

// sceDisplayUser --------------------------------------
extern int sceDisplaySetFrameBuf( int address, int bufferWidth, int pixelFormat, int syncMode );

// sceGeUser -------------------------------------------
//int sceGeEdramGetSize(); <-- inlined
//int sceGeEdramGetAddr(); <-- inlined
extern int sceGeListEnQueue( uint list, uint stall, int cbid, uint arg, int head );
extern int sceGeListDeQueue( int qid );
extern int sceGeListUpdateStallAddr( int qid, uint stall );
extern int sceGeListSync( int qid, int syncType );
extern int sceGeDrawSync( int syncType );

#pragma managed

bool R4000BiosStubs::EmitCall( R4000GenContext^ context, R4000Generator *g, int address, int nid )
{
	// Put the return value, if any, in EAX - if you don't return anything, put 0 just in case!

	switch( nid )
	{
	// sceRtc ----------------------------------------------
	case 0xc41c2853:		// sceRtcGetTickResolution
		g->call( ( int )sceRtcGetTickResolution );
		return true;
	case 0x3f7ad767:		// sceRtcGetCurrentTick
		g->mov( EAX, MREG( CTX, 4 ) );
		g->and( EAX, 0x3FFFFFFF );
		g->sub( EAX, MainMemoryBase );
		g->add( EAX, ( int )context->Memory->MainMemory );
		g->push( EAX );
		g->call( ( int )sceRtcGetCurrentTick );
		g->add( ESP, 4 );
		g->mov( EAX, 0 );
		return true;
	}

#ifdef NATIVEVIDEOINTERFACE
	// Note for video stuff: we must have a native video inteface for it to work!
	bool nativeVideoInterface = ( R4000Cpu::GlobalCpu->Emulator->Video->NativeInterface != IntPtr::Zero );

	if( nativeVideoInterface == true )
	{
		switch( nid )
		{
		// sceDisplayUser --------------------------------------
		case 0x289d82fe:		// sceDisplaySetFrameBuf
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceDisplaySetFrameBuf );
			g->add( ESP, 16 );
			g->mov( EAX, 0 );
			return true;
		// sceGeUser -------------------------------------------
		case 0x1f6752ad:		// sceGeEdramGetSize
			g->mov( EAX, FrameBufferSize );
			return true;
		case 0xe47e40e4:		// sceGeEdramGetAddr
			g-> mov( EAX, FrameBufferBase );
			return true;
		case 0xab49e76a:		// sceGeListEnQueue
			g->push( ( uint )0 ); // head = false
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListEnQueue );
			g->add( ESP, 20 );
			return true;
		case 0x1c0d95a6:		// sceGeListEnQueueHead
			g->push( ( uint )1 ); // head = true
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListEnQueue );
			g->add( ESP, 20 );
			return true;
		case 0x5fb86ab0:		// sceGeListDeQueue
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListDeQueue );
			g->add( ESP, 4 );
			return true;
		case 0xe0d68148:		// sceGeListUpdateStallAddr
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListUpdateStallAddr );
			g->add( ESP, 8 );
			return true;
		case 0x03444eb4:		// sceGeListSync
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListSync );
			g->add( ESP, 8 );
			return true;
		case 0xb287bd61:		// sceGeDrawSync
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeDrawSync );
			g->add( ESP, 4 );
			return true;
		}
	}
#endif

	return false;
}

#pragma unmanaged

// sceRtc ----------------------------------------------

int sceRtcGetTickResolution()
{
	LARGE_INTEGER frequency;
	QueryPerformanceFrequency( &frequency );
	return ( uint )frequency.LowPart;
}

void sceRtcGetCurrentTick( LARGE_INTEGER* address )
{
	QueryPerformanceCounter( address );
}

#pragma managed
<commit_msg>Thought the crazy timing behavior would be caused by starting the app with a clock so large (uptime of 30 days at 2ghz = mad clock ticks), so I wrote an sceRtcGetCurrentTick that started the app at 0. It tricked me by working right, and then on the next run not running right. Stupid POS. Going back to textures now...<commit_after>// ----------------------------------------------------------------------------
// PSP Player Emulation Suite
// Copyright (C) 2006 Ben Vanik (noxa)
// Licensed under the LGPL - see License.txt in the project root for details
// ----------------------------------------------------------------------------

#include "StdAfx.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "R4000Cpu.h"
#include "R4000BiosStubs.h"
#include "R4000Generator.h"

using namespace System;
using namespace Noxa::Emulation::Psp::Bios;
using namespace Noxa::Emulation::Psp::Cpu;

#pragma unmanaged

// sceRtc ----------------------------------------------
int sceRtcGetTickResolution();
void sceRtcGetCurrentTick( LARGE_INTEGER* address );

// sceDisplayUser --------------------------------------
extern int sceDisplaySetFrameBuf( int address, int bufferWidth, int pixelFormat, int syncMode );

// sceGeUser -------------------------------------------
//int sceGeEdramGetSize(); <-- inlined
//int sceGeEdramGetAddr(); <-- inlined
extern int sceGeListEnQueue( uint list, uint stall, int cbid, uint arg, int head );
extern int sceGeListDeQueue( int qid );
extern int sceGeListUpdateStallAddr( int qid, uint stall );
extern int sceGeListSync( int qid, int syncType );
extern int sceGeDrawSync( int syncType );

#pragma managed

bool R4000BiosStubs::EmitCall( R4000GenContext^ context, R4000Generator *g, int address, int nid )
{
	// Put the return value, if any, in EAX - if you don't return anything, put 0 just in case!

	switch( nid )
	{
	// sceRtc ----------------------------------------------
	case 0xc41c2853:		// sceRtcGetTickResolution
		g->call( ( int )sceRtcGetTickResolution );
		return true;
	case 0x3f7ad767:		// sceRtcGetCurrentTick
		g->mov( EAX, MREG( CTX, 4 ) );
		g->and( EAX, 0x3FFFFFFF );
		g->sub( EAX, MainMemoryBase );
		g->add( EAX, ( int )context->Memory->MainMemory );
		g->push( EAX );
		g->call( ( int )sceRtcGetCurrentTick );
		g->add( ESP, 4 );
		g->mov( EAX, 0 );
		return true;
	}

#ifdef NATIVEVIDEOINTERFACE
	// Note for video stuff: we must have a native video inteface for it to work!
	bool nativeVideoInterface = ( R4000Cpu::GlobalCpu->Emulator->Video->NativeInterface != IntPtr::Zero );

	if( nativeVideoInterface == true )
	{
		switch( nid )
		{
		// sceDisplayUser --------------------------------------
		case 0x289d82fe:		// sceDisplaySetFrameBuf
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceDisplaySetFrameBuf );
			g->add( ESP, 16 );
			g->mov( EAX, 0 );
			return true;
		// sceGeUser -------------------------------------------
		case 0x1f6752ad:		// sceGeEdramGetSize
			g->mov( EAX, FrameBufferSize );
			return true;
		case 0xe47e40e4:		// sceGeEdramGetAddr
			g-> mov( EAX, FrameBufferBase );
			return true;
		case 0xab49e76a:		// sceGeListEnQueue
			g->push( ( uint )0 ); // head = false
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListEnQueue );
			g->add( ESP, 20 );
			return true;
		case 0x1c0d95a6:		// sceGeListEnQueueHead
			g->push( ( uint )1 ); // head = true
			g->push( MREG( CTX, 7 ) );
			g->push( MREG( CTX, 6 ) );
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListEnQueue );
			g->add( ESP, 20 );
			return true;
		case 0x5fb86ab0:		// sceGeListDeQueue
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListDeQueue );
			g->add( ESP, 4 );
			return true;
		case 0xe0d68148:		// sceGeListUpdateStallAddr
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListUpdateStallAddr );
			g->add( ESP, 8 );
			return true;
		case 0x03444eb4:		// sceGeListSync
			g->push( MREG( CTX, 5 ) );
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeListSync );
			g->add( ESP, 8 );
			return true;
		case 0xb287bd61:		// sceGeDrawSync
			g->push( MREG( CTX, 4 ) );
			g->call( ( int )sceGeDrawSync );
			g->add( ESP, 4 );
			return true;
		}
	}
#endif

	return false;
}

#pragma unmanaged

// sceRtc ----------------------------------------------

int sceRtcGetTickResolution()
{
	LARGE_INTEGER frequency;
	QueryPerformanceFrequency( &frequency );
	return ( uint )frequency.LowPart;
}

#if 1
void sceRtcGetCurrentTick( LARGE_INTEGER* address )
{
	QueryPerformanceCounter( address );
}
#else
// This alternate version will start the app at time 0
LARGE_INTEGER startTick;
void sceRtcGetCurrentTick( LARGE_INTEGER* address )
{
	if( startTick.QuadPart == 0 )
	{
		QueryPerformanceCounter( &startTick );
	}
	QueryPerformanceCounter( address );
	address->QuadPart -= startTick.QuadPart;
}
#endif

#pragma managed
<|endoftext|>


<commit_before>#include "PlatformEntity.h"
PlatformEntity::PlatformEntity() {}
PlatformEntity::~PlatformEntity()
{
	this->Shutdown();
}
int PlatformEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp, AIComponent * aiComp)
{
	int result = 0;
	this->InitializeBase(entityID, pComp, gComp, nullptr, aiComp);
	return result;
}
int PlatformEntity::Shutdown()
{
	int result = 0;
	if (this->m_ActiveSound != nullptr)
		this->m_ActiveSound->drop();
	return result;
}

int PlatformEntity::Update(float deltaTime, InputHandler * inputHandler)
{
	int result = 0;
	this->SyncComponents();

	// Adjust misplaced graphics component - hack...
	this->m_gComp->worldMatrix = DirectX::XMMatrixMultiply(this->m_pComp->PC_OBB.ort,
		DirectX::XMMatrixTranslationFromVector(
			DirectX::XMVectorSubtract(this->m_pComp->PC_pos,
				DirectX::XMVECTOR{
		m_gComp->modelPtr->GetOBBData().position.x,
			m_gComp->modelPtr->GetOBBData().position.y,
			m_gComp->modelPtr->GetOBBData().position.z, 0})));

	if (this->GetAIComponent()->AC_triggered)
	{
		if (this->m_ActiveSound == nullptr)
		{
			DirectX::XMFLOAT3 pos;
			DirectX::XMStoreFloat3(&pos, this->GetPhysicsComponent()->PC_pos);
			this->m_ActiveSound = SoundHandler::instance().PlaySound3D(Sounds3D::GENERAL_LIFT, pos, true, true);
		}
		else
		{
			if (this->m_ActiveSound->getIsPaused())
			{
				this->m_ActiveSound->setIsPaused(false);
			}
		}
	}
	else
	{
		if (this->m_ActiveSound != nullptr && !this->m_ActiveSound->getIsPaused())
		{
			this->m_ActiveSound->setPlayPosition(0);
			this->m_ActiveSound->setIsPaused(true);	//Pause the walking sound
		}
	}
	return result;
}

int PlatformEntity::React(int entityID, EVENT reactEvent)
{
	switch (reactEvent)
	{
	//case FIELD_CONTAINS:
	//	break;
	//case FIELD_ENTERED:
	//	break;
	//case FIELD_EXITED:
	//	break;
	//case FIELD_CONDITIONS_MET:
	//	break;
	//case FIELD_ENABLED:
	//	break;
	//case FIELD_DISABLED:
	//	break;
	case BUTTON_DEACTIVE:
		this->GetAIComponent()->AC_triggered = false;
		break;
	case BUTTON_ACTIVE:
		this->GetAIComponent()->AC_triggered = true;
		break;
	case LEVER_DEACTIVE:
		this->GetAIComponent()->AC_triggered = false;
		break;
	case LEVER_ACTIVE:
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_INCREASING:
		printf("INCREASING\n");
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_DECREASING:
		printf("INCREASING\n");
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_RESET:
		printf("RESET\n");
		this->GetAIComponent()->AC_triggered = false;
		break;
	default:
		break;
	}
	return 1;
}<commit_msg>ADD Change Direction on Platforms with Wheel<commit_after>#include "PlatformEntity.h"
PlatformEntity::PlatformEntity() {}
PlatformEntity::~PlatformEntity()
{
	this->Shutdown();
}
int PlatformEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp, AIComponent * aiComp)
{
	int result = 0;
	this->InitializeBase(entityID, pComp, gComp, nullptr, aiComp);
	return result;
}
int PlatformEntity::Shutdown()
{
	int result = 0;
	if (this->m_ActiveSound != nullptr)
		this->m_ActiveSound->drop();
	return result;
}

int PlatformEntity::Update(float deltaTime, InputHandler * inputHandler)
{
	int result = 0;
	this->SyncComponents();

	// Adjust misplaced graphics component - hack...
	this->m_gComp->worldMatrix = DirectX::XMMatrixMultiply(this->m_pComp->PC_OBB.ort,
		DirectX::XMMatrixTranslationFromVector(
			DirectX::XMVectorSubtract(this->m_pComp->PC_pos,
				DirectX::XMVECTOR{
		m_gComp->modelPtr->GetOBBData().position.x,
			m_gComp->modelPtr->GetOBBData().position.y,
			m_gComp->modelPtr->GetOBBData().position.z, 0})));

	if (this->GetAIComponent()->AC_triggered)
	{
		if (this->m_ActiveSound == nullptr)
		{
			DirectX::XMFLOAT3 pos;
			DirectX::XMStoreFloat3(&pos, this->GetPhysicsComponent()->PC_pos);
			this->m_ActiveSound = SoundHandler::instance().PlaySound3D(Sounds3D::GENERAL_LIFT, pos, true, true);
		}
		else
		{
			if (this->m_ActiveSound->getIsPaused())
			{
				this->m_ActiveSound->setIsPaused(false);
			}
		}
	}
	else
	{
		if (this->m_ActiveSound != nullptr && !this->m_ActiveSound->getIsPaused())
		{
			this->m_ActiveSound->setPlayPosition(0);
			this->m_ActiveSound->setIsPaused(true);	//Pause the walking sound
		}
	}
	return result;
}

int PlatformEntity::React(int entityID, EVENT reactEvent)
{
	switch (reactEvent)
	{
	//case FIELD_CONTAINS:
	//	break;
	//case FIELD_ENTERED:
	//	break;
	//case FIELD_EXITED:
	//	break;
	//case FIELD_CONDITIONS_MET:
	//	break;
	//case FIELD_ENABLED:
	//	break;
	//case FIELD_DISABLED:
	//	break;
	case BUTTON_DEACTIVE:
		this->GetAIComponent()->AC_triggered = false;
		break;
	case BUTTON_ACTIVE:
		this->GetAIComponent()->AC_triggered = true;
		break;
	case LEVER_DEACTIVE:
		this->GetAIComponent()->AC_triggered = false;
		break;
	case LEVER_ACTIVE:
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_INCREASING:
		printf("INCREASING\n");
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_DECREASING:
		printf("INCREASING\n");
		this->GetAIComponent()->AC_triggered = true;
		break;
	case WHEEL_RESET:
		printf("RESET\n");

		this->GetAIComponent()->AC_triggered = false;

		/*if (this->GetAIComponent()->AC_direction == 0)
		{
			this->GetAIComponent()->AC_direction = 1;

			int i = this->GetAIComponent()->AC_nextWaypointID;
			int k = this->GetAIComponent()->AC_latestWaypointID;

			this->GetAIComponent()->AC_nextWaypointID = this->GetAIComponent()->AC_latestWaypointID;
			this->GetAIComponent()->AC_latestWaypointID = this->GetAIComponent()->AC_nextWaypointID;
		}
		else
		{
			this->GetAIComponent()->AC_direction = 0;
			this->GetAIComponent()->AC_nextWaypointID = this->GetAIComponent()->AC_latestWaypointID;
			this->GetAIComponent()->AC_latestWaypointID = this->GetAIComponent()->AC_nextWaypointID;
		}*/

		break;
	default:
		break;
	}
	return 1;
}<|endoftext|>