blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f5b90021e674edfb92c5685866df4fef9f0018ff
|
ed649693468835126ae0bc56a9a9745cbbe02750
|
/alljoyn_core/src/winrt/binding/inc/BusAttachment.h
|
d10773c05e3ffc95056df943f3e2f37ec0618d24
|
[] |
no_license
|
tkellogg/alljoyn-core
|
982304d78da73f07f888c7cbd56731342585d9a5
|
931ed98b3f5e5dbd40ffb529a78825f28cc59037
|
refs/heads/master
| 2020-12-25T18:22:32.166135
| 2014-07-17T13:56:18
| 2014-07-17T13:58:56
| 21,984,205
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 55,397
|
h
|
BusAttachment.h
|
/******************************************************************************
*
* Copyright (c) 2011-2012, AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*****************************************************************************/
#pragma once
#include <alljoyn/DBusStd.h>
#include <alljoyn/Session.h>
#include <alljoyn/BusAttachment.h>
#include <TransportMaskType.h>
#include <InterfaceDescription.h>
#include <SessionOpts.h>
#include <SocketStream.h>
#include <qcc/ManagedObj.h>
#include <qcc/Mutex.h>
#include <Status_CPP0x.h>
#include <map>
namespace AllJoyn {
ref class InterfaceMember;
ref class MessageReceiver;
ref class BusObject;
ref class BusListener;
ref class SessionListener;
ref class SessionPortListener;
ref class SessionOpts;
ref class ProxyBusObject;
ref class AuthListener;
ref class KeyStoreListener;
public enum class RequestNameType {
/// <summary>
///Allow others to take ownership of this name
/// </summary>
DBUS_NAME_ALLOW_REPLACEMENT = DBUS_NAME_FLAG_ALLOW_REPLACEMENT,
/// <summary>
///Attempt to take ownership of name if already taken
/// </summary>
DBUS_NAME_REPLACE_EXISTING = DBUS_NAME_FLAG_REPLACE_EXISTING,
/// <summary>
///Fail if name cannot be immediately obtained
/// </summary>
DBUS_NAME_DO_NOT_QUEUE = DBUS_NAME_FLAG_DO_NOT_QUEUE
};
/// <summary>
///The result of the asynchronous operation for joining a session
/// </summary>
public ref class JoinSessionResult sealed {
public:
/// <summary>
///The BusAttachment object that makes the call.
/// </summary>
property BusAttachment ^ Bus;
/// <summary>
///User defined context which will be passed as-is to callback.
/// </summary>
property Platform::Object ^ Context;
/// <summary>
///Optional listener called when session related events occur. May be NULL.
/// </summary>
property SessionListener ^ Listener;
/// <summary>
///Result of the operation. The value is ER_OK is the session is joined successfully.
/// </summary>
property QStatus Status;
/// <summary>
///The session id of the session joined.
/// </summary>
property ajn::SessionId SessionId;
/// <summary>
///Session options imposed by the session creator.
/// </summary>
property SessionOpts ^ Opts;
private:
friend ref class BusAttachment;
friend class _BusAttachment;
JoinSessionResult(BusAttachment ^ bus, SessionListener ^ listener, Platform::Object ^ context)
{
Bus = bus;
Context = context;
Listener = listener;
Status = QStatus::ER_OK;
SessionId = (ajn::SessionId)-1;
Opts = nullptr;
_exception = nullptr;
_stdException = NULL;
}
~JoinSessionResult()
{
Bus = nullptr;
Context = nullptr;
Listener = nullptr;
Opts = nullptr;
_exception = nullptr;
if (NULL != _stdException) {
delete _stdException;
_stdException = NULL;
}
}
void Wait()
{
qcc::Event::Wait(_event, qcc::Event::WAIT_FOREVER);
// Propagate exception state
if (nullptr != _exception) {
throw _exception;
}
if (NULL != _stdException) {
throw _stdException;
}
}
void Complete()
{
_event.SetEvent();
}
Platform::Exception ^ _exception;
std::exception* _stdException;
qcc::Event _event;
};
/// <summary>
///The result of the asynchronous operation for setting the link idle timeout
/// </summary>
public ref class SetLinkTimeoutResult sealed {
public:
/// <summary>
///The BusAttachment object that makes the call
/// </summary>
property BusAttachment ^ Bus;
/// <summary>
///User defined context which will be passed as-is to callback.
/// </summary>
property Platform::Object ^ Context;
/// <summary>
///Result of the operation. The value is ER_OK if the link timeout is set successfully.
/// </summary>
property QStatus Status;
/// <summary>
///The actual link idle timeout value.
/// </summary>
property uint32_t Timeout;
private:
friend ref class BusAttachment;
friend class _BusAttachment;
SetLinkTimeoutResult(BusAttachment ^ bus, Platform::Object ^ context)
{
Bus = bus;
Context = context;
Status = QStatus::ER_OK;
Timeout = (uint32_t)-1;
_exception = nullptr;
_stdException = NULL;
}
~SetLinkTimeoutResult()
{
Bus = nullptr;
Context = nullptr;
_exception = nullptr;
if (NULL != _stdException) {
delete _stdException;
_stdException = NULL;
}
}
void Wait()
{
qcc::Event::Wait(_event, qcc::Event::WAIT_FOREVER);
// Propagate exception state
if (nullptr != _exception) {
throw _exception;
}
if (NULL != _stdException) {
throw _stdException;
}
}
void Complete()
{
_event.SetEvent();
}
Platform::Exception ^ _exception;
std::exception* _stdException;
qcc::Event _event;
};
ref class __BusAttachment {
private:
friend ref class BusAttachment;
friend class _BusAttachment;
__BusAttachment();
~__BusAttachment();
property ProxyBusObject ^ DBusProxyBusObject;
property ProxyBusObject ^ AllJoynProxyBusObject;
property ProxyBusObject ^ AllJoynDebugProxyBusObject;
property Platform::String ^ UniqueName;
property Platform::String ^ GlobalGUIDString;
property uint32_t Timestamp;
};
class _BusAttachment : protected ajn::BusAttachment, protected ajn::BusAttachment::JoinSessionAsyncCB, protected ajn::BusAttachment::SetLinkTimeoutAsyncCB {
protected:
friend class qcc::ManagedObj<_BusAttachment>;
friend ref class BusAttachment;
friend ref class BusObject;
friend ref class ProxyBusObject;
friend class _BusListener;
friend class _AuthListener;
friend class _BusObject;
friend class _KeyStoreListener;
friend class _MessageReceiver;
friend class _ProxyBusObject;
friend class _ProxyBusObjectListener;
friend class _SessionListener;
friend class _SessionPortListener;
_BusAttachment(const char* applicationName, bool allowRemoteMessages, uint32_t concurrency);
~_BusAttachment();
void JoinSessionCB(::QStatus s, ajn::SessionId sessionId, const ajn::SessionOpts& opts, void* context);
void SetLinkTimeoutCB(::QStatus s, uint32_t timeout, void* context);
void DispatchCallback(Windows::UI::Core::DispatchedHandler ^ callback);
bool IsOriginSTA();
__BusAttachment ^ _eventsAndProperties;
KeyStoreListener ^ _keyStoreListener;
AuthListener ^ _authListener;
Windows::UI::Core::CoreDispatcher ^ _dispatcher;
bool _originSTA;
std::map<void*, void*> _busObjectMap;
std::map<void*, void*> _signalHandlerMap;
std::map<void*, void*> _busListenerMap;
std::map<ajn::SessionPort, std::map<void*, void*>*> _sessionPortListenerMap;
std::map<ajn::SessionId, std::map<void*, void*>*> _sessionListenerMap;
qcc::Mutex _mutex;
};
/// <summary>
/// BusAttachment is the top-level object responsible for connecting to and optionally managing a message bus
/// </summary>
public ref class BusAttachment sealed {
public:
/// <summary>
/// Construct a BusAttachment.
/// </summary>
/// <param name="applicationName">Name of the application.</param>
/// <param name="allowRemoteMessages">True if this attachment is allowed to receive messages from remote devices.</param>
/// <param name="concurrency">The maximum number of concurrent method and signal handlers locally executing. This value isn't enforced and only provided for API completeness.</param>
BusAttachment(Platform::String ^ applicationName, bool allowRemoteMessages, uint32_t concurrency);
/// <summary>
/// Get the concurrent method and signal handler limit.
/// </summary>
/// <returns>The maximum number of concurrent method and signal handlers.</returns>
uint32_t GetConcurrency();
/// <summary>
/// Allow the currently executing method/signal handler to enable concurrent callbacks
/// during the scope of the handler's execution.
/// </summary>
void EnableConcurrentCallbacks();
/// <summary>
/// Create an interface description with a given name.
/// </summary>
/// <remarks>
/// Typically, interfaces that are implemented by BusObjects are created here.
/// Interfaces that are implemented by remote objects are added automatically by
/// the bus if they are not already present via ProxyBusObject::IntrospectRemoteObject().
/// Because interfaces are added both explicitly (via this method) and implicitly
/// (via ProxyBusObject::IntrospectRemoteObject), there is the possibility that creating
/// an interface here will fail because the interface already exists. If this happens, and
/// exception with be thrown and the HRESULT values with be #ER_BUS_IFACE_ALREADY_EXISTS.
/// Interfaces created with this method need to be activated using InterfaceDescription::Activate()
/// once all of the methods, signals, etc have been added to the interface. The interface will
/// be unaccessible (via BusAttachment::GetInterfaces() or BusAttachment::GetInterface()) until
/// it is activated.
/// </remarks>
/// <param name="name">The requested interface name.</param>
/// <param name="iface">Returns the newly created interface description.</param>
/// <param name="secure">If true the interface is secure and method calls and signals will be encrypted.</param>
/// <exception cref="Platform::COMException">
/// HRESULT == #ER_BUS_IFACE_ALREADY_EXISTS if requested interface already exists
/// </exception>
/// <see cref="ProxyBusObject::IntrospectRemoteObject"/>
/// <see cref="InterfaceDescription::Activate"/>
/// <see cref="BusAttachment::GetInterface"/>
void CreateInterface(Platform::String ^ name, Platform::WriteOnlyArray<InterfaceDescription ^> ^ iface, bool secure);
/// <summary>
/// Create an interface description from XML
/// </summary>
/// <remarks>
/// Initialize one more interface descriptions from an XML string in DBus introspection format.
/// The root tag of the XML can be a node or a stand alone interface tag. To initialize more
/// than one interface the interfaces need to be nested in a node tag.
///
/// Note that when this method fails during parsing, an exception will be thrown.
/// However, any interfaces which were successfully parsed prior to the failure may be registered
/// with the bus.
/// </remarks>
/// <param name="xml">An XML string in DBus introspection format</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void CreateInterfacesFromXml(Platform::String ^ xml);
/// <summary>
/// Returns the existing activated InterfaceDescriptions.
/// </summary>
/// <param name="ifaces">A pointer to an InterfaceDescription array to receive the interfaces. Can be NULL in
/// which case no interfaces are returned and the return value gives the number of interface available.
/// </param>
/// <returns>The number of interfaces returned or the total number of interfaces if ifaces is NULL.</returns>
uint32_t GetInterfaces(Platform::WriteOnlyArray<InterfaceDescription ^> ^ ifaces);
/// <summary>
/// Retrieve an existing activated InterfaceDescription.
/// </summary>
/// <param name="name">Interface name</param>
/// <returns>A reference to the registered interface</returns>
InterfaceDescription ^ GetInterface(Platform::String ^ name);
/// <summary>
/// Delete an interface description with a given name.
/// </summary>
/// <remarks>
/// Deleting an interface is only allowed if that interface has never been activated.
/// </remarks>
/// <param name="iface">The unactivated interface to be deleted.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NO_SUCH_INTERFACE if the interface was not found
/// </exception>
void DeleteInterface(InterfaceDescription ^ iface);
/// <summary>
/// Start the process of spinning up the independent threads used in
/// the bus attachment, preparing it for use.
/// </summary>
/// <remarks>
/// This method only begins the process of starting the bus. Sending and
/// receiving messages cannot begin until the bus is Connect()ed.
/// In most cases, it is not required to understand the threading model of
/// the bus attachment, with one important exception: The bus attachment may
/// send callbacks to registered listeners using its own internal threads.
/// This means that any time a listener of any kind is used in a program, the
/// implication is that a the overall program is multithreaded, irrespective
/// of whether or not threads are explicitly used. This, in turn, means that
/// any time shared state is accessed in listener methods, that state must be
/// protected.
/// As soon as Start() is called, clients of a bus attachment with listeners
/// must be prepared to receive callbacks on those listeners in the context
/// of a thread that will be different from the thread running the main
/// program or any other thread in the client.
/// Although intimate knowledge of the details of the threading model are not
/// required to use a bus attachment (beyond the caveat above) we do provide
/// methods on the bus attachment that help users reason about more complex
/// threading situations. This will apply to situations where clients of the
/// bus attachment are multithreaded and need to interact with the
/// multithreaded bus attachment. These methods can be especially useful
/// during shutdown, when the two separate threading systems need to be
/// gracefully brought down together.
/// The BusAttachment methods Start(), StopAsync() and JoinSessionAsync() all work together to
/// manage the autonomous activities that can happen in a BusAttachment.
/// These activities are carried out by so-called hardware threads. POSIX
/// defines functions used to control hardware threads, which it calls
/// pthreads. Many threading packages use similar constructs.
/// In a threading package, a start method asks the underlying system to
/// arrange for the start of thread execution. Threads are not necessarily
/// running when the start method returns, but they are being *started*. Some time later,
/// a thread of execution appears in a thread run function, at which point the
/// thread is considered *running*. At some later time, executing a stop method asks the
/// underlying system to arrange for a thread to end its execution. The system
/// typically sends a message to the thread to ask it to stop doing what it is doing.
/// The thread is running until it responds to the stop message, at which time the
/// run method exits and the thread is considered *stopping*.
/// Note that neither of Start() nor Stop() are synchronous in the sense that
/// one has actually accomplished the desired effect upon the return from a
/// call. Of particular interest is the fact that after a call to Stop(),
/// threads will still be *running* for some non-deterministic time.
/// In order to wait until all of the threads have actually stopped, a
/// blocking call is required. In threading packages this is typically
/// called join, and our corresponding method is called JoinSessionAsync().
/// A Start() method call should be thought of as mapping to a threading
/// package start function. it causes the activity threads in the
/// BusAttachment to be spun up and gets the attachment ready to do its main
/// job. As soon as Start() is called, the user should be prepared for one
/// or more of these threads of execution to pop out of the bus attachment
/// and into a listener callback.
/// The Stop() method call should be thought of as mapping to a threading
/// package stop function. It asks the BusAttachment to begin shutting down
/// its various threads of execution, but does not wait for any threads to exit.
/// A call to the JoinSessionAsync() method should be thought of as mapping to a
/// threading package join function call. It blocks and waits until all of
/// the threads in the BusAttachment have in fact exited their Run functions,
/// gone through the stopping state and have returned their status. When
/// the JoinAsync() method returns, one may be assured that no threads are running
/// in the bus attachment, and therefore there will be no callbacks in
/// progress and no further callbacks will ever come out of a particular
/// instance of a bus attachment.
/// It is important to understand that since Start(), StopAsync() and JoinSessionAsync() map
/// to threads concepts and functions, one should not expect them to clean up
/// any bus attachment state when they are called. These functions are only
/// present to help in orderly termination of complex threading systems.
/// <see cref="BusAttachment::StopAsync"/>
/// <see cref="BusAttachment::JoinSessionAsync"/>
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_BUS_ALREADY_STARTED if already started.
/// Other error status codes indicating a failure.
/// </exception>
void Start();
/// <summary>
/// Ask the threading subsystem in the bus attachment to begin the
/// process of ending the execution of its threads.
/// </summary>
/// <remarks>
/// The StopAsync() method call on a bus attachment should be thought of as
/// mapping to a threading package stop function.
/// <see cref="BusAttachment::Start"/>
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error if
/// unable to begin the process of stopping the BusAttachment threads.
/// </exception>
/// <returns>A handle to the async operation which can be used for synchronization.</returns>
Windows::Foundation::IAsyncAction ^ StopAsync();
/// <summary>
/// Determine if the bus attachment has been started by a call to <see cref="Start"/>.
/// </summary>
/// <remarks>
/// For more information see:
/// <see cref="BusAttachment::Start"/>
/// <see cref="BusAttachment::StopAsync"/>
/// </remarks>
/// <returns>True if the message bus has been started by a call to <see cref="Start"/>.</returns>
bool IsStarted();
/// <summary>
/// Determine if the bus attachment has been stopped by a call to <see cref="StopAsync"/>.
/// </summary>
/// <remarks>
/// For more information see:
/// <see cref="BusAttachment::Start"/>
/// <see cref="BusAttachment::StopAsync"/>
/// </remarks>
/// <returns>True if the message bus has been started by a call to <see cref="Start"/>.</returns>
bool IsStopping();
/// <summary>
/// Connect to a remote bus address.
/// </summary>
/// <param name="connectSpec">The transport connection spec used to connect.</param>
/// <exception cref="Platform::COMException">
/// Upon completion, Platform::COMException will be raised and a HRESULT will contain the AllJoyn
/// error status code if any error occurred.
/// </exception>
/// <returns>A handle to the async operation which can be used for synchronization.</returns>
Windows::Foundation::IAsyncAction ^ ConnectAsync(Platform::String ^ connectSpec);
/// <summary>
/// Disconnect a remote bus address connection.
/// </summary>
/// <param name="connectSpec">The transport connection spec used to connect.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_BUS_NOT_STARTED if the bus is not started
/// #ER_BUS_NOT_CONNECTED if the BusAttachment is not connected to the bus
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
Windows::Foundation::IAsyncAction ^ DisconnectAsync(Platform::String ^ connectSpec);
/// <summary>
/// Indicate whether bus is currently connected.
/// </summary>
/// <remarks>
/// Messages can only be sent or received when the bus is connected.
/// </remarks>
/// <returns>True if the bus is connected.</returns>
bool IsConnected();
/// <summary>
/// Register a BusObject
/// </summary>
/// <param name="obj">BusObject to register.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_BAD_OBJ_PATH for a bad object path
/// </exception>
void RegisterBusObject(BusObject ^ obj);
/// <summary>
/// Unregister a BusObject
/// </summary>
/// <param name="object">Object to be unregistered.</param>
void UnregisterBusObject(BusObject ^ object);
/// <summary>
/// Register a signal handler.
/// </summary>
/// <remarks>
/// Signals are forwarded to the signalHandler if sender, interface, member and path
/// qualifiers are ALL met.
/// </remarks>
/// <param name="receiver">The object receiving the signal.</param>
/// <param name="member">The interface/member of the signal.</param>
/// <param name="srcPath">The object path of the emitter of the signal or NULL for all paths.</param>
void RegisterSignalHandler(MessageReceiver ^ receiver,
InterfaceMember ^ member,
Platform::String ^ srcPath);
/// <summary>
/// Unregister a signal handler.
/// </summary>
/// <remarks>
/// Remove the signal handler that was registered with the given parameters.
/// </remarks>
/// <param name="receiver">The object receiving the signal.</param>
/// <param name="member">The interface/member of the signal.</param>
/// <param name="srcPath">The object path of the emitter of the signal or NULL for all paths.</param>
void UnregisterSignalHandler(MessageReceiver ^ receiver,
InterfaceMember ^ member,
Platform::String ^ srcPath);
/// <summary>
/// Enable peer-to-peer security.
/// </summary>
/// <remarks>
/// This function must be called by applications that want to use
/// authentication and encryption . The bus must have been started by calling
/// BusAttachment::Start() before this function is called. If the application is providing its
/// own key store implementation it must have already called RegisterKeyStoreListener() before
/// calling this function.
/// </remarks>
/// <param name="authMechanisms">The authentication mechanism(s) to use for peer-to-peer authentication.
/// If this parameter is NULL peer-to-peer authentication is disabled.
/// </param>
/// <param name="listener">Passes password and other authentication related requests to the application.</param>
/// <param name="keyStoreFileName">Optional parameter to specify the filename of the default key store. The
/// default value is the applicationName parameter of BusAttachment().
/// Note that this parameter is only meaningful when using the default
/// key store implementation.
/// </param>
/// <param name="isShared">optional parameter that indicates if the key store is shared between multiple
/// applications. It is generally harmless to set this to true even when the
/// key store is not shared but it adds some unnecessary calls to the key store
/// listener to load and store the key store in this case.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_BUS_NOT_STARTED BusAttachment::Start has not be called
/// </exception>
void EnablePeerSecurity(Platform::String ^ authMechanisms,
AuthListener ^ listener,
Platform::String ^ keyStoreFileName,
bool isShared);
/// <summary>
/// Disable peer-to-peer security.
/// </summary>
/// <param name="listener">The listener that was previously registered by
/// an earlier call to <see cref="BusAttachment::EnablePeerSecurity"/>
/// </param>
void DisablePeerSecurity(AuthListener ^ listener);
/// <summary>
/// Check is peer security has been enabled for this bus attachment.
/// </summary>
/// <returns>Returns true if peer security has been enabled, false otherwise.</returns>
bool IsPeerSecurityEnabled();
/// <summary>
/// Register an object that will receive bus event notifications.
/// </summary>
/// <param name="listener">Object instance that will receive bus event notifications.</param>
void RegisterBusListener(BusListener ^ listener);
/// <summary>
/// Unregister an object that was previously registered with RegisterBusListener.
/// </summary>
/// <param name="listener">Object instance to un-register as a listener.</param>
void UnregisterBusListener(BusListener ^ listener);
/// <summary>
/// Set a key store listener to listen for key store load and store requests.
/// </summary>
/// <remarks>
/// This overrides the internal key store listener.
/// </remarks>
/// <param name="listener">The key store listener to set.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_LISTENER_ALREADY_SET if a listener has been set by this function or because
/// EnablePeerSecurity has previously been called.
/// </exception>
void RegisterKeyStoreListener(KeyStoreListener ^ listener);
/// <summary>
/// Set a key store listener to listen for key store load and store requests.
/// </summary>
/// <remarks>
/// This overrides the internal key store listener.
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void UnregisterKeyStoreListener();
/// <summary>
/// Reloads the key store for this bus attachment.
/// </summary>
/// <remarks>
/// This function would normally only be called in
/// the case where a single key store is shared between multiple bus attachments, possibly by different
/// applications. It is up to the applications to coordinate how and when the shared key store is
/// modified.
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status indicating why the key store reload failed.
/// </exception>
void ReloadKeyStore();
/// <summary>
/// Clears all stored keys from the key store.
/// </summary>
/// <remarks>
/// All store keys and authentication information is
/// deleted and cannot be recovered. Any passwords or other credentials will need to be reentered
/// when establishing secure peer connections.
/// </remarks>
void ClearKeyStore();
/// <summary>
/// Clear the keys associated with a specific remote peer as identified by its peer GUID.
/// </summary>
/// <remarks>
/// The peer GUID associated with a bus name can be obtained by calling GetPeerGUID().
/// </remarks>
/// <param name="guid">The GUID of a remote authenticated peer.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_KEY_UNAVAILABLE if there is no peer with the specified GUID.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void ClearKeys(Platform::String ^ guid);
/// <summary>
/// Set the expiration time on keys associated with a specific remote peer as identified by its peer GUID.
/// </summary>
/// <remarks>
/// The peer GUID associated with a bus name can be obtained by calling GetPeerGUID().
/// If the timeout is 0 this is equivalent to calling ClearKeys().
/// </remarks>
/// <param name="guid">The GUID of a remote authenticated peer.</param>
/// <param name="timeout">The time in seconds relative to the current time to expire the keys.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_KEY_UNAVAILABLE if there is no authenticated peer with the specified GUID.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void SetKeyExpiration(Platform::String ^ guid, uint32_t timeout);
/// <summary>
/// Get the expiration time on keys associated with a specific authenticated remote peer as
/// identified by its peer GUID.
/// </summary>
/// <remarks>
/// The peer GUID associated with a bus name can be obtained by
/// calling GetPeerGUID().
/// </remarks>
/// <param name="guid">The GUID of a remote authenticated peer.</param>
/// <param name="timeout">The time in seconds relative to the current time when the keys will expire.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_KEY_UNAVAILABLE if there is no authenticated peer with the specified GUID.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void GetKeyExpiration(Platform::String ^ guid, Platform::WriteOnlyArray<uint32> ^ timeout);
/// <summary>
/// Adds a logon entry string for the requested authentication mechanism to the key store
/// </summary>
/// <remarks>
/// This allows an authenticating server to generate offline authentication credentials for securely
/// logging on a remote peer using a user-name and password credentials pair. This only applies
/// to authentication mechanisms that support a user name + password logon functionality.
/// </remarks>
/// <param name="authMechanism">The authentication mechanism.</param>
/// <param name="userName">The user name to use for generating the logon entry.</param>
/// <param name="password">The password to use for generating the logon entry. If the password is
/// NULL the logon entry is deleted from the key store.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_INVALID_AUTH_MECHANISM if the authentication mechanism does not support logon functionality.
/// #ER_BAD_ARG_2 indicates a null string was used as the user name.
/// #ER_BAD_ARG_3 indicates a null string was used as the password.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void AddLogonEntry(Platform::String ^ authMechanism, Platform::String ^ userName, Platform::String ^ password);
/// <summary>
/// Request a well-known name.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.freedesktop.DBus.RequestName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="requestedName">Well-known name being requested.</param>
/// <param name="flags">Bitmask of DBUS_NAME_FLAG_* defines see <see cref="AllJoyn::DBusStd"/></param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void RequestName(Platform::String ^ requestedName, uint32_t flags);
/// <summary>
/// Release a previously requested well-known name.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.freedesktop.DBus.ReleaseName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="name">Well-known name being released.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void ReleaseName(Platform::String ^ name);
/// <summary>
/// Add a DBus match rule.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.freedesktop.DBus.AddMatch method call to the local daemon.
/// </remarks>
/// <param name="rule">Match rule to be added (see DBus specification for format of this string).</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void AddMatch(Platform::String ^ rule);
/// <summary>
/// Remove a DBus match rule.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.freedesktop.DBus.RemoveMatch method call to the local daemon.
/// </remarks>
/// <param name="rule">Match rule to be removed (see DBus specification for format of this string).</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void RemoveMatch(Platform::String ^ rule);
/// <summary>
/// Advertise the existence of a well-known name to other (possibly disconnected) AllJoyn daemons.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.AdvertisedName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="name">the well-known name to advertise. (Must be owned by the caller via RequestName).</param>
/// <param name="transports">Set of transports to use for sending advertisement.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void AdvertiseName(Platform::String ^ name, TransportMaskType transports);
/// <summary>
/// Stop advertising the existence of a well-known name to other AllJoyn daemons.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.CancelAdvertiseName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="name">A well-known name that was previously advertised via AdvertiseName.</param>
/// <param name="transports">Set of transports whose name advertisement will be canceled.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void CancelAdvertiseName(Platform::String ^ name, TransportMaskType transports);
/// <summary>
/// Register interest in a well-known name prefix for the purpose of discovery over transports included in TRANSPORT_ANY.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.FindAdvertisedName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="namePrefix">Well-known name prefix that application is interested in receiving
/// BusListener::FoundAdvertisedName notifications about.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void FindAdvertisedName(Platform::String ^ namePrefix);
/// <summary>
/// Register interest in a well-known name prefix for the purpose of discovery over over a set of transports.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.FindAdvertisedName method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="namePrefix">Well-known name prefix that application is interested in receiving
/// BusListener::FoundAdvertisedName notifications about.
/// </param>
/// <param name="transports">Set of transports who will do well-known name discovery.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void FindAdvertisedNameByTransport(Platform::String ^ namePrefix, TransportMaskType transports);
/// <summary>
/// Cancel interest in a well-known name prefix that was previously registered with FindAdvertisedName over transports included in TRANSPORT_ANY.
/// </summary>
/// <remarks>
/// This method is equivalent to CancelFindAdvertisedName(namePrefix, TRANSPORT_ANY).
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.CancelFindAdvertisedName method
/// call to the local daemon and interprets the response.
/// </remarks>
/// <param name="namePrefix">Well-known name prefix that application is no longer interested in receiving
/// BusListener::FoundAdvertisedName notifications about.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void CancelFindAdvertisedName(Platform::String ^ namePrefix);
/// <summary>
/// Cancel interest in a well-known name prefix that was previously registered with FindAdvertisedName over a set of transports.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.CancelFindAdvertisedName method
/// call to the local daemon and interprets the response.
/// </remarks>
/// <param name="namePrefix">Well-known name prefix that application is no longer interested in receiving
/// BusListener::FoundAdvertisedName notifications about.
/// </param>
/// <param name="transports">Set of transports who will cancel well-known name discovery.
/// </param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void CancelFindAdvertisedNameByTransport(Platform::String ^ namePrefix, TransportMaskType transports);
/// <summary>
/// Make a SessionPort available for external BusAttachments to join.
/// </summary>
/// <remarks>
/// Each BusAttachment binds its own set of SessionPorts. Session joiners use the bound session
/// port along with the name of the attachment to create a persistent logical connection (called
/// a Session) with the original BusAttachment.
/// A SessionPort and bus name form a unique identifier that BusAttachments use when joining a
/// session.
/// SessionPort values can be pre-arranged between AllJoyn services and their clients (well-known
/// SessionPorts).
/// Once a session is joined using one of the service's well-known SessionPorts, the service may
/// bind additional SessionPorts (dynamically) and share these SessionPorts with the joiner over
/// the original session. The joiner can then create additional sessions with the service by
/// calling JoinSession with these dynamic SessionPort ids.
/// </remarks>
/// <param name="sessionPort_in">SessionPort value to bind or SESSION_PORT_ANY to allow this method
/// to choose an available port.
/// </param>
/// <param name="sessionPort_out">On successful return, this value contains the chosen SessionPort.
/// </param>
/// <param name="opts">Session options that joiners must agree to in order to successfully join the session.</param>
/// <param name="listener">Called by the bus when session related events occur.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void BindSessionPort(ajn::SessionPort sessionPort_in, Platform::WriteOnlyArray<ajn::SessionPort> ^ sessionPort_out, SessionOpts ^ opts, SessionPortListener ^ listener);
/// <summary>
/// Cancel an existing port binding.
/// </summary>
/// <param name="sessionPort">Existing session port to be un-bound.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void UnbindSessionPort(ajn::SessionPort sessionPort);
/// <summary>
/// Join a session.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.JoinSession method call to the local daemon
/// and interprets the response.
/// This call executes asynchronously. When the JoinSession response is received, the callback will be called.
/// </remarks>
/// <param name="sessionHost">Bus name of attachment that is hosting the session to be joined.</param>
/// <param name="sessionPort">SessionPort of sessionHost to be joined.</param>
/// <param name="listener">Optional listener called when session related events occur. May be NULL.</param>
/// <param name="opts_in">Session options.</param>
/// <param name="opts_out">Session options.</param>
/// <param name="context">User defined context which will be passed as-is to callback.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
/// <returns>A handle to the async operation.</returns>
Windows::Foundation::IAsyncOperation<JoinSessionResult ^> ^ JoinSessionAsync(Platform::String ^ sessionHost,
ajn::SessionPort sessionPort,
SessionListener ^ listener,
SessionOpts ^ opts_in,
Platform::WriteOnlyArray<SessionOpts ^> ^ opts_out,
Platform::Object ^ context);
/// <summary>
/// Set the SessionListener for an existing sessionId.
/// </summary>
/// <remarks>
/// Calling this method will override the listener set by a previous call to SetSessionListener or any
/// listener specified in JoinSessionAsync.
/// </remarks>
/// <param name="sessionId">The session id of an existing session.</param>
/// <param name="listener">The SessionListener to associate with the session. May be NULL to clear previous listener.</param>
void SetSessionListener(ajn::SessionId sessionId, SessionListener ^ listener);
/// <summary>
/// Leave an existing session.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.alljoyn.Bus.LeaveSession method call to the local daemon
/// and interprets the response.
/// </remarks>
/// <param name="sessionId">Session id.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_BUS_NOT_CONNECTED if a connection has not been made with a local bus.
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
void LeaveSession(ajn::SessionId sessionId);
/// <summary>
/// Get the file descriptor for a raw (non-message based) session.
/// </summary>
/// <param name="sessionId">Id of an existing streaming session.</param>
/// <param name="socketStream">Socket stream for the session.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void GetSessionSocketStream(ajn::SessionId sessionId, Platform::WriteOnlyArray<AllJoyn::SocketStream ^> ^ socketStream);
/// <summary>
/// Set the link timeout for a session.
/// </summary>
/// <remarks>
/// Link timeout is the maximum number of seconds that an unresponsive daemon-to-daemon connection
/// will be monitored before declaring the session lost (via SessionLost callback). Link timeout
/// defaults to 0 which indicates that AllJoyn link monitoring is disabled.
/// Each transport type defines a lower bound on link timeout to avoid defeating transport
/// specific power management algorithms.
/// </remarks>
/// <param name="sessionid">Id of session whose link timeout will be modified.</param>
/// <param name="linkTimeout">Max number of seconds that a link can be unresponsive before being
/// declared lost. 0 indicates that AllJoyn link monitoring will be disabled.
/// </param>
/// <param name="context">User defined context which will be passed as-is to callback.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// #ER_ALLJOYN_SETLINKTIMEOUT_REPLY_NOT_SUPPORTED if local daemon does not support SetLinkTimeout
/// #ER_ALLJOYN_SETLINKTIMEOUT_REPLY_NO_DEST_SUPPORT if SetLinkTimeout not supported by destination
/// #ER_BUS_NO_SESSION if the Session id is not valid
/// #ER_ALLJOYN_SETLINKTIMEOUT_REPLY_FAILED if SetLinkTimeout failed
/// #ER_BUS_NOT_CONNECTED if the BusAttachment is not connected to the daemon
/// Or other error status codes indicating the reason the operation failed.
/// </exception>
/// <returns>A handle to the async operation.</returns>
Windows::Foundation::IAsyncOperation<SetLinkTimeoutResult ^> ^ SetLinkTimeoutAsync(ajn::SessionId sessionid,
uint32 linkTimeout,
Platform::Object ^ context);
/// <summary>
/// Determine whether a given well-known name exists on the bus.
/// </summary>
/// <remarks>
/// This method is a shortcut/helper that issues an org.freedesktop.DBus.NameHasOwner method call to the daemon
/// and interprets the response.
/// </remarks>
/// <param name="name">The well known name that the caller is inquiring about.</param>
/// <param name="hasOwner">Indicates whether name exists on the bus.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void NameHasOwner(Platform::String ^ name, Platform::WriteOnlyArray<bool> ^ hasOwner);
/// <summary>
/// Get the peer GUID for this peer of the local peer or an authenticated remote peer.
/// </summary>
/// <remarks>
/// The bus names of a remote peer can change over time, specifically the unique name is different each
/// time the peer connects to the bus and a peer may use different well-known-names at different
/// times. The peer GUID is the only persistent identity for a peer. Peer GUIDs are used by the
/// authentication mechanisms to uniquely and identify a remote application instance. The peer
/// GUID for a remote peer is only available if the remote peer has been authenticated.
/// </remarks>
/// <param name="name">Name of a remote peer or NULL to get the local (this application's) peer GUID.</param>
/// <param name="guid">Returns the GUID for the local or remote peer depending on the value of name.</param>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void GetPeerGUID(Platform::String ^ name, Platform::WriteOnlyArray<Platform::String ^> ^ guid);
/// <summary>
/// Compares two BusAttachment references
/// </summary>
/// <param name="other">The BusAttachment reference to compare.</param>
/// <returns>Returns true if this bus and the other bus are the same object.</returns>
bool IsSameBusAttachment(BusAttachment ^ other);
/// <summary>
/// Notify AllJoyn that the application is suspending. Exclusively-held resource should be released so that other applications
/// will not be prevented from acquiring the resource.
/// </summary>
/// <remarks>
/// On WinRT, an application is suspended when it becomes invisible for 10 seconds. The application should register the event when
/// the application goes into suspending state, and call OnAppSuspend()in the event handler.
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void OnAppSuspend();
/// <summary>
/// Notify AllJoyn that the application is resuming so that it can re-acquire the resource that has been released when the application was suspended.
/// </summary>
/// <remarks>
/// On WinRT, an application is suspended when it becomes invisible for 10 seconds. And it is resumed when users switch it back.
/// The application should register the event when the application goes into resuming state, and call OnAppResume()in the event handler.
/// </remarks>
/// <exception cref="Platform::COMException">
/// HRESULT will contain the AllJoyn error status code for the error.
/// </exception>
void OnAppResume();
/// <summary>
/// Get a reference to the org.freedesktop.DBus proxy object.
/// </summary>
property ProxyBusObject ^ DBusProxyBusObject
{
ProxyBusObject ^ get();
}
/// <summary>
/// Get a reference to the org.alljoyn.Bus proxy object.
/// </summary>
property ProxyBusObject ^ AllJoynProxyBusObject
{
ProxyBusObject ^ get();
}
/// <summary>
/// Get a reference to the org.alljoyn.Debug proxy object.
/// </summary>
property ProxyBusObject ^ AllJoynDebugProxyBusObject
{
ProxyBusObject ^ get();
}
/// <summary>
/// Get the unique name property of this BusAttachment.
/// </summary>
property Platform::String ^ UniqueName
{
Platform::String ^ get();
}
/// <summary>
/// Get the GUID property of this BusAttachment.
/// </summary>
/// <remarks>
/// The returned value may be appended to an advertised well-known name in order to guarantee
/// that the resulting name is globally unique.
/// </remarks>
property Platform::String ^ GlobalGUIDString
{
Platform::String ^ get();
}
/// <summary>
/// Returns the current non-absolute millisecond real-time clock used internally by AllJoyn.
/// </summary>
/// <remarks>
/// This value can be compared with the timestamps on messages to calculate the time since a time stamped message was sent.
/// </remarks>
property uint32_t Timestamp
{
uint32_t get();
}
private:
friend ref class BusObject;
friend ref class ProxyBusObject;
friend class _BusListener;
friend class _AuthListener;
friend class _BusObject;
friend class _KeyStoreListener;
friend class _MessageReceiver;
friend class _ProxyBusObject;
friend class _ProxyBusObjectListener;
friend class _SessionListener;
friend class _SessionPortListener;
BusAttachment(const ajn::BusAttachment * busAttachment);
BusAttachment(const qcc::ManagedObj<_BusAttachment>* busAttachment);
~BusAttachment();
qcc::ManagedObj<_BusAttachment>* _mBusAttachment;
_BusAttachment* _busAttachment;
};
}
// BusAttachment.h
|
578e8a2fb0654ef049e193441cdd11d1bdc278d5
|
327463f358281558482dfc52661e7b21ccf6b495
|
/lab4/main.cpp
|
7bac1e0c1bd87e0135a1df318196586882f27847
|
[
"MIT"
] |
permissive
|
maliozer/cse211_ds
|
9cd55b3bb0041c0bd40a66a04972eb19b46b25c7
|
feb60c7ccc845530490d36f7f17834d023460a1a
|
refs/heads/main
| 2023-01-24T01:04:14.906419
| 2020-12-03T18:15:42
| 2020-12-03T18:15:42
| 302,323,274
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 825
|
cpp
|
main.cpp
|
//============================================================================
// Name : main.cpp
// Author : maliozer
// Copyright : MIT
// Description : Yeditepe CSE211 Data Structures Lab2-Q2 PhoneBook
//============================================================================
#include <iostream>
#include "MyStack.h"
using namespace std;
//using namespace PhoneBook::PhoneBook;
int main() {
MyStack ms;
cout << " is empty " << ms.isEmpty() << endl;
ms.push(5);
ms.push(7);
ms.push(8);
ms.push(9);
cout << " is empty " << ms.isEmpty() << endl;
cout << "the top : " << ms.top() << endl;
cout << "remove top: " << ms.pop() << endl;
cout << "new top : " << ms.top() << endl;
cout << "size : " << ms.getSize() << endl;
ms.print();
cout << "END OF PROGRAM" << endl;
return 0;
}
|
6f7dbf6e9d4e0b28bb9d550eac381773fb4fe19f
|
5f83f82503835f30b1e5782991eac4de1267e650
|
/Sarry/Algorithm/LinearAlgebra/LinearAlgebra.cpp
|
911d04aa22202afda489d69a8b319a45495ecf81
|
[] |
no_license
|
ncrookston/startal
|
a08f0e5d07a6001ed128fb855427b9025639494c
|
8c1cf418e73bf67444b25dfa46a5364c53c97ae5
|
refs/heads/master
| 2021-01-10T21:25:10.595969
| 2013-11-09T16:43:31
| 2013-11-09T16:43:31
| 4,199,164
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,931
|
cpp
|
LinearAlgebra.cpp
|
#include "LinearAlgebra.hpp"
#include "Algorithm/getRegionParams.hpp"
#include "Algorithm/LinearAlgebra/Doi.hpp"
#include "Algorithm/LinearAlgebra/Roi.hpp"
#include "Algorithm/writeKmz.hpp"
#include "Antenna/Antenna.hpp"
#include "Antenna/getPulsesOfInterest.hpp"
#include "Antenna/PerPulseInfoLoader.hpp"
#include "Geo/Elevation.hpp"
#include "Geo/GeoToIndex.hpp"
#include <boost/range/algorithm/transform.hpp>
#include <boost/spirit/home/phoenix.hpp>
#include <boost/tuple/tuple.hpp>
#include <iostream>
namespace px = boost::phoenix;
using px::arg_names::arg1;
using namespace Sarry;
Sarry::LinearAlgebra::LinearAlgebra(int argc, char** argv,
const Antenna& antenna, const Elevation& elevation)
: m_chirp(antenna.getChirp()),
m_infoLoader(antenna.getPulseLoader()),
m_elevation(elevation),
m_pts(4),
m_resolution()
{
Geo2 corners[4];
getRegionParams(argc, argv, corners, m_resolution);
boost::transform(corners, m_pts.begin(), px::construct<Geo3>(arg1,
px::bind(&Sarry::Elevation::operator(), &elevation, arg1)));
}
void Sarry::LinearAlgebra::operator()() const
{
AlgResult::first_type gVals;
std::size_t elVals;
std::pair<FftPack, FftPack> fftPacks = m_infoLoader.getMatchedFilterPacks();
{
//Aircraft body angles and locations indexed by pulse.
const std::vector<PerPulseInfo> pulseInfo
= getPulsesOfInterest(m_infoLoader, m_chirp, m_pts);
std::clog << "Determining data of interest. . ." << std::endl;
//The data of interest.
Doi doi(pulseInfo, m_chirp, m_pts, Doi::MATCH_FILTER_DATA, fftPacks);
std::clog << "Determining region of interest closure. . ." << std::endl;
//The region of interest closure (with roi accessible).
Roi roic(doi, pulseInfo, m_chirp, m_pts, m_resolution, m_elevation,
Roi::USE_PARTIAL_ROIC);
boost::tie(gVals, elVals) = applyAlgorithm(pulseInfo, doi, roic);
}
writeKmz(gVals, elVals, m_pts);
}
|
df168d3b8366c2ab57481ee6458c4d7ecd8585b9
|
3f9044992587e1d068c6f20992d564fcf16b2cbc
|
/263B.cpp
|
b5c9022750c36d5bbb07c4795e019b12c93bbab9
|
[] |
no_license
|
HrPhoeniX/CPisNotFun
|
782abd8178342604514fa7f2a806e8c27d684628
|
c1109a9e3acfc2a74c2c71383b58e64ea9b3580d
|
refs/heads/main
| 2023-08-23T22:14:14.493689
| 2021-10-27T10:06:55
| 2021-10-27T10:06:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 462
|
cpp
|
263B.cpp
|
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
int main()
{
fast;
int n, k;
cin >> n >> k;
vector<int> v(n);
for (int i = 0; i < n; i++)
{
cin>>v[i];
}
if (k>n)
{
cout<<-1;
return 0;
}
sort(v.rbegin(),v.rend());
cout<<v[k-1]<<" "<<0;
return 0;
}
|
37b8f66bded234b340ef0c9bb8023355b76aba79
|
e822759a9f164782edefa41e0a430b836c39a237
|
/monad.cxx
|
f91a9511b154720b99a83602207ffab2cfbc5716
|
[
"MIT"
] |
permissive
|
b1f6c1c4/wicky-monads
|
209cbf5552d9e00f319a6ee9828710215b2c169b
|
f1106d361602d2c9efcdb3021138b1c76adee50d
|
refs/heads/master
| 2023-07-12T17:39:57.988029
| 2021-08-30T21:35:55
| 2021-08-30T21:35:55
| 361,520,280
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,252
|
cxx
|
monad.cxx
|
#include <chrono>
#include <csignal>
#include <deque>
#include <fcntl.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <nlohmann/json.hpp>
#include <string>
#include <sys/resource.h>
#include <sys/wait.h>
#include <unistd.h>
#include "common.h"
#include "config.h"
using json = nlohmann::json;
using namespace std::string_literals;
pid_t child{};
volatile std::sig_atomic_t timeout{};
void trap(int sig) {
if (!child) return;
if (sig == SIGALRM) {
auto t = timeout;
if (t == 0)
kill(0, SIGINT);
else if (t < 10)
kill(0, SIGTERM);
else
kill(0, SIGKILL);
timeout = t + 1;
return;
}
kill(child, sig);
}
double sec(timeval t) {
return static_cast<double>(t.tv_sec) + static_cast<double>(t.tv_usec) * 1e-6;
}
double sec(timespec t) {
return static_cast<double>(t.tv_sec) + static_cast<double>(t.tv_nsec) * 1e-9;
}
void analysis(json &j) {
if (j.contains("error"))
j["status"] = "errored";
else if (!j.contains("return"))
j["status"] = "cancelled";
else if (j.contains("timeout"))
j["status"] = "timeout";
else if (j.contains("signal"))
j["status"] = "killed";
else if (j["return"].get<int>())
j["status"] = "failed";
else
j["status"] = "success";
}
int main(int argc, char *argv[]) {
cli_t cli;
parse_cli(&cli, argc, argv,
"monad(1) from wicky-monads " PROJECT_VERSION "\n\n"
"Usage: monad [-t <time-limit>] [-m <mem-limit>] [-M|--merge]\n"
" [-p|--partial] [-P|--panic] [-v]\n"
" -o <output> <input>... -- <executable> <arg>...\n"
" Run <executable> with <arg>... <input>... and redirect stdout to <output>\n"
" Info from <input>.monad... will be read and (with --partial) failed ones\n"
" will be skipped, or (no --partial) any faulty input will cancel the run.\n"
" If the <executable> timeout/failed, <output>.monad will record the case.\n"
" If the <executable> succeed, <output>.monad will record duration and mem.\n"
" If --merge is specified, <output> itself will store such info instead.\n"
" If --panic is given, successful run will return 0, failed/cancelled will\n"
" return 1, errored will return 2. If --panic is not given, it will always\n"
" return 0 unless errored. <output> will be created/removed according to the\n"
" return value of monad (0 = always exist, 1/2 = always removed).\n");
auto fst = cli.output + (cli.merge_output ? ""s : ".monad"s);
try {
std::ofstream ofst{ fst };
if (!ofst.good())
throw std::runtime_error{ "Not good" };
} catch (const std::exception &e) {
std::cerr << "Cannot open output file " << fst << ": " << e.what() << "\n";
return 1;
}
bool maybe_good = true;
json j{ { "good", false } };
int fd;
int status;
bool to;
decltype(std::chrono::high_resolution_clock::now()) start;
try {
std::vector<const char *> args;
for (size_t i{}; i < cli.n_args; i++)
args.emplace_back(cli.args[i]);
j["parsing"]["time-limit-sec"] = sec(cli.time_limit);
j["parsing"]["mem-limit-MiB"] = static_cast<double>(cli.mem_limit) / 1024.0 / 1024.0;
j["parsing"]["merge-output"] = cli.merge_output;
j["parsing"]["output"] = cli.output;
j["parsing"]["monad-output"] = fst;
j["parsing"]["executable"] = cli.executable;
j["error"]["stage"] = "defs";
for (size_t i{}; i < cli.n_defs; i++) {
std::string_view sv{ cli.defs[i] };
auto id = sv.find('=');
if (id == std::string_view::npos) {
j[cli.defs[i]] = nullptr;
continue;
}
j[std::string{ sv.substr(0, id) }] = cli.defs[i] + id + 1;
}
j["error"]["stage"] = "input";
auto any_good = false;
auto any_bad = false;
for (size_t i{}; i < cli.n_inputs; i++) {
auto &jj = j["inputs"][i];
jj["name"] = cli.inputs[i];
std::ifstream ifst{ std::string{ cli.inputs[i] } + ".monad" };
bool good;
if (ifst.good()) {
json st;
ifst >> st;
ifst.close();
good = st["good"].get<bool>();
jj["status"] = std::move(st);
} else {
std::ifstream ifs{ cli.inputs[i] };
good = ifs.good();
}
if (good) {
any_good = true;
args.emplace_back(cli.inputs[i]);
} else {
any_bad = true;
}
}
args.emplace_back(nullptr);
if (!(cli.n_inputs == 0
|| cli.partial && any_good
|| !cli.partial && !any_bad)) {
maybe_good = false;
if (!cli.panic) {
j["error"]["stage"] = "cancelled-open";
fd = open(cli.output, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd == -1)
throw std::runtime_error{ "Cannot open: "s + std::strerror(errno) };
j["error"]["stage"] = "close";
if (close(fd) == -1)
throw std::runtime_error{ "Cannot close: "s + std::strerror(errno) };
}
goto cancelled;
}
j["error"]["stage"] = "dump-args";
for (auto a : args)
if (a)
j["parsing"]["args"].emplace_back(a);
else
j["parsing"]["args"].emplace_back(nullptr);
j["error"]["stage"] = "open";
fd = open(cli.output, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd == -1)
throw std::runtime_error{ "Cannot open: "s + std::strerror(errno) };
j["error"]["stage"] = "dup2";
if (dup2(fd, STDOUT_FILENO) == -1)
throw std::runtime_error{ "Cannot dup2: "s + std::strerror(errno) };
j["error"]["stage"] = "close";
if (close(fd) == -1)
throw std::runtime_error{ "Cannot close: "s + std::strerror(errno) };
j["error"]["stage"] = "timing-start";
start = std::chrono::high_resolution_clock::now();
j["error"]["stage"] = "sig";
signal(SIGHUP, &trap);
signal(SIGINT, &trap);
signal(SIGQUIT, &trap);
signal(SIGABRT, &trap);
signal(SIGKILL, &trap);
signal(SIGTERM, &trap);
signal(SIGUSR1, &trap);
signal(SIGUSR2, &trap);
signal(SIGALRM, &trap); // for receiving timer
j["error"]["stage"] = "fork";
if ((child = fork()) == -1)
throw std::runtime_error{ "Cannot fork: "s + std::strerror(errno) };
if (!child) { // I'm the child!
if (cli.mem_limit) {
rlimit64 rlim{ cli.mem_limit * 95 / 100, cli.mem_limit };
setrlimit64(RLIMIT_DATA, &rlim);
}
nice(19);
execvp(cli.executable, const_cast<char * const *>(args.data()));
fprintf(stderr, "execvp: %d: %s\n", errno, std::strerror(errno));
exit(127);
}
j["error"]["stage"] = "timer";
if (cli.time_limit.tv_sec || cli.time_limit.tv_nsec) {
timer_t tmr;
sigevent_t sev{ SIGEV_SIGNAL, SIGALRM };
if (timer_create(CLOCK_REALTIME, &sev, &tmr))
throw std::runtime_error{ "Cannot timer_create: "s + std::strerror(errno) };
itimerspec spec{ { 1, 0 }, cli.time_limit };
if (timer_settime(tmr, 0, &spec, nullptr))
throw std::runtime_error{ "Cannot timer_settime: "s + std::strerror(errno) };
}
j["error"]["stage"] = "waitpid";
if (waitpid(child, &status, WUNTRACED) == -1)
throw std::runtime_error{ "Cannot waitpid: "s + std::strerror(errno) };
to = timeout;
{
j["error"]["stage"] = "timing-stop";
auto end = std::chrono::high_resolution_clock::now();
auto dur = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
j["resource"]["wall-time-sec"] = static_cast<double>(dur.count()) / 1e9;
}
j["error"]["stage"] = "check-status";
if (WIFSIGNALED(status)) {
auto sig= WTERMSIG(status);
j["signal"]["value"] = sig;
j["signal"]["string"] = strsignal(sig);
if ((sig == SIGKILL || sig == SIGTERM || sig == SIGINT) && to)
j["timeout"] = true;
j["return"] = 128 | sig;
maybe_good = false;
} else {
if (!WIFEXITED(status))
throw std::runtime_error{ "Cannot waitpid: "s + std::strerror(errno) };
j["return"] = WEXITSTATUS(status);
if (WEXITSTATUS(status))
maybe_good = false;
}
{
j["error"]["stage"] = "check-resource";
rusage ru;
if (getrusage(RUSAGE_CHILDREN, &ru))
throw std::runtime_error{ "Cannot getrusage: "s + std::strerror(errno) };
j["resource"]["user-mode-time-sec"] = sec(ru.ru_utime);
j["resource"]["kernel-mode-time-sec"] = sec(ru.ru_stime);
j["resource"]["max-rss-MiB"] = static_cast<double>(ru.ru_maxrss) / 1024.0;
}
if (cli.merge_output) {
j["error"]["stage"] = "read-output";
std::ifstream ifs{ cli.output };
if (!ifs.good()) {
j["output"] = nullptr;
} else {
try {
json jj;
ifs >> jj;
j["output"] = jj;
} catch (const nlohmann::detail::parse_error &) {
ifs.seekg(std::ios::beg);
using I = std::istreambuf_iterator<char>;
j["output"] = std::string{ I{ ifs }, I{} };
}
}
}
cancelled:
j["error"]["stage"] = "write-output";
std::ofstream ofs{ fst };
if (!ofs.good())
throw std::runtime_error{ "Not good" };
j["good"] = maybe_good;
j.erase("error");
analysis(j);
if (!cli.verbose) j.erase("parsing");
ofs << j << "\n";
if (cli.panic && !maybe_good) {
unlink(cli.output);
return 1;
}
return 0;
} catch (const std::exception &e) {
j["error"]["what"] = e.what();
j["error"]["errno"]["value"] = errno;
j["error"]["errno"]["string"] = std::strerror(errno);
goto error_write_j;
}
error_write_j:
unlink(cli.output);
std::cerr << "Error during " << j["error"]["stage"] << ": " << j["error"] << "\n";
std::ofstream ofst{ fst };
analysis(j);
if (ofst.good()) {
ofst << j << "\n";
std::cerr << "Notice: Log has been written to " << fst << "\n";
} else {
std::cerr << "Fatal: Still not good, showing the log:\n" << std::setw(2) << j;
}
return 2;
}
|
70101e2c40b293e4e3fe70b431ef98ef9fc9813f
|
6e4aa50e275048cdedef07b79f5d51bd29a7bef1
|
/IPST_2016/o59_mar_c1_atleast.cpp
|
bc2f1506ea18dc14f557f27623e0f3c14c76cf29
|
[] |
no_license
|
KorlaMarch/competitive-programming
|
4b0790b8aed4286cdd65cf6e4584e61376a2615e
|
fa8d650938ad5f158c8299199a3d3c370f298a32
|
refs/heads/master
| 2021-03-27T12:31:10.145264
| 2019-03-03T02:30:51
| 2019-03-03T02:30:51
| 34,978,427
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,960
|
cpp
|
o59_mar_c1_atleast.cpp
|
#include "stdio.h"
#include "vector"
#include "algorithm"
typedef std::pair<int,int> PII;
typedef std::pair<int, long long> PILL;
struct Node{
int nc;
long long sum;
struct Node* left;
struct Node* right;
Node(int _nc = 0, long long _sum = 0) : nc(_nc), sum(_sum) {
left = nullptr;
right = nullptr;
}
};
int n,m,s,t;
double u;
PII a[100005];
std::vector<Node*> head;
Node* makeseg(int x, int y){
Node* no = new Node();
if(x!=y){
no->left = makeseg(x,x+(y-x)/2);
no->right = makeseg(x+(y-x)/2+1,y);
}
return no;
}
Node* addseg(Node* old, int pos, int v, int x, int y){
Node* no = new Node(old->nc+1,old->sum+v);
if(x!=y){
if(pos<=x+(y-x)/2){
no->left = addseg(old->left,pos,v,x,x+(y-x)/2);
no->right = old->right;
}else{
no->left = old->left;
no->right = addseg(old->right,pos,v,x+(y-x)/2+1,y);
}
}
return no;
}
bool isIntersect(int x1, int y1, int x2, int y2){
return (x1<=x2&&x2<=y1)||(x1<=y2&&y2<=y1)||(x2<=x1&&x1<=y2)||(x2<=y1&&y1<=y2);
}
PILL getseg(Node* no, int i, int j, int x, int y){
if(x<=i&&j<=y){
return {no->nc,no->sum};
}else if(isIntersect(i,j,x,y)){
PILL pi,re;
pi = getseg(no->left,i,i+(j-i)/2,x,y);
re = getseg(no->right,i+(j-i)/2+1,j,x,y);
pi.first += re.first;
pi.second += re.second;
return pi;
}
return {0,0LL};
}
int main(){
scanf("%d%d",&n,&m);
for(int i = 0; i < n; i++){
scanf("%d",&a[i].first);
a[i].second = i;
}
std::sort(a,a+n);
head.push_back(makeseg(0,n-1));
for(int i = n-1; i >= 0; i--){
head.push_back(addseg(head.back(),a[i].second,a[i].first,0,n-1));
}
for(int i = 0; i < m; i++){
scanf("%d%d%lf",&s,&t,&u);
int x = 0, y = head.size()-1;
int lm = -1;
while(x<=y){
int m = (x+y)/2;
PILL re = getseg(head[m],0,n-1,s-1,t-1);
if(re.first==0){
x = m+1;
}else if(re.second/(double)re.first>=u){
lm = re.first;
x = m+1;
}else{
y = m-1;
}
}
if(lm==-1) printf("-1\n");
else printf("%d\n",t-s+1-lm);
}
}
|
8e17ba6cfaade88a1f95d33a7c30c450aa9f1918
|
38db4bce417c9fa501ef0cbcedea52924766c572
|
/trajectory_generation/src/taskspaceonline3.cpp
|
5bfe170f5d71f7993c65c96c699d978635977766
|
[] |
no_license
|
Kassra-sinaei/SurenaIVTestsCodes
|
d0fc97d3160fccea8937d4fc61ec4310f54d0154
|
8c9edd4c608788d565c094ef19ecd9233a67f3c3
|
refs/heads/main
| 2023-07-03T11:50:58.899995
| 2021-08-11T12:22:44
| 2021-08-11T12:22:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 42,891
|
cpp
|
taskspaceonline3.cpp
|
#include "taskspaceonline3.h"
TaskSpaceOnline3::TaskSpaceOnline3(int N_s, double Ds)
{
_timeStep=.005;
NStride=N_s;
LeftHipRollModification= 2;3.2;3.1;2.7;2;
RightHipRollModification=2;3.2;3.1;2.7;2;
FirstHipRollModification=2;3.2;3.1;2.7;2;
HipPitchModification=1;//2;
beta_toe=7*M_PI/18*0;
beta_heel=-1*M_PI/18*0;
NStep=NStride*2;
StepLength=Ds;
XofAnkleMaximumHeight=StepLength*1.8;
switch (int(StepLength*100)) {
case 45://ff
ReferencePelvisHeight=.8;
Xe=0.092;
Xs=0.092;
break;
case 40://ff
ReferencePelvisHeight=.835;
Xe=0.083;
Xs=0.083;
break;
case 35://ff
ReferencePelvisHeight=.86;
Xe=0.073;
Xs=0.073;
break;
case 30:
ReferencePelvisHeight=.89; // 0.913 is gouth for xe=0.06 and xs=0.047
Xe=0.06*30/25;// 0.06 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
Xs=0.047*30/25;// 0.047 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
XofAnkleMaximumHeight=StepLength*1.8; //1.9 would cause overshoot in x-direction of ankle trajectory
Yd=.0562+0.008; //+0.008
a_d=-.438;
zmp_min=-0.025; // -0.025
zmp_max=0.025; // 0.025
YEndMax_Coef=1.1;
break;
case 28:
ReferencePelvisHeight=.9; // 0.913 is gouth for xe=0.06 and xs=0.047
Xe=0.06*28/25;// 0.06 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
Xs=0.047*28/25;// 0.047 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
XofAnkleMaximumHeight=StepLength*1.8; //1.9 would cause overshoot in x-direction of ankle trajectory
Yd=.0562+0.008; //+0.008
a_d=-.438;
zmp_min=-0.025; // -0.025
zmp_max=0.025; // 0.025
YEndMax_Coef=1.1;
break;
case 25:
ReferencePelvisHeight=.91; // 0.913 is gouth for xe=0.06 and xs=0.047
Xe=0.06;// 0.06 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
Xs=0.047;// 0.047 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
XofAnkleMaximumHeight=StepLength*1.8; //1.9 would cause overshoot in x-direction of ankle trajectory
Yd=.0562+0.008; //+0.008
a_d=-.438;
zmp_min=-0.025; // -0.025
zmp_max=0.025; // 0.025
YEndMax_Coef=1.1;
break;
case 20:
ReferencePelvisHeight=.91;
Xs=0.0201;
Xe=0.0480;
Yd=0.0701;
a_d=-0.3745;
zmp_min=0.0075;
zmp_max=0.0049;
YEndMax_Coef=1.05;
break;
case 15:
ReferencePelvisHeight=.91; //0.92
Xs=0.0123;
Xe=0.0369;
Yd=0.0708;
a_d=-0.4527;
zmp_min=0.0009; // -0.025
zmp_max=0.0174; // 0.025
YEndMax_Coef=1.05;
break;
default:
break;
}
AnkleMaximumHeight=.045;
StepNumber=1;
localTiming=0;
localtimingInteger=0;
globalTime=0;
//times
TDs =0.7;
TSS=0.9;
Tm1=.4*TSS;//0.28
Tm2=0.68*TSS;
TStartofHeel=0.4*TSS; //Tm2 (ver43)
TStartofAnkleAdaptation=Tm2;//0.75*TSS; // Tm2 (ver43)
Tc=TSS+TDs;
Tx=3;
TE=3; //3
TLastSS=1;
TStart=Tx+TSS/2+Tc;
TEnd=TLastSS+TE;
T_st_p_sx=Tx+Tc; //0.7*TStart;
T_s_st=Tx+Tc/2+TDs/2;//.5*TStart;
TGait=TStart+NStride*2*Tc;
MotionTime=TStart+NStride*2*Tc+TDs+TEnd;
TMinPelvisY=0.5*TDs; // The time that pelvis reaches its minimum distance in y direction
TMaxAnkle=TDs+0.35*TSS;//0.53 % The time that ankle reaches its maximum distance in z direction
TMaxPelvisY=TDs+0.5*TSS; // The time that pelvis reaches its maximum distance in y direction
T_end_of_first_SS=1e-4;0;
T_end_of_SS= 1e-4;0;
T_end_of_last_SS= 0;1e-4;
h_end_of_SS= 1e-6;0;
T_end_p_sx_rel=TDs+.5*TLastSS;
T_end_p_sx=TGait+T_end_p_sx_rel;
T_end_a_s=TGait+TDs;
T_end_a_e=TGait+TDs+TLastSS;
t_toe=0.2*TDs;
t_heel=0.5*TDs;
CoeffArrayAnkle();
CoeffArrayPelvis();
}
TaskSpaceOnline3::TaskSpaceOnline3()
{
_timeStep=.005;
NStride=3;
LeftHipRollModification= 2;3.2;3.1;2.7;2;
RightHipRollModification=2;3.2;3.1;2.7;2;
FirstHipRollModification=2;3.2;3.1;2.7;2;
HipPitchModification=1;//2;
beta_toe=7*M_PI/18*0;
beta_heel=-1*M_PI/18*0;
NStep=NStride*2;
StepLength=25;
XofAnkleMaximumHeight=StepLength*1.8;
switch (int(StepLength*100)) {
case 45://ff
ReferencePelvisHeight=.8;
Xe=0.092;
Xs=0.092;
break;
case 40://ff
ReferencePelvisHeight=.835;
Xe=0.083;
Xs=0.083;
break;
case 35://ff
ReferencePelvisHeight=.86;
Xe=0.073;
Xs=0.073;
break;
case 30:
// YStMax=.06;
ReferencePelvisHeight=.885;
Xe=0.065;
Xs=0.065;
break;
case 25:
ReferencePelvisHeight=.91; // 0.913 is gouth for xe=0.06 and xs=0.047
Xe=0.06;// 0.06 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
Xs=0.047;// 0.047 is gouth for anklepitch=0 and zmp_min=-0.025 , zmp_max=0.025
XofAnkleMaximumHeight=StepLength*1.8; //1.9 would cause overshoot in x-direction of ankle trajectory
Yd=.0562+0.008; //+0.008
a_d=-.438;
zmp_min=-0.025; // -0.025
zmp_max=0.025; // 0.025
YEndMax_Coef=1.1;
break;
case 20:
ReferencePelvisHeight=.91;
Xs=0.0201;
Xe=0.0480;
Yd=0.0701;
a_d=-0.3745;
zmp_min=0.0075;
zmp_max=0.0049;
YEndMax_Coef=1.05;
break;
case 15:
ReferencePelvisHeight=.91; //0.92
Xs=0.0123;
Xe=0.0369;
Yd=0.0708;
a_d=-0.4527;
zmp_min=0.0009; // -0.025
zmp_max=0.0174; // 0.025
YEndMax_Coef=1.05;
break;
default:
break;
}
AnkleMaximumHeight=.07;
//times
TDs =0.7;
TSS=0.9;
Tm1=.4*TSS;//0.28
Tm2=0.6*TSS;
TStartofHeel=0.4*TSS; //Tm2 (ver43)
TStartofAnkleAdaptation=Tm2;//0.75*TSS; // Tm2 (ver43)
Tc=TSS+TDs;
Tx=3;
TE=3; //3
TLastSS=1;
TStart=Tx+TSS/2+Tc;
TEnd=TLastSS+TE;
T_st_p_sx=Tx+Tc; //0.7*TStart;
T_s_st=Tx+Tc/2+TDs/2;//.5*TStart;
TGait=TStart+NStride*2*Tc;
MotionTime=TStart+NStride*2*Tc+TDs+TEnd;
TMinPelvisY=0.5*TDs; // The time that pelvis reaches its minimum distance in y direction
TMaxAnkle=TDs+0.35*TSS;//0.53 % The time that ankle reaches its maximum distance in z direction
TMaxPelvisY=TDs+0.5*TSS; // The time that pelvis reaches its maximum distance in y direction
T_end_of_first_SS=1e-4;0;
T_end_of_SS= 1e-4;0;
T_end_of_last_SS= 0;1e-4;
h_end_of_SS= 1e-6;0;
T_end_p_sx_rel=TDs+.5*TLastSS;
T_end_p_sx=TGait+T_end_p_sx_rel;
T_end_a_s=TGait+TDs;
T_end_a_e=TGait+TDs+TLastSS;
t_toe=0.2*TDs;
t_heel=0.5*TDs;
CoeffArrayAnkle();
CoeffArrayPelvis();
}
void TaskSpaceOnline3::numplot(double num,double min,double max){
//
QString str;
int l=100;
int n=int((num-min)/(max-min)*l);
if (num<min){n=0;}
if (num>max){n=100;}
str+=QString::number(min);
str+="|";
if (n<=l/2){
for (int i = 0; i < n; ++i) {
str+=" ";
}
for (int i = 0; i < l/2-n; ++i) {
str+="|";
}
str+="|";
for (int i = 0; i < l/2; ++i) {
str+=" ";
}
}
else {
for (int i = 0; i < l/2; ++i) {
str+=" ";
}
for (int i = 0; i < n-l/2; ++i) {
str+="|";
}
str+="|";
for (int i = 0; i < l-n; ++i) {
str+=" ";
}
}
str+="|";
str+=QString::number(max);
str+="=>";str+=QString::number(num);
qDebug()<<str;
qDebug()<<"";
}
void TaskSpaceOnline3::matrix_view(MatrixXd M){
for (int i = 0; i <M.rows() ; ++i) {
QString str;
for (int j = 0; j <M.cols() ; ++j) {
str+=QString::number(M(i,j));
str+=" ";
}
qDebug()<<str;
}
qDebug()<<"";
}
void TaskSpaceOnline3::matrix_view(VectorXd M){
QString str;
for (int i = 0; i <M.rows() ; ++i) {str+=QString::number(M(i));str+=" ";}
qDebug()<<str;
qDebug()<<"";
}
double TaskSpaceOnline3::move2pose(double max,double t_local,double T_start ,double T_end){
double T_move=T_end-T_start;
double c3=(10*max)/pow(T_move,3);
double c4=-(15*max)/pow(T_move,4);
double c5=(6*max)/pow(T_move,5);
double theta=0;
if(t_local<T_start){theta=0;}
else if (t_local<T_end){theta=c3*pow(t_local-T_start,3)+c4*pow(t_local-T_start,4)+c5*pow(t_local-T_start,5);}
else{theta=max;}
return theta;
}
double TaskSpaceOnline3::RollCharge(double t,double t_start,double t_end,double magnitude){
// double D_time_charge = t_end-t_start;
// MatrixXd Ct(1,2); Ct<<0 ,D_time_charge;
// MatrixXd Cp(1,2); Cp<<0, magnitude;
// MatrixXd Cv(1,2); Cv<<0 ,0;
// MatrixXd Ca(1,2); Ca<<0 ,0;
// MatrixXd C_roll=CoefOffline.Coefficient(Ct,Cp,Cv,Ca);
// if(t<=t_start){return 0;}
// else if((t-t_start)>=D_time_charge){return magnitude;}
// else{ MatrixXd output=CoefOffline.GetAccVelPos(C_roll,t-t_start,0,5);
// return output(0,0);}
double roll=move2pose(magnitude,t,t_start,t_end) ;
return roll;
}
double TaskSpaceOnline3::RollDecharge(double t,double t_start,double t_end,double magnitude){
// double D_time_decharge = t_end-t_start;
// MatrixXd Ct(1,2); Ct<<0 ,D_time_decharge;
// MatrixXd Cp(1,2); Cp<< 0, -magnitude;
// MatrixXd Cv(1,2); Cv<<0 ,0;
// MatrixXd Ca(1,2); Ca<<0 ,0;
// MatrixXd C_roll=CoefOffline.Coefficient(Ct,Cp,Cv,Ca);
// if(t<=t_start){return 0;}
// else if((t-t_start)>=D_time_decharge){return -magnitude;}
// else{ MatrixXd output=CoefOffline.GetAccVelPos(C_roll,t-t_start,0,5);
// return output(0,0);}
double roll=move2pose(-magnitude,t,t_start,t_end) ;
return roll;
}
MatrixXd TaskSpaceOnline3::RollAngleModification(double time){
double N;
double t;
double rollR=0;
double rollL=0;
double dt=0;
double dt2=-0.20;
double ChargeCoeffLeftStart =0.8;.4+dt;// 0.4; //after DS start
double ChargeCoeffLeftEnd =1.3;1;// 1.5; //<1 before DS ends; >1 after SS start
double DechargeCoeffLeftStart = 0.4+dt;//.4; //after DS start
double DechargeCoeffLeftEnd = 1+dt2; //<1 before DS ends; >1 after SS start
double ChargeCoeffLeftStartEndPhase =0.8; 0.4+dt; //after DS start
double ChargeCoeffLeftEndEndPhase =1.3; 1; //<1 before DS ends; >1 after SS start
double DechargeCoeffLeftStartEndPhase =.4;// 0.6;//must be bigger than 0.5; end foot pairing DS
double DechargeCoeffLeftEndEndPhase = 0.8; //must be greata
double KStartStartPhase=0.1;
double KEndStartPhase=0.45;
double StartStartPhaseRatio=(Tx+Tc/2-KStartStartPhase*0.5*TDs)/(Tx+Tc+0.5*TSS);
double EndStartPhaseRatio=(Tx+TSS/2+TDs+KEndStartPhase*TSS)/(Tx+Tc+0.5*TSS);
double ChargeCoeffRightStartStartPhase = StartStartPhaseRatio; //0.3 while reducing height(0.5 means minimum height)
double ChargeCoeffRightEndStartPhase = EndStartPhaseRatio; //0.7 almot maximum ankle height
double DechargeCoeffRightStartStartPhase = 0.4+dt; //after DS start
double DechargeCoeffRightEndStartPhase = 1+dt2; //<1 before DS ends; >1 after SS start
double ChargeCoeffRightStart =0.8;.4+dt;// 0.4; //after DS start
double ChargeCoeffRightEnd =1.3; 1;// 1.5; //<1 before DS ends; >1 after SS start
double DechargeCoeffRightStart = 0.4+dt;//.4; //after DS start
double DechargeCoeffRightEnd = 1+dt2; //<1 before DS ends; >1 after SS start
if (time<=TStart){
N=0;
t=time;
}
else if (time>TStart && time<TGait){
N=floor((time-TStart)/(2*Tc));
t=fmod((time-TStart),2*Tc)+TStart;
}
else if (time>=TGait){
t = TStart + 2*Tc + time - TGait;
}
double R_1=0.6;
double D_time=R_1*TDs;
double D_teta_r;
if(time<TStart+DechargeCoeffRightEndStartPhase*TDs){D_teta_r=-1*FirstHipRollModification*(M_PI/180);}
else{D_teta_r=-1*RightHipRollModification*(M_PI/180);}
double D_teta_l=LeftHipRollModification*(M_PI/180);
double extra_D_theta_l=0*M_PI/180;
//VectorXd t_left_charge;
//VectorXd t_left_decharge;
//VectorXd t_right_charge;
//VectorXd t_right_decharge;
//for (int i = 0; i <t_left_charge.rows() ; ++i) {rollL=rollL+RollCharge(t,t_left_charge(i),D_teta_l);}
//for (int i = 0; i <t_left_decharge.rows() ; ++i) {rollL=rollL+RollCharge(t,t_left_decharge(i),D_teta_l);}
//for (int i = 0; i <t_right_charge.rows() ; ++i) {rollR=rollR+RollCharge(t,t_right_charge(i),D_teta_r);}
//for (int i = 0; i <t_right_decharge.rows() ; ++i) {rollR=rollR+RollCharge(t,t_right_decharge(i),D_teta_r);}
rollL=rollL+RollCharge(t,TStart+ChargeCoeffLeftStart*TDs,TStart+ChargeCoeffLeftEnd*TDs,D_teta_l)+
RollDecharge(t,TStart+Tc+DechargeCoeffLeftStart*TDs,TStart+Tc+DechargeCoeffLeftEnd*TDs,D_teta_l)+
RollCharge(t,TStart+2*Tc+ChargeCoeffLeftStartEndPhase*TDs,TStart+2*Tc+ChargeCoeffLeftEndEndPhase*TDs,D_teta_l)+
RollDecharge(t,TStart+2*Tc+TDs+TLastSS+DechargeCoeffLeftStartEndPhase*TDs,TStart+2*Tc+TDs+TLastSS+DechargeCoeffLeftEndEndPhase*TDs,D_teta_l);
rollR=rollR+RollCharge(t,ChargeCoeffRightStartStartPhase*TStart,ChargeCoeffRightEndStartPhase*TStart,D_teta_r)+
RollDecharge(t,TStart+DechargeCoeffRightStartStartPhase*TDs,TStart+DechargeCoeffRightEndStartPhase*TDs,D_teta_r)+
RollCharge(t,TStart+Tc+ChargeCoeffRightStart*TDs,TStart+Tc+ChargeCoeffRightEnd*TDs,D_teta_r)+
RollDecharge(t,TStart+2*Tc+DechargeCoeffRightStart*TDs,TStart+2*Tc+DechargeCoeffRightEnd*TDs,D_teta_r);
MatrixXd RollMat(2,1);
RollMat<<rollR,rollL;
return RollMat;}
void TaskSpaceOnline3::CoeffSideStartEnd(){
//***** x start
MatrixXd Cx_st_iTime_al(1,2);
Cx_st_iTime_al<<T_s_st ,TStart-T_end_of_first_SS;
MatrixXd Cx_st_iPos_al(1,2);
Cx_st_iPos_al<<0, 2*StepLength;
MatrixXd Cx_st_iVel_al(1,2);
Cx_st_iVel_al<<0, 0;
MatrixXd Cx_st_iAcc_al(1,2);
Cx_st_iAcc_al<<0, 0;
C_st_x_al=CoefOffline.Coefficient(Cx_st_iTime_al,Cx_st_iPos_al,Cx_st_iVel_al,Cx_st_iAcc_al);
//***** x end
MatrixXd C_end_iTime_ar(1,2);
C_end_iTime_ar<<0, (T_end_a_e-T_end_a_s-T_end_of_last_SS);
MatrixXd C_end_iPos_ar(1,2);
C_end_iPos_ar<<0, 2*StepLength;
MatrixXd C_end_iVel_ar(1,2);
C_end_iVel_ar<<0, 0;
MatrixXd C_end_iAcc_ar(1,2);
C_end_iAcc_ar<<0, 0;
C_end_x_ar=CoefOffline.Coefficient(C_end_iTime_ar,C_end_iPos_ar,C_end_iVel_ar,C_end_iAcc_ar);
side_extra_step_length=true;
}
void TaskSpaceOnline3::CoeffArrayAnkle(){
//different velocities for lowering foot in end of ss
double vz_start=-(AnkleMaximumHeight-h_end_of_SS)*2/(T_s_st/2-T_end_of_first_SS)/4;
double vz_cycle=-(AnkleMaximumHeight-h_end_of_SS)*2/(TSS-T_end_of_SS-Tm2)/4;
double vz_end=-(AnkleMaximumHeight-h_end_of_SS)*2/((T_end_a_e-T_end_a_s)/2-T_end_of_last_SS)/4;
// vz_start=0;
// vz_cycle=0;
// vz_end=0;
//**************** start ***************************//
//***** x start
MatrixXd Cx_st_iTime_al(1,2);
Cx_st_iTime_al<<T_s_st ,TStart-T_end_of_first_SS;
MatrixXd Cx_st_iPos_al(1,2);
Cx_st_iPos_al<<0, StepLength;
MatrixXd Cx_st_iVel_al(1,2);
Cx_st_iVel_al<<0, 0;
MatrixXd Cx_st_iAcc_al(1,2);
Cx_st_iAcc_al<<0, 0;
C_st_x_al=CoefOffline.Coefficient(Cx_st_iTime_al,Cx_st_iPos_al,Cx_st_iVel_al,Cx_st_iAcc_al);
//***** z start 1
MatrixXd C_st_iTime(1,3);
C_st_iTime<<T_s_st, ((TStart+T_s_st)/2) ,TStart-T_end_of_first_SS;
MatrixXd C_st_iPos(1,3);
C_st_iPos<<0, AnkleMaximumHeight,h_end_of_SS;
MatrixXd C_st_iVel(1,3);
C_st_iVel<<0 ,INFINITY, vz_start;//0 ,INFINITY, vz_start
MatrixXd C_st_iAcc(1,3);
C_st_iAcc<<0 ,INFINITY, 0;
C_st_z_al=CoefOffline.Coefficient(C_st_iTime,C_st_iPos,C_st_iVel,C_st_iAcc);
//***** z start 2
MatrixXd C_st_iTime_e(1,2);
C_st_iTime_e<<TStart-T_end_of_first_SS,TStart;
MatrixXd C_st_iPos_e(1,2);
C_st_iPos_e<<h_end_of_SS,0;
MatrixXd C_st_iVel_e(1,2);
C_st_iVel_e<<vz_start , 0;
MatrixXd C_st_iAcc_e(1,2);
C_st_iAcc_e<<0 , 0;
C_st_z_al_end_of_SS=CoefOffline.Coefficient(C_st_iTime_e,C_st_iPos_e,C_st_iVel_e,C_st_iAcc_e);
//**************** cycle ***************************//
//***** x cycle
MatrixXd C_cy_iTime_ar(1,3);
C_cy_iTime_ar<<0, Tm2, TSS-T_end_of_SS;
MatrixXd C_cy_iPos_ar(1,3);
C_cy_iPos_ar<<0, XofAnkleMaximumHeight , 2*StepLength;
MatrixXd C_cy_iVel_ar(1,3);
C_cy_iVel_ar<<0,INFINITY, 0;
MatrixXd C_cy_iAcc_ar(1,3);
C_cy_iAcc_ar<<0,INFINITY, 0;
C_cy_x_ar=CoefOffline.Coefficient(C_cy_iTime_ar,C_cy_iPos_ar,C_cy_iVel_ar,C_cy_iAcc_ar);
//matrix_view(C_cy_x_ar);
//***** z cycle1
MatrixXd ordza(1,3);
ordza << 4,3,5;
MatrixXd tttza(1,4);
tttza <<0 ,Tm1 ,Tm2, TSS-T_end_of_SS;
MatrixXd conza(3,4);
conza<<0,.6*AnkleMaximumHeight,AnkleMaximumHeight ,h_end_of_SS,
0 ,INFINITY,INFINITY, vz_cycle,0 ,INFINITY,INFINITY, 0;
C_cy_z_ar.resize(3,6);
C_cy_z_ar.fill(0);
C_cy_z_ar.block(0,0,3,6)=CoefOffline.Coefficient1(tttza,ordza,conza,0.1).transpose();//.block(0,1,2,5) .block(0,2,2,4) (comment)
//***** z cycle2
MatrixXd C_cy_iTime_e(1,2);
C_cy_iTime_e<<TSS-T_end_of_SS, TSS;
MatrixXd C_cy_iPos_e(1,2);
C_cy_iPos_e<< h_end_of_SS, 0;
MatrixXd C_cy_iVel_e(1,2);
C_cy_iVel_e<<vz_cycle , 0;
MatrixXd C_cy_iAcc_e(1,2);
C_cy_iAcc_e<<0 , 0;
C_cy_z_ar_end_of_SS=CoefOffline.Coefficient(C_cy_iTime_e,C_cy_iPos_e,C_cy_iVel_e,C_cy_iAcc_e);
//*************************** end *************************************
//***** x end
MatrixXd C_end_iTime_ar(1,2);
C_end_iTime_ar<<0, (T_end_a_e-T_end_a_s-T_end_of_last_SS);
MatrixXd C_end_iPos_ar(1,2);
C_end_iPos_ar<<0, 1*StepLength;
MatrixXd C_end_iVel_ar(1,2);
C_end_iVel_ar<<0, 0;
MatrixXd C_end_iAcc_ar(1,2);
C_end_iAcc_ar<<0, 0;
C_end_x_ar=CoefOffline.Coefficient(C_end_iTime_ar,C_end_iPos_ar,C_end_iVel_ar,C_end_iAcc_ar);
//***** z end 1
MatrixXd C_end_z_iTime(1,3);
C_end_z_iTime<<0 ,(T_end_a_e-T_end_a_s)/2 ,T_end_a_e-T_end_a_s-T_end_of_last_SS;
MatrixXd C_end_z_iPos(1,3);
C_end_z_iPos<<0, AnkleMaximumHeight, h_end_of_SS;
MatrixXd C_end_z_iVel(1,3);
C_end_z_iVel<<0 ,INFINITY, vz_end;//0 ,INFINITY, vz_end
MatrixXd C_end_z_iAcc(1,3);
C_end_z_iAcc<<0 ,INFINITY, 0;
C_end_z_ar=CoefOffline.Coefficient(C_end_z_iTime,C_end_z_iPos,C_end_z_iVel,C_end_z_iAcc);
//***** z end 2
MatrixXd C_end_z_iTime_e(1,2);
C_end_z_iTime_e<<T_end_a_e-T_end_a_s-T_end_of_last_SS ,T_end_a_e-T_end_a_s;
MatrixXd C_end_z_iPos_e(1,2);
C_end_z_iPos_e<<h_end_of_SS, 0;
MatrixXd C_end_z_iVel_e(1,2);
C_end_z_iVel_e<<vz_end , 0;
MatrixXd C_end_z_iAcc_e(1,2);
C_end_z_iAcc_e<<0 , 0;
C_end_z_ar_end_of_SS=CoefOffline.Coefficient(C_end_z_iTime_e,C_end_z_iPos_e,C_end_z_iVel_e,C_end_z_iAcc_e);
//***** beta cycle
double v_beta_toe=2*beta_toe/t_toe;
MatrixXd beta_toe_t_cycle(1,2);
beta_toe_t_cycle<<0,t_toe;
MatrixXd beta_toe_Pos_cycle(1,2);
beta_toe_Pos_cycle<<0, beta_toe;
MatrixXd beta_toe_Vel_cycle(1,2);
beta_toe_Vel_cycle<<0 , v_beta_toe;
MatrixXd beta_toe_Acc_cycle(1,2);
beta_toe_Acc_cycle<<0 , 0;
C_beta_toe_cycle=CoefOffline.Coefficient(beta_toe_t_cycle,beta_toe_Pos_cycle,beta_toe_Vel_cycle,beta_toe_Acc_cycle);
MatrixXd beta_heel_t_cycle(1,2);
beta_heel_t_cycle<<0,t_heel;
MatrixXd beta_heel_Pos_cycle(1,2);
beta_heel_Pos_cycle<< beta_heel,0;
MatrixXd beta_heel_Vel_cycle(1,2);
beta_heel_Vel_cycle<<0 , 0;
MatrixXd beta_heel_Acc_cycle(1,2);
beta_heel_Acc_cycle<<0 , 0;
C_beta_heel_cycle=CoefOffline.Coefficient(beta_heel_t_cycle,beta_heel_Pos_cycle,beta_heel_Vel_cycle,beta_heel_Acc_cycle);
MatrixXd beta_toe2heel_t_cycle(1,3);
beta_toe2heel_t_cycle<<0,TStartofHeel,TSS;
MatrixXd beta_toe2heel_Pos_cycle(1,3);
beta_toe2heel_Pos_cycle<< beta_toe,INFINITY,beta_heel;
MatrixXd beta_toe2heel_Vel_cycle(1,3);
beta_toe2heel_Vel_cycle<< v_beta_toe ,INFINITY, 0;//0 ,0, 0;
MatrixXd beta_toe2heel_Acc_cycle(1,3);
beta_toe2heel_Acc_cycle<< 0 ,INFINITY, 0; //0 ,0, 0;
C_beta_toe2heel_cycle=CoefOffline.Coefficient(beta_toe2heel_t_cycle,beta_toe2heel_Pos_cycle,beta_toe2heel_Vel_cycle,beta_toe2heel_Acc_cycle);
}
void TaskSpaceOnline3::CoeffArrayPelvis(){
//------------------Coefficient of cyclic motion in X direction--------------------
double a_0=(Xe-zmp_max)/0.1;
double a_Ds=(-Xs-zmp_min)/0.1;
double A_Ds=(a_Ds-a_0)/(6*TDs);
double C_Ds=(-Xs-Xe+StepLength-A_Ds*TDs*TDs*TDs-a_0*TDs*TDs/2)/TDs;
double v_0=C_Ds;
double v_Ds=3*A_Ds*TDs*TDs+a_0*TDs+C_Ds;
//------------------Coefficient of cyclic motion in X direction--------------------
MatrixXd ord(1,2);
ord << 5,5;//3,3 (Gooth Test)
MatrixXd ttt(1,3);
ttt <<0 ,TDs, Tc;
MatrixXd con(3,3);
con<<Xe, StepLength-Xs, StepLength+Xe,v_0,v_Ds ,v_0,a_0, a_Ds ,a_0;
Cx_p_i.resize(2,6);
Cx_p_i.fill(0);
Cx_p_i.block(0,0,2,6)=CoefOffline.Coefficient1(ttt,ord,con,0.1).transpose();//.block(0,1,2,5) .block(0,2,2,4) (comment)
Cx_p.resize(1,12);
Cx_p.fill(0);
Cx_p.block(0,0,1,6)=Cx_p_i.row(0);
Cx_p.block(0,6,1,6)=Cx_p_i.row(1);
//----------------Coefficient of Start of Pelvis motion in x direction---------------------
MatrixXd Cx_st_pTime(1,2);
Cx_st_pTime<<T_st_p_sx ,TStart;
MatrixXd Cx_st_pPos(1,2);
Cx_st_pPos<<0, Xe;
MatrixXd Cx_st_pVel(1,2);
Cx_st_pVel<<0 ,Cx_p(0,4);
MatrixXd Cx_st_pAccel(1,2);
Cx_st_pAccel<<0 ,2*Cx_p(0,3);
Cx_st_p=CoefOffline.Coefficient(Cx_st_pTime,Cx_st_pPos,Cx_st_pVel,Cx_st_pAccel);
// ----------------Coefficient of End of Pelvis motion in x direction----------------------
MatrixXd Cx_end_pTime(1,2);
Cx_end_pTime<<(TDs),T_end_p_sx_rel ;
MatrixXd Cx_end_pPos(1,2);
Cx_end_pPos<<(NStep+1)*StepLength-Xs, (NStep+1)*StepLength+(side_extra_step_length)*StepLength;
MatrixXd Cx_end_pVel(1,2);
Cx_end_pVel<<5*Cx_p(0,0)*pow(TDs,4)+4*Cx_p(0,1)*pow(TDs,3)+3*Cx_p(0,2)*pow(TDs,2)+2*Cx_p(0,3)*pow(TDs,1)+Cx_p(0,4), 0;
MatrixXd Cx_end_pAccel(1,2);
Cx_end_pAccel<<5*4*Cx_p(0,0)*pow(TDs,3)+4*3*Cx_p(0,1)*pow(TDs,2)+3*2*Cx_p(0,2)*pow(TDs,1)+2*Cx_p(0,3), 0;//like the last moment of first part of trajectory of cycle
Cx_end_p=CoefOffline.Coefficient(Cx_end_pTime,Cx_end_pPos,Cx_end_pVel,Cx_end_pAccel);
//------------------Coefficient of cyclic Pelvis motion in Y direction--------------------
MatrixXd ordY(1,8);
ordY << 5,5,5,5,5,5,5,5;
MatrixXd tttY(1,9);
tttY <<0,TMinPelvisY,TDs,TDs+TSS/2,Tc,Tc+TDs/2,Tc+TDs,Tc+TDs+TSS/2,2*Tc;
MatrixXd conY(3,9);
double a_h=a_d/3/TDs;
double c_h=(Yd-a_h*TDs*TDs*TDs/8)*2/TDs;
double v_d=3*a_h*TDs*TDs/4+c_h;
double a_a_h=(a_d*TSS*TSS/2+v_d*TSS)*12/(TSS*TSS*TSS*TSS);
double b_b_h=-a_a_h*TSS;
YpMax=-.75*a_a_h*(TSS*TSS*TSS*TSS)/48+a_d*TSS*TSS/8+v_d*TSS/2+Yd;
double a_p_max=a_a_h*TSS*TSS/4+b_b_h*TSS/2+a_d;
conY<<-1*Yd,0,Yd,YpMax,Yd,0,-1*Yd,-1*YpMax,-1*Yd,
v_d, c_h,v_d, 0 ,-v_d,-c_h, -v_d,0,v_d
,-a_d, 0,a_d, a_p_max ,a_d, 0 ,-a_d,-a_p_max,-a_d;//a= ,0, INFINITY,INFINITY, INFINITY ,0,INFINITY,INFINITY,INFINITY,0;
Cy_p_i.resize(8,6);
Cy_p_i.fill(0);
Cy_p_i.block(0,0,8,6)=CoefOffline.Coefficient1(tttY,ordY,conY,0.1).transpose();//.block(0,1,8,5)
Cy_p.resize(1,48);
Cy_p.fill(0);
Cy_p.block(0,0,1,6)=Cy_p_i.row(0);
Cy_p.block(0,6,1,6)=Cy_p_i.row(1);
Cy_p.block(0,12,1,6)=Cy_p_i.row(2);
Cy_p.block(0,18,1,6)=Cy_p_i.row(3);
Cy_p.block(0,24,1,6)=Cy_p_i.row(4);
Cy_p.block(0,30,1,6)=Cy_p_i.row(5);
Cy_p.block(0,36,1,6)=Cy_p_i.row(6);
Cy_p.block(0,42,1,6)=Cy_p_i.row(7);
//--------------Coefficient of Start of Pelvis motion in y direction----------------
MatrixXd ordY_S(1,6);
ordY_S << 5,5,5,5,5,5;
MatrixXd tttY_S(1,7);
tttY_S <<0,Tx,Tx+TSS/2,Tx+Tc/2,Tx+Tc/2+TDs/2,Tx+Tc,TStart;
MatrixXd conY_S(3,7);
//qDebug()<<YpMax;
conY_S<<0,YpMax,Yd,0,-1*Yd,-1.1*YpMax,-1*Yd,
0,0,-v_d,-c_h, -v_d,0,v_d,
0,a_p_max,a_d, 0 ,-a_d,-a_p_max,-a_d;
Cy_p_i_S.resize(6,6);
Cy_p_i_S.fill(0);
Cy_p_i_S.block(0,0,6,6)=CoefOffline.Coefficient1(tttY_S,ordY_S,conY_S,0.1).transpose();
Cy_p_S.resize(1,36);
Cy_p_S.fill(0);
// -------------------Coefficient of End of Pelvis motion in y direction--------------
//YEndMax=YEndMax_Coef*YpMax;
//YEndMax=0.1;
// MatrixXd ordY_e(1,2);
// ordY_e << 5,5;
// MatrixXd tttY_e(1,3);
// tttY_e <<TGait+TDs,TGait+TDs+TLastSS/2,TGait+TDs+TLastSS+TE;
// MatrixXd conY_e(3,3);
// conY_e<<Yd,YEndMax,0,
// v_d,0,0,
// a_d,0,0;
// Cy_p_i_E.resize(2,6);
// Cy_p_i_E.fill(0);
// Cy_p_i_E.block(0,0,2,6)=CoefOffline.Coefficient1(tttY_e,ordY_e,conY_e,0.1).transpose();//.block(0,1,8,5)
YEndMax=YEndMax_Coef*YpMax;
YEndMax=0.1;
MatrixXd ordY_e(1,3);
ordY_e << 5,5,5;
MatrixXd tttY_e(1,4);
tttY_e <<TGait+TDs,TGait+TDs+TLastSS/2,TGait+TDs+TLastSS+0.5*TE,TGait+TDs+TLastSS+TE;
MatrixXd conY_e(3,4);
conY_e<<Yd,YEndMax,-0.05,0,
v_d,0,0,0,
a_d,0,-a_p_max,0;
Cy_p_i_E.resize(3,6);
Cy_p_i_E.fill(0);
Cy_p_i_E.block(0,0,3,6)=CoefOffline.Coefficient1(tttY_e,ordY_e,conY_e,0.1).transpose();//.block(0,1,8,5)
}
MatrixXd TaskSpaceOnline3::PelvisTrajectory(double time){
double N,t,xp,yp,zp,dxp,dyp,dzp,ddxp,ddyp,ddzp,yawp;
//determining N
if (time<=TStart||time>TGait){
N=0;
t=time;
}
else if (time>TStart && time<TGait){
N=floor((time-TStart)/(2*Tc));
t=fmod((time-TStart),2*Tc)+TStart;
}
else if (time==TGait){
N=NStride;
t=0;
}
//******************* x
if (t<=T_st_p_sx){
xp=0;
dxp=0;
ddxp=0;
DoubleSupport=true;
}
else if (t>T_st_p_sx && t<=TStart){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_st_p,t,T_st_p_sx,5);
xp=output(0,0);
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=true;
}
else if (t>TStart && t<=(TDs+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_p_i.row(0),t-TStart,0,5);
xp=output(0,0);
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=true;
}
else if (t>(TDs+TStart) && t<=(Tc+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_p_i.row(1),t-TStart,0,5);
xp=output(0,0);
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=false;
}
else if (t>(Tc+TStart) && t<=(Tc+TDs+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_p_i.row(0),t-Tc-TStart,0,5);
xp=output(0,0)+StepLength;
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=true;
}
else if (t>(Tc+TDs+TStart) && t<=(2*Tc+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_p_i.row(1),t-Tc-TStart,0,5);
xp=output(0,0)+StepLength;
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=false;
}
else if (t>TGait && t<(TGait+TDs)){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_p_i.row(0),t-TGait,0,5);
xp=output(0,0)+2*NStride*StepLength;
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=true;
}
else if (t>=(TGait+TDs) && t<T_end_p_sx){
MatrixXd output=CoefOffline.GetAccVelPos(Cx_end_p,t,(TGait+TDs),5);
xp=output(0,0);
dxp=output(0,1);
ddxp=output(0,2);
DoubleSupport=true;
}
else if (t>=T_end_p_sx && t<=(TGait+TDs+TEnd)){
xp=(2*NStride+1)*StepLength+(side_extra_step_length)*StepLength;
dxp=0;
ddxp=0;
DoubleSupport=true;
}
xp=xp+2*StepLength*N;
/// y
if(t<Tx){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(0),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if(t<Tx+TSS/2){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(1),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if(t<Tx+Tc/2){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(2),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if(t<Tx+Tc/2+TDs/2){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(3),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if(t<Tx+Tc){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(4),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if(t<TStart){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_S.row(5),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>TStart && t<=(TMinPelvisY+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(0),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TMinPelvisY+TStart) && t<=(TDs+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(1),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TDs+TStart) && t<=(TMaxPelvisY+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(2),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TMaxPelvisY+TStart) && t<=(Tc+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(3),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(Tc+TStart) && t<=(Tc+TMinPelvisY+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(4),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(Tc+TMinPelvisY+TStart) && t<=(Tc+TDs+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(5),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(Tc+TDs+TStart) && t<=(Tc+TMaxPelvisY+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(6),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(Tc+TMaxPelvisY+TStart) && t<=(2*Tc+TStart)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(7),t-TStart,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>TGait && t<=(TMinPelvisY+TGait)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(0),t-TGait,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TMinPelvisY+TGait) && t<=(TDs+TGait)){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i.row(1),t-TGait,0,5);
yp=output(0,0);
ddyp=output(0,2);
dyp=output(0,1);
}
else if (t>(TDs+TGait) && t<=TGait+TDs+TLastSS/2){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_E.row(0),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TDs+TGait+TLastSS/2) && t<=TGait+TDs+TLastSS+0.5*TE){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_E.row(1),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
else if (t>(TDs+TGait+TLastSS+0.5*TE) && t<=TGait+TDs+TLastSS+TE){
MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_E.row(2),t,0,5);
yp=output(0,0);
dyp=output(0,1);
ddyp=output(0,2);
}
// else if (t>(TGait+TDs+TLastSS) && t<=TGait+TDs+TLastSS+TE*0.5){
// MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_E.row(2),t,0,5);
// yp=output(0,0);
// dyp=output(0,1);
// ddyp=output(0,2);
// }
// else if (t>(TGait+TDs+TLastSS+TE*0.5) && t<=TGait+TDs+TLastSS+TE){
// MatrixXd output=CoefOffline.GetAccVelPos(Cy_p_i_E.row(3),t,0,5);
// yp=output(0,0);
// dyp=output(0,1);
// ddyp=output(0,2);
// }
else{
yp=0;
dyp=0;
ddyp=0;
}
zp=ReferencePelvisHeight;
dzp=0;
ddzp=0;
MatrixXd pelvis(10,1);
pelvis<<xp,yp,zp,dxp,dyp,dzp,ddxp,ddyp,ddzp,yawp;
return pelvis;
}
MatrixXd TaskSpaceOnline3::AnkleTrajectory(double time,int n ,double localtiming){
LeftFootOrientationAdaptator=false;
RightFootOrientationAdaptator=false;
double y_ar=-0.5*_pelvisLength;
double y_al=0.5*_pelvisLength;
double x_ar,x_al,z_ar,z_al;
double pitch_al=0;
double pitch_ar=0;
if (n==1){//left foot moves in first step
x_ar=0;
z_ar=_lenghtOfAnkle;
x_al=0;
z_al=_lenghtOfAnkle;
if (localtiming>=T_s_st && localtiming<=TStart-T_end_of_first_SS){
MatrixXd output=CoefOffline.GetAccVelPos(C_st_x_al.row(0),localtiming,T_s_st,5);
x_al=output(0,0);
if (localtiming<=(((TStart+T_s_st)/2))){
MatrixXd output=CoefOffline.GetAccVelPos(C_st_z_al.row(0),localtiming,T_s_st,5);
z_al=_lenghtOfAnkle+output(0,0);
}
else if (localtiming<=(TStart-T_end_of_first_SS)){
MatrixXd output=CoefOffline.GetAccVelPos(C_st_z_al.row(1),localtiming,((TStart+T_s_st)/2),5);
z_al=_lenghtOfAnkle+output(0,0);
}
}
else if(localtiming>TStart-T_end_of_first_SS){
LeftFootOrientationAdaptator=true;
MatrixXd output1=CoefOffline.GetAccVelPos(C_st_x_al.row(0),TStart-T_end_of_first_SS,T_s_st,5);
x_al=output1(0,0);
MatrixXd output=CoefOffline.GetAccVelPos(C_st_z_al_end_of_SS.row(0),localtiming,TStart-T_end_of_first_SS,5);
z_al=_lenghtOfAnkle+output(0,0);
}
}
if (n!=1 && n!=(NStep+2)){//cyclic walking
n=n-1;
footIndex=fmod(n,2);// shows which foot is swing foot (in cyclic mode left foots is swinging in the even steps(N))
//it means whenever the footIndex is 0 the left foots will go to the swing mode
currentLeftFootX2=(n-fmod(n+1,2))*StepLength+side_extra_step_length*StepLength;
// currentLeftFootY2;
currentLeftFootZ=0.112;
currentRightFootX2=(n-fmod(n,2))*StepLength;
//currentRightFootY2;
currentRightFootZ=0.112;
if (localtiming<TDs){// double support of cyclic walking
x_al=currentLeftFootX2;
z_al=currentLeftFootZ;
x_ar=currentRightFootX2;
z_ar=currentRightFootZ;
if(beta_heel!=0||beta_toe!=0){
if(localtiming>(TDs-t_toe)){
MatrixXd output=CoefOffline.GetAccVelPos(C_beta_toe_cycle,localtiming-(TDs-t_toe),0,5);
pitch_ar=output(0,0);
}
if(localtiming<t_heel&&n>1){
pitch_al=beta_heel;
}
if(localtiming>t_heel&&n>1){
MatrixXd output=CoefOffline.GetAccVelPos(C_beta_heel_cycle,localtiming-t_heel,0,5);
pitch_al=output(0,0);
}
}
}
else if (localtiming<Tc-T_end_of_SS){//single support of cyclic walking
if (localtiming<TDs+Tm2){
MatrixXd output1=CoefOffline.GetAccVelPos(C_cy_x_ar.row(0),localtiming-TDs,0,5);
x_al=(footIndex!=0)*currentLeftFootX2+(footIndex==0)*(footIndex==0)*(currentLeftFootX2+output1(0,0));
x_ar=(footIndex!=0)*(currentRightFootX2+output1(0,0))+(footIndex==0)*currentRightFootX2;
}
else{
MatrixXd output1=CoefOffline.GetAccVelPos(C_cy_x_ar.row(1),localtiming-TDs,Tm2,5);
x_al=(footIndex!=0)*currentLeftFootX2+(footIndex==0)*(footIndex==0)*(currentLeftFootX2+output1(0,0));
x_ar=(footIndex!=0)*(currentRightFootX2+output1(0,0))+(footIndex==0)*currentRightFootX2;
}
if(beta_heel!=0||beta_toe!=0){
if (localtiming<TDs+TStartofHeel){
MatrixXd output2=CoefOffline.GetAccVelPos(C_beta_toe2heel_cycle.row(0),localtiming-TDs,0,5);
pitch_ar=output2(0,0);
}
else{MatrixXd output2=CoefOffline.GetAccVelPos(C_beta_toe2heel_cycle.row(1),localtiming-TDs,TStartofHeel,5);
pitch_ar=output2(0,0);}
}
if (localtiming<TDs+Tm1){
MatrixXd output2=CoefOffline.GetAccVelPos(C_cy_z_ar.row(0),localtiming-TDs,0,5);
z_al=(footIndex!=0)*currentLeftFootZ+(footIndex==0)*(currentLeftFootZ+output2(0,0));
z_ar=(footIndex!=0)*(currentRightFootZ+output2(0,0))+(footIndex==0)*currentRightFootZ;
}
else if (localtiming<TDs+Tm2){
MatrixXd output2=CoefOffline.GetAccVelPos(C_cy_z_ar.row(1),localtiming-TDs,0,5);//-Tm1
z_al=(footIndex!=0)*currentLeftFootZ+(footIndex==0)*(currentLeftFootZ+output2(0,0));
z_ar=(footIndex!=0)*(currentRightFootZ+output2(0,0))+(footIndex==0)*currentRightFootZ;
}
else{
MatrixXd output2=CoefOffline.GetAccVelPos(C_cy_z_ar.row(2),localtiming-TDs,0,5);//-Tm2
z_al=(footIndex!=0)*currentLeftFootZ+(footIndex==0)*(currentLeftFootZ+output2(0,0));
z_ar=(footIndex!=0)*(currentRightFootZ+output2(0,0))+(footIndex==0)*currentRightFootZ;
}
}
else if (localtiming<Tc){
if(beta_heel!=0||beta_toe!=0){
MatrixXd output1=CoefOffline.GetAccVelPos(C_beta_toe2heel_cycle.row(1),localtiming-TDs,TStartofHeel,5); // Tm2
pitch_ar=output1(0,0);
}
LeftFootOrientationAdaptator=(footIndex==0);
RightFootOrientationAdaptator=(footIndex!=0);
x_al=(footIndex!=0)*currentLeftFootX2+(footIndex==0)*(currentLeftFootX2+2*StepLength);
x_ar=(footIndex!=0)*(currentRightFootX2+2*StepLength)+(footIndex==0)*currentRightFootX2;
MatrixXd output2=CoefOffline.GetAccVelPos(C_cy_z_ar_end_of_SS.row(0),localtiming-Tc+TSS,TSS-T_end_of_SS,5);
z_al=(footIndex!=0)*currentLeftFootZ+(footIndex==0)*(currentLeftFootZ+output2(0,0));
z_ar=(footIndex!=0)*(currentRightFootZ+output2(0,0))+(footIndex==0)*currentRightFootZ;
}
if(footIndex==0){
double temp= pitch_ar;
pitch_ar=pitch_al;
pitch_al=temp;
}
}
if(n==NStep+2){//end step of walk right foot moves
n=n-1;
currentLeftFootX2=(n-fmod(n+1,2))*StepLength+side_extra_step_length*StepLength;
currentLeftFootZ=0.112;
currentRightFootX2=(n-fmod(n,2))*StepLength;
currentRightFootZ=0.112;
if (localtiming<=(TDs+0.001)){// double support of end
z_ar=currentRightFootZ;
z_al=currentLeftFootZ;
x_ar=currentRightFootX2;
x_al=currentLeftFootX2;
}
else {
if (localtiming<=(T_end_a_e-T_end_a_s-T_end_of_last_SS)+TDs){
MatrixXd output1=CoefOffline.GetAccVelPos(C_end_x_ar.row(0),localtiming-TDs,0,5);
x_ar=currentRightFootX2+output1(0,0);
x_al=currentLeftFootX2;//*/(2*NStride+1)*StepLength;/*
z_al=currentLeftFootZ;
if (localtiming<=(T_end_a_e-T_end_a_s)/2+TDs){
MatrixXd output2=CoefOffline.GetAccVelPos(C_end_z_ar.row(0),localtiming-TDs,0,5);
z_ar=currentRightFootZ+output2(0,0);//currentRightFootZ+output2(0,0);
}
else if (localtiming>=(T_end_a_e-T_end_a_s)/2+TDs){
MatrixXd output2=CoefOffline.GetAccVelPos(C_end_z_ar.row(1),localtiming-TDs, (T_end_a_e-T_end_a_s)/2,5);
z_ar=currentRightFootZ+output2(0,0);
}
}
else if (localtiming<=(T_end_a_e-T_end_a_s)+TDs){
RightFootOrientationAdaptator=true;
MatrixXd output1=CoefOffline.GetAccVelPos(C_end_x_ar.row(0),(T_end_a_e-T_end_a_s-T_end_of_last_SS),0,5);
x_ar=currentRightFootX2+output1(0,0);
x_al=currentLeftFootX2;//*/(2*NStride+1)*StepLength;/*
z_al=currentLeftFootZ;
MatrixXd output2=CoefOffline.GetAccVelPos(C_end_z_ar_end_of_SS.row(0),localtiming,T_end_a_e-T_end_a_s-T_end_of_last_SS+TDs,5);
z_ar=currentRightFootZ+output2(0,0);
}
else{
MatrixXd output1=CoefOffline.GetAccVelPos(C_end_x_ar.row(0),(T_end_a_e-T_end_a_s-T_end_of_last_SS),0,5);
x_ar=currentRightFootX2+output1(0,0);
z_ar=currentRightFootZ;//_lenghtOfAnkle;
x_al=currentLeftFootX2;//(2*NStride+1)*StepLength;
z_al=currentLeftFootZ;//_lenghtOfAnkle;
}
}
}
MatrixXd footpos(8,1);
footpos<<x_al,y_al,z_al,pitch_al,x_ar,y_ar,z_ar,pitch_ar;
return footpos;
}
|
916046020c25e8dabc7d5177c6292e975ab004d2
|
7fc161bd29ab037e9cd8b3295f39c8cd6123d4fd
|
/src/board/usb/usb.hpp
|
d995638b9af0637e4215d1500cbf1bc9370031cc
|
[] |
no_license
|
Sleuek/Korchega
|
b7702cfebedf4e2b2bf5ec7bda7689b1e0089f6f
|
84a4c55dc7861ab655459d89e49028b79a902995
|
refs/heads/main
| 2023-03-08T23:03:50.359061
| 2021-02-18T13:04:45
| 2021-02-18T13:04:45
| 339,686,554
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 351
|
hpp
|
usb.hpp
|
/**
* Copyright (c) 2016-2017 Zubax Robotics <info@zubax.com>
*/
#pragma once
#include <hal.h>
#include <array>
#include <cstdint>
namespace board
{
namespace usb
{
/**
* Takes about one second to complete!
*/
void init();
SerialUSBDriver* getSerialUSBDriver();
enum class State
{
Disconnected,
Connected
};
State getState();
}
}
|
90a783e2541a4ac04557503a0f5f4906f6706966
|
0bac4cdcbc9bbd304cdb7aa6dc89375874b8fc2d
|
/DPGAnalysis/HGCalNanoAOD/plugins/ObjectIndexFromAssociationProducer.cc
|
2f1fae58686744a9fc6aa503bbf37ebd3fe2222f
|
[
"Apache-2.0"
] |
permissive
|
cms-pepr/cmssw
|
8c6f60b07328ad8534ffd93c579ca60ba10e1c42
|
9e78f7d5c471221cb37e926882a09ec8f6150765
|
refs/heads/pepr_CMSSW_12_6_0_pre2
| 2023-02-04T22:25:16.955809
| 2023-01-22T11:53:50
| 2023-01-22T11:53:50
| 228,587,122
| 1
| 0
|
Apache-2.0
| 2023-01-22T11:53:51
| 2019-12-17T10:01:56
|
C++
|
UTF-8
|
C++
| false
| false
| 878
|
cc
|
ObjectIndexFromAssociationProducer.cc
|
#include "PhysicsTools/NanoAOD/interface/ObjectIndexFromAssociationProducer.h"
#include "SimDataFormats/PFAnalysis/interface/PFTruthParticle.h"
#include "SimDataFormats/PFAnalysis/interface/PFTruthParticleFwd.h"
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "FWCore/Framework/interface/MakerMacros.h"
typedef ObjectIndexFromAssociationTableProducer<edm::View<CaloRecHit>, reco::PFCandidateCollection>
CaloRecHitToPFCandIndexTableProducer;
typedef ObjectIndexFromAssociationTableProducer<edm::View<CaloRecHit>, PFTruthParticleCollection>
CaloRecHitToPFTruthParticleIndexTableProducer;
DEFINE_FWK_MODULE(CaloRecHitToPFCandIndexTableProducer);
DEFINE_FWK_MODULE(CaloRecHitToPFTruthParticleIndexTableProducer);
|
92f6db7c8172b24c22dd4be465e338ef56da8946
|
6a30e6a0548ee99109da995fe2cee6a4317d39ff
|
/ControllerEdit.cpp
|
b59a4b1794bd36efb52d57f8dccecb20c920979a
|
[] |
no_license
|
daniuu/YJS-PIS-2018
|
9f9206bd9a1dcd6af3463ffd54423d00353d94f6
|
1f5c2f1a5d68915bb316e62cafc4630118b80921
|
refs/heads/master
| 2020-06-02T00:43:57.247679
| 2019-06-09T08:45:47
| 2019-06-09T08:45:47
| 190,982,640
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,304
|
cpp
|
ControllerEdit.cpp
|
//==============================================================================================
// FILE : ControllerEdit.cpp
// ABSTRACT : Binds a MipParameter to an edit box
// HISTORY : 2005.11.04 Nikon Corp. - Created
//
// Copyright (c) 2005, Nikon Corp. All rights reserved.
//==============================================================================================
#include "stdafx.h"
#include "Pathology.h"
#include "ControllerEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CControllerEdit
//==============================================================================================
// FUNCTION : CControllerEdit
// ABSTRACT : Constructor
// PARAMS : None
// RETURN : void
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
CControllerEdit::CControllerEdit()
{
m_bDirty = FALSE;
m_bAutoChange = FALSE;
m_Source.m_pProperty = NULL;
m_vt = VT_NULL;
}
//==============================================================================================
// FUNCTION : ~CControllerEdit
// ABSTRACT : destructor
// PARAMS : None
// RETURN : void
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
CControllerEdit::~CControllerEdit()
{
}
BEGIN_MESSAGE_MAP(CControllerEdit, CEdit)
//{{AFX_MSG_MAP(CControllerEdit)
ON_WM_DESTROY()
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_PAREVENT,OnParamEvent)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CControllerEdit Message handler
//==============================================================================================
// FUNCTION : OnParamEvent
// ABSTRACT : Event sink
// PARAMS : wParam: not used
// lParam: event number
// RETURN : 0
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
LRESULT CControllerEdit::OnParamEvent(WPARAM wParam, LPARAM lParam)
{
switch(lParam)
{
case EMIPPAR_VALUECHANGED:
OutputDebugString("CControllerEdit::OnParamEvent EMIPPAR_VALUECHANGED\n");
ValueChanged();
break;
case EMIPPAR_INFOCHANGED:
OutputDebugString("CControllerEdit::OnParamEvent EMIPPAR_INFOCHANGED\n");
InfoChanged();
break;
}
return 0L;
}
//==============================================================================================
// FUNCTION : Connect
// ABSTRACT : Connects a MIP parameter to an edit box
// PARAMS : piParameter: parameter to connect to the edit box
// RETURN : TRUE
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
BOOL CControllerEdit::Connect(IDispatch *piParameter)
{
try {
if (m_Source.m_pProperty)
return FALSE;
if(piParameter==NULL)
return FALSE;
Disconnect();
CComPtr<IMipParameter> spiParam;
HRESULT hr = piParameter->QueryInterface(&spiParam);
if(FAILED(hr))
return FALSE;
if(SUCCEEDED(hr)){
VARIANT var;
m_Source.m_pProperty = spiParam;
hr = m_Source.m_pProperty->get_RawValue(&var);
if (SUCCEEDED(hr)) {
m_vt = var.vt;
hr = m_Source.AdviseAsync((long)m_hWnd,WM_PAREVENT,0);
if (m_vt != VT_BSTR && m_vt != VT_R8) {
hr = m_Source->put_DisplayCFormat(CComBSTR("%.0f"));
if (!CreateSpinCtrl())
return FALSE;
}
}
InfoChanged();
ValueChanged();
}
}
catch (_com_error &e) {
_CONTROLLER_ERRORMSG(e);
return FALSE;
}
return TRUE;
}
//==============================================================================================
// FUNCTION : Disconnect
// ABSTRACT : Disconnects a MIP parameter from an edit box
// PARAMS : None
// RETURN : void
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
void CControllerEdit::Disconnect()
{
HRESULT hr;
try {
hr = m_Source.UnAdviseAsync();
if (m_Source.m_pProperty) {
m_Source.m_pProperty.Release();
m_Source.m_pProperty = NULL;
}
}
catch (_com_error &e) {
_CONTROLLER_ERRORMSG(e);
return;
}
}
//==============================================================================================
// FUNCTION : InfoChanged
// ABSTRACT : Updates the edit box when the metadata of the underlying MIP parameter changes
// PARAMS : None
// RETURN : TRUE
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
BOOL CControllerEdit::InfoChanged()
{
try {
m_Source.ResetInfoChangedFlag();
ATLASSERT(m_Source);
EMIPPAR_LIMITATION lt;
m_Source->get_LimitationType(<);
VARIANT_BOOL bRead = VARIANT_FALSE;
m_Source->get_IsReadOnly(&bRead);
if(bRead==VARIANT_TRUE)
this->EnableWindow(FALSE);
else
this->EnableWindow(TRUE);
if (m_vt != VT_BSTR && m_vt != VT_R8) {
// Upper limit, Lower limit
VARIANT low, high;
VariantInit( &low );
VariantInit( &high );
m_Source->get_RangeLowerLimit( &low );
m_Source->get_RangeHigherLimit( &high );
if (m_Spin.m_hWnd)
m_Spin.SetRange( low.lVal, high.lVal );
}
}
catch (_com_error &e) {
_CONTROLLER_ERRORMSG(e);
return FALSE;
}
return TRUE;
}
//==============================================================================================
// FUNCTION : ValueChanged
// ABSTRACT : Updates the edit box when the value of the underlying MIP parameter changes
// PARAMS : None
// RETURN : TRUE
// NOTE : The Apply button is disabled during this event
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
BOOL CControllerEdit::ValueChanged()
{
try {
m_Source.ResetValueChangedFlag();
if(m_Source.m_pProperty!=NULL){
CComBSTR bstrDisplay;
HRESULT hr = m_Source.m_pProperty->get_DisplayString(&bstrDisplay);
if (FAILED(hr))
_com_raise_error(hr);
if (!bstrDisplay.Length()) {
CComVariant var;
hr = m_Source.m_pProperty->get_RawValue(&var);
if (FAILED(hr)) {
if (hr == DISP_E_EXCEPTION)
_com_raise_error(var.lVal);
else
_com_raise_error(hr);
}
}
//Update data
if (!m_bDirty) {
CString strValue(bstrDisplay);
m_bAutoChange = TRUE;
SetWindowText(strValue);
m_bAutoChange = FALSE;
}
}
}
catch (_com_error &e) {
_CONTROLLER_ERRORMSG_LOG(e);
return FALSE;
}
return TRUE;
}
//==============================================================================================
// FUNCTION : OnDestroy
// ABSTRACT :
// PARAMS : None
// RETURN : void
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
void CControllerEdit::OnDestroy()
{
CEdit::OnDestroy();
Disconnect();
if (m_Spin.m_hWnd)
m_Spin.DestroyWindow();
}
//==============================================================================================
// FUNCTION : CreateSpinCtrl
// ABSTRACT : create a spin control
// PARAMS : None
// RETURN : TRUE
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
BOOL CControllerEdit::CreateSpinCtrl()
{
if (m_Spin.m_hWnd)
return TRUE;
BOOL res = m_Spin.Create(UDS_SETBUDDYINT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_ALIGNRIGHT,
CRect(0, 0, 0, 0), GetParent(), GetDlgCtrlID() + 100);
if (!res) return FALSE;
m_Spin.SetBuddy(this);
m_Spin.ShowWindow(SW_SHOW);
return TRUE;
}
//==============================================================================================
// FUNCTION : OnChange
// ABSTRACT :
// PARAMS : None
// RETURN : void
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
void CControllerEdit::OnChange()
{
if (!m_bAutoChange) {
m_bDirty = TRUE;
((CPropertyPage*)GetParent())->SetModified(TRUE);
}
}
//==============================================================================================
// FUNCTION : PutValue
// ABSTRACT : Apply the current settings to the camera
// PARAMS : None
// RETURN : TRUE
// NOTE :
// HISTORY : 2005.11.04 Nikon Corp. - Created
//==============================================================================================
BOOL CControllerEdit::PutValue()
{
CString str;
if (!m_bDirty) return TRUE;
GetWindowText(str);
try {
if(m_Source.m_pProperty!=NULL){
CComBSTR bstrDisplay;
bstrDisplay = str;
HRESULT hr = m_Source.m_pProperty->put_DisplayString(bstrDisplay);
if (FAILED(hr))
_com_raise_error(hr);
m_bDirty = FALSE;
return TRUE;
}
return FALSE;
}
catch (_com_error &e) {
_CONTROLLER_ERRORMSG(e);
return FALSE;
}
}
|
0a940eb16efdcb38aac781e02211aeb60fdf8f52
|
a7899e791b99948bbda5ce281e278f573fab8f3e
|
/SineWave/source.cpp
|
e762be473b23d8c304e9bfe8c380f461bfa1e4e3
|
[] |
no_license
|
PratikBingewar/Win32-SDK-2020---Astromedicomp
|
5e19febc2b1278734adde47be667846f983c2932
|
560a0fc4a697f971a9ca89b7e1f5a6867f093606
|
refs/heads/master
| 2022-12-06T02:45:22.689279
| 2020-09-01T11:36:07
| 2020-09-01T11:36:07
| 291,980,236
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,930
|
cpp
|
source.cpp
|
#include<windows.h>
#include<math.h>
#define NUM 1000
#define TWOPI (2 * 3.14159)
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int iCmdShow) {
WNDCLASSEX wndClass;
MSG msg;
TCHAR szAppName[] = TEXT("SineWaveProgram");
HWND hwnd;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor = LoadCursor(NULL, IDC_HAND);
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hInstance = hInstance;
wndClass.lpfnWndProc = WndProc;
wndClass.lpszClassName = szAppName;
wndClass.lpszMenuName = NULL;
wndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&wndClass);
hwnd = CreateWindow(
szAppName,
TEXT("SineWave Program CHARLES-PETZOLD"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return ((int)msg.wParam);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
static int cxClient, cyClient;
HDC hdc;
int i;
PAINTSTRUCT ps;
POINT apt[NUM];
switch (iMsg) {
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_CREATE:
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
MoveToEx(hdc, 0, cyClient / 2, NULL);
LineTo(hdc, cxClient, cyClient / 2);
for (i = 0; i < NUM; i++) {
apt[i].x = i * cxClient / NUM;
apt[i].y = (int)(cyClient / 2 * (1 -sin(TWOPI * i / NUM)));
}
Polyline(hdc, apt, NUM);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return (DefWindowProc(hwnd, iMsg, wParam, lParam));
}
|
1a60bfb31d4a206b20b62d1b866416af5172ee78
|
9e038c38e3baa58e65368946920c0c1c4a9f8380
|
/gym/pushup/mirror-tree.cpp
|
0247f7d088a1c4e48544e15ad290bb243cdb4704
|
[] |
no_license
|
switchkiller/sandbox
|
2707bafd7cae2e069b4602432738bb6c381a0c0f
|
0cf8c99f13c35377c2bcdab0420574febb88f693
|
refs/heads/master
| 2021-01-25T15:52:18.030476
| 2020-04-14T03:04:21
| 2020-04-14T03:04:21
| 38,898,148
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 640
|
cpp
|
mirror-tree.cpp
|
//function Template for C++
/* A binary tree node has data, pointer to left child
and a pointer to right child /
struct Node
{
int data;
Node* left;
Node* right;
}; */
/* Should convert tree to its mirror */
void rotate(Node *node){
if (node->left != NULL && node->right != NULL){
Node *temp = node->left;
node->left = node->right;
node->right = temp;
}
}
void mirrorUtil(Node *node){
if (node == NULL) return;
rotate(node);
mirrorUtil(node->left);
mirrorUtil(node->right);
}
void mirror(Node* node)
{
// Your Code Here
mirrorUtil(node);
//inorder(node);
}
|
8eece8ef55cbb30039e8135d40e1a981db00f572
|
f14471ad6993834266bf3328b4126d921c959c3b
|
/kokkos-kernels/src/batched/dense/impl/KokkosBatched_Vector_SIMD_Arith.hpp
|
90bf2e4dc619dc725f921a1b9bd79aea17e4e022
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
sandialabs/compadre
|
07b06f095ed0f171aba66839e8e01e619b7403ea
|
bf4cd8db7104a2102ee9af5fbc8962f43c6df876
|
refs/heads/master
| 2023-08-31T11:47:01.409672
| 2023-05-03T15:13:07
| 2023-05-03T15:13:07
| 165,897,408
| 8
| 1
|
NOASSERTION
| 2023-05-03T15:13:09
| 2019-01-15T17:52:40
|
C++
|
UTF-8
|
C++
| false
| false
| 28,337
|
hpp
|
KokkosBatched_Vector_SIMD_Arith.hpp
|
#ifndef __KOKKOSBATCHED_VECTOR_SIMD_ARITH_HPP__
#define __KOKKOSBATCHED_VECTOR_SIMD_ARITH_HPP__
/// \author Kyungjoo Kim (kyukim@sandia.gov)
#include "Kokkos_Complex.hpp"
#include "KokkosKernels_Macros.hpp"
namespace KokkosBatched {
#define KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l) Vector<SIMD<T>, l>
#define KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(T, l) \
Vector<SIMD<T>, l> &
/// simd, simd
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 8) operator+(
const Vector<SIMD<double>, 8> &a, const Vector<SIMD<double>, 8> &b) {
return _mm512_add_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator+(const Vector<SIMD<Kokkos::complex<double> >, 4> &a,
const Vector<SIMD<Kokkos::complex<double> >, 4> &b) {
return _mm512_add_pd(a, b);
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator+(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
return _mm256_add_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 2)
operator+(const Vector<SIMD<Kokkos::complex<double> >, 2> &a,
const Vector<SIMD<Kokkos::complex<double> >, 2> &b) {
return _mm256_add_pd(a, b);
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator+(const Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
Vector<SIMD<T>, l> r_val;
if (std::is_fundamental<T>::value) {
KOKKOSKERNELS_FORCE_SIMD
for (int i = 0; i < l; ++i) r_val[i] = a[i] + b[i];
} else {
for (int i = 0; i < l; ++i) r_val[i] = a[i] + b[i];
}
return r_val;
}
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 2) operator+(
const Vector<SIMD<float>, 2> &a, const Vector<SIMD<float>, 2> &b) {
float2 r_val;
r_val.x = a.float2().x + b.float2().x;
r_val.y = a.float2().y + b.float2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 2) operator+(
const Vector<SIMD<double>, 2> &a, const Vector<SIMD<double>, 2> &b) {
double2 r_val;
r_val.x = a.double2().x + b.double2().x;
r_val.y = a.double2().y + b.double2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 4) operator+(
const Vector<SIMD<float>, 4> &a, const Vector<SIMD<float>, 4> &b) {
float4 r_val;
r_val.x = a.float4().x + b.float4().x;
r_val.y = a.float4().y + b.float4().y;
r_val.z = a.float4().z + b.float4().z;
r_val.w = a.float4().w + b.float4().w;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator+(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
double4 r_val;
r_val.x = a.double4().x + b.double4().x;
r_val.y = a.double4().y + b.double4().y;
r_val.z = a.double4().z + b.double4().z;
r_val.w = a.double4().w + b.double4().w;
return r_val;
}
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator+=(Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
a = a + b;
return a;
}
/// simd, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator+(const Vector<SIMD<T>, l> &a, const T b) {
return a + Vector<SIMD<T>, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator+(const T a, const Vector<SIMD<T>, l> &b) {
return Vector<SIMD<T>, l>(a) + b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator+=(Vector<SIMD<T>, l> &a, const T b) {
a = a + b;
return a;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator++(Vector<SIMD<T>, l> &a, int) {
Vector<SIMD<T>, l> a0 = a;
a = a + typename Kokkos::Details::ArithTraits<T>::mag_type(1);
return a0;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator++(Vector<SIMD<T>, l> &a) {
a = a + typename Kokkos::Details::ArithTraits<T>::mag_type(1);
return a;
}
/// simd complex, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator+(const Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
return a + Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator+(const T a, const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) + b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator+=(Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
a = a + b;
return a;
}
/// simd complex, complex
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator+(const Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
return a + Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator+(const Kokkos::complex<T> a,
const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) + b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator+=(Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
a = a + b;
return a;
}
/// ---------------------------------------------------------------------------------------------------
/// simd, simd
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 8) operator-(
const Vector<SIMD<double>, 8> &a, const Vector<SIMD<double>, 8> &b) {
return _mm512_sub_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator-(const Vector<SIMD<Kokkos::complex<double> >, 4> &a,
const Vector<SIMD<Kokkos::complex<double> >, 4> &b) {
return _mm512_sub_pd(a, b);
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator-(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
return _mm256_sub_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 2)
operator-(const Vector<SIMD<Kokkos::complex<double> >, 2> &a,
const Vector<SIMD<Kokkos::complex<double> >, 2> &b) {
return _mm256_sub_pd(a, b);
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator-(const Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
Vector<SIMD<T>, l> r_val;
if (std::is_fundamental<T>::value) {
KOKKOSKERNELS_FORCE_SIMD
for (int i = 0; i < l; ++i) r_val[i] = a[i] - b[i];
} else {
for (int i = 0; i < l; ++i) r_val[i] = a[i] - b[i];
}
return r_val;
}
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 2) operator-(
const Vector<SIMD<float>, 2> &a, const Vector<SIMD<float>, 2> &b) {
float2 r_val;
r_val.x = a.float2().x - b.float2().x;
r_val.y = a.float2().y - b.float2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 2) operator-(
const Vector<SIMD<double>, 2> &a, const Vector<SIMD<double>, 2> &b) {
double2 r_val;
r_val.x = a.double2().x - b.double2().x;
r_val.y = a.double2().y - b.double2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 4) operator-(
const Vector<SIMD<float>, 4> &a, const Vector<SIMD<float>, 4> &b) {
float4 r_val;
r_val.x = a.float4().x - b.float4().x;
r_val.y = a.float4().y - b.float4().y;
r_val.z = a.float4().z - b.float4().z;
r_val.w = a.float4().w - b.float4().w;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator-(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
double4 r_val;
r_val.x = a.double4().x - b.double4().x;
r_val.y = a.double4().y - b.double4().y;
r_val.z = a.double4().z - b.double4().z;
r_val.w = a.double4().w - b.double4().w;
return r_val;
}
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator-(const Vector<SIMD<T>, l> &a) {
Vector<SIMD<T>, l> r_val;
if (std::is_fundamental<T>::value) {
KOKKOSKERNELS_FORCE_SIMD
for (int i = 0; i < l; ++i) r_val[i] = -a[i];
} else {
for (int i = 0; i < l; ++i) r_val[i] = -a[i];
}
return r_val;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator-=(Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
a = a - b;
return a;
}
/// simd, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator-(const Vector<SIMD<T>, l> &a, const T b) {
return a - Vector<SIMD<T>, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator-(const T a, const Vector<SIMD<T>, l> &b) {
return Vector<SIMD<T>, l>(a) - b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator-=(Vector<SIMD<T>, l> &a, const T b) {
a = a - b;
return a;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator--(Vector<SIMD<T>, l> &a, int) {
Vector<SIMD<T>, l> a0 = a;
a = a - typename Kokkos::Details::ArithTraits<T>::mag_type(1);
return a0;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator--(Vector<SIMD<T>, l> &a) {
a = a - typename Kokkos::Details::ArithTraits<T>::mag_type(1);
return a;
}
/// simd complex, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator-(const Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
return a - Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator-(const T a, const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) - b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator-=(Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
a = a - b;
return a;
}
/// simd complex, complex
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator-(const Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
return a - Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator-(const Kokkos::complex<T> a,
const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) - b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator-=(Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
a = a - b;
return a;
}
/// ---------------------------------------------------------------------------------------------------
/// simd, simd
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 8) operator*(
const Vector<SIMD<double>, 8> &a, const Vector<SIMD<double>, 8> &b) {
return _mm512_mul_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4) operator
*(const Vector<SIMD<Kokkos::complex<double> >, 4> &a,
const Vector<SIMD<Kokkos::complex<double> >, 4> &b) {
const __m512d as = _mm512_permute_pd(a, 0x55),
br = _mm512_permute_pd(b, 0x00),
bi = _mm512_permute_pd(b, 0xff);
#if defined(__FMA__)
// latency 7, throughput 0.5
return _mm512_fmaddsub_pd(a, br, _mm512_mul_pd(as, bi));
#else
return _mm512_add_pd(
_mm512_mul_pd(a, br),
_mm512_castsi512_pd(_mm512_xor_si512(
_mm512_castpd_si512(_mm512_mul_pd(as, bi)),
_mm512_castpd_si512(_mm512_mask_broadcast_f64x4(
_mm512_setzero_pd(), 0x55, _mm256_set1_pd(-0.0))))));
// const __mm512d cc = _mm512_mul_pd(as, bi);
// return _mm512_mask_sub_pd(_mm512_mask_add_pd(_mm512_mul_pd(a, br), 0x55,
// cc), 0xaa, cc);
#endif
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator*(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
return _mm256_mul_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static Vector<SIMD<Kokkos::complex<double> >, 2> operator*(
const Vector<SIMD<Kokkos::complex<double> >, 2> &a,
const Vector<SIMD<Kokkos::complex<double> >, 2> &b) {
const __m256d as = _mm256_permute_pd(a, 0x5), br = _mm256_permute_pd(b, 0x0),
bi = _mm256_permute_pd(b, 0xf);
#if defined(__FMA__)
return _mm256_fmaddsub_pd(a, br, _mm256_mul_pd(as, bi));
#else
return _mm256_add_pd(_mm256_mul_pd(a, br),
_mm256_xor_pd(_mm256_mul_pd(as, bi),
_mm256_set_pd(0.0, -0.0, 0.0, -0.0)));
#endif
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator*(const Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
Vector<SIMD<T>, l> r_val;
if (std::is_fundamental<T>::value) {
KOKKOSKERNELS_FORCE_SIMD
for (int i = 0; i < l; ++i) r_val[i] = a[i] * b[i];
} else {
for (int i = 0; i < l; ++i) r_val[i] = a[i] * b[i];
}
return r_val;
}
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 2) operator*(
const Vector<SIMD<float>, 2> &a, const Vector<SIMD<float>, 2> &b) {
float2 r_val;
r_val.x = a.float2().x * b.float2().x;
r_val.y = a.float2().y * b.float2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 2) operator*(
const Vector<SIMD<double>, 2> &a, const Vector<SIMD<double>, 2> &b) {
double2 r_val;
r_val.x = a.double2().x * b.double2().x;
r_val.y = a.double2().y * b.double2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 4) operator*(
const Vector<SIMD<float>, 4> &a, const Vector<SIMD<float>, 4> &b) {
float4 r_val;
r_val.x = a.float4().x * b.float4().x;
r_val.y = a.float4().y * b.float4().y;
r_val.z = a.float4().z * b.float4().z;
r_val.w = a.float4().w * b.float4().w;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator*(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
double4 r_val;
r_val.x = a.double4().x * b.double4().x;
r_val.y = a.double4().y * b.double4().y;
r_val.z = a.double4().z * b.double4().z;
r_val.w = a.double4().w * b.double4().w;
return r_val;
}
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator*=(Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
a = a * b;
return a;
}
/// simd, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator*(const Vector<SIMD<T>, l> &a, const T b) {
return a * Vector<SIMD<T>, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator*(const T a, const Vector<SIMD<T>, l> &b) {
return Vector<SIMD<T>, l>(a) * b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator*=(Vector<SIMD<T>, l> &a, const T b) {
a = a * b;
return a;
}
/// simd complex, real
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator*(const Vector<SIMD<Kokkos::complex<double> >, 4> &a, const double b) {
return _mm512_mul_pd(a, _mm512_set1_pd(b));
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 2) operator
*(const Vector<SIMD<Kokkos::complex<double> >, 2> &a, const double b) {
return _mm256_mul_pd(a, _mm256_set1_pd(b));
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator*(const Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
return a * Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator*(const double a, const Vector<SIMD<Kokkos::complex<double> >, 4> &b) {
return _mm512_mul_pd(_mm512_set1_pd(a), b);
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 2) operator
*(const double a, const Vector<SIMD<Kokkos::complex<double> >, 2> &b) {
return _mm256_mul_pd(_mm256_set1_pd(a), b);
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator*(const T a, const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) * b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator*=(Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
a = a * b;
return a;
}
/// simd complex, complex
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator*(const Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
return a * Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator*(const Kokkos::complex<T> a,
const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) * b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator*=(Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
a = a * b;
return a;
}
/// ---------------------------------------------------------------------------------------------------
/// simd, simd
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 8) operator/(
const Vector<SIMD<double>, 8> &a, const Vector<SIMD<double>, 8> &b) {
return _mm512_div_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator/(const Vector<SIMD<Kokkos::complex<double> >, 4> &a,
const Vector<SIMD<Kokkos::complex<double> >, 4> &b) {
const __m512d as = _mm512_permute_pd(a, 0x55),
cb = _mm512_castsi512_pd(_mm512_xor_si512(
_mm512_castpd_si512(b),
_mm512_castpd_si512(_mm512_mask_broadcast_f64x4(
_mm512_setzero_pd(), 0xAA, _mm256_set1_pd(-0.0))))),
br = _mm512_permute_pd(cb, 0x00),
bi = _mm512_permute_pd(cb, 0xff);
#if defined(__FMA__)
return _mm512_div_pd(_mm512_fmaddsub_pd(a, br, _mm512_mul_pd(as, bi)),
_mm512_fmadd_pd(br, br, _mm512_mul_pd(bi, bi)));
#else
return _mm512_div_pd(
_mm512_add_pd(
_mm512_mul_pd(a, br),
_mm512_castsi512_pd(_mm512_xor_si512(
_mm512_castpd_si512(_mm512_mul_pd(as, bi)),
_mm512_castpd_si512(_mm512_mask_broadcast_f64x4(
_mm512_setzero_pd(), 0xAA, _mm256_set1_pd(-0.0)))))),
_mm512_add_pd(_mm512_mul_pd(br, br), _mm512_mul_pd(bi, bi)));
// const __mm512d cc = _mm512_mul_pd(as, bi);
// return _mm512_div_pd(_mm512_mask_sub_pd(_mm512_mask_add_pd(_mm512_mul_pd(a,
// br), 0x55, cc), 0xaa, cc),
// _mm512_add_pd(_mm512_mul_pd(br, br), _mm512_mul_pd(bi,
// bi)));
#endif
}
#endif
#endif
#if defined(__AVX__) || defined(__AVX2__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator/(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
return _mm256_div_pd(a, b);
}
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 2)
operator/(Vector<SIMD<Kokkos::complex<double> >, 2> const &a,
Vector<SIMD<Kokkos::complex<double> >, 2> const &b) {
const __m256d as = _mm256_permute_pd(a, 0x5),
cb = _mm256_xor_pd(b, _mm256_set_pd(-0.0, 0.0, -0.0, 0.0)),
br = _mm256_permute_pd(cb, 0x0),
bi = _mm256_permute_pd(cb, 0xf);
#if defined(__FMA__)
return _mm256_div_pd(
_mm256_fmaddsub_pd(a, br, _mm256_mul_pd(as, bi)),
_mm256_add_pd(_mm256_mul_pd(br, br), _mm256_mul_pd(bi, bi)));
#else
return _mm256_div_pd(
_mm256_add_pd(_mm256_mul_pd(a, br),
_mm256_xor_pd(_mm256_mul_pd(as, bi),
_mm256_set_pd(0.0, -0.0, 0.0, -0.0))),
_mm256_add_pd(_mm256_mul_pd(br, br), _mm256_mul_pd(bi, bi)));
#endif
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator/(const Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
Vector<SIMD<T>, l> r_val;
if (std::is_fundamental<T>::value) {
KOKKOSKERNELS_FORCE_SIMD
for (int i = 0; i < l; ++i) r_val[i] = a[i] / b[i];
} else {
for (int i = 0; i < l; ++i) r_val[i] = a[i] / b[i];
}
return r_val;
}
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 2) operator/(
const Vector<SIMD<float>, 2> &a, const Vector<SIMD<float>, 2> &b) {
float2 r_val;
r_val.x = a.float2().x / b.float2().x;
r_val.y = a.float2().y / b.float2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 2) operator/(
const Vector<SIMD<double>, 2> &a, const Vector<SIMD<double>, 2> &b) {
double2 r_val;
r_val.x = a.double2().x / b.double2().x;
r_val.y = a.double2().y / b.double2().y;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(float, 4) operator/(
const Vector<SIMD<float>, 4> &a, const Vector<SIMD<float>, 4> &b) {
float4 r_val;
r_val.x = a.float4().x / b.float4().x;
r_val.y = a.float4().y / b.float4().y;
r_val.z = a.float4().z / b.float4().z;
r_val.w = a.float4().w / b.float4().w;
return r_val;
}
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(double, 4) operator/(
const Vector<SIMD<double>, 4> &a, const Vector<SIMD<double>, 4> &b) {
double4 r_val;
r_val.x = a.double4().x / b.double4().x;
r_val.y = a.double4().y / b.double4().y;
r_val.z = a.double4().z / b.double4().z;
r_val.w = a.double4().w / b.double4().w;
return r_val;
}
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator/=(Vector<SIMD<T>, l> &a, const Vector<SIMD<T>, l> &b) {
a = a / b;
return a;
}
/// simd, real
#if defined(__KOKKOSBATCHED_ENABLE_AVX__)
#if defined(__AVX512F__)
#if !defined(KOKKOS_COMPILER_GNU)
KOKKOS_FORCEINLINE_FUNCTION
static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(Kokkos::complex<double>, 4)
operator/(const Vector<SIMD<Kokkos::complex<double> >, 4> &a, const double b) {
return _mm512_div_pd(a, _mm512_set1_pd(b));
}
#endif
#endif
#endif
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator/(const Vector<SIMD<T>, l> &a, const T b) {
return a / Vector<SIMD<T>, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator/(const T a, const Vector<SIMD<T>, l> &b) {
return Vector<SIMD<T>, l>(a) / b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator/=(Vector<SIMD<T>, l> &a, const T b) {
a = a / b;
return a;
}
/// simd complex, real
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator/(const Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
return a / Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator/(const T a, const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) / b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator/=(Vector<SIMD<Kokkos::complex<T> >, l> &a, const T b) {
a = a / b;
return a;
}
/// simd complex, complex
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator/(const Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
return a / Vector<SIMD<Kokkos::complex<T> >, l>(b);
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(
Kokkos::complex<T>, l)
operator/(const Kokkos::complex<T> a,
const Vector<SIMD<Kokkos::complex<T> >, l> &b) {
return Vector<SIMD<Kokkos::complex<T> >, l>(a) / b;
}
template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
Kokkos::complex<T>, l)
operator/=(Vector<SIMD<Kokkos::complex<T> >, l> &a,
const Kokkos::complex<T> b) {
a = a / b;
return a;
}
#undef KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE
#undef KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE
} // namespace KokkosBatched
#endif
|
e33e6710b23e963dba96f1157d33f151a977a636
|
3873700b758996625fe4249d9cfdd1a7f2866227
|
/hdu2222.cpp
|
daa4b8ec1899b96e2ac9f0145b5cb4a448de9381
|
[] |
no_license
|
termonitor/ACM
|
4d4354a0af47fbfb3a40b52a1eb38217383c9eae
|
36962a860523bd5e77903ca23c2fe27325a13e80
|
refs/heads/master
| 2020-12-24T16:16:22.925602
| 2017-04-30T11:12:06
| 2017-04-30T11:12:06
| 23,687,584
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,979
|
cpp
|
hdu2222.cpp
|
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
char str[1000000+100];
struct node
{
int count;
struct node *next[26];
struct node *fail;
void init()
{
int i;
for(i=0; i<26; i++)
next[i] = NULL;
count = 0;
fail = NULL;
}
}*root;
void insert()
{
int len, k;
node *p = root;
len = strlen(str);
for(k=0; k<len; k++)
{
int pos = str[k] - 'a';
if(p->next[pos] == NULL)
{
p->next[pos] = new node;
p->next[pos]->init();
p = p->next[pos];
}
else
p = p->next[pos];
}
p->count++;
}
void getfail()
{
int i;
node *p=root;
node *son, *temp;
queue<struct node*> que;
que.push(p);
while(!que.empty())
{
temp = que.front();
que.pop();
for(i=0; i<26; i++)
{
son = temp->next[i];
if(son != NULL)
{
if(temp == root)
{
son->fail = root;
}
else
{
p = temp->fail;
while(p)
{
if(p->next[i])
{
son->fail = p->next[i];
break;
}
p = p->fail;
}
if(!p) son->fail = root;
}
que.push(son);
}
}
}
}
void query()
{
int len, i, cnt=0;
len = strlen(str);
node *p, *temp;
p = root;
for(i=0; i<len; i++)
{
int pos = str[i] - 'a';
while(!p->next[pos] && p!=root)
{
p = p->fail;
}
p = p->next[pos];
if(!p)
p = root;
temp = p;
while(temp != root)
{
if(temp->count >= 0)
{
cnt += temp->count;
temp->count = -1;
}
else
break;
temp = temp->fail;
}
}
printf("%d\n", cnt);
}
int main()
{
// freopen("test.in", "r", stdin);
int cas, n;
scanf("%d", &cas);
while(cas--)
{
root = new node;
root->init();
root->fail = NULL;
scanf("%d", &n);
int i;
getchar();
for(i=0; i<n; i++)
{
gets(str);
insert();
}
getfail();
gets(str);
query();
}
return 0;
}
|
83fea6b0612cb402a972259301cdcd732dc4c834
|
a64a8d76aac2c9a9cba574f7361f055472488557
|
/Semester 1/Praktikum/Pertemuan 6 Function/Exe1.cpp
|
1fa7401fe2e94fadeb76be3a8350b4b535950899
|
[] |
no_license
|
danielsitepu36/Cpp-as-the-first
|
10ea28beff8557afecea15e4db5d677ac08e4ee2
|
d94b8b7cfe8c3bdb3fbd55fb3cea11ee72534bd6
|
refs/heads/master
| 2020-07-06T12:49:53.446105
| 2019-08-28T12:29:16
| 2019-08-28T12:29:16
| 203,023,073
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 775
|
cpp
|
Exe1.cpp
|
#include<iostream>
using namespace std;
double triangle(double a, double t){
return (a*t)/2;
}
double circle(double r){
return r*r*3.14;
}
double square(double r){
return r*r;
}
int main(){
int x,a,t,r,L;
cout<<"CALCULATE AREA"<<endl;
cout<<"Menu :"<<endl;
cout<<"1) Triangle"<<endl;
cout<<"2) Circle"<<endl;
cout<<"3) Square"<<endl;
cout<<"Pilihan anda = ";\
cin>>x;
switch(x){
case 1:
cout<<"Masukkan alas = ";
cin>>a;
cout<<"Masukkan tinggi = ";
cin>>t;
L=triangle(a,t);
cout<<"Luas = "<<L;
break;
case 2:
cout<<"Masukkan panjang jari-jari = ";
cin>>r;
L=circle(r);
cout<<"Luas = "<<L;
break;
case 3:
cout<<"Masukkan panjang sisi = ";
cin>>r;
L=square(r);
cout<<"Luas = "<<L;
break;
}
return 0;
}
|
096f0ef7432ca6d1bb3ca54ff3f8501bbec59bfe
|
0ca9dc2f82b7b24141ca27b391e649916073c3e3
|
/Homework/Hackerrank/Pointer Challenge/main.cpp
|
690bbf3f4245ba0eb939b54418e93fa7c73e42cf
|
[] |
no_license
|
Jadiepie-658/CSC17A-47827
|
627319b6e87c60268057665742140f6155f4acd6
|
7a15274b2c119f6c228cd32d44412a5c0a5c1a4b
|
refs/heads/master
| 2020-07-23T18:07:49.709653
| 2019-10-30T04:37:24
| 2019-10-30T04:37:24
| 207,661,058
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 565
|
cpp
|
main.cpp
|
#include <stdio.h>
void update(int *a,int *b) {
// Complete this function
int val1 = *a;
int val2 = *b;
*a = val1 + val2;
if(val1 > val2) //to create an absolute value marker over b
{
*b = val1 - val2;
}//if b is greater than val it subtracts b with val
else
{//these ensure b will always come out positive
*b = val2 - val1;
}
}
int main() {
int a, b;
int *pa = &a, *pb = &b;
scanf("%d %d", &a, &b);
update(pa, pb);
printf("%d\n%d", a, b);
return 0;
}
|
42c57507c30c40a6034d108e3fb3972bbd99a139
|
39ff97eed9cbaba710bccde1f8e2f7e806a733f2
|
/wii/briickout/source/Player.cpp
|
f3aaba18629be47238eda321187a48ae56582e3d
|
[
"BSD-3-Clause"
] |
permissive
|
BHSPitMonkey/bhspitmonkey-code
|
a6070c51bb8b5fd5a1e717b4ea88c79cdc4f0a45
|
5e76784f0ff8ccd5970eb99e1a7753d02bd6623b
|
refs/heads/master
| 2020-08-23T18:44:23.763173
| 2009-10-18T23:06:16
| 2009-10-18T23:06:16
| 309,178
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,062
|
cpp
|
Player.cpp
|
/*
* Player.cpp
*
* Copyright 2009 Stephen Eisenhauer <mail@stepheneisenhauer.com>
*
* Class for Player objects.
*/
#include <wiisprite.h>
#include "Player.h"
using namespace wsp;
// Default constructor
Player::Player() {
// Player width and height
theRect.width = 64;
theRect.height = 20;
// Player's y position (never changes)
y_coord = 440;
// Player should be gray
theQuad.SetFillColor((GXColor){ 100, 100, 100, 255 });
}
// Destructor
Player::~Player() { }
// Reset the player's position and velocity
void Player::spawn() {
// Default position for a Player (centered)
x_coord = 320; // - (theRect.width/2);
// Reset Player velocity to 0
x_veloc = 0;
y_veloc = 0;
max_x_speed = 30;
}
// Moves the player left
void Player::pushLeft() {
x_veloc--;
}
// Moves the player right
void Player::pushRight() {
x_veloc++;
}
// Reposition the player
void Player::Move() {
// Bring velocity down (closer to zero) each tick.
if (x_veloc < 0) x_veloc += 0.25;
if (x_veloc > 0) x_veloc -= 0.25;
Mover::Move();
}
|
a0adb868e1adba5dbeeb59850ca5dab89a008ea0
|
656fb1a231d169f5316888b682da970d99cf4b35
|
/src/Alternate Sort.cpp
|
214f2f1c1471b39e51541b9102ff134a598dd01c
|
[] |
no_license
|
ayush-artist07/CipherSchools_Assignment
|
41ef053da6c0a92dc347dde9e831523c8329c23b
|
9330214bb23392e1750780b01e21cced4b02d3b1
|
refs/heads/main
| 2023-03-07T03:07:40.744489
| 2021-02-23T06:19:54
| 2021-02-23T06:19:54
| 338,588,170
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 530
|
cpp
|
Alternate Sort.cpp
|
/*
Given an array of integers, print the array in such a way that the
first element is first maximum and second element is first minimum and so on.
*/
#include<bits/stdc++.h>
using namespace std;
void alternateSort(int arr[],int n){
sort(arr,arr+n);
int i=0,j=n-1;
int flag=1;
while(i<=j){
if(flag){
cout<<arr[j]<<" ";
flag=0;
j--;
}
else{
cout<<arr[i]<<" ";
flag=1;
i++;
}
}
}
int main(){
int arr[]={1, 6, 9, 4, 3, 7, 8, 2};
alternateSort(arr,8);
}
|
31dd98398182cfc50cb564439c31f504404d7e01
|
bed3ac926beac0f4e0293303d7b2a6031ee476c9
|
/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
|
10ac23cca4b134b83429498a1b3bcb8b0465c43e
|
[
"IJG",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"SMLNJ",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"LicenseRef-scancode-free-unknown",
"Spencer-86",
"LicenseRef-scancode-llnl",
"FSFUL",
"Libpng",
"libtiff",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-hdf5",
"MIT",
"NTP",
"LicenseRef-scancode-mit-old-style",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MPL-2.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] |
permissive
|
InsightSoftwareConsortium/ITK
|
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
|
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
|
refs/heads/master
| 2023-08-31T17:21:47.754304
| 2023-08-31T00:58:51
| 2023-08-31T14:12:21
| 800,928
| 1,229
| 656
|
Apache-2.0
| 2023-09-14T17:54:00
| 2010-07-27T15:48:04
|
C++
|
UTF-8
|
C++
| false
| false
| 53,685
|
cxx
|
gdcmJPEG2000Codec.cxx
|
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html 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 "gdcmJPEG2000Codec.h"
#include "gdcmTransferSyntax.h"
#include "gdcmTrace.h"
#include "gdcmDataElement.h"
#include "gdcmSequenceOfFragments.h"
#include "gdcmSwapper.h"
#include <cstring>
#include <cstdio> // snprintf
#include <numeric>
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define snprintf _snprintf
#endif
#include "gdcm_openjpeg.h"
namespace gdcm
{
/* Part 1 Table A.2 List of markers and marker segments */
using MarkerType = enum {
FF30 = 0xFF30,
FF31 = 0xFF31,
FF32 = 0xFF32,
FF33 = 0xFF33,
FF34 = 0xFF34,
FF35 = 0xFF35,
FF36 = 0xFF36,
FF37 = 0xFF37,
FF38 = 0xFF38,
FF39 = 0xFF39,
FF3A = 0xFF3A,
FF3B = 0xFF3B,
FF3C = 0xFF3C,
FF3D = 0xFF3D,
FF3E = 0xFF3E,
FF3F = 0xFF3F,
SOC = 0xFF4F,
CAP = 0xFF50,
SIZ = 0xFF51,
COD = 0xFF52,
COC = 0xFF53,
TLM = 0xFF55,
PLM = 0XFF57,
PLT = 0XFF58,
QCD = 0xFF5C,
QCC = 0xFF5D,
RGN = 0xFF5E,
POC = 0xFF5F,
PPM = 0XFF60,
PPT = 0XFF61,
CRG = 0xFF63,
COM = 0xFF64,
SOT = 0xFF90,
SOP = 0xFF91,
EPH = 0XFF92,
SOD = 0xFF93,
EOC = 0XFFD9 /* EOI in old jpeg */
};
using OtherType = enum {
JP = 0x6a502020,
FTYP = 0x66747970,
JP2H = 0x6a703268,
JP2C = 0x6a703263,
JP2 = 0x6a703220,
IHDR = 0x69686472,
COLR = 0x636f6c72,
XML = 0x786d6c20,
CDEF = 0x63646566,
CMAP = 0x636D6170,
PCLR = 0x70636c72,
RES = 0x72657320
};
static inline bool hasnolength( uint_fast16_t marker )
{
switch( marker )
{
case FF30:
case FF31:
case FF32:
case FF33:
case FF34:
case FF35:
case FF36:
case FF37:
case FF38:
case FF39:
case FF3A:
case FF3B:
case FF3C:
case FF3D:
case FF3E:
case FF3F:
case SOC:
case SOD:
case EOC:
case EPH:
return true;
}
return false;
}
static inline bool read16(const char ** input, size_t * len, uint16_t * ret)
{
if( *len >= 2 )
{
union { uint16_t v; char bytes[2]; } u;
memcpy(u.bytes, *input, 2);
*ret = SwapperDoOp::Swap(u.v);
*input += 2; *len -= 2;
return true;
}
return false;
}
static inline bool read32(const char ** input, size_t * len, uint32_t * ret)
{
if( *len >= 4 )
{
union { uint32_t v; char bytes[4]; } u;
memcpy(u.bytes, *input, 4);
*ret = SwapperDoOp::Swap(u.v);
*input += 4; *len -= 4;
return true;
}
return false;
}
static inline bool read64(const char ** input, size_t * len, uint64_t * ret)
{
if( *len >= 8 )
{
union { uint64_t v; char bytes[8]; } u;
memcpy(u.bytes, *input, 8);
*ret = SwapperDoOp::Swap(u.v);
*input += 8; *len -= 8;
return true;
}
return false;
}
static bool parsej2k_imp( const char * const stream, const size_t file_size, bool * lossless, bool * mct )
{
uint16_t marker;
size_t lenmarker;
const char * cur = stream;
size_t cur_size = file_size;
*lossless = false; // default init
while( read16(&cur, &cur_size, &marker) )
{
if ( !hasnolength( marker ) )
{
uint16_t l;
bool r = read16( &cur, &cur_size, &l );
if( !r || l < 2 )
break;
lenmarker = (size_t)l - 2;
if( marker == COD )
{
const uint8_t MCTransformation = *(cur+4);
if( MCTransformation == 0x0 ) *mct = false;
else if( MCTransformation == 0x1 ) *mct = true;
else return false;
const uint8_t Transformation = *(cur+9);
if( Transformation == 0x0 ) { *lossless = false; return true; }
else if( Transformation == 0x1 ) *lossless = true;
else return false;
}
cur += lenmarker; cur_size -= lenmarker;
}
else if( marker == SOD )
return true;
}
return false;
}
static bool parsejp2_imp( const char * const stream, const size_t file_size, bool * lossless, bool * mct )
{
uint32_t marker;
uint64_t len64; /* ref */
uint32_t len32; /* local 32bits op */
const char * cur = stream;
size_t cur_size = file_size;
while( read32(&cur, &cur_size, &len32) )
{
bool b0 = read32(&cur, &cur_size, &marker);
if( !b0 ) break;
len64 = len32;
if( len32 == 1 ) /* 64bits ? */
{
bool b = read64(&cur, &cur_size, &len64);
assert( b ); (void)b;
len64 -= 8;
}
if( marker == JP2C )
{
const size_t start = cur - stream;
if( !len64 )
{
len64 = (size_t)(file_size - start + 8);
}
assert( len64 >= 8 );
return parsej2k_imp( cur, (size_t)(len64 - 8), lossless, mct );
}
const size_t lenmarker = (size_t)(len64 - 8);
cur += lenmarker;
}
return false;
}
/**
sample error callback expecting a FILE* client object
*/
void error_callback(const char *msg, void *) {
(void)msg;
gdcmErrorMacro( "Error in gdcmopenjpeg" << msg );
}
/**
sample warning callback expecting a FILE* client object
*/
void warning_callback(const char *msg, void *) {
(void)msg;
gdcmWarningMacro( "Warning in gdcmopenjpeg" << msg );
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char *msg, void *) {
(void)msg;
gdcmDebugMacro( "Info in gdcmopenjpeg" << msg );
}
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define PXM_DFMT 10
#define PGX_DFMT 11
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
#define PNG_DFMT 17
#define CODEC_JP2 OPJ_CODEC_JP2
#define CODEC_J2K OPJ_CODEC_J2K
#define CLRSPC_GRAY OPJ_CLRSPC_GRAY
#define CLRSPC_SRGB OPJ_CLRSPC_SRGB
struct myfile
{
char *mem;
char *cur;
size_t len;
};
void gdcm_error_callback(const char* msg, void* )
{
fprintf( stderr, "%s", msg );
}
OPJ_SIZE_T opj_read_from_memory(void * p_buffer, OPJ_SIZE_T p_nb_bytes, myfile* p_file)
{
//OPJ_UINT32 l_nb_read = fread(p_buffer,1,p_nb_bytes,p_file);
OPJ_SIZE_T l_nb_read;
if( p_file->cur + p_nb_bytes <= p_file->mem + p_file->len )
{
l_nb_read = 1*p_nb_bytes;
}
else
{
l_nb_read = (OPJ_SIZE_T)(p_file->mem + p_file->len - p_file->cur);
assert( l_nb_read < p_nb_bytes );
}
memcpy(p_buffer,p_file->cur,l_nb_read);
p_file->cur += l_nb_read;
assert( p_file->cur <= p_file->mem + p_file->len );
//std::cout << "l_nb_read: " << l_nb_read << std::endl;
return l_nb_read ? l_nb_read : ((OPJ_SIZE_T)-1);
}
OPJ_SIZE_T opj_write_from_memory (void * p_buffer, OPJ_SIZE_T p_nb_bytes, myfile* p_file)
{
//return fwrite(p_buffer,1,p_nb_bytes,p_file);
OPJ_SIZE_T l_nb_write;
//if( p_file->cur + p_nb_bytes < p_file->mem + p_file->len )
// {
l_nb_write = 1*p_nb_bytes;
// }
//else
// {
// l_nb_write = p_file->mem + p_file->len - p_file->cur;
// assert( l_nb_write < p_nb_bytes );
// }
memcpy(p_file->cur,p_buffer,l_nb_write);
p_file->cur += l_nb_write;
p_file->len += l_nb_write;
//assert( p_file->cur < p_file->mem + p_file->len );
return l_nb_write;
//return p_nb_bytes;
}
OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T p_nb_bytes, myfile * p_file)
{
//if (fseek(p_user_data,p_nb_bytes,SEEK_CUR))
// {
// return -1;
// }
if( p_file->cur + p_nb_bytes <= p_file->mem + p_file->len )
{
p_file->cur += p_nb_bytes;
return p_nb_bytes;
}
p_file->cur = p_file->mem + p_file->len;
return -1;
}
OPJ_BOOL opj_seek_from_memory (OPJ_OFF_T p_nb_bytes, myfile * p_file)
{
//if (fseek(p_user_data,p_nb_bytes,SEEK_SET))
// {
// return false;
// }
//return true;
assert( p_nb_bytes >= 0 );
if( (size_t)p_nb_bytes <= p_file->len )
{
p_file->cur = p_file->mem + p_nb_bytes;
return OPJ_TRUE;
}
p_file->cur = p_file->mem + p_file->len;
return OPJ_FALSE;
}
opj_stream_t* OPJ_CALLCONV opj_stream_create_memory_stream (myfile* p_mem,OPJ_SIZE_T p_size,bool p_is_read_stream)
{
opj_stream_t* l_stream = nullptr;
if
(! p_mem)
{
return nullptr;
}
l_stream = opj_stream_create(p_size,p_is_read_stream);
if
(! l_stream)
{
return nullptr;
}
opj_stream_set_user_data(l_stream,p_mem,nullptr);
opj_stream_set_read_function(l_stream,(opj_stream_read_fn) opj_read_from_memory);
opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_memory);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_memory);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_memory);
opj_stream_set_user_data_length(l_stream, p_mem->len /* p_size*/); /* important to avoid an assert() */
return l_stream;
}
/*
* Divide an integer by a power of 2 and round upwards.
*
* a divided by 2^b
*/
inline int int_ceildivpow2(int a, int b) {
return (a + (1 << b) - 1) >> b;
}
class JPEG2000Internals
{
public:
JPEG2000Internals()
{
memset(&coder_param, 0, sizeof(coder_param));
opj_set_default_encoder_parameters(&coder_param);
}
opj_cparameters coder_param;
int nNumberOfThreadsForDecompression{ -1 };
};
void JPEG2000Codec::SetRate(unsigned int idx, double rate)
{
Internals->coder_param.tcp_rates[idx] = (float)rate;
if( Internals->coder_param.tcp_numlayers <= (int)idx )
{
Internals->coder_param.tcp_numlayers = idx + 1;
}
Internals->coder_param.cp_disto_alloc = 1;
}
double JPEG2000Codec::GetRate(unsigned int idx ) const
{
return (double)Internals->coder_param.tcp_rates[idx];
}
void JPEG2000Codec::SetQuality(unsigned int idx, double q)
{
Internals->coder_param.tcp_distoratio[idx] = (float)q;
if( Internals->coder_param.tcp_numlayers <= (int)idx )
{
Internals->coder_param.tcp_numlayers = idx + 1;
}
Internals->coder_param.cp_fixed_quality = 1;
}
double JPEG2000Codec::GetQuality(unsigned int idx) const
{
return (double)Internals->coder_param.tcp_distoratio[idx];
}
void JPEG2000Codec::SetTileSize(unsigned int tx, unsigned int ty)
{
Internals->coder_param.cp_tdx = tx;
Internals->coder_param.cp_tdy = ty;
Internals->coder_param.tile_size_on = true;
}
void JPEG2000Codec::SetNumberOfResolutions(unsigned int nres)
{
Internals->coder_param.numresolution = nres;
}
void JPEG2000Codec::SetNumberOfThreadsForDecompression( int nThreads)
{
#if ((OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR >= 3) || (OPJ_VERSION_MAJOR > 2))
if( nThreads < 0 )
{
const int x = opj_get_num_cpus();
Internals->nNumberOfThreadsForDecompression = x == 1 ? 0 : x;
}
else
{
Internals->nNumberOfThreadsForDecompression = nThreads;
}
#else
(void)nThreads;
Internals->nNumberOfThreadsForDecompression = 0;
#endif
}
void JPEG2000Codec::SetReversible(bool res)
{
LossyFlag = !res;
Internals->coder_param.irreversible = !res;
}
void JPEG2000Codec::SetMCT(unsigned int mct)
{
// Set the Multiple Component Transformation value (COD -> SGcod)
// 0 for none, 1 to apply to components 0, 1, 2
Internals->coder_param.tcp_mct = mct;
}
JPEG2000Codec::JPEG2000Codec()
{
Internals = new JPEG2000Internals;
SetNumberOfThreadsForDecompression( -1 );
}
JPEG2000Codec::~JPEG2000Codec()
{
delete Internals;
}
bool JPEG2000Codec::CanDecode(TransferSyntax const &ts) const
{
return ts == TransferSyntax::JPEG2000Lossless
|| ts == TransferSyntax::JPEG2000
|| ts == TransferSyntax::JPEG2000Part2Lossless
|| ts == TransferSyntax::JPEG2000Part2;
}
bool JPEG2000Codec::CanCode(TransferSyntax const &ts) const
{
return ts == TransferSyntax::JPEG2000Lossless
|| ts == TransferSyntax::JPEG2000
|| ts == TransferSyntax::JPEG2000Part2Lossless
|| ts == TransferSyntax::JPEG2000Part2;
}
/*
A.4.4 JPEG 2000 image compression
If the object allows multi-frame images in the pixel data field, then for these JPEG 2000 Part 1 Transfer
Syntaxes, each frame shall be encoded separately. Each fragment shall contain encoded data from a
single frame.
Note: That is, the processes defined in ISO/IEC 15444-1 shall be applied on a per-frame basis. The proposal
for encapsulation of multiple frames in a non-DICOM manner in so-called 'Motion-JPEG' or 'M-JPEG'
defined in 15444-3 is not used.
*/
bool JPEG2000Codec::Decode(DataElement const &in, DataElement &out)
{
if( NumberOfDimensions == 2 )
{
const SequenceOfFragments *sf = in.GetSequenceOfFragments();
const ByteValue *j2kbv = in.GetByteValue();
if( !sf && !j2kbv ) return false;
SmartPointer<SequenceOfFragments> sf_bug = new SequenceOfFragments;
if ( j2kbv )
{
gdcmWarningMacro( "Pixel Data is not encapsulated correctly. Continuing anyway" );
assert( !sf );
std::stringstream is;
size_t j2kbv_len = j2kbv->GetLength();
char *mybuffer = new char[j2kbv_len];
bool b = j2kbv->GetBuffer(mybuffer, (unsigned long)j2kbv_len);
if( b ) is.write(mybuffer, j2kbv_len);
delete[] mybuffer;
if( !b ) return false;
try {
sf_bug->Read<SwapperNoOp>(is,true);
} catch ( ... ) {
return false;
}
sf = &*sf_bug;
}
if( !sf ) return false;
std::stringstream is;
unsigned long totalLen = sf->ComputeByteLength();
char *buffer = new char[totalLen];
sf->GetBuffer(buffer, totalLen);
is.write(buffer, totalLen);
delete[] buffer;
std::stringstream os;
bool r = DecodeByStreams(is, os);
if(!r) return false;
out = in;
std::string str = os.str();
out.SetByteValue( str.data(), (uint32_t)str.size() );
//memcpy(buffer, os.str().c_str(), len);
return r;
}
else if ( NumberOfDimensions == 3 )
{
/* I cannot figure out how to use openjpeg to support multiframes
* as encoded in DICOM
* MM: Hack. If we are lucky enough the number of encapsulated fragments actually match
* the number of Z frames.
* MM: hopefully this is the standard so people are following it ...
*/
//#ifdef SUPPORT_MULTIFRAMESJ2K_ONLY
const SequenceOfFragments *sf = in.GetSequenceOfFragments();
if( !sf ) return false;
std::stringstream os;
if( sf->GetNumberOfFragments() != Dimensions[2] )
{
gdcmErrorMacro( "Not handled" );
return false;
}
for(unsigned int i = 0; i < sf->GetNumberOfFragments(); ++i)
{
std::stringstream is;
const Fragment &frag = sf->GetFragment(i);
if( frag.IsEmpty() ) return false;
const ByteValue *bv = frag.GetByteValue();
if( !bv ) return false;
size_t bv_len = bv->GetLength();
char *mybuffer = new char[bv_len];
bv->GetBuffer(mybuffer, bv->GetLength());
is.write(mybuffer, bv->GetLength());
delete[] mybuffer;
bool r = DecodeByStreams(is, os);
if(!r) return false;
assert( r == true );
}
std::string str = os.str();
assert( !str.empty() );
out.SetByteValue( str.data(), (uint32_t)str.size() );
return true;
}
// else
return false;
}
static inline bool check_comp_valid(opj_image_t *image)
{
int compno = 0;
opj_image_comp_t *comp = &image->comps[compno];
if (comp->prec > 32) // I doubt openjpeg will reach here.
return false;
bool invalid = false;
if (image->numcomps == 3)
{
opj_image_comp_t *comp1 = &image->comps[1];
opj_image_comp_t *comp2 = &image->comps[2];
if (comp->prec != comp1->prec) invalid = true;
if (comp->prec != comp2->prec) invalid = true;
if (comp->sgnd != comp1->sgnd) invalid = true;
if (comp->sgnd != comp2->sgnd) invalid = true;
if (comp->h != comp1->h) invalid = true;
if (comp->h != comp2->h) invalid = true;
if (comp->w != comp1->w) invalid = true;
if (comp->w != comp2->w) invalid = true;
}
return !invalid;
}
std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffer, size_t buf_size)
{
opj_dparameters_t parameters; /* decompression parameters */
opj_codec_t* dinfo = nullptr; /* handle to a decompressor */
opj_stream_t *cio = nullptr;
opj_image_t *image = nullptr;
unsigned char *src = (unsigned char*)dummy_buffer;
uint32_t file_length = (uint32_t)buf_size; // 32bits truncation should be ok since DICOM cannot have larger than 2Gb image
// WARNING: OpenJPEG is very picky when there is a trailing 00 at the end of the JPC
// so we need to make sure to remove it:
// See for example: DX_J2K_0Padding.dcm
// and D_CLUNIE_CT1_J2KR.dcm
// Marker 0xffd9 EOI End of Image (JPEG 2000 EOC End of codestream)
// gdcmData/D_CLUNIE_CT1_J2KR.dcm contains a trailing 0xFF which apparently is ok...
while( file_length > 0 && src[file_length-1] != 0xd9 )
{
file_length--;
}
// what if 0xd9 is never found ?
if( !( file_length > 0 && src[file_length-1] == 0xd9 ) )
{
return std::make_pair( nullptr, 0 );
}
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(¶meters);
const char jp2magic[] = "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A";
if( memcmp( src, jp2magic, sizeof(jp2magic) ) == 0 )
{
/* JPEG-2000 compressed image data ... sigh */
// gdcmData/ELSCINT1_JP2vsJ2K.dcm
// gdcmData/MAROTECH_CT_JP2Lossy.dcm
gdcmWarningMacro( "J2K start like JPEG-2000 compressed image data instead of codestream" );
parameters.decod_format = JP2_CFMT;
assert(parameters.decod_format == JP2_CFMT);
}
else
{
/* JPEG-2000 codestream */
parameters.decod_format = J2K_CFMT;
assert(parameters.decod_format == J2K_CFMT);
}
parameters.cod_format = PGX_DFMT;
assert(parameters.cod_format == PGX_DFMT);
/* get a decoder handle */
switch(parameters.decod_format)
{
case J2K_CFMT:
dinfo = opj_create_decompress(CODEC_J2K);
break;
case JP2_CFMT:
dinfo = opj_create_decompress(CODEC_JP2);
break;
default:
gdcmErrorMacro( "Impossible happen" );
return std::pair<char*,size_t>(nullptr,0);
}
#if ((OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR >= 3) || (OPJ_VERSION_MAJOR > 2))
opj_codec_set_threads(dinfo, Internals->nNumberOfThreadsForDecompression);
#endif
int reversible;
myfile mysrc;
myfile *fsrc = &mysrc;
fsrc->mem = fsrc->cur = (char*)src;
fsrc->len = file_length;
OPJ_UINT32 *s[2];
// the following hack is used for the file: DX_J2K_0Padding.dcm
// see the function j2k_read_sot in openjpeg (line: 5946)
// to deal with zero length Psot
OPJ_UINT32 fl = file_length - 100;
s[0] = &fl;
s[1] = nullptr;
opj_set_error_handler(dinfo, gdcm_error_callback, s);
cio = opj_stream_create_memory_stream(fsrc,OPJ_J2K_STREAM_CHUNK_SIZE, true);
/* setup the decoder decoding parameters using user parameters */
OPJ_BOOL bResult;
bResult = opj_setup_decoder(dinfo, ¶meters);
if( !bResult )
{
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);
gdcmErrorMacro( "opj_setup_decoder failure" );
return std::pair<char*,size_t>(nullptr,0);
}
#if 0
OPJ_INT32 l_tile_x0,l_tile_y0;
OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
#endif
bResult = opj_read_header(
cio,
dinfo,
&image);
if( !bResult )
{
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);
gdcmErrorMacro( "opj_setup_decoder failure" );
return std::pair<char*,size_t>(nullptr,0);
}
#if 0
/* Optional if you want decode the entire image */
opj_set_decode_area(dinfo, image, (OPJ_INT32)parameters.DA_x0,
(OPJ_INT32)parameters.DA_y0, (OPJ_INT32)parameters.DA_x1, (OPJ_INT32)parameters.DA_y1);
#endif
bResult = opj_decode(dinfo, cio,image);
if (!bResult )
{
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);
gdcmErrorMacro( "opj_decode failed" );
return std::pair<char*,size_t>(nullptr,0);
}
bResult = bResult && (image != nullptr);
bResult = bResult && opj_end_decompress(dinfo,cio);
if (!image || !check_comp_valid(image) )
{
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);
gdcmErrorMacro( "opj_decode failed" );
return std::pair<char*,size_t>(nullptr,0);
}
#if 0
if( image->color_space )
{
if( image->color_space == CLRSPC_GRAY )
{
assert( this->GetPhotometricInterpretation() == PhotometricInterpretation::MONOCHROME2
|| this->GetPhotometricInterpretation() == PhotometricInterpretation::MONOCHROME1
|| this->GetPhotometricInterpretation() == PhotometricInterpretation::PALETTE_COLOR );
}
else if( image->color_space == CLRSPC_SRGB )
{
assert( this->GetPhotometricInterpretation() == PhotometricInterpretation::RGB );
}
else
{
assert(0);
}
}
#endif
bool b = false;
bool lossless = false;
bool mct = false;
if( parameters.decod_format == JP2_CFMT )
b = parsejp2_imp( dummy_buffer, buf_size, &lossless, &mct);
else if( parameters.decod_format == J2K_CFMT )
b = parsej2k_imp( dummy_buffer, buf_size, &lossless, &mct);
reversible = 0;
if( b ) {
reversible = lossless;
}
LossyFlag = !reversible;
assert( image->numcomps == this->GetPixelFormat().GetSamplesPerPixel() );
assert( image->numcomps == this->GetPhotometricInterpretation().GetSamplesPerPixel() );
if( this->GetPhotometricInterpretation() == PhotometricInterpretation::RGB
|| this->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_FULL )
{
if( mct ) { gdcmWarningMacro("Invalid PhotometricInterpretation, should be YBR_RCT"); }
}
else if( this->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_RCT
|| this->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_ICT )
{
if( !mct ) { gdcmWarningMacro("Invalid PhotometricInterpretation, should be RGB"); }
}
else
{
if( mct ) { gdcmWarningMacro("MCT flag was set in SamplesPerPixel = 1 image. corrupt j2k ?"); }
}
/* close the byte stream */
opj_stream_destroy(cio);
// Copy buffer
unsigned long len = Dimensions[0]*Dimensions[1] * (PF.GetBitsAllocated() / 8) * image->numcomps;
char *raw = new char[len];
//assert( len == fsrc->len );
for (unsigned int compno = 0; compno < (unsigned int)image->numcomps; compno++)
{
opj_image_comp_t *comp = &image->comps[compno];
int w = image->comps[compno].w;
int wr = int_ceildivpow2(image->comps[compno].w, image->comps[compno].factor);
//int h = image.comps[compno].h;
int hr = int_ceildivpow2(image->comps[compno].h, image->comps[compno].factor);
//assert( wr * hr * 1 * image->numcomps * (comp->prec/8) == len );
// ELSCINT1_JP2vsJ2K.dcm
// -> prec = 12, bpp = 0, sgnd = 0
//assert( wr == Dimensions[0] );
//assert( hr == Dimensions[1] );
if( comp->sgnd != PF.GetPixelRepresentation() )
{
PF.SetPixelRepresentation( (uint16_t)comp->sgnd );
}
#ifndef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
assert( comp->prec == PF.GetBitsStored()); // D_CLUNIE_RG3_JPLY.dcm
assert( comp->prec - 1 == PF.GetHighBit());
#endif
//assert( comp->prec >= PF.GetBitsStored());
if( comp->prec != PF.GetBitsStored() )
{
if( comp->prec <= 8 )
PF.SetBitsAllocated( 8 );
else if( comp->prec <= 16 )
PF.SetBitsAllocated( 16 );
else if( comp->prec <= 32 )
PF.SetBitsAllocated( 32 );
PF.SetBitsStored( (unsigned short)comp->prec );
PF.SetHighBit( (unsigned short)(comp->prec - 1) ); // ??
}
assert( PF.IsValid() );
assert( comp->prec <= 32 );
if (comp->prec <= 8)
{
uint8_t *data8 = (uint8_t*)raw + compno;
for (int i = 0; i < wr * hr; i++)
{
int v = image->comps[compno].data[i / wr * w + i % wr];
*data8 = (uint8_t)v;
data8 += image->numcomps;
}
}
else if (comp->prec <= 16)
{
// ELSCINT1_JP2vsJ2K.dcm is a 12bits image
uint16_t *data16 = (uint16_t*)(void*)raw + compno;
for (int i = 0; i < wr * hr; i++)
{
int v = image->comps[compno].data[i / wr * w + i % wr];
*data16 = (uint16_t)v;
data16 += image->numcomps;
}
}
else
{
uint32_t *data32 = (uint32_t*)(void*)raw + compno;
for (int i = 0; i < wr * hr; i++)
{
int v = image->comps[compno].data[i / wr * w + i % wr];
*data32 = (uint32_t)v;
data32 += image->numcomps;
}
}
}
/* free remaining structures */
if (dinfo)
{
opj_destroy_codec(dinfo);
}
/* free image data structure */
opj_image_destroy(image);
return std::make_pair(raw,len);
}
bool JPEG2000Codec::DecodeByStreams(std::istream &is, std::ostream &os)
{
// FIXME: Do some stupid work:
is.seekg( 0, std::ios::end);
size_t buf_size = (size_t)is.tellg();
char *dummy_buffer = new char[buf_size];
is.seekg(0, std::ios::beg);
is.read( dummy_buffer, buf_size);
std::pair<char*,size_t> raw_len = this->DecodeByStreamsCommon(dummy_buffer, buf_size);
/* free the memory containing the code-stream */
delete[] dummy_buffer;
if( !raw_len.first || !raw_len.second ) return false;
os.write( raw_len.first, raw_len.second);
delete[] raw_len.first;
return true;
}
template<typename T>
void rawtoimage_fill2(const T *inputbuffer, int w, int h, int numcomps, opj_image_t *image, int pc, int bitsallocated, int bitsstored, int highbit, int sign)
{
uint16_t pmask = 0xffff;
pmask = (uint16_t)(pmask >> ( bitsallocated - bitsstored ));
const T *p = inputbuffer;
if( sign )
{
// smask : to check the 'sign' when BitsStored != BitsAllocated
uint16_t smask = 0x0001;
smask = (uint16_t)(
smask << ( 16 - (bitsallocated - bitsstored + 1) ));
// nmask : to propagate sign bit on negative values
int16_t nmask = (int16_t)0x8000;
nmask = (int16_t)(nmask >> ( bitsallocated - bitsstored - 1 ));
if( pc )
{
for(int compno = 0; compno < numcomps; compno++)
{
for (int i = 0; i < w * h; i++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
uint16_t c = *p;
c = (uint16_t)(c >> (bitsstored - highbit - 1));
if ( c & smask )
{
c = (uint16_t)(c | nmask);
}
else
{
c = c & pmask;
}
int16_t fix; memcpy(&fix, &c, sizeof fix);
image->comps[compno].data[i] = fix;
++p;
}
}
}
else
{
for (int i = 0; i < w * h; i++)
{
for(int compno = 0; compno < numcomps; compno++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
uint16_t c = *p;
c = (uint16_t)(c >> (bitsstored - highbit - 1));
if ( c & smask )
{
c = (uint16_t)(c | nmask);
}
else
{
c = c & pmask;
}
int16_t fix; memcpy(&fix, &c, sizeof fix);
image->comps[compno].data[i] = fix;
++p;
}
}
}
}
else
{
if( pc )
{
for(int compno = 0; compno < numcomps; compno++)
{
for (int i = 0; i < w * h; i++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
uint16_t c = *p;
c = (uint16_t)(
(c >> (bitsstored - highbit - 1)) & pmask);
image->comps[compno].data[i] = c;
++p;
}
}
}
else
{
for (int i = 0; i < w * h; i++)
{
for(int compno = 0; compno < numcomps; compno++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
uint16_t c = *p;
c = (uint16_t)(
(c >> (bitsstored - highbit - 1)) & pmask);
image->comps[compno].data[i] = c;
++p;
}
}
}
}
}
template<typename T>
void rawtoimage_fill(const T *inputbuffer, int w, int h, int numcomps, opj_image_t *image, int pc)
{
const T *p = inputbuffer;
if( pc )
{
for(int compno = 0; compno < numcomps; compno++)
{
for (int i = 0; i < w * h; i++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
image->comps[compno].data[i] = *p;
++p;
}
}
}
else
{
for (int i = 0; i < w * h; i++)
{
for(int compno = 0; compno < numcomps; compno++)
{
/* compno : 0 = GREY, (0, 1, 2) = (R, G, B) */
image->comps[compno].data[i] = *p;
++p;
}
}
}
}
opj_image_t* rawtoimage(const char *inputbuffer8, opj_cparameters_t *parameters,
size_t fragment_size, int image_width, int image_height, int sample_pixel,
int bitsallocated, int bitsstored, int highbit, int sign, int quality, int pc)
{
(void)quality;
(void)fragment_size;
int w, h;
int numcomps;
OPJ_COLOR_SPACE color_space;
opj_image_cmptparm_t cmptparm[3]; /* maximum of 3 components */
opj_image_t * image = nullptr;
const void * inputbuffer = inputbuffer8;
assert( sample_pixel == 1 || sample_pixel == 3 );
if( sample_pixel == 1 )
{
numcomps = 1;
color_space = CLRSPC_GRAY;
}
else // sample_pixel == 3
{
numcomps = 3;
color_space = CLRSPC_SRGB;
/* Does OpenJPEg support: CLRSPC_SYCC ?? */
}
if( bitsallocated % 8 != 0 )
{
gdcmDebugMacro( "BitsAllocated is not % 8" );
return nullptr;
}
assert( bitsallocated % 8 == 0 );
// eg. fragment_size == 63532 and 181 * 117 * 3 * 8 == 63531 ...
assert( ((fragment_size + 1)/2 ) * 2 == (((size_t)image_height * image_width * numcomps * (bitsallocated/8) + 1)/ 2 )* 2 );
int subsampling_dx = parameters->subsampling_dx;
int subsampling_dy = parameters->subsampling_dy;
// FIXME
w = image_width;
h = image_height;
/* initialize image components */
memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
//assert( bitsallocated == 8 );
for(int i = 0; i < numcomps; i++) {
cmptparm[i].prec = bitsstored;
cmptparm[i].prec = bitsallocated; // FIXME
cmptparm[i].bpp = bitsallocated;
cmptparm[i].sgnd = sign;
cmptparm[i].dx = subsampling_dx;
cmptparm[i].dy = subsampling_dy;
cmptparm[i].w = w;
cmptparm[i].h = h;
}
/* create the image */
image = opj_image_create(numcomps, &cmptparm[0], color_space);
if(!image) {
return nullptr;
}
/* set image offset and reference grid */
image->x0 = parameters->image_offset_x0;
image->y0 = parameters->image_offset_y0;
image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
/* set image data */
//assert( fragment_size == numcomps*w*h*(bitsallocated/8) );
if (bitsallocated <= 8)
{
if( sign )
{
rawtoimage_fill<int8_t>((const int8_t*)inputbuffer,w,h,numcomps,image,pc);
}
else
{
rawtoimage_fill<uint8_t>((const uint8_t*)inputbuffer,w,h,numcomps,image,pc);
}
}
else if (bitsallocated <= 16)
{
if( bitsallocated != bitsstored )
{
if( sign )
{
rawtoimage_fill2<int16_t>((const int16_t*)inputbuffer,w,h,numcomps,image,pc, bitsallocated, bitsstored, highbit, sign);
}
else
{
rawtoimage_fill2<uint16_t>((const uint16_t*)inputbuffer,w,h,numcomps,image,pc, bitsallocated, bitsstored, highbit, sign);
}
}
else
{
if( sign )
{
rawtoimage_fill<int16_t>((const int16_t*)inputbuffer,w,h,numcomps,image,pc);
}
else
{
rawtoimage_fill<uint16_t>((const uint16_t*)inputbuffer,w,h,numcomps,image,pc);
}
}
}
else if (bitsallocated <= 32)
{
if( sign )
{
rawtoimage_fill<int32_t>((const int32_t*)inputbuffer,w,h,numcomps,image,pc);
}
else
{
rawtoimage_fill<uint32_t>((const uint32_t*)inputbuffer,w,h,numcomps,image,pc);
}
}
else // dead branch ?
{
opj_image_destroy(image);
return nullptr;
}
return image;
}
bool JPEG2000Codec::CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t & complen, const char * inputdata, size_t inputlength )
{
complen = 0; // default init
#if 0
if( NeedOverlayCleanup )
{
gdcmErrorMacro( "TODO" );
return false;
}
#endif
const unsigned int *dims = this->GetDimensions();
int image_width = dims[0];
int image_height = dims[1];
int numZ = 0; //dims[2];
const PixelFormat &pf = this->GetPixelFormat();
int sample_pixel = pf.GetSamplesPerPixel();
int bitsallocated = pf.GetBitsAllocated();
int bitsstored = pf.GetBitsStored();
int highbit = pf.GetHighBit();
int sign = pf.GetPixelRepresentation();
int quality = 100;
//// input_buffer is ONE image
//// fragment_size is the size of this image (fragment)
(void)numZ;
bool bSuccess;
//bool delete_comment = true;
opj_cparameters_t parameters; /* compression parameters */
opj_image_t *image = nullptr;
//quality = 100;
/* set encoding parameters to default values */
//memset(¶meters, 0, sizeof(parameters));
//opj_set_default_encoder_parameters(¶meters);
memcpy(¶meters, &(Internals->coder_param), sizeof(parameters));
if ((parameters.cp_disto_alloc || parameters.cp_fixed_alloc || parameters.cp_fixed_quality)
&& (!(parameters.cp_disto_alloc ^ parameters.cp_fixed_alloc ^ parameters.cp_fixed_quality)))
{
gdcmErrorMacro( "Error: options -r -q and -f cannot be used together." );
return false;
} /* mod fixed_quality */
/* if no rate entered, lossless by default */
if (parameters.tcp_numlayers == 0)
{
parameters.tcp_rates[0] = 0;
parameters.tcp_numlayers = 1;
parameters.cp_disto_alloc = 1;
}
if(parameters.cp_comment == nullptr) {
const char comment[] = "Created by GDCM/OpenJPEG version %s";
const char * vers = opj_version();
parameters.cp_comment = (char*)malloc(strlen(comment) + 10);
snprintf( parameters.cp_comment, strlen(comment) + 10, comment, vers );
/* no need to delete parameters.cp_comment on exit */
//delete_comment = false;
}
// Compute the proper number of resolutions to use.
// This is mostly done for images smaller than 64 pixels
// along any dimension.
unsigned int numberOfResolutions = 0;
unsigned int tw = image_width >> 1;
unsigned int th = image_height >> 1;
while( tw && th )
{
numberOfResolutions++;
tw >>= 1;
th >>= 1;
}
// Clamp the number of resolutions to 6.
if( numberOfResolutions > 6 )
{
numberOfResolutions = 6;
}
parameters.numresolution = numberOfResolutions;
/* decode the source image */
/* ----------------------- */
image = rawtoimage((const char*)inputdata, ¶meters,
inputlength,
image_width, image_height,
sample_pixel, bitsallocated, bitsstored, highbit, sign, quality, this->GetPlanarConfiguration() );
if (!image) {
free(parameters.cp_comment);
return false;
}
/* encode the destination image */
/* ---------------------------- */
parameters.cod_format = J2K_CFMT; /* J2K format output */
size_t codestream_length;
opj_codec_t* cinfo = nullptr;
opj_stream_t *cio = nullptr;
/* get a J2K compressor handle */
cinfo = opj_create_compress(CODEC_J2K);
/* setup the encoder parameters using the current image and using user parameters */
opj_setup_encoder(cinfo, ¶meters, image);
myfile mysrc;
myfile *fsrc = &mysrc;
char *buffer_j2k = new char[inputlength * 2]; // overallocated for weird case
fsrc->mem = fsrc->cur = buffer_j2k;
fsrc->len = 0; //inputlength;
/* open a byte stream for writing */
/* allocate memory for all tiles */
cio = opj_stream_create_memory_stream(fsrc,OPJ_J2K_STREAM_CHUNK_SIZE,false);
if (! cio)
{
free(parameters.cp_comment);
return false;
}
/* encode the image */
/*if (*indexfilename) // If need to extract codestream information
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else*/
bSuccess = opj_start_compress(cinfo,image,cio) ? true : false;
bSuccess = bSuccess && opj_encode(cinfo, cio);
bSuccess = bSuccess && opj_end_compress(cinfo, cio);
if (!bSuccess)
{
opj_stream_destroy(cio);
free(parameters.cp_comment);
return false;
}
codestream_length = mysrc.len;
/* write the buffer to disk */
//f = fopen(parameters.outfile, "wb");
//if (!f) {
// fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
// free(parameters.cp_comment);
// return 1;
//}
//fwrite(cio->buffer, 1, codestream_length, f);
//#define MDEBUG
#ifdef MDEBUG
static int c = 0;
std::ostringstream os;
os << "/tmp/debug";
os << c;
c++;
os << ".j2k";
std::ofstream debug(os.str().c_str(), std::ios::binary);
debug.write((char*)(cio->buffer), codestream_length);
debug.close();
#endif
bool success = false;
if( codestream_length <= outlen )
{
success = true;
memcpy(outdata, (char*)(mysrc.mem), codestream_length);
}
delete [] buffer_j2k;
/* close and free the byte stream */
opj_stream_destroy(cio);
/* free remaining compression structures */
opj_destroy_codec(cinfo);
complen = codestream_length;
/* free user parameters structure */
if(parameters.cp_comment) free(parameters.cp_comment);
if(parameters.cp_matrice) free(parameters.cp_matrice);
/* free image data */
opj_image_destroy(image);
return success;
}
// Compress into JPEG
bool JPEG2000Codec::Code(DataElement const &in, DataElement &out)
{
out = in;
//
// Create a Sequence Of Fragments:
SmartPointer<SequenceOfFragments> sq = new SequenceOfFragments;
const unsigned int *dims = this->GetDimensions();
int image_width = dims[0];
int image_height = dims[1];
const ByteValue *bv = in.GetByteValue();
const char *input = bv->GetPointer();
unsigned long len = bv->GetLength();
unsigned long image_len = len / dims[2];
size_t inputlength = image_len;
for(unsigned int dim = 0; dim < dims[2]; ++dim)
{
const char *inputdata = input + dim * image_len;
std::vector<char> rgbyteCompressed;
rgbyteCompressed.resize(image_width * image_height * 4);
size_t cbyteCompressed;
const bool b = this->CodeFrameIntoBuffer((char*)rgbyteCompressed.data(), rgbyteCompressed.size(), cbyteCompressed, inputdata, inputlength );
if( !b ) return false;
Fragment frag;
assert( cbyteCompressed <= rgbyteCompressed.size() ); // default alloc would be bogus
frag.SetByteValue( rgbyteCompressed.data(), (uint32_t)cbyteCompressed );
sq->AddFragment( frag );
}
assert( sq->GetNumberOfFragments() == dims[2] );
out.SetValue( *sq );
return true;
}
bool JPEG2000Codec::GetHeaderInfo(std::istream &is, TransferSyntax &ts)
{
// FIXME: Do some stupid work:
is.seekg( 0, std::ios::end);
size_t buf_size = (size_t)is.tellg();
char *dummy_buffer = new char[buf_size];
is.seekg(0, std::ios::beg);
is.read( dummy_buffer, buf_size);
bool b = GetHeaderInfo( dummy_buffer, (size_t)buf_size, ts );
delete[] dummy_buffer;
return b;
}
bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, TransferSyntax &ts)
{
opj_dparameters_t parameters; /* decompression parameters */
opj_codec_t* dinfo = nullptr; /* handle to a decompressor */
opj_stream_t *cio = nullptr;
opj_image_t *image = nullptr;
const unsigned char *src = (const unsigned char*)dummy_buffer;
size_t file_length = buf_size;
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(¶meters);
const char jp2magic[] = "\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A";
if( memcmp( src, jp2magic, sizeof(jp2magic) ) == 0 )
{
/* JPEG-2000 compressed image data */
// gdcmData/ELSCINT1_JP2vsJ2K.dcm
gdcmWarningMacro( "J2K start like JPEG-2000 compressed image data instead of codestream" );
parameters.decod_format = JP2_CFMT;
assert(parameters.decod_format == JP2_CFMT);
}
else
{
/* JPEG-2000 codestream */
parameters.decod_format = J2K_CFMT;
assert(parameters.decod_format == J2K_CFMT);
}
parameters.cod_format = PGX_DFMT;
assert(parameters.cod_format == PGX_DFMT);
/* get a decoder handle */
switch(parameters.decod_format )
{
case J2K_CFMT:
dinfo = opj_create_decompress(CODEC_J2K);
break;
case JP2_CFMT:
dinfo = opj_create_decompress(CODEC_JP2);
break;
default:
gdcmErrorMacro( "Impossible happen" );
return false;
}
#if ((OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR >= 3) || (OPJ_VERSION_MAJOR > 2))
opj_codec_set_threads(dinfo, Internals->nNumberOfThreadsForDecompression);
#endif
myfile mysrc;
myfile *fsrc = &mysrc;
fsrc->mem = fsrc->cur = (char*)const_cast<unsigned char*>(src);
fsrc->len = file_length;
// the hack is not used when reading meta-info of a j2k stream:
opj_set_error_handler(dinfo, gdcm_error_callback, nullptr);
cio = opj_stream_create_memory_stream(fsrc,OPJ_J2K_STREAM_CHUNK_SIZE, true);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, ¶meters);
bool bResult;
#if 0
OPJ_INT32 l_tile_x0,l_tile_y0;
OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
#endif
bResult = opj_read_header(
cio,
dinfo,
&image) ? true : false;
if(!bResult)
{
opj_stream_destroy(cio);
return false;
}
//image = opj_decode(dinfo, cio);
//bResult = bResult && (image != 00);
//bResult = bResult && opj_end_decompress(dinfo,cio);
//if (!image)
// {
// opj_destroy_codec(dinfo);
// opj_stream_destroy(cio);
// gdcmErrorMacro( "opj_decode failed" );
// return false;
// }
int reversible;
int mct = 0;
#if 0
reversible = opj_get_reversible(dinfo, ¶meters );
assert( reversible == 0 || reversible == 1 );
// FIXME
assert( mct == 0 || mct == 1 );
#else
bool b = false;
bool lossless = false;
bool mctb = false;
if( parameters.decod_format == JP2_CFMT )
b = parsejp2_imp( dummy_buffer, buf_size, &lossless, &mctb);
else if( parameters.decod_format == J2K_CFMT )
b = parsej2k_imp( dummy_buffer, buf_size, &lossless, &mctb);
reversible = 0;
if( b ) {
reversible = lossless;
mct = mctb;
}
#endif
LossyFlag = !reversible;
int compno = 0;
opj_image_comp_t *comp = &image->comps[compno];
if( !check_comp_valid( image ) )
{
gdcmErrorMacro( "Invalid test failed" );
return false;
}
this->Dimensions[0] = comp->w;
this->Dimensions[1] = comp->h;
if( comp->prec <= 8 )
{
this->PF = PixelFormat( PixelFormat::UINT8 );
}
else if( comp->prec <= 16 )
{
this->PF = PixelFormat( PixelFormat::UINT16 );
}
else if( comp->prec <= 32 )
{
this->PF = PixelFormat( PixelFormat::UINT32 );
}
else
{
gdcmErrorMacro( "do not handle precision: " << comp->prec );
return false;
}
this->PF.SetBitsStored( (unsigned short)comp->prec );
this->PF.SetHighBit( (unsigned short)(comp->prec - 1) );
this->PF.SetPixelRepresentation( (unsigned short)comp->sgnd );
if( image->numcomps == 1 )
{
// normally we have codec only, but in some case we have a JP2 with
// color space info:
// - gdcmData/MAROTECH_CT_JP2Lossy.dcm
// - gdcmData/D_CLUNIE_CT1_J2KI.dcm -> color_space = 32767
//assert( image->color_space == 0 || image->color_space == CLRSPC_GRAY );
PI = PhotometricInterpretation::MONOCHROME2;
this->PF.SetSamplesPerPixel( 1 );
}
else if( image->numcomps == 3 )
{
//assert( image->color_space == 0 );
//PI = PhotometricInterpretation::RGB;
/*
8.2.4 JPEG 2000 IMAGE COMPRESSION
The JPEG 2000 bit stream specifies whether or not a reversible or irreversible
multi-component (color) transformation, if any, has been applied. If no
multi-component transformation has been applied, then the components shall
correspond to those specified by the DICOM Attribute Photometric Interpretation
(0028,0004). If the JPEG 2000 Part 1 reversible multi-component transformation
has been applied then the DICOM Attribute Photometric Interpretation
(0028,0004) shall be YBR_RCT. If the JPEG 2000 Part 1 irreversible
multi-component transformation has been applied then the DICOM Attribute
Photometric Interpretation (0028,0004) shall be YBR_ICT. Notes: 1. For
example, single component may be present, and the Photometric Interpretation
(0028,0004) may be MONOCHROME2. 2. Though it would be unusual, would not take
advantage of correlation between the red, green and blue components, and would
not achieve effective compression, a Photometric Interpretation of RGB could be
specified as long as no multi-component transformation was specified by the
JPEG 2000 bit stream. 3. Despite the application of a multi-component color
transformation and its reflection in the Photometric Interpretation attribute,
the color space remains undefined. There is currently no means of conveying
standard color spaces either by fixed values (such as sRGB) or by ICC
profiles. Note in particular that the JP2 file header is not sent in the JPEG
2000 bitstream that is encapsulated in DICOM.
*/
if( mct )
PI = PhotometricInterpretation::YBR_RCT;
else
PI = PhotometricInterpretation::RGB;
this->PF.SetSamplesPerPixel( 3 );
}
else if( image->numcomps == 4 )
{
/* Yes this is legal */
// http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
// jpeg2000testimages/Part4TestStreams/codestreams_profile0/p0_06.j2k
gdcmErrorMacro( "Image is 4 components which is not supported anymore in DICOM (ARGB is retired)" );
// TODO: How about I get the 3 comps and set the alpha plane in the overlay ?
return false;
}
else
{
// jpeg2000testimages/Part4TestStreams/codestreams_profile0/p0_13.j2k
gdcmErrorMacro( "Image is " << image->numcomps << " components which is not supported in DICOM" );
return false;
}
assert( PI != PhotometricInterpretation::UNKNOWN );
bool bmct = false;
if( bmct )
{
if( reversible )
{
ts = TransferSyntax::JPEG2000Part2Lossless;
}
else
{
ts = TransferSyntax::JPEG2000Part2;
if( PI == PhotometricInterpretation::YBR_RCT )
{
// FIXME ???
PI = PhotometricInterpretation::YBR_ICT;
}
}
}
else
{
if( reversible )
{
ts = TransferSyntax::JPEG2000Lossless;
}
else
{
ts = TransferSyntax::JPEG2000;
if( PI == PhotometricInterpretation::YBR_RCT )
{
// FIXME ???
PI = PhotometricInterpretation::YBR_ICT;
}
}
}
//assert( ts.IsLossy() == this->GetPhotometricInterpretation().IsLossy() );
//assert( ts.IsLossless() == this->GetPhotometricInterpretation().IsLossless() );
if( this->GetPhotometricInterpretation().IsLossy() )
{
assert( ts.IsLossy() );
}
if( ts.IsLossless() && !ts.IsLossy() )
{
assert( this->GetPhotometricInterpretation().IsLossless() );
}
/* close the byte stream */
opj_stream_destroy(cio);
/* free remaining structures */
if (dinfo)
{
opj_destroy_codec(dinfo);
}
/* free image data structure */
opj_image_destroy(image);
return true;
}
bool JPEG2000Codec::DecodeExtent(
char *buffer,
unsigned int xmin, unsigned int xmax,
unsigned int ymin, unsigned int ymax,
unsigned int zmin, unsigned int zmax,
std::istream & is
)
{
BasicOffsetTable bot;
bot.Read<SwapperNoOp>( is );
const unsigned int * dimensions = this->GetDimensions();
// retrieve pixel format *after* DecodeByStreamsCommon !
const PixelFormat pf = this->GetPixelFormat(); // make a copy !
assert( pf.GetBitsAllocated() % 8 == 0 );
assert( pf != PixelFormat::SINGLEBIT );
assert( pf != PixelFormat::UINT12 && pf != PixelFormat::INT12 );
if( NumberOfDimensions == 2 )
{
char *dummy_buffer = nullptr;
std::vector<char> vdummybuffer;
size_t buf_size = 0;
const Tag seqDelItem(0xfffe,0xe0dd);
Fragment frag;
while( frag.ReadPreValue<SwapperNoOp>(is) && frag.GetTag() != seqDelItem )
{
size_t fraglen = frag.GetVL();
size_t oldlen = vdummybuffer.size();
if( fraglen == 0 && oldlen == 0 )
break;
// update
buf_size = fraglen + oldlen;
vdummybuffer.resize( buf_size );
dummy_buffer = vdummybuffer.data();
// read J2K
is.read( &vdummybuffer[oldlen], fraglen );
}
assert( frag.GetTag() == seqDelItem && frag.GetVL() == 0 );
assert( zmin == zmax );
assert( zmin == 0 );
std::pair<char*,size_t> raw_len = this->DecodeByStreamsCommon(dummy_buffer, buf_size);
if( !raw_len.first || !raw_len.second ) return false;
// check pixel format *after* DecodeByStreamsCommon !
const PixelFormat & pf2 = this->GetPixelFormat();
// SC16BitsAllocated_8BitsStoredJ2K.dcm
if( pf.GetSamplesPerPixel() != pf2.GetSamplesPerPixel()
|| pf.GetBitsAllocated() != pf2.GetBitsAllocated()
/*
|| pf.GetPixelRepresentation() != pf2.GetPixelRepresentation() // TODO, we are a bit too aggressive here
*/
)
{
gdcmErrorMacro( "Invalid PixelFormat found (mismatch DICOM vs J2K)" );
return false;
}
char *raw = raw_len.first;
const unsigned int rowsize = xmax - xmin + 1;
const unsigned int colsize = ymax - ymin + 1;
const unsigned int bytesPerPixel = pf.GetPixelSize();
const char *tmpBuffer1 = raw;
unsigned int z = 0;
for (unsigned int y = ymin; y <= ymax; ++y)
{
size_t theOffset = 0 + (z*dimensions[1]*dimensions[0] + y*dimensions[0] + xmin)*bytesPerPixel;
tmpBuffer1 = raw + theOffset;
memcpy(&(buffer[((z-zmin)*rowsize*colsize +
(y-ymin)*rowsize)*bytesPerPixel]),
tmpBuffer1, rowsize*bytesPerPixel);
}
delete[] raw_len.first;
}
else if ( NumberOfDimensions == 3 )
{
const Tag seqDelItem(0xfffe,0xe0dd);
Fragment frag;
std::streamoff thestart = is.tellg();
unsigned int numfrags = 0;
std::vector< size_t > offsets;
while( frag.ReadPreValue<SwapperNoOp>(is) && frag.GetTag() != seqDelItem )
{
//std::streamoff relstart = is.tellg();
//assert( relstart - thestart == 8 );
std::streamoff off = frag.GetVL();
offsets.push_back( (size_t)off );
is.seekg( off, std::ios::cur );
++numfrags;
}
assert( frag.GetTag() == seqDelItem && frag.GetVL() == 0 );
assert( numfrags == offsets.size() );
if( numfrags != Dimensions[2] )
{
gdcmErrorMacro( "Not handled" );
return false;
}
for( unsigned int z = zmin; z <= zmax; ++z )
{
size_t curoffset = std::accumulate( offsets.begin(), offsets.begin() + z, size_t(0) );
is.seekg( thestart + curoffset + 8 * z, std::ios::beg );
is.seekg( 8, std::ios::cur );
const size_t buf_size = offsets[z];
char *dummy_buffer = new char[ buf_size ];
is.read( dummy_buffer, buf_size );
std::pair<char*,size_t> raw_len = this->DecodeByStreamsCommon(dummy_buffer, buf_size);
/* free the memory containing the code-stream */
delete[] dummy_buffer;
if( !raw_len.first || !raw_len.second ) return false;
// check pixel format *after* DecodeByStreamsCommon !
const PixelFormat & pf2 = this->GetPixelFormat();
if( pf.GetSamplesPerPixel() != pf2.GetSamplesPerPixel()
|| pf.GetBitsAllocated() != pf2.GetBitsAllocated()
)
{
gdcmErrorMacro( "Invalid PixelFormat found (mismatch DICOM vs J2K)" );
return false;
}
char *raw = raw_len.first;
const unsigned int rowsize = xmax - xmin + 1;
const unsigned int colsize = ymax - ymin + 1;
const unsigned int bytesPerPixel = pf.GetPixelSize();
const char *tmpBuffer1 = raw;
for (unsigned int y = ymin; y <= ymax; ++y)
{
size_t theOffset = 0 + (0*dimensions[1]*dimensions[0] + y*dimensions[0] + xmin)*bytesPerPixel;
tmpBuffer1 = raw + theOffset;
memcpy(&(buffer[((z-zmin)*rowsize*colsize +
(y-ymin)*rowsize)*bytesPerPixel]),
tmpBuffer1, rowsize*bytesPerPixel);
}
delete[] raw_len.first;
}
}
return true;
}
ImageCodec * JPEG2000Codec::Clone() const
{
JPEG2000Codec * copy = new JPEG2000Codec;
return copy;
}
bool JPEG2000Codec::StartEncode( std::ostream & )
{
return true;
}
bool JPEG2000Codec::IsRowEncoder()
{
return false;
}
bool JPEG2000Codec::IsFrameEncoder()
{
return true;
}
bool JPEG2000Codec::AppendRowEncode( std::ostream & , const char * , size_t )
{
return false;
}
bool JPEG2000Codec::AppendFrameEncode( std::ostream & out, const char * data, size_t datalen )
{
const unsigned int * dimensions = this->GetDimensions();
const PixelFormat & pf = this->GetPixelFormat();
assert( datalen == dimensions[0] * dimensions[1] * pf.GetPixelSize() ); (void)pf;
std::vector<char> rgbyteCompressed;
rgbyteCompressed.resize(dimensions[0] * dimensions[1] * 4);
size_t cbyteCompressed;
const bool b = this->CodeFrameIntoBuffer((char*)rgbyteCompressed.data(), rgbyteCompressed.size(), cbyteCompressed, data, datalen );
if( !b ) return false;
out.write( (char*)rgbyteCompressed.data(), cbyteCompressed );
return true;
}
bool JPEG2000Codec::StopEncode( std::ostream & )
{
return true;
}
} // end namespace gdcm
|
12dc7fe8623d6774f3b2fe8948fd2d79679811f9
|
a57d8437088ac1eb627169ed82c4bbc8e8f3447a
|
/Kernel_Linux/ss/src/include/ICenterClient.h
|
90e0cde6b53db311d72c0bf99c9580e0cc3236bd
|
[] |
no_license
|
linchendev/kernel
|
7a74ac4ab5fddaede0f7eb94527fd2e60ba147cc
|
3f5e76dbb15bef9a57dcbd1e924e38ac3bf1a15b
|
refs/heads/master
| 2021-05-26T17:27:43.499709
| 2013-08-21T09:22:54
| 2013-08-21T09:22:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,844
|
h
|
ICenterClient.h
|
//
// Copyright(C) 2011-2012 Loogia, All rights reserved.
//
// $Rev: 7062 $
// $Author: than $
// $Date: 2012-04-28 11:08:42 +0800 (鍛ㄥ叚, 2012-04-28) $
//
// Define interface ICenterClient.
//
#ifndef __ICENTER__CLIENT__H
#define __ICENTER__CLIENT__H
#include "include/GameSys.h"
#include "include/IOsApi.h"
#include "common/DServerDef.h"
struct ITimerAxis;
struct SServerKey;
struct SCenterActorLoginContext;
struct ILog;
struct IServerKernel;
// 应用服务器接口(需要每台非中心服的服务器继承这些接口)
// 主要用于:中心服客户端在其他服务器使用中可能需要用到服务器的一些接口
// 因为这里抽象了所有其他服务器使用的中心服客户端,所以接口被
// 揉到了一起...
// 这些接口基本上是各服务器的中心服客户端接到中心服的一些消息
// 后,进行的一些回调,因为不同的服务器有不同的响应,或不同的
// 服务器只需要使用其中一部分接口,所以这些接口都是非主动调用
// 的。
struct IAppServer {
virtual ~IAppServer() {}
// 获取应用服务器信息
// len为name的大小
// type 值参考 DCenterServerMsg.h 的定义
virtual BOOL GetInfo(LPSTR name, s32 len, u32 &id, u8 &type, u16 &port) = 0;
// 应用服务器登录后回调
// result:TRUE表示登录成功,FALSE表示登录失败
virtual void OnServerLogin(BOOL result, LPCSTR desc) = 0;
// 应用服务器退出时回调
virtual void OnServerLogout() = 0;
// 发给某个角色数据的回调
virtual void OnSendDataToActor(s32 actor_id, LPSTR buff, s32 len) = 0;
// 发给某个房间数据的回调
virtual void OnSendDataToRoom(s32 map_id, LPSTR buff, s32 len) = 0;
// 全服务器广播数据的回调
virtual void OnBroadcastData(LPSTR buff, s32 len) = 0;
// 服务器登录和登出时回调
virtual void OnAppInfo(LPSTR buff, s32 len) = 0;
};
// 社会服务器接口
struct ISocietyAppServer : public IAppServer {
virtual ~ISocietyAppServer() {}
// 社会服务器接收消息回调接口
virtual void OnSendDataToSociety(LPSTR buff, s32 len) = 0;
};
// 登录服务器接口
struct ILoginServer : public IAppServer {
virtual ~ILoginServer() {}
// 在线人数更新通知
virtual void OnUpdateOnlineNum(LPSTR buff, s32 len) = 0;
// 角色登录登出后回调
virtual void OnActorLoginLogout(LPSTR buff, s32 len) = 0;
};
// 大厅服务器接口
struct ILobbyServer : public IAppServer {
virtual ~ILobbyServer() {}
// 创建新房间后回调
virtual void OnNewRoom(LPSTR buff, s32 len) = 0;
// 房间登录后回调
virtual void OnRoomLogin(u32 room_id, u32 map_id) = 0;
};
struct IRoomServer : public IAppServer {};
// 中心服务器客户端接口
struct ICenterClient {
virtual ~ICenterClient() {}
// 销毁中心服客户端
virtual void Release() = 0;
// 得到游戏世界名字
virtual LPCSTR GetGameName() = 0;
// 房间更新列表,应用服务器登录成功后,需要调用此方法进行更新
// first 用于分批次更新时,表明是否是第一批更新
virtual BOOL RoomUpdateList(s32 room_num, ServerRoomInfo *room_ids, BOOL first) = 0;
// 房间创建
virtual BOOL RoomLogin(u32 room_id, u32 map_id) = 0;
// 房间销毁
virtual BOOL RoomLogout(u32 room_id) = 0;
// 角色更新列表,应用服务器登录成功后,需要调用此方法进行更新
// first 用于分批次更新时,表明是否是第一批更新
virtual BOOL ActorUpdateList(s32 actor_num, SCenterActorLoginContext *actor_list, BOOL first) = 0;
// 角色登录 op_type = 0: 上线登录,op_type = 1: 跨场景服登录
virtual BOOL ActorLogin(s64 user_id, s32 actor_id, LPCSTR actor_name, u8 op_type, s32 reserve) = 0;
// 角色退出 op_type = 0: 下线登出,op_type = 1: 跨场景服登出
virtual BOOL ActorLogout(s64 user_id, s32 actor_id, u8 op_type, s32 reserve) = 0;
// 发送数据给某个角色
virtual BOOL SendDataToActor(s32 actor_id, LPSTR buff, s32 len) = 0;
// 发送数据给某个房间
virtual BOOL SendDataToRoom(s32 room_id, char *buff, s32 len) = 0;
// 向全世界广播消息
virtual BOOL BroadcastData(LPSTR buff, s32 len) = 0;
// 向插件模块发送消息
virtual BOOL SendToPlugin(u16 event_id, u8 src_type_id, LPSTR buff, s32 len) = 0;
// 发送数据到社会服务器
virtual BOOL SendDataToSciety(LPSTR buff, s32 len) = 0;
// 查找一个网关服务器,获取的是在线人数最低的 找到返回TRUE
// user_id:玩家ID 用于负载均衡
virtual BOOL FindGateWay(SServerKey &ServerKey, s64 user_id) = 0;
// 获取所有服务器总在线人数
virtual s32 GetTotalOnlineNum() = 0;
// 获取服务器在线人数
virtual s32 GetServerOnlineNum(SServerKey &key) = 0;
// 直接发送数据中心服
virtual BOOL SendToCenterSvr(LPSTR buff, s32 len) = 0;
// 检查某个服务器是否存在
virtual BOOL ExistServer(SServerKey key) = 0;
// 根据地图ID查询服务器信息
virtual BOOL FindServer(s32 room_id, SServerKey &key) = 0;
// 查找最闲的房间
virtual BOOL FindFreeRoomServer(SServerKey &key) = 0;
// 查找大厅服务器
virtual BOOL FindLobbyServer(s32 server_id, SServerKey &key) = 0;
};
extern "C" BOOL CreateCenterClient(ICenterClient **center_client, IAppServer *app_server, ITimerAxis *time_axis,
ILog *log, IServerKernel *server_kernel, LPCSTR center_server_ip, u16 center_server_port);
typedef BOOL (*ProcCreateCenterClient)(ICenterClient **center_client, IAppServer *app_server, ITimerAxis *time_axis,
ILog *log, IServerKernel *server_kernel, LPCSTR center_server_ip, u16 center_server_port);
// 中心服客户端创建辅助类
class CCenterClientHelper {
public:
CCenterClientHelper() : center_client_(NULL) {}
~CCenterClientHelper() { this->Close(); }
BOOL Create(IAppServer *app_server, ITimerAxis *time_axis, ILog *log, IServerKernel *server_kernel,
LPCSTR center_server_ip, u16 center_server_port, const char *center_client_so) {
if(this->dynamic_loader_.LoadLibrary(center_client_so) == FALSE) {
return FALSE;
}
ProcCreateCenterClient proc = NULL;
proc = (ProcCreateCenterClient)(this->dynamic_loader_.GetProcAddress("CreateCenterClient"));
if(proc == NULL)
return FALSE;
return proc(&(this->center_client_), app_server, time_axis, log, server_kernel,
center_server_ip, center_server_port);
}
void Close() {
if(this->center_client_) {
this->center_client_->Release();
this->center_client_ = NULL;
}
this->dynamic_loader_.FreeLibrary();
}
ICenterClient *center_client_;
private:
CDynamicLoader dynamic_loader_;
};
#endif // __ICENTER__CLIENT__H
|
23e120ecd232071db34c50517ba91c753ca613a3
|
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
|
/3WeekTutorial/day1/elbow_tri/56/phi
|
2fd1e2e4a85fabbbc6bb5c4d6cb403d2dafd230f
|
[] |
no_license
|
labsandy/OpenFOAM_workspace
|
a74b473903ddbd34b31dc93917e3719bc051e379
|
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
|
refs/heads/master
| 2022-02-25T02:36:04.164324
| 2019-08-23T02:27:16
| 2019-08-23T02:27:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,690
|
phi
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "56";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 3 -1 0 0 0 0];
internalField nonuniform List<scalar>
1300
(
3.75095
5.62643
-3.34511
3.75095
-7.76706
5.62643
-4.24251
4.24251
-0.565187
0.565187
1.87647
1.87448
-2.5116
2.5116
-1.9337
1.9337
-2.53637
2.53637
-5.24795
5.24795
-5.06978
5.06978
4.7058
-4.7058
-6.31337
6.31337
-0.991305
0.991305
-3.56238
3.56238
3.17266
-3.17266
-1.97407
1.97407
-0.0550126
0.0550126
-0.55409
4.30504
3.19686
3.19686
-1.9753
1.9753
-4.87467
4.87467
6.22235
-6.22235
5.27589
-5.27589
-1.93077
-2.47893
1.81643
-11.5289
-5.95063
-5.95063
-8.441
8.441
-2.81457
2.81186
2.94671
-2.94671
-1.73121
1.73121
-4.25482
0.0123148
-4.25482
4.20917
0.033338
4.20917
-0.639277
0.074091
-0.639277
3.90914
-3.90914
0.466486
0.0987004
0.466486
3.06715
-3.06715
-1.87686
3.75333
1.87409
-1.87208
6.17713
-1.87887
3.75335
-6.06912
6.06912
-2.72887
0.217277
-2.72887
2.31227
0.199322
2.31227
-6.87078
6.87078
-1.99015
0.0564554
-1.99015
1.9416
-0.00789734
1.9416
2.88576
-2.88576
-2.63646
0.100084
-2.63646
2.39666
0.139717
2.39666
0.353423
5.27301
-5.97985
8.79171
-5.27301
0.0250545
5.21017
0.0377824
5.21017
-5.10535
0.035577
-5.10535
5.01284
0.056933
5.01284
4.79681
-0.0910052
4.79681
-4.82361
0.117807
-4.82361
-3.36606
-4.06003
-6.47076
0.157388
-6.47076
-1.04992
0.0586143
-1.04992
0.898993
0.0923119
0.898993
-3.71872
3.71872
-3.90412
0.341741
-3.90412
3.12764
0.0450228
3.12764
1.86813
1.88283
5.61908
-5.61908
2.44641
-1.93665
-0.0374155
-1.93665
-2.02835
-3.24753
2.02835
-0.0542836
-0.277113
0.2221
-0.277113
3.15708
0.0397858
3.15708
2.22324
0.173411
-2.22324
0.247944
3.29083
-3.29083
1.3085
0.666805
1.3085
-5.55855
5.55855
4.96179
0.0510572
-4.96179
0.0871114
6.15742
0.0649306
6.15742
-6.20753
-0.0148217
-6.20753
2.49401
-4.97293
-2.63113
6.13132
0.182051
-6.13132
0.180691
2.91801
0.028699
2.91801
-2.92
2.92
-2.98385
0.0371425
-2.98385
-2.15428
0.423076
-2.15428
1.41631
0.314895
1.41631
-4.16688
-0.0879433
-4.16688
-4.05721
0.153086
4.05721
0.151963
1.10736
-1.10736
-0.712063
0.0727854
-0.712063
-4.01337
-0.153505
4.01337
-0.104237
-3.85482
-0.054313
-3.85482
-3.02164
0.037789
3.02164
0.0455075
3.11203
0.0450459
-3.11203
0.0448833
-1.87098
3.75381
-1.87997
3.75406
-5.68815
-0.380977
-5.68815
6.35303
-0.283903
6.35303
3.11379
0.448594
-3.11379
0.384912
2.16613
0.146149
2.16613
-6.84703
-0.0237559
-6.84703
6.87237
-0.00158495
6.87237
2.06099
0.105133
-2.06099
0.0708381
1.9415
0.000101023
1.9415
2.91258
-0.0268159
2.91258
-2.88024
-0.00551623
-2.88024
2.79406
-2.79406
2.72121
0.0728421
-2.72121
0.0847579
-11.1242
11.1094
-0.0361713
-11.088
5.174
5.174
4.25182
0.544987
4.25182
-5.01723
0.193623
-5.01723
2.66687
-5.298
3.08482
-6.45089
4.67035
-16.1992
4.30574
-8.36577
6.71918
-6.71918
6.60122
0.117956
-6.60122
0.130467
-1.14543
0.0955152
-1.14543
-3.09854
-0.620183
-3.09854
4.35043
-0.631704
4.35043
-3.02792
3.02792
-3.07661
0.0486891
3.07661
0.0510353
1.93196
0.00953544
-1.93196
-0.00469445
0.364718
0.101768
-0.364718
0.0876051
3.50815
-0.217321
3.50815
-3.09006
-0.200766
-3.09006
-1.23074
0.0853077
1.23074
0.0777539
-5.8072
0.248646
-5.8072
-11.1817
0.0936757
-11.1439
-6.11386
-6.11386
2.32714
11.1189
-2.89604
0.0158008
2.89604
0.0219655
2.97552
0.0524006
-2.97552
0.0555212
-2.86001
0.0659526
2.86001
0.0599855
-2.52291
0.368629
-2.52291
-1.02909
1.02909
-1.17959
0.150491
1.17959
0.236728
1.40145
-0.294094
1.40145
0.804788
0.0942054
-0.804788
0.0927247
-3.80799
-0.0468337
-3.80799
6.5914
-0.238372
6.5914
-2.96257
-0.127488
2.96257
-0.0499987
-0.0347146
11.1441
-5.13928
0.0339312
5.13928
-11.209
11.2429
-3.22957
0.706658
3.22957
1.02225
5.28484
0.273709
-5.28484
0.267611
6.8111
0.0612699
-6.8111
0.0919174
-2.618
-0.480542
-2.618
-5.08772
-0.600422
5.08772
-0.737294
-11.482
-0.203712
11.6857
-11.425
6.01091
0.146516
-6.01091
11.3895
-0.992624
-0.114736
0.992623
0.0364712
1.73855
-0.337092
1.73855
3.71937
-0.211218
-3.71937
-0.0886216
-6.74458
-0.102447
6.74458
-0.153182
-2.16686
-0.451144
2.16686
-0.42831
-4.26734
4.30712
1.90979
-2.34861
-2.62433
-5.59614
1.85516
1.89865
4.30158
-10.173
-6.02622
-9.99233
7.21343
-6.94581
-9.33947
9.24846
7.87871
-7.93302
-5.77775
5.82878
6.48438
-6.43887
1.87932
1.87401
8.00516
-7.78789
-15.7131
15.3321
7.58424
-7.52779
15.8567
-15.8804
-17.8989
17.9602
-5.69484
5.79493
-6.74014
6.73463
-6.97504
6.92504
-2.8056
-3.64529
13.148
-12.9906
8.56969
-8.6071
-8.64593
8.98767
3.38457
0.922556
3.42961
-1.88187
3.76119
-1.87148
3.78127
2.73342
-5.53902
2.56457
-5.1889
4.35495
4.21474
-4.30066
-1.29548
-5.92776
5.95646
-5.8103
5.87029
9.13086
-9.11854
-1.88498
3.759
-1.86908
3.76773
-3.42328
-2.35447
3.37826
0.923321
8.09021
5.05776
-8.27226
-1.72007
-7.9985
7.78728
-8.20672
8.00595
-0.437068
5.83746
-5.40039
4.43761
-1.65367
7.49113
5.55975
5.75338
5.86016
-5.58646
1.08565
-6.48604
-6.39893
-2.39637
2.46915
2.28958
-2.19088
6.09993
1.77878
5.99569
-5.77906
-2.15395
-5.8259
3.82008
2.00871
3.86877
4.08169
2.40269
4.11948
3.02987
-3.03648
0.00660481
-3.0591
6.08897
0.722517
-5.41357
-4.49024
4.99013
3.01503
5.18945
-5.55271
-2.23518
-5.16779
-9.5871
-6.12595
-10.1875
10.1106
5.22152
9.82665
-11.9899
11.8367
4.87525
2.70899
4.86736
-4.96117
-2.56662
-4.89033
11.6759
-2.62785
-9.04808
-10.3489
-7.55
10.3505
5.50617
10.9931
6.96713
11.085
4.43109
7.24484
-9.93726
2.38726
-3.86236
-1.83248
-3.77761
3.65096
2.14397
3.79067
-4.21807
-2.52207
-4.20227
-4.29365
-2.68139
4.32047
2.41416
-4.41337
-3.79334
4.54086
2.38418
4.04698
-10.0732
4.3188
-7.96409
-9.22021
-3.77037
-9.08975
3.52736
2.59836
-6.12572
-2.01166
8.49604
-4.2813
7.20056
-5.19701
-3.41009
-5.2017
-6.92544
-1.7205
-6.77235
-8.94386
8.46332
-9.2437
8.61199
12.5846
-5.67103
-6.91354
-3.96692
-2.47195
3.92204
-0.492426
-3.7101
3.71671
0.0510864
3.83236
4.75491
4.26249
-3.88242
-1.92788
-3.8269
3.82228
2.048
3.88823
6.81264
2.31822
6.84598
-6.57616
-2.54239
-6.6641
9.11627
-8.69319
2.81914
-2.73383
5.36053
2.64541
-5.14321
-2.85529
6.24103
-3.20057
-3.04046
-12.3494
10.8171
1.53228
-4.85826
-0.42065
-0.365637
-5.57622
-3.76325
5.45841
0.294967
11.1121
7.34882
-5.51485
5.7635
6.17083
6.22188
-0.177043
5.90157
-5.19491
5.28341
-2.65574
-2.62767
5.4434
-5.59691
-1.2207
-5.51236
4.29166
0.398783
1.59599
-1.37389
-1.84822
-0.548144
-1.7555
1.30707
0.982513
1.40884
0.920674
1.54848
-2.91653
0.568314
2.34822
-1.99586
-1.62257
-3.76039
-1.13613
4.89651
5.69931
2.08797
-5.61069
-0.215208
2.6163
-2.52399
-0.804557
-2.95583
2.19676
-3.00132
-3.49089
-1.89404
5.38492
-3.36892
-0.457984
3.31652
0.552249
-3.8278
-2.09996
3.79065
0.328825
-3.12822
6.19011
-3.06189
-5.0561
2.52891
3.56006
4.53761
-4.79029
2.44894
2.34135
-1.23023
4.27045
0.919001
4.4166
-6.97929
4.74411
5.71915
3.26852
-6.16775
0.999952
-5.97933
8.5532
-7.39148
-1.16173
4.11493
4.43827
7.05971
5.52486
-5.6914
12.7511
-1.16134
-6.23014
7.14067
-3.87215
4.85275
-8.7249
-10.3776
4.14748
-9.22951
11.0635
-1.83395
-3.61503
-8.37487
12.8445
-1.21342
-11.6311
8.61324
-4.27605
-4.31595
8.59201
-6.9039
6.88258
-1.98232
-4.90026
-10.1655
-5.71492
10.268
1.56875
-9.89346
12.2807
-2.64862
4.15618
0.711179
4.15628
3.3165
-5.44728
2.13078
3.58741
-5.56973
2.06743
-7.51471
-6.76309
12.1012
-5.33815
-10.5335
-9.5612
-0.972259
2.55054
9.73018
-9.51767
7.448
2.06967
3.29921
0.589019
-3.37206
-0.405548
0.239872
4.51524
-4.75511
4.03055
4.20396
3.23221
1.28303
3.84861
2.10785
-3.87058
-0.331693
-4.16686
1.48547
-1.7527
-3.69196
5.17743
-4.06198
0.370019
-2.74703
-3.49423
6.24127
-4.57951
3.03649
3.15362
5.08449
-4.91379
1.41956
-2.39121
-2.52258
2.64242
-4.39512
1.99651
3.18092
4.38069
0.587346
5.90314
6.19809
-8.5015
0.537415
11.2559
-9.53578
2.48391
8.60108
-9.93191
0.370709
-8.71904
0.978097
-5.2594
-5.14762
5.19108
-6.91158
-3.53382
6.21795
0.628027
-6.36991
-0.40244
-6.0745
-2.86936
-6.52564
-3.08128
-6.16242
-8.77267
-1.68071
-7.09196
6.7826
-6.69896
-3.48856
7.43626
1.17574
-7.4858
7.37106
-7.55028
7.21319
0.0946359
3.62207
4.35712
1.88518
-2.39185
4.27702
-5.06068
7.3789
-8.72501
3.66433
4.21042
-6.7528
-4.5146
5.06665
4.04962
5.38155
8.946
-10.4068
1.46075
-10.6844
12.0294
-1.34507
-16.4748
5.79046
-7.52882
2.45906
0.360077
2.55457
0.570818
2.49427
-3.06509
-2.16301
-2.08526
-2.42845
-3.49613
5.92458
1.0822
-3.45002
2.36782
-3.57541
4.65761
-0.0386831
-3.41134
5.2005
-2.70622
5.56057
-3.61409
1.94648
3.53481
5.83979
-2.30498
4.42254
-1.77712
1.92888
-4.23385
-1.56725
-2.95578
5.09975
-3.28549
3.6555
-0.344639
4.00014
-4.0641
0.863526
-0.831887
3.37207
3.62001
4.33027
-3.04724
2.94405
-4.72117
-1.28981
-4.13382
-0.9529
-0.193798
-3.80718
4.00098
6.02717
-6.22096
-5.2902
9.53934
-4.24915
7.71319
-5.44707
-2.26612
-4.29971
-4.39349
3.93108
1.9705
9.68369
0.179746
-5.62682
-5.01517
-3.99292
3.12086
2.16255
-1.79743
3.32971
2.16307
-0.567077
0.431039
0.9778
1.77916
-1.34812
0.308489
1.47067
-1.06541
1.78449
0.831813
-1.87869
0.123197
-1.26936
3.46612
1.07886
-2.06137
0.71325
0.913535
-3.56928
5.02679
-2.68742
-2.33937
5.94033
1.14986
-3.83729
4.3625
-3.96372
2.42468
-3.5608
-1.41261
-5.37633
-3.59755
-2.50554
4.87336
-3.41903
5.507
1.38247
-5.2918
6.67427
-3.61907
1.72503
-3.07422
3.90603
-1.03854
-2.03568
2.89696
2.48796
-3.1059
0.150075
-0.208941
2.40812
-2.61706
-0.593201
-2.58906
-4.57551
4.90433
-2.1042
4.55315
2.17282
-1.91712
6.47027
1.8082
-3.72532
-3.2479
-3.70589
-1.38398
3.15364
-0.5967
-4.29363
-5.49696
4.1885
0.228106
-6.99409
7.85215
-0.858056
-3.97906
-0.765044
4.87998
-6.04887
0.479138
-3.98144
3.87071
4.78971
5.01782
-11.4068
-0.224357
-6.18526
1.11282
-7.29808
5.55109
-3.54895
7.69642
-10.3779
6.88934
-9.20216
6.53469
-0.763386
6.24592
-4.11514
2.80215
-8.51708
-6.94832
5.49674
-2.78775
6.20792
-3.15564
9.36355
-5.80426
5.28525
4.0783
-1.02232
-4.17938
-5.27168
4.24936
0.0135713
4.16985
4.98606
-2.87821
4.65437
2.26282
-4.65403
-2.13229
-6.48816
1.83413
-3.33454
-1.92142
3.75555
3.16308
3.75209
1.23297
-3.34655
7.22952
-8.20177
-1.89137
-3.25625
5.25772
-1.00835
3.41177
-6.66802
-1.84762
4.78435
-0.730946
-4.05341
0.886678
-4.4205
1.67519
-6.09569
5.23638
-5.63882
2.25256
-9.78138
-5.23324
-5.19677
-2.28087
-5.26941
-7.59802
5.31715
-1.80756
5.5635
-8.54791
7.81696
-3.48152
8.79866
-5.47128
-1.05436
5.89959
1.31359
10.1123
0.150158
-4.66475
-1.93529
3.76741
-1.83212
1.18557
-3.65703
0.110384
2.48204
3.45828
-6.77371
0.0209051
-4.64385
-3.91463
7.96425
5.62471
11.6519
1.24513
9.15348
-1.18923
10.3986
4.19232
4.42904
-3.03534
4.49609
0.965644
4.62997
-0.883301
2.82979
1.67127
1.72989
0.794104
2.30069
1.31932
3.16422
0.0991262
-1.98613
4.64026
-8.63318
-0.986557
-8.08819
1.16027
5.42835
-4.26808
2.91791
-0.755361
1.08579
-0.103294
-1.33987
1.44317
-2.73096
-1.90695
-0.436281
-1.61046
2.32371
1.85566
-1.88743
-0.84353
0.326596
-3.92414
3.23421
-3.08413
-0.59617
6.0781
-2.87505
0.257995
-1.15002
-2.33106
-2.87921
2.75601
6.1746
0.295664
3.11272
5.2
3.10003
0.221822
3.84388
-5.67783
-3.67082
-5.90219
-0.351098
4.52888
1.73514
7.99504
5.81344
4.80509
-1.86294
-10.0647
6.55113
-2.05504
5.20606
-1.15265
-4.94304
5.054
2.3249
-5.68203
0.0432037
-4.89984
-6.95488
-0.482495
8.29946
-9.62976
8.5754
5.70604
1.38592
-4.44303
-0.753735
4.29254
0.136504
10.5351
-0.908362
-7.09826
8.00662
-4.51999
3.53343
0.695595
2.63412
2.13876
1.3834
-5.71486
-9.98294
-2.02624
-1.54304
-4.36561
0.530904
-2.38657
6.08351
-2.55008
3.81739
5.45655
6.54234
-2.05421
-4.16675
6.30336
-2.48597
4.05637
)
;
boundaryField
{
wall-4
{
type calculated;
value uniform 0;
}
velocity-inlet-5
{
type calculated;
value uniform -3.75095;
}
velocity-inlet-6
{
type calculated;
value uniform -5.62643;
}
pressure-outlet-7
{
type calculated;
value nonuniform List<scalar> 8(3.34511 7.76706 4.4097 9.71246 7.42609 5.12514 5.75169 8.97609);
}
wall-8
{
type calculated;
value uniform 0;
}
frontAndBackPlanes
{
type empty;
value nonuniform 0();
}
}
// ************************************************************************* //
|
|
c809598a98f402f1ec1b43f7fb267bb5d35dcd2d
|
109bd8e1774bf490558a771742ed6fff7ac8d813
|
/src/game_api/fmod.hpp
|
048a978c4a23310ac0172291cb5e8f4b6d9e4020
|
[
"MIT",
"Unlicense"
] |
permissive
|
evannoahrp/overlunky
|
d3f5e4bb4ccb616b0a49a82d836f13037d73d2d7
|
d0498347efc0ff8dcba11dafd5bbc61912204f23
|
refs/heads/main
| 2023-08-26T10:37:36.059514
| 2021-10-18T15:25:25
| 2021-10-18T15:25:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,014
|
hpp
|
fmod.hpp
|
#pragma once
#define FMOD_CHECK_CALL(x) \
[](auto err) { \
if (err != FMOD::FMOD_RESULT::OK) \
{ \
DEBUG("{}: {}", #x, FMOD::ErrStr(err)); \
return false; \
} \
return true; \
}((x))
namespace FMOD
{
enum class FMOD_RESULT
{
OK,
ERR_BADCOMMAND,
ERR_CHANNEL_ALLOC,
ERR_CHANNEL_STOLEN,
ERR_DMA,
ERR_DSP_CONNECTION,
ERR_DSP_DONTPROCESS,
ERR_DSP_FORMAT,
ERR_DSP_INUSE,
ERR_DSP_NOTFOUND,
ERR_DSP_RESERVED,
ERR_DSP_SILENCE,
ERR_DSP_TYPE,
ERR_FILE_BAD,
ERR_FILE_COULDNOTSEEK,
ERR_FILE_DISKEJECTED,
ERR_FILE_EOF,
ERR_FILE_ENDOFDATA,
ERR_FILE_NOTFOUND,
ERR_FORMAT,
ERR_HEADER_MISMATCH,
ERR_HTTP,
ERR_HTTP_ACCESS,
ERR_HTTP_PROXY_AUTH,
ERR_HTTP_SERVER_ERROR,
ERR_HTTP_TIMEOUT,
ERR_INITIALIZATION,
ERR_INITIALIZED,
ERR_INTERNAL,
ERR_INVALID_FLOAT,
ERR_INVALID_HANDLE,
ERR_INVALID_PARAM,
ERR_INVALID_POSITION,
ERR_INVALID_SPEAKER,
ERR_INVALID_SYNCPOINT,
ERR_INVALID_THREAD,
ERR_INVALID_VECTOR,
ERR_MAXAUDIBLE,
ERR_MEMORY,
ERR_MEMORY_CANTPOINT,
ERR_NEEDS3D,
ERR_NEEDSHARDWARE,
ERR_NET_CONNECT,
ERR_NET_SOCKET_ERROR,
ERR_NET_URL,
ERR_NET_WOULD_BLOCK,
ERR_NOTREADY,
ERR_OUTPUT_ALLOCATED,
ERR_OUTPUT_CREATEBUFFER,
ERR_OUTPUT_DRIVERCALL,
ERR_OUTPUT_FORMAT,
ERR_OUTPUT_INIT,
ERR_OUTPUT_NODRIVERS,
ERR_PLUGIN,
ERR_PLUGIN_MISSING,
ERR_PLUGIN_RESOURCE,
ERR_PLUGIN_VERSION,
ERR_RECORD,
ERR_REVERB_CHANNELGROUP,
ERR_REVERB_INSTANCE,
ERR_SUBSOUNDS,
ERR_SUBSOUND_ALLOCATED,
ERR_SUBSOUND_CANTMOVE,
ERR_TAGNOTFOUND,
ERR_TOOMANYCHANNELS,
ERR_TRUNCATED,
ERR_UNIMPLEMENTED,
ERR_UNINITIALIZED,
ERR_UNSUPPORTED,
ERR_VERSION,
ERR_EVENT_ALREADY_LOADED,
ERR_EVENT_LIVEUPDATE_BUSY,
ERR_EVENT_LIVEUPDATE_MISMATCH,
ERR_EVENT_LIVEUPDATE_TIMEOUT,
ERR_EVENT_NOTFOUND,
ERR_STUDIO_UNINITIALIZED,
ERR_STUDIO_NOT_LOADED,
ERR_INVALID_STRING,
ERR_ALREADY_LOCKED,
ERR_NOT_LOCKED,
ERR_RECORD_DISCONNECTED,
ERR_TOOMANYSAMPLES
};
inline const char* ErrStr(FMOD_RESULT err)
{
#define ERR_CASE(err_enum) \
case FMOD_RESULT::err_enum: \
return #err_enum
switch (err)
{
ERR_CASE(OK);
ERR_CASE(ERR_BADCOMMAND);
ERR_CASE(ERR_CHANNEL_ALLOC);
ERR_CASE(ERR_CHANNEL_STOLEN);
ERR_CASE(ERR_DMA);
ERR_CASE(ERR_DSP_CONNECTION);
ERR_CASE(ERR_DSP_DONTPROCESS);
ERR_CASE(ERR_DSP_FORMAT);
ERR_CASE(ERR_DSP_INUSE);
ERR_CASE(ERR_DSP_NOTFOUND);
ERR_CASE(ERR_DSP_RESERVED);
ERR_CASE(ERR_DSP_SILENCE);
ERR_CASE(ERR_DSP_TYPE);
ERR_CASE(ERR_FILE_BAD);
ERR_CASE(ERR_FILE_COULDNOTSEEK);
ERR_CASE(ERR_FILE_DISKEJECTED);
ERR_CASE(ERR_FILE_EOF);
ERR_CASE(ERR_FILE_ENDOFDATA);
ERR_CASE(ERR_FILE_NOTFOUND);
ERR_CASE(ERR_FORMAT);
ERR_CASE(ERR_HEADER_MISMATCH);
ERR_CASE(ERR_HTTP);
ERR_CASE(ERR_HTTP_ACCESS);
ERR_CASE(ERR_HTTP_PROXY_AUTH);
ERR_CASE(ERR_HTTP_SERVER_ERROR);
ERR_CASE(ERR_HTTP_TIMEOUT);
ERR_CASE(ERR_INITIALIZATION);
ERR_CASE(ERR_INITIALIZED);
ERR_CASE(ERR_INTERNAL);
ERR_CASE(ERR_INVALID_FLOAT);
ERR_CASE(ERR_INVALID_HANDLE);
ERR_CASE(ERR_INVALID_PARAM);
ERR_CASE(ERR_INVALID_POSITION);
ERR_CASE(ERR_INVALID_SPEAKER);
ERR_CASE(ERR_INVALID_SYNCPOINT);
ERR_CASE(ERR_INVALID_THREAD);
ERR_CASE(ERR_INVALID_VECTOR);
ERR_CASE(ERR_MAXAUDIBLE);
ERR_CASE(ERR_MEMORY);
ERR_CASE(ERR_MEMORY_CANTPOINT);
ERR_CASE(ERR_NEEDS3D);
ERR_CASE(ERR_NEEDSHARDWARE);
ERR_CASE(ERR_NET_CONNECT);
ERR_CASE(ERR_NET_SOCKET_ERROR);
ERR_CASE(ERR_NET_URL);
ERR_CASE(ERR_NET_WOULD_BLOCK);
ERR_CASE(ERR_NOTREADY);
ERR_CASE(ERR_OUTPUT_ALLOCATED);
ERR_CASE(ERR_OUTPUT_CREATEBUFFER);
ERR_CASE(ERR_OUTPUT_DRIVERCALL);
ERR_CASE(ERR_OUTPUT_FORMAT);
ERR_CASE(ERR_OUTPUT_INIT);
ERR_CASE(ERR_OUTPUT_NODRIVERS);
ERR_CASE(ERR_PLUGIN);
ERR_CASE(ERR_PLUGIN_MISSING);
ERR_CASE(ERR_PLUGIN_RESOURCE);
ERR_CASE(ERR_PLUGIN_VERSION);
ERR_CASE(ERR_RECORD);
ERR_CASE(ERR_REVERB_CHANNELGROUP);
ERR_CASE(ERR_REVERB_INSTANCE);
ERR_CASE(ERR_SUBSOUNDS);
ERR_CASE(ERR_SUBSOUND_ALLOCATED);
ERR_CASE(ERR_SUBSOUND_CANTMOVE);
ERR_CASE(ERR_TAGNOTFOUND);
ERR_CASE(ERR_TOOMANYCHANNELS);
ERR_CASE(ERR_TRUNCATED);
ERR_CASE(ERR_UNIMPLEMENTED);
ERR_CASE(ERR_UNINITIALIZED);
ERR_CASE(ERR_UNSUPPORTED);
ERR_CASE(ERR_VERSION);
ERR_CASE(ERR_EVENT_ALREADY_LOADED);
ERR_CASE(ERR_EVENT_LIVEUPDATE_BUSY);
ERR_CASE(ERR_EVENT_LIVEUPDATE_MISMATCH);
ERR_CASE(ERR_EVENT_LIVEUPDATE_TIMEOUT);
ERR_CASE(ERR_EVENT_NOTFOUND);
ERR_CASE(ERR_STUDIO_UNINITIALIZED);
ERR_CASE(ERR_STUDIO_NOT_LOADED);
ERR_CASE(ERR_INVALID_STRING);
ERR_CASE(ERR_ALREADY_LOCKED);
ERR_CASE(ERR_NOT_LOCKED);
ERR_CASE(ERR_RECORD_DISCONNECTED);
ERR_CASE(ERR_TOOMANYSAMPLES);
}
#undef ERR_CASE
return "UNKNONW";
}
enum class FMOD_MODE : std::uint32_t
{
MODE_DEFAULT = 0x00000000,
MODE_LOOP_OFF = 0x00000001,
MODE_LOOP_NORMAL = 0x00000002,
MODE_LOOP_BIDI = 0x00000004,
MODE_2D = 0x00000008,
MODE_3D = 0x00000010,
MODE_CREATESTREAM = 0x00000080,
MODE_CREATESAMPLE = 0x00000100,
MODE_CREATECOMPRESSEDSAMPLE = 0x00000200,
MODE_OPENUSER = 0x00000400,
MODE_OPENMEMORY = 0x00000800,
MODE_OPENMEMORY_POINT = 0x10000000,
MODE_OPENRAW = 0x00001000,
MODE_OPENONLY = 0x00002000,
MODE_ACCURATETIME = 0x00004000,
MODE_MPEGSEARCH = 0x00008000,
MODE_NONBLOCKING = 0x00010000,
MODE_UNIQUE = 0x00020000,
MODE_3D_HEADRELATIVE = 0x00040000,
MODE_3D_WORLDRELATIVE = 0x00080000,
MODE_3D_INVERSEROLLOFF = 0x00100000,
MODE_3D_LINEARROLLOFF = 0x00200000,
MODE_3D_LINEARSQUAREROLLOFF = 0x00400000,
MODE_3D_INVERSETAPEREDROLLOFF = 0x00800000,
MODE_3D_CUSTOMROLLOFF = 0x04000000,
MODE_3D_IGNOREGEOMETRY = 0x40000000,
MODE_IGNORETAGS = 0x02000000,
MODE_LOWMEM = 0x08000000,
MODE_VIRTUAL_PLAYFROMSTART = 0x80000000
};
enum class SOUND_FORMAT
{
NONE,
PCM8,
PCM16,
PCM24,
PCM32,
PCMFLOAT,
BITSTREAM,
MAX
};
enum class CHANNELORDER : int
{
DEFAULT,
WAVEFORMAT,
PROTOOLS,
ALLMONO,
ALLSTEREO,
ALSA,
MAX,
};
enum class SOUND_TYPE
{
UNKNOWN,
AIFF,
ASF,
DLS,
FLAC,
FSB,
IT,
MIDI,
MOD,
MPEG,
OGGVORBIS,
PLAYLIST,
RAW,
S3M,
USER,
WAV,
XM,
XMA,
AUDIOQUEUE,
AT9,
VORBIS,
MEDIA_FOUNDATION,
MEDIACODEC,
FADPCM,
OPUS,
MAX,
};
enum class TIMEUNIT : std::uint32_t
{
MS = 0x00000001,
PCM = 0x00000002,
PCMBYTES = 0x00000004,
RAWBYTES = 0x00000008,
PCMFRACTION = 0x00000010,
MODORDER = 0x00000100,
MODROW = 0x00000200,
MODPATTERN = 0x00000400,
};
struct CREATESOUNDEXINFO
{
int cbsize;
std::uint32_t length;
std::uint32_t fileoffset;
int numchannels;
int defaultfrequency;
SOUND_FORMAT format;
std::uint32_t decodebuffersize;
int initialsubsound;
int numsubsounds;
std::intptr_t inclusionlist;
int inclusionlistnum;
void* pcmreadcallback;
void* pcmsetposcallback;
void* nonblockcallback;
std::intptr_t dlsname;
std::intptr_t encryptionkey;
int maxpolyphony;
std::intptr_t userdata;
SOUND_TYPE suggestedsoundtype;
void* fileuseropen;
void* fileuserclose;
void* fileuserread;
void* fileuserseek;
void* fileuserasyncread;
void* fileuserasynccancel;
std::intptr_t fileuserdata;
int filebuffersize;
CHANNELORDER channelorder;
std::intptr_t initialsoundgroup;
std::uint32_t initialseekposition;
TIMEUNIT initialseekpostype;
int ignoresetfilesystem;
std::uint32_t audioqueuepolicy;
std::uint32_t minmidigranularity;
int nonblockthreadid;
std::intptr_t fsbguid;
};
enum class ChannelControlType
{
Channel,
ChannelGroup
};
enum class ChannelControlCallbackType
{
End,
VirtualVoice,
SyncPoint,
Occlusion
};
using BOOL = int;
template <class tag>
struct tagged_void
{
};
using System = tagged_void<struct system_tag>;
using Bank = tagged_void<struct bank_tag>;
using Sound = tagged_void<struct sound_tag>;
using Channel = tagged_void<struct channel_tag>;
using ChannelGroup = tagged_void<struct channel_group_tag>;
using ChannelControl = tagged_void<struct channel_control_tag>; // Either a Channel or a ChannelGroup
using CreateSound = FMOD_RESULT(System*, const char*, FMOD_MODE, CREATESOUNDEXINFO*, Sound**);
using ReleaseSound = FMOD_RESULT(Sound*);
using PlaySound = FMOD_RESULT(System*, Sound*, ChannelGroup*, bool, Channel**);
using ChannelControlCallback = FMOD_RESULT(ChannelControl*, ChannelControlType, ChannelControlCallbackType, void*, void*);
using ChannelIsPlaying = FMOD_RESULT(Channel*, BOOL*);
using ChannelStop = FMOD_RESULT(Channel*);
using ChannelSetPaused = FMOD_RESULT(Channel*, BOOL);
using ChannelSetMute = FMOD_RESULT(Channel*, BOOL);
using ChannelSetPitch = FMOD_RESULT(Channel*, float);
using ChannelSetPan = FMOD_RESULT(Channel*, float);
using ChannelSetVolume = FMOD_RESULT(Channel*, float);
using ChannelSetFrequency = FMOD_RESULT(Channel*, float);
using ChannelSetMode = FMOD_RESULT(Channel*, FMOD_MODE);
using ChannelSetCallback = FMOD_RESULT(Channel*, ChannelControlCallback*);
using ChannelSetUserData = FMOD_RESULT(Channel*, void*);
using ChannelGetUserData = FMOD_RESULT(Channel*, void**);
using ChannelGetChannelGroup = FMOD_RESULT(Channel*, ChannelGroup**);
} // namespace FMOD
namespace FMODStudio
{
using namespace FMOD;
enum StopMode
{
AllowFadeOut,
Immediate
};
enum EventCallbackType
{
Created = 0x00000001,
Destroyed = 0x00000002,
Starting = 0x00000004,
Started = 0x00000008,
Restarted = 0x00000010,
Stopped = 0x00000020,
StartFailed = 0x00000040,
CreateProgrammerSound = 0x00000080,
DestroyProgrammerSound = 0x00000100,
PluginCreated = 0x00000200,
PluginDestroyed = 0x00000400,
TimelineMarker = 0x00000800,
TimelineBeat = 0x00001000,
SoundPlayed = 0x00002000,
SoundStopped = 0x00004000,
RealToVirtal = 0x00008000,
VirtualToReal = 0x00010000,
All = 0xFFFFFFFF,
Num = 17
};
enum class PlaybackState
{
Playing,
Sustaining,
Stopped,
Starting,
Stopping
};
enum class ParameterType
{
GameControlled,
AutomaticDistance,
AutomaticEventConeAngle,
AutomaticEventOrientation,
AutomaticDirection,
AutomaticElevation,
AutomaticListenerOrientation,
AutomaticSpeed,
};
enum class ParameterFlags
{
ReadOnly = 0x00000001,
Automatic = 0x00000002,
Global = 0x00000004,
};
struct ParameterId
{
uint32_t data1;
uint32_t data2;
};
struct ParameterDescription
{
const char* name;
ParameterId id;
float minimum;
float maximum;
float defaultvalue;
ParameterType type;
ParameterFlags flags;
};
using System = tagged_void<struct system_tag>;
using Bus = tagged_void<struct bus_tag>;
using EventDescription = tagged_void<struct event_description_tag>;
using EventInstance = tagged_void<struct event_instance_tag>;
using GetCoreSystem = FMOD_RESULT(System*, FMOD::System**);
using FlushCommands = FMOD_RESULT(System*);
using GetBus = FMOD_RESULT(System*, const char*, Bus**);
using LockChannelGroup = FMOD_RESULT(Bus*);
using GetChannelGroup = FMOD_RESULT(Bus*, ChannelGroup**);
using EventInstanceCallback = FMOD_RESULT(EventCallbackType, EventInstance*, void*);
using EventDescriptionCreateInstance = FMOD_RESULT(EventDescription*, EventInstance**);
using EventDescriptionGetParameterDescriptionByID = FMOD_RESULT(EventDescription*, ParameterId, ParameterDescription*);
using EventDescriptionGetParameterDescriptionByName = FMOD_RESULT(EventDescription*, const char*, ParameterDescription*);
using EventDescriptionSetCallback = FMOD_RESULT(EventDescription*, EventInstanceCallback*, EventCallbackType);
using EventInstanceStart = FMOD_RESULT(EventInstance*);
using EventInstanceStop = FMOD_RESULT(EventInstance*, StopMode);
using EventInstanceGetPlaybackState = FMOD_RESULT(EventInstance*, PlaybackState*);
// using EventInstanceIsPlaying = FMOD_RESULT(EventInstance*, BOOL*);
using EventInstanceSetPaused = FMOD_RESULT(EventInstance*, BOOL);
using EventInstanceGetPaused = FMOD_RESULT(EventInstance*, BOOL*);
// using EventInstanceSetMute = FMOD_RESULT(EventInstance*, BOOL);
using EventInstanceSetPitch = FMOD_RESULT(EventInstance*, float);
// using EventInstanceSetPan = FMOD_RESULT(EventInstance*, float);
using EventInstanceSetVolume = FMOD_RESULT(EventInstance*, float);
// using EventInstanceSetFrequency = FMOD_RESULT(EventInstance*, float);
// using EventInstanceSetMode = FMOD_RESULT(EventInstance*, FMOD_MODE);
using EventInstanceSetCallback = FMOD_RESULT(EventInstance*, EventInstanceCallback*, EventCallbackType);
using EventInstanceSetUserData = FMOD_RESULT(EventInstance*, void*);
using EventInstanceGetUserData = FMOD_RESULT(EventInstance*, void**);
using EventInstanceGetDescription = FMOD_RESULT(EventInstance*, EventDescription**);
using EventInstanceGetParameterByID = FMOD_RESULT(EventInstance*, ParameterId, float*, float*);
using EventInstanceSetParameterByID = FMOD_RESULT(EventInstance*, ParameterId, float, bool);
} // namespace FMODStudio
|
beea7396a264dc92c6ecf11dc7f6493fdb485c7e
|
a83913ffec0267d35b003597a186733c26df89a9
|
/kernel/util/string.cpp
|
1de5ffa051c5fe969516c45267bb3fa886d5e7dd
|
[] |
no_license
|
zuban32/proj
|
8aa61c15b1095c4fb4fcae13e6de6bccf3a493f9
|
8dbb63bb494706e06dc6d75d222c305473a686fd
|
refs/heads/master
| 2020-05-21T04:42:09.026668
| 2017-10-01T22:10:48
| 2017-10-01T22:10:48
| 24,896,402
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,077
|
cpp
|
string.cpp
|
#include <util/string.h>
#include <console.h>
#include <util/port.h>
int kisspace(const char c)
{
return (c == ' ' || c == '\n');
}
int kisdigit(const char c)
{
return (c >= '0' && c <= '9');
}
int kisletter(const char c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
int kstrlen(const char *s)
{
const char *s0 = s;
while(*s++);
return s - s0;
}
int kstrcmp(const char *s1, const char *s2)
{
while (*s1 == *s2 && *s1 && *s2 && !kisspace(*s1) && !kisspace(*s2))
s1++, s2++;
return *s1 - *s2;
}
void kmemset(void *s0, int val, uint32_t size)
{
const char *s = (char *) s0 + size;
char *s1 = (char *)s0;
while (s1 < s)
*s1++ = val;
}
void kmemcpy(char *dest, char *src, int size)
{
char *end = src + size;
while(src < end) {
*dest++ = *src++;
}
}
uint32_t kstoi(const char *s)
{
// kprintf(1, "kstoi started: %s\n", s);
const char *str = s;
while (*str++)
;
str -= 2;
uint32_t res = 0;
uint32_t mult = 1;
while (str >= s) {
res += mult * (*str-- - '0');
mult *= 10;
}
// kprintf(1, "%s -> %d\n", s, res);
return res;
}
|
27bcb4ebba38f44735777f419fb917c51dada87e
|
d8279850a32ee519717876051d73ce1a935bb2b5
|
/CppMultiThreadCourse/CppMultiThreadCourse/CppMultiThreadCourse3.cpp
|
f992792366c801ead2d512b05f629dc95e1eddb9
|
[] |
no_license
|
GitGaryHuang/CppLearning
|
994d9458b2af92da6c6e1e00b8c477cedfc57c10
|
64b9cc66c194b9f4626a5a5ef2795ccf1dad6e02
|
refs/heads/master
| 2020-05-03T19:38:31.137640
| 2019-05-01T06:14:01
| 2019-05-01T06:14:01
| 178,787,866
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 4,713
|
cpp
|
CppMultiThreadCourse3.cpp
|
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<thread>
using namespace std;
//
//void myprint(const int &i, char *pmybuf)
//{
// cout << i << endl; //分析认为,此处i并非主线程中的mvar引用,实际是值传递,但即便主线程detach了子线程,那么子线程的i值仍然是安全的。
// cout << pmybuf << endl;//指针在detach子线程时绝对会有问题
// return;
//}
//class A
//{
//public :
// int m_i;
// //类型转换构造函数(因为这个类只有一个参数)
// A(int a) : m_i(a) { cout << "[A::A(int a)构造函数执行]" << this << " thread id = " << this_thread::get_id() << endl; }
// A(const A &a) : m_i(a.m_i) { cout << "[A::A(const A& a)拷贝构造函数执行]" << this << " thread id = " << this_thread::get_id() << endl; }
// ~A() { cout << "[A::~A()析构函数执行]" << this << " thread id = " << this_thread::get_id() << endl; }
//
// void thread_work(int num)
// {
// ;
// }
// void operator()(int num)
// {
// cout << " thread id = " << this_thread::get_id() << endl;
// }
//};
//
////void myprint(const int i, const string &pmybuf)
////{
//// cout << i << endl;
//// cout << pmybuf.c_str() << endl;
//// return;
////}
//
////void myprint(const int i, const A& pmybuf)
////{
//// cout << &pmybuf << endl;
//// return;
////}
//
////void myprint2(const A& pmybuf) //虽然用引用,但实际是拷贝构造了一个类对象,除非使用ref
////{
//// pmybuf.m_i = 199; //修改该值不会影响main函数
//// cout << "子线程2的参数地址是:" << &pmybuf << " thread id = " << this_thread::get_id() << endl;
////}
//
//void myprint3(unique_ptr<int> pzn) //虽然用引用,但实际是拷贝构造了一个类对象,除非使用ref
//{
// ;
//}
//
//int main()
//{
// //一:传递临时对象作为线程参数
// //(1.1)要避免的仙境(解释1)
// //(1.2)要避免的仙境(解释2)
// //事实1:只要用临时构造的A类对象作为参数传递给线程,那么在一定能在主线程执行完毕前,把线程函数的第二个参数构造出来,从而确保即便detach了,子线程也能安全运行。
// //(1.3)总结:
// //a)若传递int这种简单类型,建议都是值传递,不要用引用,防止节外生枝(detach中)。
// //b)如果传递类对象,避免隐式类型转换。全部都在创建线程这一行中构建出临时对象,然后在函数参数里,用引用来接受,否则系统还会构造出一次对象
// //终极结论:
// //c)建议不使用detach() 只是用join(),这样就不存在局部变量失效,导致线程对内存的非法引用问题
//
// //二、临时对象作为线程参数继续讲。
// //(2.1)线程id概念:id是个数字,每个线程(不管是主线程还是子线程)实际上都对应着一个数字。
// //也就是说不同线程对应的ID(数字)是不同的
// //线程id可以用c++标准库里的函数来获取。
// //(2.2)临时对象构造时机抓捕
//
// //三、传递类对象、智能指针为线程参数
// //std::ref函数
//
// //四、用成员函数指针做线程参数
// //int mvar = 1;
// //int &myvary = mvar;
// //char mybuf[] = "this is a test!";
//
// //thread mytobj(myprint, mvar, mybuf);//mybuf什么时候被转成string
// // //事实上存在当mybuf被回收后,系统才试图将mybuf转成string
// ////mytobj.join();
// //thread mytobj(myprint, mvar, string(mybuf)); //在这里先将mybuf转为string临时对象,可以保证在一个线程里用肯定有效
//
// /*int mvar = 1;
// int mysecondpar = 12;*/
// //thread mytobj(myprint, mvar, mysecondpar); //我们希望mysecondpar转成A类型对象传递给myprint的第二个参数
// //thread mytobj(myprint2, A(mysecondpar)); //在创建线程的同时构造临时对象的方法传递参数是可行的 (thread构造函数将带引用的全部整成复制构造)
// //mytobj.join();
// //mytobj.join(); //子线程与主线程分别执行
//
// cout << "主线程ID:" << this_thread::get_id() << endl;
// //int mvar = 1;
// //thread mytobj(myprint2, A(mvar));//用了临时对象后,所有的A类对象都在main()函数中已经构建完毕了,否则会到子线程中构建
// //mytobj.detach();
// //cout << "I LOVE CHINA!" << endl;
//
// //A myobj(10); //生成一个类对象
// //thread mytobj(myprint2, ref(myobj));
// //mytobj.join();
// //unique_ptr<int> myp(new int(100));
// //thread mytobj(myprint3, move(myp));
// //A myobj(10);
// //thread mytobj(&A::thread_work, myobj, 15);
// //mytobj.join();
// A myobj(10);
// thread mytobj(ref(myobj), 15);
// mytobj.join();
// //while (1)
// //{
// // ;
// //}
// return 0;
//}
|
02ac7dbd204195fa2690eaa00e6f8407d1730296
|
d444e71bfde74e160a5b032f716f5784f232fa71
|
/SimpleDCTParallelCodec/SimpleDCTParallelCodec/SimpleDCTDec.h
|
8a1377ad3313230672e6e43ffd5e351b21173187
|
[] |
no_license
|
thejasper/Parallel-DXT-Compressor
|
44e52601eb442ffeb4419f9e8eeac628dbe2c96a
|
698a01d7b7fb916299721fde1bd1b08c1c25a773
|
refs/heads/master
| 2020-05-30T14:40:45.411886
| 2013-01-04T11:02:50
| 2013-01-04T11:02:50
| 6,825,017
| 1
| 2
| null | 2012-11-29T16:00:48
| 2012-11-23T09:25:14
|
C++
|
UTF-8
|
C++
| false
| false
| 3,432
|
h
|
SimpleDCTDec.h
|
/**
*
* This software module was originally developed for research purposes,
* by Multimedia Lab at Ghent University (Belgium).
* Its performance may not be optimized for specific applications.
*
* Those intending to use this software module in hardware or software products
* are advized that its use may infringe existing patents. The developers of
* this software module, their companies, Ghent Universtity, nor Multimedia Lab
* have any liability for use of this software module or modifications thereof.
*
* Ghent University and Multimedia Lab (Belgium) retain full right to modify and
* use the code for their own purpose, assign or donate the code to a third
* party, and to inhibit third parties from using the code for their products.
*
* This copyright notice must be included in all copies or derivative works.
*
* For information on its use, applications and associated permission for use,
* please contact Prof. Rik Van de Walle (rik.vandewalle@ugent.be).
*
* Detailed information on the activities of
* Ghent University Multimedia Lab can be found at
* http://multimedialab.elis.ugent.be/.
*
* Copyright (c) Ghent University 2004-2009.
*
**/
/* Based on code by Tony Lin, which is based on code by the IJG
http://www.codeproject.com/KB/graphics/tonyjpeglib.aspx
*/
class SimpleDCTDec {
unsigned short quality, scale;
// To speed up, we precompute two DCT quant tables
unsigned short qtblY[64], qtblCoCg[64];
// Derived data constructed for each Huffman table
typedef struct {
int mincode[17]; // smallest code of length k
int maxcode[18]; // largest code of length k (-1 if none)
int valptr[17]; // huffval[] index of 1st symbol of length k
unsigned char bits[17]; // bits[k] = # of symbols with codes of
unsigned char huffval[256]; // The symbols, in order of incr code length
int look_nbits[256];// # bits, or 0 if too long
unsigned char look_sym[256]; // symbol, or unused
} HUFFTABLE;
HUFFTABLE htblYDC, htblYAC, htblCoCgDC, htblCoCgAC;
unsigned short width, height;
int dcY, dcCo, dcCg, dcA;
int nGetBits, nGetBuff, nDataBytes;
unsigned char * pData;
void scaleQuantTable(unsigned short* tblRst, unsigned short* tblStd, unsigned short* tblAan);
void initHuffmanTables(void);
void computeHuffmanTable(unsigned char * pBits, unsigned char * pVal, HUFFTABLE * dtbl);
bool decompressOneTile(unsigned char *rgba);
void inverseDct(short* coef, unsigned char* data, int nBlock);
void huffmanDecode(short* coef, int iBlock);
int getCategory( HUFFTABLE* htbl );
void fillBitBuffer( void );
int getBits(int nbits);
int specialDecode( HUFFTABLE* htbl, int nMinBits );
int valueFromCategory(int nCate, int nOffset);
static void YCoCgAToRGBA(unsigned char * yCoCgA, unsigned char * rgba);
static void YCoCgAToYCoCgA(unsigned char * pYCoCgA, unsigned char * out );
void (*colorConverter)(unsigned char * pYCoCgA, unsigned char * out );
public:
SimpleDCTDec(int quality = 50);
~SimpleDCTDec();
//Set the quality the next decompress call will use...
//you can call this once for a number of decomrpess calls to
//gain some speed.
void setQuality(int quality);
enum ColorSpace {
CS_RGBA,
CS_YCOCGA
};
void setColorSpace(ColorSpace cs);
bool decompress(unsigned char *dest, unsigned char *source, int width, int height, int compressedSize);
};
|
3c138b4c1e536c432e38be83a39f7780895a3107
|
4f5691998e1e55451b17fe6c0d35f294cc38c405
|
/LinkedRawList.hpp
|
6900c4e437912fd5bb4295ea183346114e65b922
|
[
"BSD-3-Clause"
] |
permissive
|
PankeyCR/aMonkeyEngine
|
9bb3c3f89ec9cab2a181f3cfd43d89f379a39124
|
a5fb3f7f73f51b17cfe90f6fc26c529b7e8e6c2d
|
refs/heads/master
| 2023-06-22T01:36:55.745033
| 2023-06-15T22:03:09
| 2023-06-15T22:03:09
| 198,529,019
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,603
|
hpp
|
LinkedRawList.hpp
|
#ifndef LinkedRawList_hpp
#define LinkedRawList_hpp
#define LinkedRawList_AVAILABLE
#include "RawList.hpp"
#include "LinkedRawPointerList.hpp"
#include "LinkedListNode.hpp"
#include "LinkedIterator.hpp"
#ifdef LinkedRawList_LogApp
#include "ame_Logger_config.hpp"
#include "ame_Logger.hpp"
#define LinkedRawListLog(location,method,type,mns) ame_Log(this,location,"LinkedRawList",method,type,mns)
#define const_LinkedRawListLog(location,method,type,mns)
#else
#ifdef LinkedRawList_LogDebugApp
#include "ame_Logger_config.hpp"
#include "ame_Logger.hpp"
#define LinkedRawListLog(location,method,type,mns) ame_LogDebug(this,location,"LinkedRawList",method,type)
#define const_LinkedRawListLog(location,method,type,mns)
#else
#define LinkedRawListLog(location,method,type,mns)
#define const_LinkedRawListLog(location,method,type,mns)
#endif
#endif
namespace ame{
template<class T>
class LinkedRawList : public LinkedRawPointerList<T>, virtual public RawList<T>{
public:
LinkedRawList<T>(){}
LinkedRawList<T>(const LinkedRawList<T>& c_list){
LinkedListNode<T>* c_node = c_list.getStartNode();
if(c_node == nullptr){
return;
}
for(int x=0; x < c_list.getPosition(); x++){
T* f_value = c_node->get();
if(f_value == nullptr){
c_node = c_list.getNextNode(c_node);
continue;
}
this->addLValue(*f_value);
c_node = c_list.getNextNode(c_node);
}
}
virtual ~LinkedRawList<T>(){}
virtual LinkedListNode<T>* getNodeByLValue(T key) const{
const_LinkedRawListLog(ame_Log_StartMethod, "getNodeByLValue", "println", "");
LinkedListNode<T>* node = this->getStartNode();
for(int count = 0; node != nullptr; count++){
T* i_value = node->get();
if(i_value == nullptr){
node = this->getNextNode(node);
continue;
}
if(key == *i_value){
return node;
}
node = this->getNextNode(node);
}
const_LinkedRawListLog(ame_Log_EndMethod, "getNodeByLValue", "println", "");
return nullptr;
}
virtual LinkedListNode<T>* getNodeByLValueI(T key) const{
const_LinkedRawListLog(ame_Log_StartMethod, "getNodeByLValueI", "println", "");
LinkedListNode<T>* node = this->getEndNode();
for(int count = 0; node != nullptr; count++){
T* i_value = node->get();
if(i_value == nullptr){
node = this->getLastNode(node);
continue;
}
if(key == *i_value){
return node;
}
node = this->getLastNode(node);
}
const_LinkedRawListLog(ame_Log_EndMethod, "getNodeByLValueI", "println", "");
return nullptr;
}
virtual T* addLValue(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "addLValue", "println", "");
T* i_value = new T();
*i_value = a_value;
LinkedRawListLog(ame_Log_EndMethod, "addLValue", "println", "");
return this->addPointerToEndNode(i_value);
}
virtual T* setLValue(int a_position, T a_value){
LinkedRawListLog(ame_Log_StartMethod, "setLValue", "println", "");
T* i_value = new T();
*i_value = a_value;
LinkedRawListLog(ame_Log_EndMethod, "setLValue", "println", "");
return this->setPointer(a_position, i_value);
}
virtual T* insertLValue(int a_position, T a_value){
LinkedRawListLog(ame_Log_StartMethod, "insertLValue", "println", "");
T* i_value = new T();
*i_value = a_value;
LinkedRawListLog(ame_Log_EndMethod, "insertLValue", "println", "");
return this->insertPointer(a_position, i_value);
}
virtual T* getByLValue(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "getByLValue", "println", "");
LinkedListNode<T>* i_node = this->getNodeByLValue(a_value);
if(i_node == nullptr){
return nullptr;
}
LinkedRawListLog(ame_Log_EndMethod, "getByLValue", "println", "");
return i_node->get();
}
virtual bool containByLValue(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "containByLValue", "println", "");
LinkedListNode<T>* i_node = this->getNodeByLValue(a_value);
if(i_node == nullptr){
return false;
}
LinkedRawPointerListLog(ame_Log_EndMethod, "containByLValue", "println", "");
return true;
}
virtual int getIndexByLValue(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "getIndexByLValue", "println", "");
LinkedListNode<T>* node = this->getStartNode();
for(int count = 0; node != nullptr; count++){
T* i_value = node->get();
if(i_value == nullptr){
node = this->getNextNode(node);
continue;
}
if(a_value == *i_value){
return count;
}
node = this->getNextNode(node);
}
LinkedRawListLog(ame_Log_EndMethod, "getIndexByLValue", "println", "");
return -1;
}
virtual T* removeByLValue(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "removeByLValue", "println", "");
LinkedListNode<T>* i_node = this->getNodeByLValue(a_value);
if(i_node == nullptr){
return nullptr;
}
T* i_value = i_node->get();
i_node->set(nullptr);
if(!this->isInOrder()){
LinkedRawPointerListLog(ame_Log_EndMethod, "removeByPosition", "println", "!this->isInOrder()");
return i_value;
}
i_node->removeNode();
delete i_node;
this->decrementPosition();
this->decrementSize();
LinkedRawListLog(ame_Log_EndMethod, "removeByLValue", "println", "");
return i_value;
}
virtual bool removeAll(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "removeAll", "println", "");
LinkedListNode<T>* node = this->getStartNode();
int count = 0;
for( ; node != nullptr; count++){
T* i_value = node->get();
if(i_value == nullptr){
node = this->getNextNode(node);
continue;
}
if(a_value == *i_value){
node->set(nullptr);
if(this->isInOrder()){
node->removeNode();
if(this->isOwner()){
delete i_value;
}
delete node;
}
}
node = this->getNextNode(node);
}
this->decrementPosition(count);
this->decrementSize(count);
LinkedRawListLog(ame_Log_EndMethod, "removeAll", "println", "");
return -1;
}
virtual bool removeFirst(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "removeFirst", "println", "");
LinkedRawListLog(ame_Log_EndMethod, "removeFirst", "println", "");
return this->removeDeleteByLValue(a_value);
}
virtual bool removeLast(T a_value){
LinkedRawListLog(ame_Log_StartMethod, "removeLast", "println", "");
LinkedListNode<T>* i_node = this->getNodeByLValueI(a_value);
if(i_node == nullptr){
return false;
}
T* i_value = i_node->get();
i_node->set(nullptr);
if(!this->isInOrder()){
LinkedRawPointerListLog(ame_Log_EndMethod, "removeLast", "println", "!this->isInOrder()");
return i_value;
}
i_node->removeNode();
if(this->isOwner() && i_value != nullptr){
delete i_value;
}
delete i_node;
this->decrementPosition();
this->decrementSize();
LinkedRawListLog(ame_Log_EndMethod, "removeLast", "println", "");
return true;
}
virtual T& operator[](int x){
LinkedRawListLog(ame_Log_StartMethod, "operator[]", "println", "");
LinkedRawListLog(ame_Log_EndMethod, "operator[]", "println", "");
return *this->getByPosition(x);
}
virtual LinkedIterator<T> begin(){
LinkedRawListLog(ame_Log_StartMethod, "begin", "println", "");
LinkedRawListLog(ame_Log_EndMethod, "begin", "println", "");
return LinkedIterator<T>(this->getStartNode(),0);
}
virtual LinkedIterator<T> end(){
LinkedRawListLog(ame_Log_StartMethod, "end", "println", "");
LinkedRawListLog(ame_Log_EndMethod, "end", "println", this->getPosition());
return LinkedIterator<T>(this->getStartNode(), this->getPosition());
}
};
}
#endif
|
8af1f35e01732136849fd81dfedd0a48851aceb0
|
c094d381422c2788d67a3402cff047b464bf207b
|
/c++_primer_plus/c++_primer_plus/p048cout.put().cpp
|
a192c0c83415cda5d80617a5104af5a83b24d210
|
[] |
no_license
|
liuxuanhai/C-code
|
cba822c099fd4541f31001f73ccda0f75c6d9734
|
8bfeab60ee2f8133593e6aabfeefaf048357a897
|
refs/heads/master
| 2020-04-18T04:26:33.246444
| 2016-09-05T08:32:33
| 2016-09-05T08:32:33
| 67,192,848
| 1
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,055
|
cpp
|
p048cout.put().cpp
|
// 程序清单 3.6
// cout.put();和cout对字符的识别输出
#include <iostream>
int main()
{
using namespace std;
char ch = 'M';
int i = ch;
cout << ch << "的ascll编码为: " << i << endl;
cout << "加上一以后:" << endl;
ch = ch + 1;
i = ch;
cout << ch << "的ascll编码为: " << i << endl;
cout << "使用cout.put()函数输出字符:" << endl;
cout.put(ch); // 句点被称为成员运算符
cout.put('|');
cout << endl << "---------" << 'm' << "-------------" << endl;
// 此时输出的是'm'而不是m的asill码的值, 但是早期的c把'm'常量储存在
// int中, 对于cout来说, 他只认识8位的char而不认识32位的int, 所以他把他当做int输出而不是当早
// 字符输出, 所有就诞生了cout.put(), 但是后来的c都实现了把字符常量m储存在char当中, 所以即使
// 不用cout.put()也能输出了
cout << sizeof('m') << endl;
cout << endl << "Done!" << endl;
// cout << "Let them eat g\u00E2teau." << endl;
// 查看是否支持拓展字符集 不支持
return 0;
}
|
e32730186cd24b5efc6bbb41a271ddcf13399e6a
|
98a28d1727be1ad2cdc60aa08e6c1a48c42c950b
|
/source/utilities/thread_pool.hpp
|
0720fdce0c8c399872109a5d3795d1f4f3150939
|
[
"BSD-3-Clause"
] |
permissive
|
coder0xff/Plange
|
154b926fa9be2bf52d3575272548cedd7e3cb9f3
|
26535f6c72d7ab0aaf753218ddbf3f4ad16283f7
|
refs/heads/master
| 2021-01-24T06:02:47.900282
| 2020-06-08T16:02:34
| 2020-06-08T16:02:34
| 45,961,377
| 16
| 5
|
BSD-3-Clause
| 2018-11-06T00:40:22
| 2015-11-11T05:17:50
|
C++
|
UTF-8
|
C++
| false
| false
| 1,200
|
hpp
|
thread_pool.hpp
|
#ifndef INCLUDED_UTILITIES_THREAD_POOL_HPP
#define INCLUDED_UTILITIES_THREAD_POOL_HPP
#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
#include "wait_flag.hpp"
class thread_pool {
public:
static thread_pool & default_pool();
explicit thread_pool(size_t threadCount = std::thread::hardware_concurrency());
~thread_pool();
private:
struct work_item {
work_item(std::function<void(void *)> const & f, void * const data);
std::function<void(void *)> const f;
void * const data;
wait_flag w;
};
public:
class work_handle {
std::shared_ptr<work_item> item;
explicit work_handle(std::shared_ptr<work_item> const & item) : item(item) {}
friend class thread_pool;
public:
void wait() const {
item->w();
}
};
work_handle schedule(std::function<void(void *)> const & f, void * const userData = nullptr);
std::vector<std::thread> threads;
std::queue<std::shared_ptr<work_item>> queue;
std::mutex m;
std::condition_variable cv;
std::atomic<size_t> handle_counter = 0;
std::atomic<bool> destructing = false;
void thread_loop();
};
#endif // INCLUDED_UTILITIES_THREAD_POOL_HPP
|
cb2c6465c97a6bc722f149e920b6768f2742e22d
|
4352b5c9e6719d762e6a80e7a7799630d819bca3
|
/tutorials/oldd/Basic-Dynamic-Mesh-Tutorial-OpenFoam/TUT16rotating/2.82/epsilon
|
e398a9316cb8aa87af1ed2e2c77f4012456d3766
|
[] |
no_license
|
dashqua/epicProject
|
d6214b57c545110d08ad053e68bc095f1d4dc725
|
54afca50a61c20c541ef43e3d96408ef72f0bcbc
|
refs/heads/master
| 2022-02-28T17:20:20.291864
| 2019-10-28T13:33:16
| 2019-10-28T13:33:16
| 184,294,390
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 44,104
|
epsilon
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "2.82";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField nonuniform List<scalar>
4214
(
0.161451
0.0679357
0.0358677
0.0293553
0.0437532
0.0920243
0.19889
0.390275
0.675752
1.03484
1.42008
1.79242
2.10769
2.34697
2.52653
2.64458
2.71103
2.7531
2.79828
2.85707
2.91639
2.95095
2.95574
2.97473
3.2227
3.67734
3.87595
3.45392
2.49162
1.49074
0.779172
0.362375
0.157843
0.0684208
0.0323003
0.0187172
0.0146799
0.0159907
0.02379
0.0464523
0.111637
0.0316836
0.0207692
0.0194485
0.0294663
0.0652536
0.157825
0.348658
0.668454
1.10959
1.6172
2.12335
2.57226
2.93295
3.19796
3.37898
3.5106
3.64173
3.79808
3.96644
4.09704
4.12066
4.00769
3.80945
3.70645
3.83931
4.05296
4.01246
3.43951
2.45901
1.48369
0.779104
0.368099
0.163096
0.0717153
0.0339189
0.0190071
0.0133858
0.011612
0.0118468
0.0141588
0.0206936
0.0150884
0.0149201
0.0203609
0.0423057
0.110689
0.280084
0.609583
1.12107
1.76979
2.46569
3.1095
3.65535
4.07787
4.36428
4.53589
4.65845
4.77942
4.88175
4.9174
4.83395
4.61538
4.31033
4.04502
3.97436
4.07668
4.15694
3.94718
3.28229
2.32018
1.40639
0.749645
0.361853
0.164215
0.0738579
0.0354957
0.0199211
0.0137618
0.0114166
0.0106891
0.0108518
0.0119686
0.0130901
0.0156061
0.0266439
0.0680251
0.195469
0.498206
1.04753
1.83443
2.76096
3.68224
4.4994
5.13065
5.53166
5.71971
5.78086
5.81156
5.81801
5.7417
5.55296
5.24951
4.88244
4.52995
4.29785
4.24998
4.26251
4.16048
3.76442
3.02472
2.11335
1.29028
0.70064
0.34684
0.161968
0.0749511
0.0368708
0.0209332
0.0144134
0.011782
0.0107601
0.0104609
0.0106213
0.0135922
0.0183808
0.0385484
0.115696
0.349913
0.876132
1.76043
2.93467
4.22148
5.4356
6.36002
6.86569
6.98518
6.85683
6.63573
6.4039
6.13674
5.81665
5.45995
5.1002
4.76153
4.51502
4.3946
4.33757
4.23266
3.95544
3.42253
2.66546
1.84427
1.13617
0.630673
0.321856
0.155679
0.0746787
0.0379072
0.0219473
0.0151765
0.0123256
0.0111276
0.010641
0.0105102
0.0149449
0.0231991
0.0597316
0.202347
0.623894
1.51109
2.88962
4.61627
6.37421
7.71302
8.29981
8.18988
7.69201
7.09042
6.51436
6.01322
5.58572
5.23108
4.93395
4.70279
4.52934
4.40456
4.30103
4.16405
3.92004
3.50907
2.91988
2.22239
1.53252
0.957391
0.54614
0.289129
0.145903
0.0731332
0.0386194
0.0229699
0.0160403
0.0129924
0.0116416
0.0110326
0.0107705
0.0170038
0.0310518
0.0967418
0.355805
1.09442
2.54349
4.68442
7.12971
9.0552
9.78006
9.292
8.28189
7.2202
6.28596
5.56266
5.06213
4.73219
4.5282
4.39208
4.28757
4.18742
4.06779
3.90359
3.665
3.32392
2.86949
2.32449
1.74737
1.21131
0.772318
0.455568
0.251943
0.133692
0.0706155
0.0391071
0.0240532
0.017036
0.0137897
0.0122746
0.0115478
0.0111942
0.0199175
0.0435473
0.1594
0.616418
1.87122
4.23187
7.37349
10.1537
11.2266
10.3943
8.83196
7.24749
5.96244
5.05341
4.4802
4.16385
3.99441
3.89025
3.80573
3.71162
3.58781
3.42029
3.19837
2.91429
2.5661
2.16317
1.72941
1.30008
0.914544
0.600195
0.368834
0.214697
0.120767
0.0677607
0.0396291
0.0253303
0.0182439
0.0147635
0.0130431
0.0121729
0.0117251
0.0239219
0.0625818
0.259474
1.03518
3.12494
6.73837
10.6118
12.5849
11.7257
9.69751
7.5536
5.85026
4.71108
4.03336
3.65132
3.43124
3.29282
3.18079
3.06915
2.94138
2.78675
2.59931
2.37678
2.1203
1.83526
1.53166
1.22425
0.931259
0.67114
0.457263
0.295096
0.182135
0.109356
0.0655725
0.0406642
0.0270609
0.0198197
0.0160086
0.014001
0.0129297
0.0123546
0.029074
0.0890387
0.404602
1.66303
4.93534
9.7857
13.3926
13.3686
11.2092
8.51849
6.25804
4.73547
3.83539
3.31594
2.99285
2.76752
2.59111
2.44423
2.30852
2.17068
2.02236
1.85838
1.67771
1.48229
1.27662
1.0672
0.861869
0.66933
0.497936
0.354271
0.241454
0.158784
0.10211
0.0655081
0.0430212
0.0297203
0.0220575
0.0177083
0.0152589
0.013878
0.0131059
0.0348906
0.120057
0.58366
2.45932
6.99661
12.4742
14.8147
13.4239
10.4691
7.52087
5.36536
4.04347
3.26595
2.7791
2.44088
2.19129
1.99861
1.84535
1.71907
1.60301
1.48693
1.36316
1.22979
1.08822
0.941615
0.794527
0.651906
0.518523
0.39886
0.296443
0.213173
0.149015
0.102178
0.0696611
0.0480468
0.0341735
0.0255158
0.0202177
0.0170361
0.0151442
0.0140462
0.0399238
0.146057
0.740852
3.15396
8.61905
14.0492
15.6592
13.6734
10.2763
7.17773
4.99674
3.67934
2.89944
2.38234
2.02423
1.77706
1.60465
1.48133
1.38652
1.30144
1.21884
1.1288
1.0286
0.919837
0.805291
0.688715
0.574748
0.467424
0.37023
0.285525
0.214612
0.157641
0.113727
0.0812091
0.0580219
0.0420022
0.0312674
0.0242374
0.0197789
0.0169951
0.0153295
0.0418999
0.151333
0.770484
3.29725
8.94978
14.6384
16.5296
14.644
10.9738
7.46487
5.04336
3.57863
2.69657
2.13262
1.76696
1.54298
1.40802
1.32414
1.26504
1.21326
1.15168
1.08327
1.00265
0.910703
0.811224
0.706743
0.601944
0.500765
0.40708
0.323428
0.251361
0.191376
0.143099
0.105448
0.0770566
0.0562146
0.041444
0.031191
0.0244177
0.0199895
0.0172965
0.0394285
0.126029
0.61622
2.71969
8.0213
14.1366
17.0505
16.0287
12.6015
8.71864
5.67509
3.76908
2.67646
2.02439
1.64743
1.44729
1.34815
1.29861
1.26729
1.23919
1.20318
1.1486
1.0819
1.00015
0.909928
0.811303
0.708969
0.60607
0.507028
0.414983
0.332454
0.260879
0.200803
0.151651
0.112828
0.082708
0.0604335
0.0440625
0.0329758
0.0253259
0.0207192
0.0346297
0.084166
0.365179
1.69555
5.94887
12.2373
16.62
17.1494
14.6633
10.82
7.16128
4.61637
2.98784
2.06376
1.62617
1.43303
1.3611
1.34229
1.33509
1.3265
1.30628
1.2706
1.22201
1.14911
1.06865
0.97601
0.877511
0.774147
0.669887
0.567777
0.471086
0.382393
0.304023
0.235925
0.17971
0.133012
0.0974553
0.0691814
0.0500483
0.0356043
0.0274012
0.0321376
0.0530007
0.16789
0.740292
3.33453
8.95009
14.6194
17.1023
16.1901
13.0583
9.36915
6.17173
3.94959
2.43077
1.70355
1.47036
1.41151
1.42417
1.43695
1.4488
1.44795
1.42649
1.39231
1.33752
1.27212
1.1881
1.09715
0.999149
0.895405
0.789107
0.682156
0.576485
0.478
0.383653
0.303543
0.228377
0.171878
0.119475
0.0864865
0.0562859
0.0417339
0.0346514
0.0427885
0.0832856
0.234921
1.37148
4.99204
11.0442
15.354
16.2145
14.4791
11.3364
8.16334
5.41229
3.49794
2.16675
1.69927
1.51773
1.55663
1.56512
1.5922
1.61595
1.61381
1.60041
1.56333
1.50887
1.4477
1.36699
1.2829
1.18544
1.08433
0.979774
0.861222
0.754942
0.625555
0.527831
0.400912
0.324275
0.217402
0.169286
0.0973489
0.0756105
0.0412681
0.0286026
0.0214273
0.0176701
0.015618
0.0143413
0.0134205
0.0126799
0.0120463
0.0114934
0.0110331
0.0107084
0.0106507
0.0113382
0.0149634
0.0385469
0.310927
0.0350868
0.0246067
0.0195938
0.0170004
0.0154783
0.0144429
0.0136437
0.012974
0.0123886
0.0118692
0.0114301
0.0111189
0.0110635
0.0117298
0.0152808
0.0403983
0.304677
0.0239475
0.0205537
0.0181834
0.0165984
0.0154869
0.0146376
0.0139358
0.0133243
0.0127775
0.0122882
0.011868
0.0115705
0.0115215
0.012178
0.0156523
0.0410587
0.303955
0.0223786
0.0194491
0.017683
0.0165059
0.0156273
0.0149074
0.0142818
0.0137195
0.0132067
0.0127448
0.0123457
0.0120634
0.0120255
0.0126842
0.0161499
0.042082
0.310107
0.0195779
0.0183956
0.0174034
0.0165786
0.0158734
0.0152498
0.0146841
0.0141623
0.0136795
0.0132417
0.0128657
0.012601
0.0125801
0.0132568
0.016758
0.0434171
0.32274
0.0194185
0.0183695
0.0175373
0.0168385
0.0162236
0.0156636
0.015143
0.0146544
0.014198
0.0137832
0.0134303
0.0131884
0.0131928
0.0139089
0.0175026
0.0451214
0.341539
0.019153
0.0184392
0.0177956
0.0172061
0.0166593
0.0161462
0.0156605
0.0151993
0.0147667
0.014375
0.0140465
0.0138328
0.0138748
0.014661
0.0184249
0.0471936
0.366247
0.0194086
0.0188012
0.0182264
0.0176876
0.0171805
0.0166997
0.0162403
0.0158021
0.0153919
0.0150242
0.0147231
0.0145445
0.0146414
0.0155411
0.0195922
0.0497661
0.396774
0.0198951
0.019297
0.0187588
0.0182568
0.0177806
0.0173245
0.0168862
0.0164684
0.0160809
0.0157394
0.0154704
0.015337
0.0155142
0.0165868
0.0210872
0.0530861
0.433225
0.0203192
0.0198505
0.0193729
0.0189076
0.0184579
0.0180228
0.0176031
0.0172056
0.0168425
0.0165309
0.0163011
0.0162271
0.0165172
0.0178509
0.0230109
0.0574917
0.475886
0.0211216
0.0205768
0.0200943
0.0196444
0.0192139
0.0187972
0.0183967
0.0180219
0.0176872
0.0174115
0.017231
0.0172374
0.0176847
0.0193799
0.0254987
0.0633835
0.52511
0.0216586
0.0212747
0.020863
0.0204509
0.0200454
0.0196499
0.0192724
0.0189259
0.0186263
0.0183958
0.0182807
0.018397
0.0190624
0.0212435
0.0285985
0.0713699
0.581452
0.0226797
0.0221859
0.0217549
0.0213516
0.0209629
0.0205889
0.0202393
0.0199283
0.0196733
0.0195019
0.0194752
0.0197439
0.0207082
0.0235297
0.0324359
0.0812119
0.646646
0.0233229
0.0230234
0.0226775
0.0223193
0.0219625
0.0216201
0.0213078
0.0210428
0.0208454
0.0207527
0.0208471
0.021326
0.0226927
0.0263404
0.0371659
0.0931453
0.72174
0.024545
0.0241132
0.0237425
0.0233948
0.0230637
0.022758
0.0224932
0.0222871
0.0221654
0.0221789
0.0224392
0.0232045
0.0251025
0.0297946
0.0429646
0.107572
0.807962
0.0253062
0.0251039
0.0248343
0.0245455
0.0242642
0.0240125
0.0238114
0.0236828
0.023662
0.0238192
0.0243055
0.0254539
0.0280387
0.0340239
0.0500067
0.12474
0.906309
0.0267341
0.0263813
0.0260904
0.0258267
0.0255935
0.0254067
0.0252861
0.0252582
0.0253712
0.0257219
0.0265109
0.0281604
0.0316133
0.0391697
0.0584752
0.144528
1.01673
0.0276385
0.0275536
0.0273865
0.0272068
0.0270537
0.0269566
0.0269419
0.0270458
0.0273359
0.0279439
0.0291294
0.0314179
0.0359396
0.0453603
0.0684495
0.167534
1.13941
0.0292882
0.0290432
0.0288742
0.0287492
0.0286813
0.0286929
0.0288111
0.0290848
0.0296062
0.0305481
0.0322395
0.0353216
0.0411274
0.052714
0.0801012
0.19405
1.27497
0.0303764
0.0304451
0.0304319
0.0304276
0.0304843
0.0306378
0.030926
0.0314171
0.0322343
0.0335991
0.0359188
0.0399604
0.0472723
0.0613269
0.0935358
0.22436
1.42392
0.0322779
0.0321903
0.0322116
0.0323069
0.032502
0.0328262
0.0333246
0.0340875
0.035274
0.0371606
0.0402395
0.0454116
0.0544505
0.0712656
0.10882
0.258524
1.58559
0.0336073
0.0338824
0.0341022
0.034369
0.034748
0.0352844
0.0360413
0.0371375
0.0387731
0.0412845
0.0452543
0.0517236
0.0626975
0.0825507
0.125979
0.296511
1.7603
0.0358083
0.0359414
0.0362509
0.0366758
0.0372599
0.0380465
0.0391115
0.0406047
0.0427702
0.0460079
0.0509938
0.0589128
0.0720075
0.0951543
0.144954
0.338081
1.94696
0.0374409
0.037998
0.0385577
0.0392167
0.0400557
0.0411377
0.0425642
0.0445191
0.0472925
0.0513492
0.057461
0.0669585
0.0823276
0.108991
0.165643
0.383023
2.14377
0.0399986
0.0404425
0.041158
0.0420474
0.0431695
0.0445894
0.0464286
0.0489048
0.0523543
0.0573071
0.0646297
0.0757993
0.0935518
0.12391
0.18784
0.430822
2.34655
0.0420049
0.0429423
0.0439732
0.0451699
0.0466252
0.0484284
0.0507292
0.0537791
0.0579588
0.0638615
0.072446
0.0853341
0.105518
0.139673
0.211144
0.480023
2.54699
0.0449967
0.0458676
0.0471299
0.0486392
0.0504602
0.0526873
0.0554917
0.0591545
0.0640979
0.0709728
0.0808238
0.0954107
0.117986
0.1559
0.234826
0.527592
2.73261
0.0474686
0.048915
0.0505739
0.0524741
0.0547105
0.0574028
0.0607472
0.0650498
0.0707675
0.0786007
0.0896683
0.105855
0.130668
0.172097
0.257907
0.5697
2.88662
0.0510047
0.0524493
0.0544343
0.056743
0.0594361
0.0626353
0.0665535
0.0715143
0.0780001
0.0867482
0.0989336
0.116543
0.143305
0.187772
0.279174
0.601554
2.98457
0.0540702
0.0562087
0.0586964
0.0615013
0.0647143
0.0684737
0.0730064
0.0786473
0.0858925
0.0954994
0.108674
0.127466
0.155764
0.202525
0.297553
0.619003
3.00126
0.0583023
0.0605476
0.0635005
0.0668523
0.070658
0.0750505
0.0802584
0.0866222
0.0946382
0.105064
0.119104
0.138813
0.168137
0.216205
0.312451
0.62145
2.9187
0.0621409
0.0652634
0.0688833
0.0729053
0.0774144
0.0825502
0.0885374
0.0957141
0.104567
0.115833
0.130675
0.151085
0.180923
0.229197
0.324221
0.613159
2.7363
0.0672582
0.0706912
0.0750046
0.0798157
0.0851785
0.0912229
0.0981635
0.106324
0.11618
0.128426
0.144152
0.16521
0.195224
0.242742
0.334366
0.600003
2.47345
0.0720932
0.0766919
0.0819551
0.0877571
0.0941903
0.101388
0.109557
0.119002
0.130177
0.143739
0.160676
0.182652
0.212925
0.259263
0.345917
0.587034
2.16418
0.0782757
0.0835584
0.0899081
0.0969399
0.104737
0.113439
0.123244
0.13445
0.147488
0.162976
0.181821
0.205488
0.236825
0.282573
0.364144
0.579407
1.84699
0.0843247
0.0912095
0.0989908
0.107589
0.117146
0.127829
0.139852
0.153518
0.169262
0.187686
0.209639
0.236464
0.270694
0.317834
0.394351
0.577495
1.55901
0.0917123
0.0998795
0.109376
0.119949
0.131768
0.145061
0.160093
0.177207
0.196882
0.219765
0.246734
0.279204
0.318857
0.370641
0.447046
0.600438
1.3103
0.0992242
0.10955
0.121199
0.134247
0.148953
0.165652
0.184731
0.206642
0.23198
0.261547
0.296336
0.337278
0.387459
0.451305
0.537602
0.672972
1.10169
0.10797
0.120352
0.134559
0.150647
0.168976
0.19005
0.214489
0.242988
0.276442
0.315473
0.3613
0.416806
0.485697
0.573574
0.688397
0.833201
0.929651
0.117059
0.13213
0.149386
0.16917
0.192004
0.218617
0.249986
0.287437
0.331458
0.3836
0.446939
0.525694
0.626294
0.75853
0.936145
1.1546
0.788998
0.0740425
0.076988
0.0799594
0.0830265
0.0862386
0.089633
0.0932273
0.0970405
0.101076
0.105348
0.109855
0.114611
0.119619
0.1249
0.130444
0.136241
0.142264
0.148475
0.15484
0.161323
0.168712
0.176051
0.182068
0.187494
0.192219
0.196082
0.198919
0.200601
0.201023
0.200131
0.197918
0.194418
0.189719
0.183939
0.177232
0.169756
0.161682
0.153181
0.144423
0.135546
0.12662
0.0817606
0.0849574
0.0881471
0.091435
0.0948904
0.0985552
0.102456
0.106609
0.111027
0.11572
0.120698
0.125965
0.131541
0.137438
0.143667
0.150206
0.157036
0.164115
0.171404
0.178867
0.187283
0.195691
0.202789
0.209304
0.21509
0.219953
0.223702
0.226166
0.227212
0.226751
0.224752
0.221231
0.216269
0.209986
0.202552
0.194148
0.184974
0.175237
0.16515
0.154885
0.144572
0.0913168
0.0947367
0.0981196
0.101617
0.105315
0.10926
0.113482
0.118001
0.122833
0.127992
0.133489
0.139333
0.145545
0.152146
0.159148
0.166539
0.174294
0.182373
0.190731
0.199327
0.208937
0.218587
0.226954
0.234749
0.241788
0.247839
0.252672
0.256074
0.257871
0.257938
0.25621
0.252685
0.247429
0.240568
0.232284
0.222782
0.212294
0.201075
0.189378
0.177432
0.165422
0.103285
0.106862
0.110393
0.114076
0.118007
0.122237
0.126795
0.131705
0.136987
0.142658
0.148733
0.155226
0.162158
0.169558
0.177445
0.185812
0.194634
0.203868
0.213467
0.223381
0.234379
0.245475
0.255335
0.264637
0.273154
0.280612
0.286732
0.291253
0.293949
0.294651
0.293256
0.289736
0.284143
0.276605
0.267313
0.256497
0.24443
0.231416
0.217768
0.203782
0.189735
0.118418
0.122044
0.125654
0.129485
0.133631
0.138142
0.143047
0.148373
0.154143
0.160379
0.167098
0.174321
0.182073
0.190387
0.199288
0.208778
0.218833
0.229408
0.240451
0.251902
0.264518
0.277305
0.288918
0.299993
0.310254
0.319374
0.327019
0.332867
0.336633
0.338091
0.337093
0.33358
0.327586
0.319241
0.308737
0.296333
0.282349
0.267149
0.251133
0.234705
0.218254
0.137714
0.141241
0.144839
0.148758
0.153085
0.157863
0.16312
0.168883
0.175182
0.18204
0.189482
0.197531
0.206216
0.215579
0.225651
0.236441
0.247926
0.260063
0.27279
0.286038
0.300545
0.315311
0.328985
0.342142
0.354456
0.365536
0.374981
0.382396
0.387425
0.389771
0.389234
0.385716
0.379232
0.369902
0.357924
0.343584
0.327248
0.309379
0.290518
0.271217
0.251965
0.162512
0.165767
0.169238
0.173162
0.177612
0.182625
0.188227
0.194445
0.201314
0.208859
0.217111
0.226098
0.235853
0.246426
0.257853
0.270152
0.283303
0.297263
0.311961
0.327317
0.344037
0.361122
0.377214
0.392817
0.407541
0.420924
0.432482
0.441736
0.448239
0.451615
0.451595
0.448037
0.440931
0.430379
0.41659
0.399857
0.38062
0.359519
0.337294
0.314638
0.292094
0.194673
0.197474
0.200671
0.204477
0.208957
0.214147
0.220071
0.226754
0.234231
0.242535
0.251697
0.261751
0.272737
0.284711
0.297713
0.311773
0.32687
0.342965
0.359974
0.377803
0.397117
0.41692
0.435844
0.45431
0.471852
0.487923
0.501946
0.513334
0.521537
0.526083
0.526618
0.522949
0.515025
0.502943
0.486906
0.467188
0.444397
0.41945
0.393279
0.366664
0.340179
0.236878
0.239019
0.241741
0.245255
0.249625
0.254895
0.261089
0.26823
0.276352
0.285486
0.295671
0.306943
0.319349
0.33295
0.34779
0.363909
0.381285
0.399882
0.419604
0.440335
0.462687
0.485667
0.507896
0.529696
0.55051
0.569695
0.586557
0.60039
0.610519
0.616353
0.617448
0.613538
0.604527
0.590514
0.571667
0.54824
0.521189
0.491731
0.460911
0.429566
0.398349
0.293097
0.294289
0.296258
0.299231
0.303286
0.308482
0.314854
0.32242
0.331209
0.341247
0.352576
0.365236
0.37928
0.394773
0.41176
0.430288
0.450336
0.47186
0.49476
0.518886
0.544783
0.571458
0.597516
0.623163
0.647736
0.670475
0.690559
0.707135
0.719386
0.726588
0.728186
0.723829
0.713378
0.696931
0.674583
0.646653
0.614627
0.579909
0.543591
0.506618
0.469794
0.369305
0.369104
0.369918
0.372004
0.375454
0.380349
0.386743
0.394657
0.404107
0.41511
0.427707
0.441941
0.457867
0.475552
0.495041
0.516378
0.539543
0.564478
0.591072
0.619139
0.649137
0.680062
0.710498
0.740511
0.769321
0.796034
0.819676
0.839238
0.85374
0.862307
0.864269
0.859177
0.846851
0.827382
0.800755
0.767572
0.729869
0.689054
0.646311
0.602777
0.559448
0.474651
0.472407
0.471497
0.472213
0.474655
0.478919
0.485086
0.493199
0.503253
0.515247
0.52922
0.545212
0.563274
0.58347
0.60584
0.630416
0.657172
0.686028
0.71685
0.749411
0.784065
0.819773
0.855089
0.889921
0.923355
0.954347
0.98176
1.00441
1.02116
1.03097
1.03305
1.02686
1.01218
0.989082
0.957441
0.918436
0.8744
0.826684
0.776664
0.725712
0.675025
0.623489
0.618345
0.614946
0.613627
0.614504
0.617672
0.623239
0.631284
0.641789
0.654726
0.67012
0.688006
0.70842
0.731414
0.757011
0.785216
0.815987
0.849209
0.884705
0.922201
0.961937
1.0028
1.04329
1.08316
1.12134
1.15664
1.18776
1.21334
1.23208
1.24283
1.24468
1.237
1.21954
1.19236
1.15526
1.1102
1.05942
1.0043
0.946466
0.887503
0.828794
0.839073
0.830035
0.823212
0.819012
0.817582
0.819027
0.823451
0.830987
0.841625
0.855294
0.871998
0.891752
0.914566
0.940466
0.969442
1.00145
1.0364
1.07413
1.1144
1.15686
1.20168
1.24759
1.29302
1.33755
1.38001
1.41905
1.45323
1.48108
1.50119
1.51233
1.51351
1.50405
1.48369
1.45239
1.41011
1.35944
1.30222
1.23999
1.17455
1.10767
1.04084
1.16035
1.14663
1.13551
1.12756
1.123
1.12195
1.12452
1.13086
1.14103
1.15488
1.17241
1.19359
1.21834
1.24668
1.27854
1.31382
1.35234
1.39387
1.43808
1.48451
1.53319
1.58276
1.6316
1.67916
1.72419
1.76525
1.80086
1.82949
1.84973
1.86034
1.86037
1.84923
1.82654
1.79217
1.7464
1.692
1.63033
1.56304
1.49197
1.41894
1.34537
1.6551
1.63722
1.62186
1.61
1.60191
1.59778
1.59776
1.60199
1.6106
1.62343
1.64034
1.66132
1.68629
1.71514
1.74772
1.78383
1.8232
1.86549
1.91027
1.957
2.00549
2.05444
2.10234
2.14856
2.19186
2.2309
2.26432
2.29074
2.30891
2.31773
2.31641
2.30442
2.28164
2.2475
2.20276
2.14967
2.08915
2.02273
1.95203
1.8787
1.80372
2.44662
2.4297
2.41393
2.40105
2.39142
2.38528
2.38281
2.38417
2.38948
2.39856
2.41137
2.42783
2.44779
2.47108
2.49749
2.52673
2.5585
2.5924
2.628
2.66478
2.70241
2.73992
2.77626
2.81087
2.84284
2.87124
2.89515
2.91366
2.92596
2.93135
2.92931
2.91952
2.90189
2.8761
2.84259
2.80264
2.75678
2.70593
2.65114
2.59346
2.53264
0.439471
0.0626155
0.0190237
0.0130922
0.0124993
0.0129721
0.0138365
0.0149464
0.0163419
0.0180425
0.0199912
0.0218947
0.0232626
0.0238828
0.024425
0.0261373
0.029634
0.418659
0.056718
0.0175047
0.0132502
0.0129843
0.0134651
0.0141605
0.0149496
0.0157965
0.0166842
0.0176078
0.0185693
0.0195455
0.0206537
0.0222669
0.0248179
0.0286424
0.399056
0.0476088
0.016468
0.013628
0.0135345
0.0139857
0.0145751
0.0151992
0.0158129
0.0164391
0.0171027
0.0178301
0.018674
0.0197626
0.0212964
0.0235668
0.0270485
0.384928
0.0413121
0.0162687
0.0141468
0.0140951
0.0145038
0.0150142
0.0155417
0.0160581
0.016591
0.0171654
0.0178064
0.0185613
0.0195168
0.0207753
0.0224475
0.0245357
0.377134
0.0383387
0.0165892
0.0147469
0.0146725
0.0150351
0.0154899
0.0159725
0.0164573
0.0169613
0.0175064
0.0181237
0.0188642
0.0197949
0.0209896
0.0225353
0.024492
0.376318
0.0382999
0.0172862
0.0154099
0.0152708
0.0155821
0.0159999
0.0164605
0.0169344
0.0174296
0.0179633
0.0185617
0.0192677
0.0201329
0.0212167
0.0225905
0.0243721
0.382985
0.0400796
0.0182781
0.0161438
0.015906
0.01616
0.0165488
0.0169929
0.01746
0.0179533
0.018486
0.0190779
0.019756
0.0205492
0.0214875
0.0225987
0.0239135
0.397649
0.0433089
0.019521
0.0169801
0.0166021
0.0167866
0.0171427
0.0175698
0.0180318
0.0185267
0.0190638
0.0196592
0.0203295
0.0210923
0.0219641
0.0229629
0.0241075
0.420937
0.0475865
0.021088
0.0179661
0.0173875
0.0174786
0.0177899
0.0181953
0.0186505
0.019146
0.0196865
0.0202821
0.0209428
0.0216801
0.0225059
0.0234277
0.0244309
0.453181
0.0530733
0.0230782
0.0191637
0.0182978
0.0182584
0.0185057
0.0188782
0.019318
0.0198075
0.0203458
0.0209354
0.0215795
0.0222846
0.0230623
0.0239329
0.0249318
0.494799
0.0599315
0.0256106
0.0206489
0.0193808
0.0191576
0.0193119
0.0196336
0.0200453
0.0205197
0.0210477
0.0216263
0.0222526
0.0229241
0.0236388
0.0243976
0.0252167
0.546108
0.0682936
0.0288297
0.0225156
0.0206985
0.0202165
0.0202356
0.0204801
0.0208454
0.0212902
0.0217976
0.0223603
0.0229731
0.0236295
0.0243206
0.0250263
0.025692
0.607438
0.0782175
0.0328964
0.024874
0.0223272
0.0214862
0.0213126
0.021443
0.0217354
0.0221297
0.0225999
0.0231334
0.0237217
0.0243583
0.0250421
0.0257847
0.0266168
0.679162
0.0900456
0.0379846
0.0278499
0.024358
0.0230304
0.0225879
0.022555
0.0227403
0.0230592
0.0234734
0.0239626
0.0245115
0.0251039
0.0257231
0.02636
0.0270335
0.761724
0.104536
0.0442807
0.0315813
0.0268957
0.0249254
0.0241153
0.023856
0.0238908
0.0241034
0.0244389
0.0248695
0.0253756
0.0259367
0.0265258
0.0271037
0.0275971
0.85575
0.122199
0.0519789
0.036212
0.0300533
0.0272575
0.0259588
0.0253933
0.0252233
0.0252897
0.0255158
0.0258625
0.0263055
0.0268251
0.027404
0.0280361
0.0287357
0.962225
0.143607
0.0612695
0.0418816
0.033944
0.0301174
0.0281887
0.0272199
0.0267785
0.0266514
0.026732
0.026965
0.0273159
0.0277552
0.0282517
0.0287796
0.0293484
1.08208
0.169089
0.0723192
0.048708
0.0386704
0.0335911
0.0308746
0.0293901
0.0285977
0.0282211
0.0281158
0.0282055
0.0284453
0.0287997
0.0292279
0.0296708
0.0300265
1.21627
0.198804
0.0852373
0.0567814
0.0443154
0.0377518
0.0340771
0.0319526
0.0307189
0.0300269
0.0296878
0.0295971
0.0296955
0.0299444
0.0303124
0.0307749
0.0313191
1.36434
0.232777
0.100078
0.0661483
0.0509289
0.0426485
0.03784
0.0349434
0.0331708
0.0320923
0.031467
0.0311559
0.0310771
0.0311773
0.031414
0.0317508
0.0321816
1.52518
0.271013
0.116853
0.0768091
0.0585233
0.0483004
0.042183
0.0383805
0.0359683
0.0344294
0.0334645
0.0328952
0.0326123
0.0325472
0.0326465
0.0328487
0.0330296
1.69761
0.313727
0.135506
0.088705
0.0670529
0.0546782
0.04709
0.0422555
0.0391073
0.0370359
0.0356788
0.0348126
0.0342964
0.0340434
0.0340022
0.0341472
0.034464
1.87421
0.360712
0.155746
0.101642
0.0763821
0.0616931
0.0525027
0.0465299
0.0425624
0.0398951
0.0380989
0.0369011
0.0361234
0.0356515
0.0354156
0.0353857
0.0355843
2.05457
0.410631
0.176917
0.115267
0.0862658
0.0691778
0.058309
0.0511303
0.0462864
0.0429768
0.040705
0.0391485
0.0380904
0.0373864
0.0369456
0.0367177
0.0366307
2.24084
0.460496
0.198305
0.129103
0.0963725
0.0769024
0.0643529
0.055955
0.0502132
0.0462384
0.0434699
0.0415362
0.0401822
0.0392341
0.038586
0.0382064
0.0381631
2.42456
0.507299
0.219143
0.142726
0.106412
0.0846525
0.0704853
0.0609009
0.0542752
0.0496367
0.0463666
0.0440468
0.0423865
0.0411812
0.0402997
0.0396908
0.0394804
2.59985
0.547911
0.238657
0.155737
0.116119
0.0922475
0.0765841
0.0658896
0.0584233
0.0531422
0.0493771
0.0466698
0.0446981
0.0432298
0.0421101
0.0412563
0.040705
2.75033
0.57819
0.256042
0.167808
0.1253
0.0995678
0.082576
0.0708774
0.0626335
0.0567443
0.0524982
0.0494058
0.0471177
0.0453786
0.0440183
0.042945
0.0422764
2.85169
0.594876
0.27062
0.17868
0.13383
0.106557
0.0884408
0.0758641
0.0669154
0.0604556
0.0557449
0.0522689
0.0496565
0.047635
0.0460186
0.0446906
0.0437565
2.87684
0.597253
0.28203
0.188191
0.141672
0.113237
0.0942222
0.0808986
0.071316
0.0643188
0.059153
0.0552891
0.0523391
0.0500182
0.0481286
0.0465353
0.0452177
2.80581
0.588314
0.290316
0.196344
0.148929
0.119742
0.10005
0.0860948
0.0759309
0.0684122
0.0627857
0.0585163
0.0552039
0.0525552
0.0503679
0.0485069
0.0469198
2.63514
0.572917
0.295993
0.20349
0.155958
0.126386
0.106184
0.0916588
0.0809219
0.0728617
0.0667411
0.0620253
0.0583065
0.0552871
0.0527638
0.0505999
0.0487139
2.38212
0.555227
0.300279
0.210609
0.163549
0.133778
0.113079
0.097932
0.0865448
0.0778593
0.0711636
0.065923
0.0617259
0.0582714
0.0553567
0.0528472
0.0506781
2.08081
0.53897
0.305623
0.219634
0.173123
0.142937
0.121469
0.105444
0.0931841
0.0836878
0.076258
0.0703584
0.06557
0.0615835
0.0582026
0.0552884
0.052849
1.77055
0.528067
0.316385
0.233717
0.186854
0.155388
0.132435
0.114965
0.101393
0.0907412
0.0823069
0.0755324
0.0699783
0.0653253
0.0613677
0.0580451
0.0552003
1.48992
0.522904
0.336978
0.256607
0.20762
0.173235
0.147472
0.127541
0.11191
0.0995474
0.0896858
0.0817069
0.0751193
0.0696345
0.065019
0.0611067
0.0577754
1.24929
0.540013
0.377164
0.294065
0.238943
0.198791
0.168245
0.144454
0.125691
0.110794
0.0988755
0.0892231
0.081288
0.0746891
0.0691651
0.0645209
0.0605921
1.04919
0.602469
0.450292
0.354385
0.2863
0.235733
0.19718
0.16727
0.143799
0.12523
0.110403
0.098422
0.0886273
0.0805572
0.0738769
0.0683186
0.0636543
0.88566
0.74609
0.576677
0.449549
0.357098
0.288781
0.237357
0.198026
0.167548
0.143657
0.124718
0.109541
0.0972761
0.0873111
0.0791785
0.072496
0.066954
0.753116
1.04178
0.791284
0.599213
0.462857
0.364747
0.292776
0.239011
0.198173
0.166684
0.142083
0.12267
0.107245
0.094924
0.0850242
0.0770032
0.0704384
0.0445482
0.0905492
1.84811
11.1597
14.5295
10.6632
6.16017
3.29279
1.87665
1.74661
1.81648
1.83563
1.7716
1.64061
1.46136
1.23914
0.970763
0.668684
0.379896
0.166931
0.0524267
0.0874067
0.960102
8.92452
13.7628
11.7282
7.90771
4.8702
2.72521
2.00017
2.04484
2.13144
2.14453
2.07284
1.9294
1.71371
1.41514
1.0321
0.615644
0.274436
0.063233
0.0988272
0.534083
6.66742
12.3659
12.0881
9.2133
6.36312
4.02634
2.52551
2.30295
2.42765
2.5347
2.5681
2.5177
2.35338
2.03921
1.56165
0.976117
0.448339
0.0779589
0.11823
0.347019
4.6377
10.4811
11.7869
10.0596
7.61524
5.36868
3.50979
2.70945
2.7259
2.90706
3.06527
3.17045
3.15067
2.8936
2.32559
1.51746
0.718928
0.0981665
0.146287
0.285117
3.06425
8.41868
10.9689
10.3929
8.57718
6.61644
4.9288
3.52701
3.09958
3.26266
3.52401
3.80587
4.02076
3.9617
3.3923
2.31503
1.13181
0.125949
0.186317
0.289083
1.97619
6.4373
9.72147
10.1788
9.11311
7.61125
6.10302
4.63094
3.75075
3.65787
3.95303
4.38893
4.86655
5.13325
4.74981
3.45132
1.74996
0.164571
0.244239
0.334997
1.30587
4.73155
8.20978
9.56181
9.19538
8.19315
7.00738
5.85076
4.73877
4.2357
4.40979
4.9478
5.67694
6.31656
6.28363
4.96139
2.64619
0.219595
0.33089
0.422828
0.960689
3.41529
6.6689
8.63812
8.95435
8.42831
7.60987
6.70068
5.73379
5.0707
5.01787
5.5294
6.49836
7.52045
7.92464
6.76609
3.89242
0.30102
0.466864
0.580596
0.862568
2.5135
5.29386
7.54684
8.44041
8.36621
7.93197
7.31556
6.6375
6.02665
5.85591
6.26323
7.34925
8.76493
9.63386
8.7725
5.49804
0.426802
0.692841
0.866834
0.993813
2.01407
4.24377
6.51484
7.84166
8.19435
8.06233
7.70668
7.28691
6.88156
6.78414
7.21376
8.34274
10.0091
11.3449
10.8471
7.40874
0.631636
1.09189
1.4348
1.46994
2.07521
3.78336
5.83278
7.29122
7.94618
8.06952
7.94318
7.74924
7.5842
7.68463
8.25997
9.51402
11.2794
12.9518
12.8337
9.51127
0.984975
1.83599
2.61502
2.75704
2.9418
4.00656
5.61863
6.98865
7.76507
8.06146
8.11517
8.12332
8.23313
8.55431
9.33849
10.733
12.5658
14.3193
14.5283
11.6388
1.62861
3.24064
4.86516
5.40834
5.0133
5.12475
5.97725
6.96893
7.6636
8.04103
8.24233
8.4375
8.78575
9.38183
10.3869
11.8695
13.6546
15.2952
15.7106
13.6124
2.84538
5.67271
7.87505
7.72088
6.54073
5.90051
6.18284
6.82179
7.40114
7.83406
8.18733
8.58284
9.17753
10.0586
11.2233
12.6709
14.2307
15.5766
16.159
15.1629
5.08528
8.88557
9.48624
7.2983
5.79164
5.44541
5.80551
6.37349
6.91593
7.40875
7.90267
8.48116
9.25372
10.2546
11.436
12.6759
13.8607
14.8301
15.6253
15.9571
8.6933
11.0048
8.15679
5.69231
4.86136
4.95578
5.44641
5.98294
6.49879
7.02331
7.63059
8.15023
8.92016
9.77615
10.6575
11.5389
12.319
12.9686
13.965
15.5039
12.5901
9.63879
5.88024
4.89465
4.74795
4.98768
5.39661
5.86125
6.3329
6.79426
7.24338
7.64859
8.14092
8.62148
9.04542
9.41234
9.78103
10.2461
11.1977
13.06
12.1405
6.60294
5.03415
4.73437
4.86917
5.20359
5.61634
6.03968
6.43145
6.7571
7.00299
7.18308
7.32047
7.34753
7.3039
7.21715
7.14675
7.26718
7.89466
9.28879
9.23056
5.95606
5.21012
5.21685
5.47111
5.82452
6.2109
6.58223
6.89405
7.11251
7.21815
7.19896
7.0201
6.70102
6.31839
5.91071
5.59728
5.42449
5.54012
6.25942
8.7983
7.97184
8.30561
8.90933
9.58984
10.3048
11.0053
11.5706
11.9508
12.0818
11.9608
11.6561
11.202
10.6119
9.92822
9.19435
8.47666
7.86608
7.4567
7.21009
8.4614
7.7283
11.1535
14.6484
14.8398
12.5755
10.0344
7.70115
5.70893
4.10237
2.86497
1.94589
1.2931
0.843765
0.544954
0.34655
0.218211
0.137483
0.0880851
0.0586089
6.97925
7.74425
12.4072
11.9896
7.87508
4.98692
3.21452
2.11474
1.4144
0.956299
0.65004
0.440739
0.299105
0.20224
0.136359
0.0925516
0.0641218
0.0460876
0.0348291
0.0278849
5.51865
7.22451
14.2136
7.61781
3.62867
1.84246
1.02123
0.61011
0.38605
0.254743
0.173122
0.120333
0.0853586
0.0620191
0.046487
0.0362789
0.0296565
0.0253985
0.0226529
0.0208655
5.0972
8.17562
11.808
4.57993
1.85549
0.853585
0.445587
0.256587
0.159129
0.104787
0.0727712
0.0531867
0.0409209
0.0331342
0.0281638
0.0249787
0.0229184
0.0215616
0.0206334
0.0199715
4.70621
13.2085
8.26375
2.86515
1.07374
0.476556
0.244948
0.141078
0.0890915
0.0610169
0.0450645
0.0356923
0.0300537
0.0265928
0.0244256
0.0230343
0.0221093
0.0214665
0.0209904
0.0206192
3.34981
12.4767
5.66263
1.80722
0.659364
0.294004
0.154632
0.09263
0.0617379
0.0451761
0.0358868
0.0305168
0.0273306
0.0253854
0.024157
0.0233485
0.0227895
0.0223825
0.0220663
0.0218094
2.14738
8.79121
3.53268
1.08335
0.408338
0.192139
0.107861
0.0692491
0.0494475
0.038669
0.0326124
0.0291203
0.0270475
0.025773
0.0249562
0.0244075
0.0240216
0.0237371
0.0235158
0.0233339
1.23139
5.49351
2.03148
0.629275
0.259818
0.134163
0.0823447
0.0569439
0.0433166
0.0357876
0.031563
0.029139
0.0277017
0.0268147
0.0262445
0.0258629
0.0256004
0.0254121
0.0252749
0.0251587
0.620297
3.14263
1.10909
0.37563
0.174968
0.101582
0.0678385
0.0499013
0.0400143
0.0345802
0.0315757
0.0298721
0.0288707
0.0282609
0.0278807
0.0276402
0.0274925
0.0273984
0.0273522
0.0272992
0.275674
1.70722
0.595113
0.235813
0.128097
0.082969
0.0589959
0.0455772
0.0382567
0.0343512
0.0322527
0.0310909
0.030429
0.0300505
0.0298436
0.0297436
0.0297171
0.0297256
0.0297872
0.0297946
0.125651
0.904547
0.328473
0.163151
0.103892
0.0719616
0.0532145
0.0428856
0.0375409
0.0348386
0.0334521
0.0327243
0.0323508
0.0321869
0.032156
0.0322098
0.0323203
0.032449
0.0326414
0.0327066
0.0828959
0.482199
0.205658
0.130322
0.0907593
0.0645516
0.0491927
0.0413609
0.0376562
0.0359294
0.0351178
0.0347573
0.0346509
0.0347052
0.0348673
0.035098
0.0353693
0.0356476
0.0359975
0.036141
0.0826283
0.285483
0.161017
0.116307
0.0822659
0.0588012
0.0463852
0.0408045
0.0384914
0.0375629
0.0372315
0.0372036
0.0373646
0.0376568
0.0380418
0.0384838
0.0389533
0.0394229
0.0399638
0.0402106
0.0872786
0.197351
0.14317
0.108281
0.0749756
0.0540978
0.044691
0.0411314
0.0399631
0.0396887
0.0397844
0.0400866
0.0405371
0.0411029
0.0417547
0.0424578
0.0431808
0.0438999
0.0446762
0.0450877
0.0918183
0.156456
0.137189
0.101409
0.0681679
0.0505676
0.0440893
0.0422165
0.0419649
0.0422533
0.0427678
0.0434286
0.0442133
0.0451063
0.0460864
0.0471206
0.0481764
0.049227
0.0503006
0.050998
0.096066
0.151709
0.135902
0.0937712
0.0619154
0.0482812
0.04444
0.0438898
0.0443811
0.045198
0.0461637
0.0472416
0.0484289
0.049724
0.0511154
0.0525756
0.0540727
0.0555739
0.0570634
0.0582126
0.100232
0.16438
0.134289
0.0845516
0.0567487
0.0472496
0.0455358
0.0459806
0.0471032
0.048456
0.0499319
0.0515086
0.0531911
0.0549878
0.0568991
0.0589089
0.060991
0.063109
0.0652118
0.0670284
0.104691
0.183114
0.128663
0.0746626
0.0530748
0.0473265
0.0471496
0.0483417
0.0500318
0.051942
0.0539927
0.056161
0.0584499
0.0608722
0.0634399
0.0661536
0.0690008
0.0719519
0.0749414
0.0777355
0.109798
0.201732
0.1163
0.0655107
0.0510076
0.0482445
0.0490855
0.0508624
0.0530777
0.0555531
0.0582232
0.0610629
0.0640693
0.067254
0.0706363
0.0742346
0.0780589
0.0821019
0.0863143
0.0905226
0.0995679
0.204453
0.0960112
0.0585752
0.0504374
0.0497192
0.0512114
0.0534677
0.056168
0.0591874
0.0624802
0.0660278
0.0698283
0.0738918
0.0782409
0.0829088
0.087932
0.0933418
0.099142
0.105264
0.197178
0.187826
0.160199
0.137887
0.120702
0.107143
0.0966387
0.0886553
0.083073
0.0801433
0.0807015
0.0811537
0.0810708
0.0816936
0.083347
0.0862543
0.0905669
0.0969327
0.105438
0.0992227
0.321002
0.2962
0.273688
0.250911
0.230329
0.209875
0.19273
0.178308
0.167674
0.164979
0.174831
0.175982
0.171448
0.168831
0.168823
0.171239
0.175351
0.184058
0.192253
0.198166
0.0950481
0.101886
0.104971
0.105446
0.103275
0.0996475
0.0954983
0.0911046
0.0871364
0.0861753
0.0897551
0.0888493
0.08622
0.0841849
0.0828046
0.0816174
0.0801794
0.078003
0.0751887
0.070785
0.0596667
0.0624995
0.0648144
0.0661688
0.0666057
0.0662884
0.0654197
0.064034
0.0625472
0.062309
0.0646139
0.0641633
0.0628488
0.0616521
0.0606231
0.0596039
0.0584634
0.0571506
0.0555288
0.0538819
0.0504629
0.0520663
0.0534856
0.0545697
0.0552622
0.0555803
0.0555712
0.0552288
0.054783
0.0549643
0.0570358
0.0570761
0.056554
0.0559577
0.0553481
0.0546778
0.0539058
0.0530329
0.0520346
0.0509585
0.0475993
0.0487594
0.0498485
0.0507892
0.0515469
0.0521103
0.0524792
0.0526468
0.0527682
0.0532888
0.0555139
0.0559416
0.055889
0.0556344
0.0552554
0.0547551
0.0541244
0.0533792
0.0525016
0.0515134
0.0470315
0.0480866
0.0491078
0.0500557
0.0509086
0.0516561
0.0522911
0.0528163
0.0533443
0.0541779
0.0566976
0.0574494
0.0577129
0.057672
0.0574133
0.0569651
0.0563362
0.0555416
0.0545765
0.053455
0.047467
0.0485717
0.0496612
0.0507146
0.0517197
0.0526709
0.0535636
0.0544108
0.055301
0.0564592
0.0593423
0.0603938
0.0609031
0.0610078
0.0608005
0.0603272
0.0596091
0.0586641
0.0574921
0.0561039
0.0484087
0.0496482
0.0508874
0.0521157
0.0533268
0.0545195
0.0556943
0.0568727
0.0581285
0.0596415
0.0629377
0.0642921
0.0650235
0.0652433
0.0650477
0.0644971
0.0636248
0.0624526
0.0609866
0.0592368
0.0496447
0.0510724
0.0525162
0.0539717
0.0554371
0.0569146
0.0584095
0.0599499
0.0615995
0.0635105
0.067268
0.068949
0.0699085
0.0702363
0.0700293
0.0693613
0.0682782
0.0668087
0.0649664
0.0627628
0.0510786
0.052734
0.0544246
0.0561518
0.0579172
0.0597258
0.0615867
0.063533
0.0656205
0.0679828
0.0722558
0.0743035
0.0755176
0.0759628
0.0757314
0.0749098
0.0735583
0.0717161
0.069408
0.06665
0.0526681
0.0545848
0.0565595
0.0585995
0.0607107
0.0629001
0.0651798
0.0675864
0.0701687
0.0730455
0.0778968
0.0803659
0.0818776
0.0824614
0.0821984
0.0811853
0.0795001
0.0771979
0.07432
0.0708924
0.0543985
0.0566091
0.0589039
0.0612982
0.063803
0.0664276
0.0691866
0.0721184
0.0752648
0.0787301
0.0842319
0.0871918
0.0890576
0.0898113
0.0895119
0.0882639
0.086167
0.0832997
0.0797288
0.0754986
0.0562713
0.0588102
0.0614628
0.064255
0.0672055
0.070326
0.0736336
0.0771671
0.08096
0.0851008
0.0913342
0.0948699
0.0971599
0.0981231
0.097783
0.0962477
0.0936435
0.0900836
0.085673
0.0804882
0.0582995
0.0612045
0.0642557
0.0674941
0.0709481
0.0746333
0.0785693
0.0827945
0.0873318
0.0922504
0.0993053
0.103519
0.106317
0.107537
0.107151
0.105264
0.102035
0.0976271
0.0922031
0.0858926
0.0605049
0.0638185
0.0673141
0.0710534
0.0750765
0.0794055
0.0840622
0.0890848
0.0944826
0.100301
0.108276
0.113291
0.116693
0.118227
0.117789
0.115469
0.11147
0.106027
0.0993852
0.0917579
0.0629182
0.066689
0.0706806
0.0749837
0.0796522
0.0847163
0.0902023
0.096147
0.102543
0.109408
0.118408
0.12437
0.128493
0.130406
0.129905
0.127056
0.122111
0.115406
0.107307
0.098147
0.0655802
0.0698632
0.0744096
0.0793496
0.0847533
0.0906599
0.0971033
0.104118
0.111676
0.119764
0.129905
0.136987
0.141965
0.144336
0.143764
0.140271
0.134168
0.125926
0.116087
0.105137
0.0685438
0.0734002
0.0785692
0.0842319
0.0904774
0.0973546
0.104908
0.113171
0.122086
0.131608
0.143017
0.151425
0.157418
0.160343
0.159697
0.155432
0.147921
0.137811
0.125878
0.112814
0.071878
0.0773748
0.0832446
0.0897324
0.0969476
0.10495
0.113797
0.123521
0.134025
0.145237
0.15806
0.16804
0.175239
0.178839
0.17813
0.172963
0.163762
0.151381
0.1369
0.121269
0.0330992
0.0383223
0.045368
0.054769
0.0673199
0.0840602
0.106517
0.137003
0.179124
0.239108
0.328999
0.473194
0.724793
1.21188
2.27431
4.75836
10.4386
18.663
15.0538
7.17116
0.0267336
0.0294469
0.033085
0.0379775
0.0445799
0.0534903
0.065525
0.0818311
0.104125
0.135164
0.179729
0.246948
0.35594
0.550368
0.941521
1.85117
4.23292
10.311
12.4687
5.54768
0.0254256
0.0268978
0.0288028
0.0313222
0.0347174
0.0393484
0.0457211
0.054553
0.0668809
0.0842482
0.109079
0.14555
0.201849
0.296462
0.475884
0.870923
1.94208
5.19956
11.8035
3.54355
0.0261765
0.0271089
0.0281957
0.029528
0.031249
0.0335674
0.0367898
0.0413715
0.0479949
0.0576915
0.0720346
0.0934699
0.126031
0.177507
0.266768
0.447742
0.892571
2.38863
6.49893
1.79222
0.0278488
0.0285753
0.0293055
0.0300819
0.0309768
0.0321037
0.0336364
0.03585
0.0391827
0.0443422
0.0524758
0.0654244
0.0860671
0.118919
0.172206
0.266576
0.47132
1.08825
3.12062
0.828174
0.0300892
0.0307197
0.0312746
0.0317823
0.032276
0.0328162
0.0334909
0.0344485
0.0359416
0.0384139
0.0426584
0.0500914
0.063153
0.0857711
0.12371
0.185386
0.29053
0.528599
1.42475
0.35625
0.032867
0.0333878
0.0337854
0.0341023
0.0343542
0.0345787
0.0348185
0.0351452
0.0356847
0.0366759
0.0385915
0.042391
0.0500083
0.0651308
0.0939567
0.144164
0.221195
0.343677
0.702461
0.176727
0.0362373
0.0365789
0.0367618
0.0368627
0.0368915
0.0368771
0.0368433
0.0368244
0.0368791
0.0371195
0.0377817
0.039406
0.0432651
0.0523041
0.0728854
0.115417
0.186278
0.276684
0.423865
0.150059
0.0402324
0.040311
0.0402
0.0400227
0.0397922
0.0395303
0.0392533
0.0389796
0.0387383
0.0385829
0.0386221
0.0391175
0.0407504
0.0454115
0.0584686
0.0921082
0.160202
0.249243
0.317532
0.14948
0.0448511
0.0445882
0.0441062
0.0435848
0.0430449
0.0425014
0.041964
0.0414424
0.0409525
0.0405241
0.0402149
0.040155
0.0406711
0.0427321
0.0499797
0.0738261
0.135682
0.239455
0.301241
0.151331
0.0501466
0.0494265
0.0485127
0.0475822
0.0466784
0.045811
0.0449806
0.0441892
0.0434441
0.0427637
0.042186
0.0417927
0.0417649
0.0425476
0.0461553
0.0610025
0.111048
0.226603
0.331461
0.155293
0.0563591
0.05496
0.0534929
0.0520848
0.0507606
0.0495181
0.04835
0.0472514
0.0462229
0.0452751
0.0444355
0.0437646
0.0433903
0.0435752
0.0453768
0.0536047
0.0889614
0.202725
0.37126
0.161428
0.0639121
0.061412
0.0591906
0.057185
0.0553532
0.0536652
0.0520998
0.0506431
0.0492887
0.048041
0.0469203
0.0459768
0.0453188
0.0451824
0.0461759
0.0506136
0.0727689
0.165171
0.391814
0.170729
)
;
boundaryField
{
inlet
{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.01;
phi phi;
k k;
value uniform 3.77336;
}
outlet
{
type inletOutlet;
inletValue uniform 0.01;
value nonuniform List<scalar>
41
(
0.161451
0.0679357
0.0358677
0.0293553
0.0437532
0.0920243
0.19889
0.390275
0.675752
1.03484
1.42008
1.79242
2.10769
2.34697
2.52653
2.64458
2.71103
2.7531
2.79828
2.85707
2.91639
2.95095
2.95574
2.97473
3.2227
3.67734
3.87595
3.45392
2.49162
1.49074
0.779172
0.362375
0.157843
0.0684208
0.0323003
0.0187172
0.0146799
0.0159907
0.02379
0.0464523
0.111637
)
;
}
dymWall
{
Cmu 0.09;
kappa 0.41;
E 9.8;
type epsilonWallFunction;
value nonuniform List<scalar>
73
(
8.4614
6.97925
5.51865
5.0972
4.70621
3.34981
2.14738
1.23139
0.620297
0.275674
0.125651
0.0828959
0.0826283
0.0872786
0.0918183
0.096066
0.100232
0.104691
0.109798
0.0995679
8.7983
7.97184
8.30561
8.90933
9.58984
10.3048
11.0053
11.5706
11.9508
12.0818
11.9608
11.6561
11.202
10.6119
9.92822
9.19435
8.47666
7.86608
7.4567
7.21009
7.17116
5.54768
3.54355
1.79222
0.828174
0.35625
0.176727
0.150059
0.14948
0.151331
0.155293
0.161428
0.170729
0.197178
0.187826
0.160199
0.137887
0.120702
0.107143
0.0966387
0.0886553
0.083073
0.0801433
0.0807015
0.0811537
0.0810708
0.0816936
0.083347
0.0862543
0.0905669
0.0969327
0.105438
0.0992227
)
;
}
AMI1
{
type cyclicAMI;
value nonuniform List<scalar>
73
(
0.0430537
0.136005
2.53428
12.0921
14.7986
10.145
5.30515
2.62841
1.71095
1.66382
1.71365
1.70192
1.61281
1.46436
1.27474
1.05355
0.805022
0.544325
0.30717
0.136885
0.0507098
0.025938
0.0202558
0.0196186
0.020316
0.0215244
0.0230742
0.0249442
0.0271567
0.0297562
0.0328113
0.0364182
0.0406827
0.0457522
0.0518358
0.0592157
0.0682317
0.0792195
0.0924421
0.107953
0.0733372
0.0791833
0.0854632
0.0924572
0.100288
0.10902
0.118717
0.129405
0.140947
0.153238
0.16689
0.177776
0.185586
0.189414
0.18845
0.18252
0.17212
0.15826
0.14222
0.125087
0.0313741
0.0257402
0.0247835
0.0256956
0.0274482
0.0297646
0.0326456
0.0361205
0.0401266
0.0446565
0.0500457
0.0567753
0.0650858
)
;
}
AMI2
{
type cyclicAMI;
value nonuniform List<scalar>
162
(
0.0405591
0.0439014
0.0857028
0.146292
1.57338
3.12058
10.6402
12.9339
15.0818
14.5073
11.153
9.52187
6.03491
4.90634
2.89781
2.52253
1.77187
1.71873
1.66266
1.66925
1.71014
1.71403
1.71314
1.69781
1.6442
1.60902
1.52711
1.46449
1.37678
1.28115
1.19918
1.06511
0.991314
0.818341
0.757307
0.555689
0.513171
0.314514
0.291888
0.140276
0.132336
0.0520114
0.0488612
0.0262416
0.0253303
0.0202758
0.0201493
0.0195608
0.0196986
0.0202227
0.0204874
0.021401
0.0217631
0.0229167
0.0233752
0.0247434
0.0253083
0.0268997
0.0275884
0.0294271
0.0302648
0.0323931
0.0334124
0.0359005
0.0371291
0.0400618
0.0415263
0.0450266
0.0467631
0.0510022
0.0530663
0.0582657
0.0607362
0.0671547
0.0701136
0.0780094
0.0814853
0.0910761
0.0950104
0.106415
0.110542
0.0727023
0.0738565
0.0782116
0.0796589
0.0840799
0.0859368
0.0906234
0.0929375
0.0979601
0.10077
0.106151
0.109493
0.115245
0.119166
0.12529
0.129811
0.136217
0.141286
0.147853
0.153397
0.160687
0.167209
0.172801
0.17789
0.181936
0.185678
0.187797
0.189553
0.189494
0.188718
0.186582
0.183003
0.179266
0.172901
0.168334
0.159402
0.154868
0.143723
0.139893
0.127002
0.123418
0.0318246
0.0313982
0.0305989
0.0257981
0.0257419
0.0256472
0.0246938
0.0247527
0.0248976
0.0254542
0.025618
0.0258839
0.0269767
0.0273197
0.0276802
0.0289845
0.0295702
0.0300443
0.0314893
0.0323693
0.0329861
0.0345752
0.0357671
0.0365189
0.0382369
0.0397165
0.0405499
0.0423654
0.0441586
0.0450748
0.0470134
0.0493329
0.0504336
0.0525024
0.0557836
0.0570243
0.0588996
0.0638022
0.0651443
0.0664728
)
;
}
walls
{
Cmu 0.09;
kappa 0.41;
E 9.8;
type epsilonWallFunction;
value nonuniform List<scalar>
80
(
0.310927
0.304677
0.303955
0.310107
0.32274
0.341539
0.366247
0.396774
0.433225
0.475886
0.52511
0.581452
0.646646
0.72174
0.807962
0.906309
1.01673
1.13941
1.27497
1.42392
1.58559
1.7603
1.94696
2.14377
2.34655
2.54699
2.73261
2.88662
2.98457
3.00126
2.9187
2.7363
2.47345
2.16418
1.84699
1.55901
1.3103
1.10169
0.929651
0.788998
0.439471
0.418659
0.399056
0.384928
0.377134
0.376318
0.382985
0.397649
0.420937
0.453181
0.494799
0.546108
0.607438
0.679162
0.761724
0.85575
0.962225
1.08208
1.21627
1.36434
1.52518
1.69761
1.87421
2.05457
2.24084
2.42456
2.59985
2.75033
2.85169
2.87684
2.80581
2.63514
2.38212
2.08081
1.77055
1.48992
1.24929
1.04919
0.88566
0.753116
)
;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //
|
|
f2848045c87ffca337540bdd2eb0aaed49b4dbc8
|
34ee115a5b12ee92e67943346ba2d99668373401
|
/modfile/records/obwrldrecord.cpp
|
b4417ebdf9aced8e0d90422cda30e9d444bbdefd
|
[
"MIT"
] |
permissive
|
uesp/tes4lib
|
5745493180c16a3b89ba30a721c9bcd4de610489
|
7b426c9209ff7996d3d763e6d4e217abfefae406
|
refs/heads/master
| 2021-05-21T03:57:53.664107
| 2020-04-02T18:20:23
| 2020-04-02T18:20:23
| 252,532,347
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,993
|
cpp
|
obwrldrecord.cpp
|
/*===========================================================================
*
* File: ObWlrdRecord.CPP
* Author: Dave Humphrey (uesp@sympatico.ca)
* Created On: April 12, 2006
*
* Implements the CObWrldRecord class for worldspace records.
*
*=========================================================================*/
/* Include Files */
#include "obwrldrecord.h"
/*===========================================================================
*
* Begin Subrecord Creation Array
*
*=========================================================================*/
BEGIN_OBSUBRECCREATE(CObWrldRecord, CObIdRecord)
DEFINE_OBSUBRECCREATE(OB_NAME_FULL, CObFullSubrecord::Create)
DEFINE_OBSUBRECCREATE(OB_NAME_NAM2, CObFormidSubrecord::Create)
DEFINE_OBSUBRECCREATE(OB_NAME_CNAM, CObFormidSubrecord::Create)
DEFINE_OBSUBRECCREATE(OB_NAME_WNAM, CObFormidSubrecord::Create)
END_OBSUBRECCREATE()
/*===========================================================================
* End of Subrecord Creation Array
*=========================================================================*/
/*===========================================================================
*
* Begin CObWrldRecord Field Map
*
*=========================================================================*/
BEGIN_OBFIELDMAP(CObWrldRecord, CObIdRecord)
ADD_OBFIELDALL("Full Name", OB_FIELD_FULLNAME, 0, CObWrldRecord, FieldFullName)
END_OBFIELDMAP()
/*===========================================================================
* End of CObRefrRecord Field Map
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Constructor
*
*=========================================================================*/
CObWrldRecord::CObWrldRecord () {
m_pFullName = NULL;
}
/*===========================================================================
* End of Class CObCellRecord Constructor
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Method - void Destroy (void);
*
*=========================================================================*/
void CObWrldRecord::Destroy (void) {
m_pFullName = NULL;
CObIdRecord::Destroy();
}
/*===========================================================================
* End of Class Method CObWrldRecord::Destroy()
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Method - void InitializeNew (void);
*
*=========================================================================*/
void CObWrldRecord::InitializeNew (void) {
/* Call the base class method first */
CObIdRecord::InitializeNew();
/* Create a new item name subrecords if required */
if (HasFullItemName()) {
AddNewSubrecord(OB_NAME_FULL);
if (m_pFullName != NULL) m_pFullName->InitializeNew();
}
}
/*===========================================================================
* End of Class Method CObWrldRecord::InitializeNew()
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Event - void OnAddSubrecord (pSubrecord);
*
*=========================================================================*/
void CObWrldRecord::OnAddSubrecord (CObSubrecord* pSubrecord) {
if (pSubrecord->GetRecordType() == OB_NAME_FULL) {
m_pFullName = ObCastClass(CObFullSubrecord, pSubrecord);
}
else {
CObIdRecord::OnAddSubrecord(pSubrecord);
}
}
/*===========================================================================
* End of Class Event CObWrldRecord::OnAddSubRecord()
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Event - void OnDeleteSubrecord (pSubrecord);
*
*=========================================================================*/
void CObWrldRecord::OnDeleteSubrecord (CObSubrecord* pSubrecord) {
if (m_pFullName == pSubrecord) {
m_pFullName = NULL;
}
else {
CObIdRecord::OnDeleteSubrecord(pSubrecord);
}
}
/*===========================================================================
* End of Class Event CObWrldRecord::OnDeleteSubrecord()
*=========================================================================*/
/*===========================================================================
*
* Class CObWrldRecord Method - void SetFullName (pString);
*
*=========================================================================*/
void CObWrldRecord::SetFullName (const SSCHAR* pString) {
if (m_pFullName == NULL) {
AddNewSubrecord(OB_NAME_FULL);
if (m_pFullName == NULL) return;
m_pFullName->InitializeNew();
}
m_pFullName->SetString(pString);
}
/*===========================================================================
* End of Class Method CObWrldRecord::SetCellName()
*=========================================================================*/
/*===========================================================================
*
* Begin CObWrldRecord Get Field Methods
*
*=========================================================================*/
DEFINE_OBGETFIELD(CObWrldRecord::GetFieldFullName, String.Format("%s", GetFullName()))
/*===========================================================================
* End of CObWrldRecord Get Field Methods
*=========================================================================*/
/*===========================================================================
*
* Begin CObWrldRecord Compare Field Methods
*
*=========================================================================*/
DEFINE_OBCOMPFIELDSTRING(CObWrldRecord, CompareFieldFullName, GetFullName)
/*===========================================================================
* End of CObWrldRecord Compare Field Methods
*=========================================================================*/
/*===========================================================================
*
* Begin CObWrldRecord Set Field Methods
*
*=========================================================================*/
BEGIN_OBSETFIELD(CObWrldRecord::SetFieldFullName)
SetFullName(pString);
END_OBSETFIELD()
/*===========================================================================
* End of CObWrldRecord Field Methods
*=========================================================================*/
|
0b758adc5e32e24b12d7b01f5e50d4f7b2fc5a7c
|
4060dfd3ee62b32ecf287944ebbc38ef889f5fca
|
/Array/442. Find All Duplicates in an Array.cpp
|
b3fd37092187aa40a32883db436856bd4a68430d
|
[] |
no_license
|
Sensrdt/Leet-Code-Sol
|
e5cd6b25a6aa9628f1d311d02ad03c4a435fe47c
|
893d0614849b2416d920929e0ee1156b6218c6b9
|
refs/heads/master
| 2020-07-01T15:12:07.546062
| 2020-06-07T13:34:55
| 2020-06-07T13:34:55
| 201,206,677
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 400
|
cpp
|
442. Find All Duplicates in an Array.cpp
|
class Solution {
public:
vector<int> findDuplicates(vector<int>& nums) {
int n = nums.size();
map<int, int> mp;
vector<int> a;
for (int i=0; i<n; i++)
{
if (mp[nums[i]] == 0)
{
mp[nums[i]]++;
}else{
a.push_back(nums[i]);
}
}
return a;
}
};
|
6e678b5faae8fd465162e4574d631334a9feb88a
|
010aa4175ee4f08b73baf60d1546bd101edf97ce
|
/LibDomoticPi/srcs/DomoticNode.cpp
|
df8a8cfd93551494327c8c5bbed252d2d2217c63
|
[] |
no_license
|
Ansaya/DomoticPi
|
5e5ffabde718722642e525afc2ed6b0d42cea0ac
|
77fae3bcf4dab8b1d0793ebdb6250ebdecb0a64e
|
refs/heads/master
| 2020-03-15T08:38:48.830037
| 2018-11-04T07:54:54
| 2018-11-04T07:54:54
| 132,056,010
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,390
|
cpp
|
DomoticNode.cpp
|
#include <DomoticNode.h>
#include <domoticPi.h>
#include <exceptions.h>
#include <IInput.h>
#include <InputFactory.h>
#include <IOutput.h>
#include <OutputFactory.h>
#include <SerialInterface.h>
#include <algorithm>
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
#include <hap/libHAP.h>
#endif // DOMOTIC_PI_APPLE_HOMEKIT
using namespace domotic_pi;
DomoticNode::DomoticNode(const std::string& id) : _id(id)
{
}
DomoticNode::~DomoticNode()
{
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
if (isHAPEnabled())
disableHAP();
#endif
}
DomoticNode_ptr DomoticNode::from_json(const rapidjson::Value& config, bool checkSchema)
{
if (checkSchema && !json::hasValidSchema(config, DOMOTIC_PI_JSON_DOMOTIC_NODE)) {
console->error("DomoticNode::fromJson : json schema not valid for an Output.");
throw domotic_pi_exception("Json configuration for domotic_pi::DomoticNode not valid.");
}
DomoticNode_ptr domoticNode = std::make_shared<DomoticNode>(config["id"].GetString());
// Load available comm interfaces
if (config.HasMember("comms")) {
console->info("DomoticNode::from_json : loading comm interfaces for node '{}'.",
domoticNode->getID().c_str());
for (auto& it : config["comms"].GetArray()) {
CommFactory::from_json(it, domoticNode);
}
}
// Load available outputs
if (config.HasMember("outputs")) {
console->info("DomoticNode::from_json : loading outputs for node '{}'.",
domoticNode->getID().c_str());
for (auto& it : config["outputs"].GetArray()) {
OutputFactory::from_json(it, domoticNode);
}
}
// Load available programmed events
if (config.HasMember("programmedEvents")) {
console->info("DomoticNode::from_json : loading programmed events for node '{}'.",
domoticNode->getID().c_str());
for (auto& it : config["programmedEvents"].GetArray()) {
ProgrammedEvent::from_json(it, domoticNode);
}
}
// Load available inputs
if (config.HasMember("inputs")) {
console->info("DomoticNode::from_json : loading inputs for node '{}'.",
domoticNode->getID().c_str());
for (auto& it : config["inputs"].GetArray()) {
InputFactory::from_json(it, domoticNode);
}
}
// Set node name
if (config.HasMember("name"))
domoticNode->setName(config["name"].GetString());
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
// Enable Apple HomeKit if required
if (config.HasMember("homekit")) {
const rapidjson::Value& homekitConfig = config["homekit"];
domoticNode->enableHAP(
homekitConfig["password"].GetString(),
homekitConfig.HasMember("name") ? homekitConfig["name"].GetString() : domoticNode->_name);
}
#endif // DOMOTIC_PI_APPLE_HOMEKIT
console->info("DomoticNode::from_json : new domotic node '{}' loaded succesfully.",
domoticNode->getID().c_str());
return domoticNode;
}
DomoticNode_ptr DomoticNode::from_json(const std::string& jsonConfig)
{
rapidjson::Document config;
if (config.Parse(jsonConfig.c_str()).HasParseError()) {
console->error("DomoticNode::from_json : could not parse given json configuration to document.");
throw domotic_pi_exception("Could not parse given json string.");
}
return DomoticNode::from_json(config, true);
}
const std::string& DomoticNode::getID() const
{
return _id;
}
void DomoticNode::setName(const std::string & name)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_nameLock);
#endif // DOMOTIC_PI_THREAD_SAFE
_name = name;
}
std::string DomoticNode::getName() const
{
return _name;
}
Input_ptr DomoticNode::getInput(const std::string& id) const
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::shared_lock<std::shared_mutex> lock(_inputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for required id in present inputs
auto it = std::find_if(_inputs.begin(), _inputs.end(),
[id](const Input_ptr& i) { return id == i->getID(); });
// If id exists return found input
if (it != _inputs.end())
return *it;
return nullptr;
}
const std::vector<Input_ptr>& DomoticNode::getInputs() const
{
return _inputs;
}
bool DomoticNode::addInput(Input_ptr input)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_inputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for conflicting id in present inputs
auto it = std::find_if(_inputs.begin(), _inputs.end(),
[input](const Input_ptr& i) { return input->getID() == i->getID(); });
// If conflict exists return immediately
if (it != _inputs.end())
return false;
_inputs.push_back(input);
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
if (input->hasAHKAccessory()) {
hap::AccessorySet::getInstance().addAccessory(input->getAHKAccessory());
}
#endif
return true;
}
void DomoticNode::removeInput(const std::string & inputId)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_inputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
auto input = std::find_if(_inputs.begin(), _inputs.end(),
[inputId](const Input_ptr& i) { return inputId == i->getID(); });
if (input != _inputs.end()) {
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
if ((*input)->hasAHKAccessory()) {
hap::AccessorySet::getInstance().removeAccessory((*input)->getAHKAccessory());
}
#endif
_inputs.erase(input);
}
}
Output_ptr DomoticNode::getOutput(const std::string& id) const
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::shared_lock<std::shared_mutex> lock(_outputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for required id in present outputs
auto it = std::find_if(_outputs.begin(), _outputs.end(),
[id](const Output_ptr& o) { return id == o->getID(); });
// If id exists return found output
if (it != _outputs.end())
return *it;
return nullptr;
}
const std::vector<Output_ptr>& DomoticNode::getOutputs() const
{
return _outputs;
}
bool DomoticNode::addOutput(Output_ptr output)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_outputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for conflicting id in present outputs
auto it = std::find_if(_outputs.begin(), _outputs.end(),
[output](const Output_ptr& o) { return output->getID() == o->getID(); });
// If conflict exists return immediately
if (it != _outputs.end())
return false;
_outputs.push_back(output);
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
if(output->hasAHKAccessory()) {
hap::AccessorySet::getInstance().addAccessory(output->getAHKAccessory());
}
#endif
return true;
}
void DomoticNode::removeOutput(const std::string & outputId)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_outputsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
auto output = std::find_if(_outputs.begin(), _outputs.end(),
[outputId](const Output_ptr& o) { return outputId == o->getID(); });
if (output != _outputs.end()) {
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
if ((*output)->hasAHKAccessory()) {
hap::AccessorySet::getInstance().removeAccessory((*output)->getAHKAccessory());
}
#endif
_outputs.erase(output);
}
}
Comm_ptr DomoticNode::getComm(const std::string& id) const
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::shared_lock<std::shared_mutex> lock(_commsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for port name in already present serial interfaces
auto it = std::find_if(_comms.begin(), _comms.end(),
[id](const Comm_ptr& si) {
return id == si->getID();
});
// If port exists return found serial interface
if (it != _comms.end())
return *it;
return nullptr;
}
const std::vector<Comm_ptr>& DomoticNode::getComms() const
{
return _comms;
}
bool DomoticNode::addComm(Comm_ptr comm)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_commsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for port name in already present serial interfaces
auto it = std::find_if(_comms.begin(), _comms.end(),
[comm](const Comm_ptr& si) {
return comm->getID() == si->getID();
});
// If conflict exists return immediately
if (it != _comms.end())
return false;
_comms.push_back(comm);
return true;
}
void DomoticNode::removeComm(const std::string & id)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_commsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
std::remove_if(_comms.begin(), _comms.end(),
[id](const Comm_ptr& comm) {
return id == comm->getID();
});
}
ProgrammedEvent_ptr DomoticNode::getProgrammedEvent(const std::string& id) const
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::shared_lock<std::shared_mutex> lock(_programmedEventsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for event id in already present programmed events
auto it = std::find_if(_programmedEvents.begin(), _programmedEvents.end(),
[&](const ProgrammedEvent_ptr &evt) {
return evt->getID() == id;
});
if (it != _programmedEvents.end()) {
return *it;
}
return nullptr;
}
const std::vector<ProgrammedEvent_ptr> &DomoticNode::getProgrammedEvents() const
{
return _programmedEvents;
}
bool DomoticNode::addProgrammedEvent(ProgrammedEvent_ptr programmedEvent)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_programmedEventsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
// Search for event id in already present programmed events
auto it = std::find_if(_programmedEvents.begin(), _programmedEvents.end(),
[&](const ProgrammedEvent_ptr &evt) {
return evt->getID() == programmedEvent->getID();
});
// If conflict exists return immediately
if (it != _programmedEvents.end()) {
return false;
}
_programmedEvents.push_back(programmedEvent);
return true;
}
void DomoticNode::removeProgrammedEvent(const std::string& id)
{
#ifdef DOMOTIC_PI_THREAD_SAFE
std::unique_lock<std::shared_mutex> lock(_programmedEventsLock);
#endif // DOMOTIC_PI_THREAD_SAFE
auto it = std::remove_if(_programmedEvents.begin(), _programmedEvents.end(),
[&](const ProgrammedEvent_ptr &evt) {
return evt->getID().compare(id) == 0;
});
}
rapidjson::Document DomoticNode::to_json() const
{
console->debug("DomoticNode::to_json : serializing node '{}'.", _id.c_str());
rapidjson::Document domoticNode(rapidjson::kObjectType);
// Set node id
rapidjson::Value id;
id.SetString(_id.c_str(), domoticNode.GetAllocator());
domoticNode.AddMember("id", id, domoticNode.GetAllocator());
// Set node name
rapidjson::Value name;
name.SetString(_name.c_str(), domoticNode.GetAllocator());
domoticNode.AddMember("name", name, domoticNode.GetAllocator());
// Populate and set node inputs
rapidjson::Value inputs(rapidjson::kArrayType);
for (auto& it : _inputs)
inputs.PushBack(it->to_json(), domoticNode.GetAllocator());
domoticNode.AddMember("inputs", inputs, domoticNode.GetAllocator());
// Populate and set node outputs
rapidjson::Value outputs(rapidjson::kArrayType);
for (auto& it : _outputs)
outputs.PushBack(it->to_json(), domoticNode.GetAllocator());
domoticNode.AddMember("outputs", outputs, domoticNode.GetAllocator());
// Populate and set node comm interfaces
rapidjson::Value comms(rapidjson::kArrayType);
for (auto& it : _comms)
comms.PushBack(it->to_json(), domoticNode.GetAllocator());
domoticNode.AddMember("comms", comms, domoticNode.GetAllocator());
// Populate and set node programmed events
rapidjson::Value programmedEvents(rapidjson::kArrayType);
for (auto& it : _programmedEvents) {
programmedEvents.PushBack(it->to_json(), domoticNode.GetAllocator());
}
domoticNode.AddMember("programmedEvents", programmedEvents, domoticNode.GetAllocator());
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
// Set node homekit information
rapidjson::Value homekit(rapidjson::kObjectType);
rapidjson::Value homekitName;
homekitName.SetString(hap::net::HAPService::getInstance().getServiceName().c_str(), domoticNode.GetAllocator());
homekit.AddMember("name", homekitName, domoticNode.GetAllocator());
rapidjson::Value homekitPassword;
homekitPassword.SetString(hap::net::HAPService::getInstance().getServicePassword().c_str(), domoticNode.GetAllocator());
homekit.AddMember("password", homekitPassword, domoticNode.GetAllocator());
domoticNode.AddMember("homekit", homekit, domoticNode.GetAllocator());
#endif // DOMOTIC_PI_APPLE_HOMEKIT
return domoticNode;
}
#ifdef DOMOTIC_PI_APPLE_HOMEKIT
bool DomoticNode::enableHAP(const std::string& password, const std::string& hapName)
{
return hap::net::HAPService::getInstance()
.setupAndListen(hapName.empty() ? _id : hapName, password);
}
void DomoticNode::disableHAP()
{
hap::net::HAPService::getInstance().stop();
}
bool DomoticNode::isHAPEnabled() const
{
return hap::net::HAPService::getInstance().isRunning();
}
#endif
|
4f77d0529f7611820f0474d090070d0d36f2dd12
|
7ca235ddecbbc97a5e7ba2993769cda9363c4930
|
/Project0/Animation.cpp
|
501480eea39d688119cf30778c7bc3a8ccd639d7
|
[] |
no_license
|
syonker/KeyframeAnimation
|
1cfb541b4698752771fc5d3844ee1cac95ba4bbc
|
c86a81ab2777d63143101205d90aacd91ca66e8c
|
refs/heads/master
| 2021-03-22T02:55:50.796542
| 2018-04-03T05:19:15
| 2018-04-03T05:19:15
| 120,973,752
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,195
|
cpp
|
Animation.cpp
|
#include "Animation.h"
Animation::Animation() {
}
Animation::~Animation() {
}
bool Animation::Load(const char *file) {
if (file == "") {
file = "../animations/wasp2_walk.anim";
}
std::cerr << "file: " << file << std::endl;
Tokenizer* token = new Tokenizer();
token->Open(file);
//get initial params
token->FindToken("animation"); token->FindToken("{");
token->FindToken("range"); tStart = token->GetFloat(); tEnd = token->GetFloat();
token->FindToken("numchannels"); numChannels = token->GetFloat();
//parse each channel
for (int i = 0; i < numChannels; i++) {
token->FindToken("channel");
token->FindToken("{");
Channel* newChannel = new Channel();
channels.push_back(newChannel);
newChannel->Load(token);
token->FindToken("}");
}
// Finish
token->FindToken("}");
token->Close();
Precompute();
return true;
}
void Animation::Evaluate(float time, std::vector<float> &pose) {
//for each channel get the new pose value
for (int i = 0; i < numChannels; i++) {
pose[i] = channels[i]->Evaluate(time);
}
}
void Animation::Precompute() {
//for each channel
for (int i = 0; i < numChannels; i++) {
channels[i]->Precompute();
}
}
|
ae023b1cf03c07b66a425695f09b503000cc3c5b
|
0b067d0fbdec4c91f11d58834b41648d587e4ae8
|
/teensy-sketch.ino
|
95ad75a0ce8857aeca30f4c072da903b74339eea
|
[] |
no_license
|
jotamjr/3dof_imu_tracking
|
f1acf3b3a158ea90c520a9ad6911f819e4cd284a
|
ee0f9cf3cdc5e4e32262fffecd3934df4c54baae
|
refs/heads/master
| 2020-12-30T23:35:38.114480
| 2017-04-16T22:47:00
| 2017-04-16T22:47:00
| 86,605,002
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,871
|
ino
|
teensy-sketch.ino
|
//
// Description: Simple 3 axis joystick using the LSM9DS1 sensor
//
#include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>
#include <math.h>
// LSM9DS1 setup
LSM9DS1 imu;
#define LSM9DS1_M 0x1E
#define LSM9DS1_AG 0x6B
#define PRINT_CALCULATED
#define REFRESH_RATE 20
// Enable debug on serial
#define ON_SERIAL 0
// Need to change the declination for your own location:
// http://www.ngdc.noaa.gov/geomag-web/#declination
#define DECLINATION -0.39
// Fscale to convert the angles from imu to joy values (0-1023) got this from:
// http://playground.arduino.cc/Main/Fscale
float fscale( float originalMin, float originalMax, float newBegin, float
newEnd, float inputValue, float curve){
float OriginalRange = 0;
float NewRange = 0;
float zeroRefCurVal = 0;
float normalizedCurVal = 0;
float rangedValue = 0;
boolean invFlag = 0;
// condition curve parameter
// limit range
if (curve > 10) curve = 10;
if (curve < -10) curve = -10;
curve = (curve * -.1) ; // - invert and scale - this seems more intuitive - postive numbers give more weight to high end on output
curve = pow(10, curve); // convert linear scale into lograthimic exponent for other pow function
// Check for out of range inputValues
if (inputValue < originalMin) {
inputValue = originalMin;
}
if (inputValue > originalMax) {
inputValue = originalMax;
}
// Zero Refference the values
OriginalRange = originalMax - originalMin;
if (newEnd > newBegin){
NewRange = newEnd - newBegin;
}
else
{
NewRange = newBegin - newEnd;
invFlag = 1;
}
zeroRefCurVal = inputValue - originalMin;
normalizedCurVal = zeroRefCurVal / OriginalRange; // normalize to 0 - 1 float
// Check for originalMin > originalMax - the math for all other cases i.e. negative numbers seems to work out fine
if (originalMin > originalMax ) {
return 0;
}
if (invFlag == 0){
rangedValue = (pow(normalizedCurVal, curve) * NewRange) + newBegin;
}
else // invert the ranges
{
rangedValue = newBegin - (pow(normalizedCurVal, curve) * NewRange);
}
return rangedValue;
}
void setup(){
// Setting communication mode and address for devices
imu.settings.device.commInterface = IMU_MODE_I2C;
imu.settings.device.mAddress = LSM9DS1_M;
imu.settings.device.agAddress = LSM9DS1_AG;
if (!imu.begin())
{
if (ON_SERIAL){
Serial.println("Failed to communicate with LSM9DS1.");
Serial.println("Double-check wiring.");
Serial.println("Default settings in this sketch will " \
"work for an out of the box LSM9DS1 " \
"Breakout, but may need to be modified " \
"if the board jumpers are.");
}
while (1)
;
}
}
void loop() {
printGyro();
printAccel();
printMag();
printAttitude(imu.ax, imu.ay, imu.az, -imu.my, -imu.mx, imu.mz);
if (ON_SERIAL){
Serial.println();
}
delay(REFRESH_RATE);
}
void printGyro()
{
imu.readGyro();
if (ON_SERIAL){
Serial.print("G: ");
#ifdef PRINT_CALCULATED
Serial.print(imu.calcGyro(imu.gx), 2);
Serial.print(", ");
Serial.print(imu.calcGyro(imu.gy), 2);
Serial.print(", ");
Serial.print(imu.calcGyro(imu.gz), 2);
Serial.println(" deg/s");
#elif defined PRINT_RAW
Serial.print(imu.gx);
Serial.print(", ");
Serial.print(imu.gy);
Serial.print(", ");
Serial.println(imu.gz);
#endif
}
}
void printAccel()
{
imu.readAccel();
if (ON_SERIAL){
Serial.print("A: ");
#ifdef PRINT_CALCULATED
Serial.print(imu.calcAccel(imu.ax), 2);
Serial.print(", ");
Serial.print(imu.calcAccel(imu.ay), 2);
Serial.print(", ");
Serial.print(imu.calcAccel(imu.az), 2);
Serial.println(" g");
#elif defined PRINT_RAW
Serial.print(imu.ax);
Serial.print(", ");
Serial.print(imu.ay);
Serial.print(", ");
Serial.println(imu.az);
#endif
}
}
void printMag()
{
imu.readMag();
if (ON_SERIAL){
Serial.print("M: ");
#ifdef PRINT_CALCULATED
Serial.print(imu.calcMag(imu.mx), 2);
Serial.print(", ");
Serial.print(imu.calcMag(imu.my), 2);
Serial.print(", ");
Serial.print(imu.calcMag(imu.mz), 2);
Serial.println(" gauss");
#elif defined PRINT_RAW
Serial.print(imu.mx);
Serial.print(", ");
Serial.print(imu.my);
Serial.print(", ");
Serial.println(imu.mz);
#endif
}
}
void printAttitude(float ax, float ay, float az, float mx, float my, float mz)
{
float roll = atan2(ay, az);
float pitch = atan2(-ax, sqrt(ay * ay + az * az));
float heading;
if (my == 0)
heading = (mx < 0) ? 180.0 : 0;
else
heading = atan2(mx, my);
heading -= DECLINATION * PI / 180;
if (heading > PI) heading -= (2 * PI);
else if (heading < -PI) heading += (2 * PI);
else if (heading < 0) heading += 2 * PI;
heading *= 180.0 / PI;
pitch *= 180.0 / PI;
roll *= 180.0 / PI;
heading = abs(heading);
int fpitch;
int froll;
int fheading;
if(pitch<0){
fpitch= (int) fscale(-90,0,0,512,pitch,0);
}else{
fpitch= (int) fscale(0,90,512,1023,pitch,0);
}
if(roll<0){
froll= (int) fscale(-180,0,0,512,roll,0);
}else{
froll= (int) fscale(0,180,512,1023,roll,0);
}
if(heading<180){
fheading= (int) fscale(0,180,0,512,heading,0);
}else{
fheading= (int) fscale(180,360,512,1023,heading,0);
}
Joystick.X(froll);
Joystick.Y(fpitch);
Joystick.Z(fheading);
if (ON_SERIAL){
Serial.print("Pitch, Roll, fPitch, fRoll: ");
Serial.print(pitch, 2);
Serial.print(", ");
Serial.print(roll, 2);
Serial.print(", ");
Serial.print(fpitch);
Serial.print(", ");
Serial.println(froll);
Serial.print("Heading, fHeading: ");
Serial.print(heading, 2);
Serial.print(", ");
Serial.println(fheading);
}
}
|
f7a2dff22e12b487f878c3b98db73020935cd528
|
32e8da727732ffc5ba6de149daf2a4ca0b57b292
|
/Duskfall/Source/Duskfall/Characters/DuskfallCharacter.h
|
9ea3f3adce9f628b8e8851c888f417b21f54b735
|
[] |
no_license
|
RoseBush1404/Duskfall
|
3f8160c4f6c5bdff675d372eacee646c7bb5782a
|
94532c78fd52872c9d681c3c25ec4311d866f661
|
refs/heads/master
| 2020-08-06T14:19:25.540441
| 2020-07-01T21:13:46
| 2020-07-01T21:13:46
| 213,003,404
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,788
|
h
|
DuskfallCharacter.h
|
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Characters/CharacterControls.h"
#include "Characters/HealthSystem.h"
#include "Characters/CharacterGetters.h"
#include "Camera/CameraShake.h"
#include "DuskfallCharacter.generated.h"
class ABaseWeapon;
class ABaseShield;
class USoundCue;
class UAudioComponent;
UENUM(BlueprintType)
enum class ECharacterState : uint8
{
ECS_Moveable UMETA(DisplayName = "Moveable"),
ECS_Died UMETA(DisplayName = "Died"),
ECS_Attacking UMETA(DisplayName = "Attacking"),
ECS_Blocking UMETA(DisplayName = "Blocking"),
ECS_Staggered UMETA(DisplayName = "Starggered"),
ECS_Parrying UMETA(DisplayName = "Parrying"),
ECS_Parryed UMETA(DisplayName = "Parryed"),
ECS_UsingItem UMETA(DisplayName = "Using Item")
};
UCLASS(config=Game)
class ADuskfallCharacter : public ACharacter, public ICharacterControls, public IHealthSystem, public ICharacterGetters
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Muzzle, meta = (AllowPrivateAccess = "true"))
UArrowComponent* MuzzlePoint;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Muzzle, meta = (AllowPrivateAccess = "true"))
USceneComponent* MuzzleAttachmentPoint;
public:
ADuskfallCharacter();
/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
float BaseTurnRate;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
float CurrentStamina = 0.0f;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
float CurrentHealth = 0.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float MaxHealth = 100.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float MaxStamina = 100.0f;
ECharacterState GetCharacterState() { return CharacterState; }
void UpdateCharacterState(ECharacterState NewState) { CharacterState = NewState; }
void UpdateMuzzleRotation(FRotator NewRotation);
virtual void CharacterStaggered();
virtual void EndStagger();
virtual void CharacterParryed();
virtual void RegenStamina();
void DecreaseStamina(float StaminaToLose) { CurrentStamina = CurrentStamina - StaminaToLose; }
virtual void PlayGivenCameraShake(TSubclassOf<UCameraShake> GivenCameraShake, float Scale);
/* Health System Interface */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Health Sytem")
void TakeDamage(float Damage, float DamageMoifier, AActor* DamageCauser);
virtual void TakeDamage_Implementation(float Damage, float DamageMoifier, AActor* DamageCauser) override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Health Sytem")
void GainHealth(float HealthToGain, AActor* HealingCauser);
virtual void GainHealth_Implementation(float HealthToGain, AActor* HealingCauser) override;
/* End of Health System Interface */
/* Character Getters Interface */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Getters")
ABaseWeapon* GetWeapon();
virtual ABaseWeapon* GetWeapon_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Getters")
UCharacterMovementComponent* GetCharacterMovementComponent();
virtual UCharacterMovementComponent* GetCharacterMovementComponent_Implementation() override;
/* End of Character Getters Interface*/
/* Character control interface */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void JumpPressed();
virtual void JumpPressed_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void JumpReleased();
virtual void JumpReleased_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void AttackPressed();
virtual void AttackPressed_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void AttackReleased();
virtual void AttackReleased_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void BlockPressed();
virtual void BlockPressed_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void BlockReleased();
virtual void BlockReleased_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void DashPressed();
virtual void DashPressed_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void DashReleased();
virtual void DashReleased_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void UsePressed();
virtual void UsePressed_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void UseReleased();
virtual void UseReleased_Implementation() override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void MoveForward(float Scale);
virtual void MoveForward_Implementation(float Scale) override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void MoveRight(float Scale);
virtual void MoveRight_Implementation(float Scale) override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void TurnRate(float Scale);
virtual void TurnRate_Implementation(float Scale) override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character Controls")
void Turn(float Scale);
virtual void Turn_Implementation(float Scale) override;
/* End of Character Controls Interface */
//virtual void Die();
protected:
virtual void BeginPlay();
virtual void RemoveHealth(float Damage);
virtual void Dash();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Default)
ECharacterState CharacterState = ECharacterState::ECS_Moveable;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float StaminaRegenAmount = 0.1f;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float StaminaRegenRate = 0.1f;
FTimerHandle RegenStaminaTimer;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float DashVelocityModifier = 1.5f;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float DashUpwardForce = 100.0f;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float DashStaminaDrain = 20.0f;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float StaggerLength = 1.0f;
UPROPERTY(EditDefaultsOnly, Category = "Stats")
float ParryedLength = 2.0f;
UPROPERTY(EditDefaultsOnly, Category = "Equipment")
TSubclassOf<ABaseWeapon> StartingWeapon;
UPROPERTY(EditDefaultsOnly, Category = "Equipment")
TSubclassOf<ABaseShield> StartingShield;
ABaseWeapon* Weapon;
ABaseShield* Shield;
FTimerHandle StaggerDelayTimer;
FTimerHandle ParryedDelayTimer;
//Audio
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* WalkAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* JumpAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* DashAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* DeathAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* HitAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
USoundCue* ParriedAudio;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Audio")
float MasterVolume = 1.0f;
UAudioComponent* MovementAudioComponent;
};
|
f8b9d0a80b04c1dc35a60632ccc67a4a75ebe304
|
cbdaec7d7ff7e0d72a49b4338aadcfe58678a094
|
/YJ/20200904/Graph/가장 먼 노드.cpp
|
2eb4952e25b464e8ede2ef53f93cff6cd87c5efd
|
[] |
no_license
|
peterhyun1234/Algorithm_team_BOJ
|
e17bda47d1080d5a289c9a59973a245d83fa4690
|
30efb9d0627e4143f4d887e833c4b2f77aab00e6
|
refs/heads/master
| 2022-12-10T16:11:43.995299
| 2020-09-16T14:43:18
| 2020-09-16T14:43:18
| 278,537,750
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 977
|
cpp
|
가장 먼 노드.cpp
|
#include <string>
#include <vector>
#include <queue>
using namespace std;
int solution(int n, vector<vector<int>> edge) {
int answer = 0, max_val = -2147000000;
queue<pair<int, int>> Q;
vector<int> graph[n + 1];
vector<int> chk(n + 1, 0);
for (int i = 0; i < edge.size(); i ++) {
graph[edge[i][0]].push_back(edge[i][1]);
graph[edge[i][1]].push_back(edge[i][0]);
}
Q.push({1, 0});
while(!Q.empty()) {
int tmp = Q.front().first;
int now_dist = Q.front().second;
Q.pop();
if (chk[tmp] == 0) {
chk[tmp] = now_dist + 1;
if (now_dist + 1 > max_val) max_val = now_dist + 1;
for (int i = 0; i < graph[tmp].size(); i ++) {
Q.push({graph[tmp][i], now_dist + 1});
}
}
}
for (int i = 1; i <= chk.size(); i ++) {
if (chk[i] == max_val) answer++;
}
return answer;
}
|
41cfd98071629a03fdb9797790465cc603a60548
|
cdbce8b09cf43bf2e66e5e3437ae591262a55270
|
/(4360) Software Engineering/ConsoleApplication1/ConsoleApplication1/Source.cpp
|
af9ce5eaecab0509761e9b7cc8d57eccf87c1403
|
[] |
no_license
|
tokenok/Visual-Studio-Projects
|
b82a53f141eff01eef69f119f55dabd8b52e803e
|
c3947dda48fdccdba01a21b0e5052b12a18fe2a6
|
refs/heads/master
| 2022-05-02T11:06:46.201991
| 2018-10-28T22:07:24
| 2018-10-28T22:07:24
| 89,531,738
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 628
|
cpp
|
Source.cpp
|
#include <iostream>
#include <sstream>
#include <string>
#include <sapi.h>
#include <fstream>
ISpVoice *Voice = NULL;
HRESULT hRes;
std::wstring str_to_wstr(std::string s) {
std::wstring w(s.begin(), s.end());
return w;
}
void init_voice_com() {
CoInitialize(0);
hRes = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&Voice);
}
void voice_release() {
if (Voice) {
Voice->Release();
Voice = NULL;
CoUninitialize();
}
}
int main() {
init_voice_com();
std::string s = "";
while (std::getline(std::cin, s)) {
Voice->Speak(str_to_wstr(s + "\0").c_str(), 0, 0);
}
voice_release();
}
|
16d38ad02f40611e839636b8d264c893f3306f77
|
90689ab567acedb0b8ac606eceb2a8b49ffb6b0f
|
/RecordStore/Trade.cpp
|
41461fda9f79638989596917bf5a386cadf3fa68
|
[] |
no_license
|
AndrewTVK/Programming_Projects
|
a07fbd5083277373e4c727a28cba07eb67408f15
|
a841d3745cbc370fa87f5521dd2f3fb15e98eb08
|
refs/heads/master
| 2021-01-24T17:48:01.198518
| 2017-12-15T21:00:48
| 2017-12-15T21:00:48
| 50,820,301
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,977
|
cpp
|
Trade.cpp
|
//Trade.cpp
//Author: Andrew VanKooten
//Description: Derived class that derives from Transaction that stores a trade transaction
//Assumptions: Appropiate files are included
#include "Trade.h"
Trade::Trade()
{
}
//Overloaded Constructor
//Description: the info in descriptions will be added to the protected members in *this
//Preconditions: descriptions must be correctly formatted
//Postconditions: the members of *this will be equal to the info in descriptions
Trade::Trade(string& descriptions)
{
type = 'T';
stringstream stream(descriptions);
string stuff;
//Get customer ID
getline(stream, stuff, ',');
stream.get();
ID = atoi(stuff.c_str());
stuff = "";
//Get Object type
getline(stream, stuff, ',');
stream.get();
objectType = stuff[0];
stuff += ", ";
//Get the rest
string rest;
getline(stream, rest);
history = "Trade: " + stuff + rest;
item = Factory.createObject(objectType, rest);
}
Trade::~Trade()
{
delete item;
}
//create()
//Description: returns a transactions pointer that points to a trade object will the correct data
//Preconditions: descriptions must be formatted correctly
//Postconditions: the transaction pointer will point to a new trade object
Transaction* Trade::create(string& descriptions)
{
Trade* returnPtr = new Trade(descriptions);
return returnPtr;
}
//executeCommand
//Description: adds item to the Inventory and adds the history to th customer
//Preconditions: all the accepted objects must point to data on the heap
//Postconditions: item will be added to Inventory and the history will be updated
void Trade::executeCommand(BSTree* Inventory[], Customer* customerList[], BSTree& customers)
{
//If customer doesnt exist, return
if (customerList[ID] == NULL) return;
//Add item to Inventory
ObjectBox* newItem = new ObjectBox(item);
Inventory[item->getType() - 'A']->insert(newItem);
//Add item to History
Customer* customer = customerList[ID];
if (customer != NULL) customer->addHistory(history);
}
|
c4e5646e942770e28c4d259e455a15a741d4f3fd
|
5ddca05617a40ff1f20832c5f50916cbe850c61f
|
/sch/Scheduler.h
|
963e80ae48a999f60108bcf96f318114f10a9695
|
[] |
no_license
|
arikolsh/sch
|
faf09e3d3b4f025e60a1fa0ac1a2f25fc066dbe0
|
7d538850c4ffd8b492e858dfa240b845ce3e1587
|
refs/heads/final
| 2021-01-23T04:30:11.308756
| 2017-06-11T14:32:03
| 2017-06-11T14:32:03
| 92,930,702
| 0
| 0
| null | 2017-06-11T09:34:06
| 2017-05-31T09:43:11
|
C++
|
UTF-8
|
C++
| false
| false
| 1,395
|
h
|
Scheduler.h
|
#pragma once
#include "SchedulerData.h"
#include <fstream>
class Scheduler
{
public:
explicit Scheduler(std::string schedulerType, int weight, int quantum);
~Scheduler();
bool init(const std::string& inPath, const std::string& outPath);
void run();
/* Get packet from file and put in appropriate queue in dataStruct. if reached EOF update isEOF to true.
* put weight of packet in weight: if not first packet of flow weight will be default weight. this is okay because
* the actual weight of the flow was already determined and put in the flows Data structure. */
Packet getPacketFromFile(int& weight);
/* Return up to "weight" packets from the flow that shpuld be currently served according to WRR algorithm */
std::vector<Packet> getPacketsToSend_WRR(int& currFlow);
private:
int _defaultWeight;
std::string _schedulerType; // "RR" or "DRR"
SchedulerData _flowsData; // SchedulerData class object that holds all flows and relevant data ("On-Line")
std::ifstream _inputFile;
std::ofstream _outputFile;
bool _isEOF; // Set to true once reached end of input file
Packet _lastReceivedPacket;
int _lastReceivedPacketWeight;
int _currentTime;
int _currentFlowIndex; // Keep track of the flow that should be served next
bool _currFlowChanged = false;
int _packetsSent = 0; // In "RR" mode we send packets until _packetsSent = weight (or no more packets to send from flow)
};
|
87166c3040dadfbce45843f757d32e6b35eb3dc5
|
3eaf76b85f0109a422d301fe431c5601fad007cd
|
/cookoff_1.cpp
|
6aade82845d57754fda8ebdf9f3269eecd930014
|
[] |
no_license
|
apsc/Competitive_Programming
|
7dda3eb61a1fbb9b84a7b22f758d856cb61cfc9f
|
fce9cac47a0e3d97d1d1c7c9332bcd1e1fba2ee1
|
refs/heads/master
| 2021-01-20T21:53:16.948844
| 2013-05-04T17:59:03
| 2013-05-04T17:59:03
| 7,189,483
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 635
|
cpp
|
cookoff_1.cpp
|
#include<stdio.h>
int main(){
int t,a,b,c[110],sum,temp,flag;
scanf("%d",&t);
while(t--){
int i;flag=0;
for(i=0;i<=109;i++)c[i]=0;
sum=0;
scanf("%d%d",&a,&b);
i=a;
while(a--){
scanf("%d",&temp);
c[temp]=1;
sum+=temp;
}
a=sum/b;
a*=b;
for(int i=a;i<sum;i++)if(c[sum-i]==1){flag=1;break;}
if(flag)printf("%d\n",-1);
else printf("%d\n",a/b);
}
return 0;
}
|
99f1105b0959fa552f96a942277ce77cf0b39df9
|
0bff4b1aecddd53ab393c9787228483cb2a556aa
|
/src/utils/ServoDiagnostics.cpp
|
bf77cddacc003e541892e9f5542cee23a8346161
|
[
"MIT"
] |
permissive
|
PEQUI-MEC/HUMANOID-MBED
|
9e8486de79d7f205247f6f4bd5fdbcdbd6252307
|
ba5eef581315aa04b171fbc27c7fb0d2475985fc
|
refs/heads/master
| 2021-08-07T18:38:31.660626
| 2019-01-08T19:40:11
| 2019-01-08T19:40:11
| 132,956,472
| 1
| 0
|
MIT
| 2019-01-08T19:35:22
| 2018-05-10T21:32:01
|
C
|
UTF-8
|
C++
| false
| false
| 2,314
|
cpp
|
ServoDiagnostics.cpp
|
#include "ServoDiagnostics.h"
#ifdef CFG_X
// TODO: Ler a posição de vários motores
// TODO: Controlar a posição do motor atraves da serial do pc
ServoDiagnostics::ServoDiagnostics(PinName tx, PinName rx, int baud) {
this->tx = tx;
this->rx = rx;
this->baudRate = baud;
this->serial = new BufferSerial(tx, rx, 32);
this->serial->baud(baud);
}
void ServoDiagnostics::detectServo(int id) {
XYZrobotServo servo(id, *this->serial, this->baudRate);
servo.readStatus();
if (servo.getLastError()) {
if (servo.getLastError() == (uint8_t)XYZrobotServoError::HeaderTimeout) {
printf("Timeout with id %d...\n", id);
} else {
printf("ID %d error: %d\n", id, servo.getLastError());
}
return;
}
printf("ID %d: Servo detected\n", id);
// Make the servo's LED shine magenta for one second.
// blinkServoLed(servo);
}
void ServoDiagnostics::detectServos(int rps) {
printf("Detecting servos at %d baud...\n", this->baudRate);
for (int id = 1 ; id <= 255 ; id++) {
detectServo(id);
wait_ms(1000/rps);
}
}
void ServoDiagnostics::detectServos(int* ids, int length, int rps) {
printf("Detecting servos at %d baud...\n", this->baudRate);
for (int i = 0 ; i < length ; i++) {
detectServo(ids[i]);
wait_ms(1000/rps);
}
}
void ServoDiagnostics::trackServoPosition(int id, int rps) {
DigitalOut led1(LED1);
XYZrobotServo servo(id, *this->serial, this->baudRate);
XYZrobotServoStatus status;
while(true) {
wait_ms(1000/rps);
status = servo.readStatus();
if (servo.getLastError()) {
led1 = 0;
printf("Error: %d\n", servo.getLastError());
} else {
led1 = 1;
printf("$%d;\n", status.position);
}
}
}
void ServoDiagnostics::setServoPosition(int id, int position, int playtime) {
XYZrobotServo servo(id, *this->serial, this->baudRate);
printf("Setting position to %d...\n", position);
servo.setPosition(position, playtime);
}
void ServoDiagnostics::setServoPosition(
int id,
int* positions,
int length,
float interval,
int playtime
) {
XYZrobotServo servo(id, *this->serial, this->baudRate);
for (int i = 0 ; i < length ; i++) {
printf("Setting position to %d...\n", positions[i]);
servo.setPosition(positions[i], playtime);
wait_ms(interval);
}
}
#endif
|
448abaeb5bf0155ea894f48cdb2a8356f016f9b5
|
0eff74b05b60098333ad66cf801bdd93becc9ea4
|
/second/download/httpd/gumtree/httpd_repos_function_1853_httpd-2.0.58.cpp
|
fde6c0fbdc55761cf45fa03fe88597346478e8a7
|
[] |
no_license
|
niuxu18/logTracker-old
|
97543445ea7e414ed40bdc681239365d33418975
|
f2b060f13a0295387fe02187543db124916eb446
|
refs/heads/master
| 2021-09-13T21:39:37.686481
| 2017-12-11T03:36:34
| 2017-12-11T03:36:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 747
|
cpp
|
httpd_repos_function_1853_httpd-2.0.58.cpp
|
const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips)
{
char *host, *scope_id;
apr_port_t port;
apr_status_t rv;
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return err;
}
rv = apr_parse_addr_port(&host, &scope_id, &port, ips, cmd->pool);
if (rv != APR_SUCCESS) {
return "Invalid address or port";
}
if (host && !strcmp(host, "*")) {
host = NULL;
}
if (scope_id) {
/* XXX scope id support is useful with link-local IPv6 addresses */
return "Scope id is not supported";
}
if (!port) {
return "Port must be specified";
}
return alloc_listener(cmd->server->process, host, port);
}
|
76c01bcfc5223ede63d8168116dd0dea6d8120fc
|
1c25c11c16492e9f9202b797203a6ac75ebef6e5
|
/src/Camera.cpp
|
fabcbb10bdae4fba842045389d38fd0b4b02b48e
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] |
permissive
|
bernhardmgruber/hlbsp
|
2fabd9d66ca69ae1f04f73fe393efa7a33897c27
|
a2144818fb6e747409dcd93cab97cea7f055dbfd
|
refs/heads/master
| 2021-07-19T03:15:25.849155
| 2020-04-27T23:34:13
| 2020-04-27T23:35:50
| 144,419,170
| 10
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 762
|
cpp
|
Camera.cpp
|
#include "Camera.h"
#include "global.h"
#include "mathlib.h"
Camera::Camera(PlayerMove& pmove) : pmove(pmove) {}
auto Camera::viewVector() const -> glm::vec3 {
return pmove.forward;
}
auto Camera::viewMatrix() const -> glm::mat4 {
auto& pitch = pmove.angles.x;
auto& yaw = pmove.angles.y;
auto& position = pmove.origin;
// in BSP v30 the z axis points up and we start looking parallel to x axis
glm::mat4 mat = glm::eulerAngleXZ(degToRad(pitch - 90.0f), degToRad(-yaw + 90.0f));
mat = glm::translate(mat, -position); // move
return mat;
}
auto Camera::projectionMatrix() const -> glm::mat4 {
return glm::perspective(degToRad(fovy), static_cast<float>(viewportWidth) / static_cast<float>(viewportHeight), 1.0f, 4000.0f);
}
|
9c1427b8aee2f07378e80bc28c4df31b95a2f762
|
fdf08b05ff4c660e183739dbc18009d0a9b8a49a
|
/OpenTESArena/src/Audio/AudioManager.h
|
904dc3d54e591fed13867720d90225df48e0ed63
|
[
"MIT"
] |
permissive
|
afritz1/OpenTESArena
|
f67c4f6ee8981ef3bffbfe5894e2b48d67554475
|
7e91599157e2b9268237b6689f691d29e89b1d74
|
refs/heads/main
| 2023-08-31T09:25:21.908575
| 2023-08-27T01:24:29
| 2023-08-27T01:24:29
| 50,629,945
| 942
| 100
|
MIT
| 2023-08-21T03:42:36
| 2016-01-29T02:07:08
|
C++
|
UTF-8
|
C++
| false
| false
| 4,741
|
h
|
AudioManager.h
|
#ifndef AUDIO_MANAGER_H
#define AUDIO_MANAGER_H
#include <deque>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include "al.h"
#include "Midi.h"
#include "../Math/Vector3.h"
// This class manages what sounds and music are played by OpenAL Soft.
class MusicDefinition;
class OpenALStream;
class Options;
class AudioManager
{
public:
// Contains data for defining the state of an audio listener.
class ListenerData
{
private:
Double3 position;
Double3 direction;
public:
ListenerData(const Double3 &position, const Double3 &direction);
const Double3 &getPosition() const;
const Double3 &getDirection() const;
};
private:
static constexpr ALint UNSUPPORTED_EXTENSION = -1;
float mMusicVolume;
float mSfxVolume;
bool mHasResamplerExtension; // Whether AL_SOFT_source_resampler is supported.
ALint mResampler;
bool mIs3D;
std::string mNextSong;
// Sounds which are allowed only one active instance at a time, otherwise they would
// sound a bit obnoxious. This functionality is added here because the original game
// can only play one sound at a time, so it doesn't have this problem.
std::vector<std::string> mSingleInstanceSounds;
// Currently active song and playback stream.
MidiSongPtr mCurrentSong;
std::unique_ptr<OpenALStream> mSongStream;
// Loaded sound buffers from .VOC files.
std::unordered_map<std::string, ALuint> mSoundBuffers;
// A deque of available sources to play sounds and streams with.
std::deque<ALuint> mFreeSources;
// A deque of currently used sources for sounds (the music source is owned
// by OpenALStream). The string is the filename and the integer is the ID.
// The filename is required for some sounds that can only have one instance
// active at a time.
std::deque<std::pair<std::string, ALuint>> mUsedSources;
// Use this when resetting sound sources back to their default resampling. This uses
// whatever setting is the default within OpenAL.
static ALint getDefaultResampler();
// Gets the resampling index to use, given some resampling option. The two values are not
// necessarily identical (depending on the resampling implementation). Causes an error
// if the resampling extension is unsupported.
static ALint getResamplingIndex(int value);
// Whether there is a music queued after the current one.
bool hasNextMusic() const;
void setListenerPosition(const Double3 &position);
void setListenerOrientation(const Double3 &direction);
void playMusic(const std::string &filename, bool loop);
public:
AudioManager();
~AudioManager();
void init(double musicVolume, double soundVolume, int maxChannels, int resamplingOption,
bool is3D, const std::string &midiConfig, const std::string &audioDataPath);
static constexpr double MIN_VOLUME = 0.0;
static constexpr double MAX_VOLUME = 1.0;
double getMusicVolume() const;
double getSoundVolume() const;
// Returns whether the implementation supports resampling options.
bool hasResamplerExtension() const;
// Returns whether the given filename is playing in any sound handle.
bool isPlayingSound(const std::string &filename) const;
// Returns whether the given filename references an actual sound.
bool soundExists(const std::string &filename) const;
// Plays a sound file. All sounds should play once. If 'position' is empty then the sound
// is played globally.
void playSound(const std::string &filename,
const std::optional<Double3> &position = std::nullopt);
// Sets the music to the given music definition, with an optional music to play first as a
// lead-in to the actual music. If no music definition is given, the current music is stopped.
void setMusic(const MusicDefinition *musicDef, const MusicDefinition *optMusicDef = nullptr);
// Stops the music.
void stopMusic();
// Stops all sounds.
void stopSound();
// Sets the music volume. Percent must be between 0.0 and 1.0.
void setMusicVolume(double percent);
// Sets the sound volume. Percent must be between 0.0 and 1.0.
void setSoundVolume(double percent);
// Sets the resampling option used by all sources. Note that the given index does not
// necessarily map to a specific index in the resampling list. Causes an error if
// resampling options are not supported.
void setResamplingOption(int resamplingOption);
// Sets whether game world audio should be played in 2D (global) or 3D (with a listener).
// The 2D option is provided for parity with the original engine.
void set3D(bool is3D);
// Updates state not handled by a background thread, such as resetting finished sources.
void updateSources();
// Updates the position of the 3D listener.
void updateListener(const ListenerData &listenerData);
};
#endif
|
cc6a09ae5346c31c12ae18b34fe96758631084f0
|
fa640678cd5d8a4e65798300da94d02c795b137a
|
/src/track.cpp
|
77a7fe5271854a585124ed4af0ddea26ebf6a2f3
|
[] |
no_license
|
cjquinn/rollercoaster
|
e5917bfdc4d3245c88a5b457a5675fe34c2e435d
|
401213a3fc3f82ee5fa8b967f6b19c4bc597b6ee
|
refs/heads/master
| 2021-04-11T16:55:47.042356
| 2020-03-23T02:37:30
| 2020-03-23T02:37:30
| 249,038,812
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,922
|
cpp
|
track.cpp
|
#include "track.h"
#include <iostream>
#include <fstream>
#include "canvas.h"
#include "circle.h"
#include "frame.h"
#include "lighting.h"
#include "matrixstack.h"
#include "mesh.h"
#include "shaderprogram.h"
#include "spline.h"
#include "support.h"
#include "texture.h"
#include "vertex.h"
Track::Track() : mesh_(NULL), spline_(NULL), texture_(NULL) {}
Track::~Track()
{
while(!supports_.empty()) {
delete supports_.back();
supports_.pop_back();
}
while(!circles_.empty()) {
delete circles_.back();
circles_.pop_back();
}
delete mesh_;
delete spline_;
delete texture_;
}
void Track::create(std::string track)
{
std::vector<glm::vec3> points;
std::string line;
std::ifstream file(track);
while (std::getline(file, line)) {
std::vector<float> coords;
std::stringstream ss(line);
std::string coord;
while (std::getline(ss, coord, ',')) {
coords.push_back(std::stof(coord));
}
points.push_back(glm::vec3(coords.at(0), coords.at(1), coords.at(2)));
}
mesh_ = new Mesh;
spline_ = new Spline;
spline_->create(points);
texture_ = new Texture;
texture_->load(ROOT_DIR + std::string("/resources/textures/track.jpg"));
texture_->setFiltering(TEXTURE_FILTER_MAG_BILINEAR, TEXTURE_FILTER_MIN_BILINEAR);
texture_->setSamplerParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
texture_->setSamplerParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
std::vector<Vertex> vertices;
std::vector<unsigned int> triangles;
int samples = 5;
for (unsigned int i = 0; i < spline_->sampled_points().size() - 1; i++) {
Circle *circle = new Circle;
circle->create(new Frame(spline_->sampled_points().at(i), spline_->sampled_points().at(i+1)), samples, 2.0f);
circles_.push_back(circle);
if (i % (int) (spline_->sampled_points().size() / 60) == 0) {
Support *support = new Support;
support->create(spline_->sampled_points().at(i));
supports_.push_back(support);
}
}
for (unsigned int j = 0; j < circles_.size(); ++j) {
for (int i = 0; i < samples; ++i) {
Vertex v(circles_.at(j)->vertices().at(i), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec2(0.0f, 0.0f));
vertices.push_back(v);
}
}
for (int i = 0; i < samples; ++i) {
for (unsigned int j = 0; j < circles_.size(); ++j) {
int index = i + j * samples;
if (j < circles_.size() - 1) {
triangles.push_back((index + 1 + samples) % vertices.size());
triangles.push_back((index + 1) % vertices.size());
triangles.push_back((index) % vertices.size());
triangles.push_back((index + samples) % vertices.size());
triangles.push_back((index + 1 + samples) % vertices.size());
triangles.push_back((index) % vertices.size());
} else {
triangles.push_back((1 + i) % vertices.size());
triangles.push_back((index + 1) % vertices.size());
triangles.push_back((index) % vertices.size());
triangles.push_back((i) % vertices.size());
triangles.push_back((1 + i) % vertices.size());
triangles.push_back((index) % vertices.size());
}
}
}
mesh_->create(vertices, triangles, true);
}
void Track::render()
{
ShaderProgram *main = Canvas::instance().shader_programs(0);
main->use();
main->setUniform("toonify", true);
main->setUniform("texture_fragment", true);
texture_->bind();
// Set up a matrix stack
glutil::MatrixStack modelview = Canvas::instance().modelview();
// Set light and materials in main shader program
glm::vec4 light_position(0, 100, 0, 1);
glm::vec4 light_eye = modelview.top() * light_position;
Lighting::setPosition(light_eye);
Lighting::setReflectance(glm::vec3(1.0f, 0.443f, 0.654f), glm::vec3(1.0f, 0.356f, 0.603f), glm::vec3(0.1f), 15.0f);
modelview.push();
main->setUniform("matrices.modelview", modelview.top());
mesh_->render();
modelview.pop();
for (unsigned int i = 0; i < supports_.size(); i++) {
supports_.at(i)->render();
}
}
Spline* Track::spline()
{
return spline_;
}
|
388774765e1ce359f37548786eb3d1f320835a2c
|
42a2966d8e8a75c615f2171502932611f9d7fd96
|
/Lab4/Student_Code/ORDeque.h
|
c6151fc0d1d32806e914e3759b1f361f9d24d069
|
[] |
no_license
|
tebbsja/cs235
|
7d68d12709b0ba328c54acad2f6acb783f32aefd
|
4d92a877cf07c6784185231c72d0b69606571437
|
refs/heads/master
| 2021-01-10T21:55:10.728618
| 2015-12-10T10:20:54
| 2015-12-10T10:20:54
| 42,635,703
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 526
|
h
|
ORDeque.h
|
//
// ORDeque.hpp
// Lab4
//
// Created by Austin Tebbs on 10/20/15.
// Copyright © 2015 Austin Tebbs. All rights reserved.
//
#ifndef ORDeque_h
#define ORDeque_h
#include "LinkedList.h"
#include <stdio.h>
class ORDeque
{
private:
LinkedList <int> my_ordeque;
public:
bool exists(int car);
bool pushLeft(int car);
bool pushRight(int car);
ORDeque(){};
int left();
int right();
bool empty();
bool popLeft();
bool popRight();
int size();
};
#endif /* ORDeque_h */
|
8c4085412e7413d7d54aa4477daeee28041d7e2a
|
a5bd3c4316afcf2c3e347bf76ffa4fd3d00322ed
|
/Person.h
|
5356f1f8a861f6a4fa729dcc4a6fdb03d0deec01
|
[] |
no_license
|
eif-courses/searchingTechniques
|
7e4ddd16f4fc0cbf16738abc6e39c717ce963add
|
27c0f2af987745ede108545c471ae0b4191f4516
|
refs/heads/master
| 2021-05-18T12:15:04.802231
| 2020-03-30T08:05:24
| 2020-03-30T08:05:24
| 251,240,115
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 574
|
h
|
Person.h
|
//
// Created by Marius on 3/28/2020.
//
#ifndef SEARCHINGTECHNIQUES_PERSON_H
#define SEARCHINGTECHNIQUES_PERSON_H
#include <iostream>
class Person {
private:
std::string name;
std::string address;
std::string skills;
int age;
int id;
public:
Person(const std::string &name, const std::string &address, const std::string &skills, int age, int id);
const std::string &getName() const;
int getId() const;
const std::string &getAddress() const;
const std::string &getSkills() const;
int getAge() const;
};
#endif //SEARCHINGTECHNIQUES_PERSON_H
|
1fd3b44fbf0f4e8c9da97b6c09e9420d3a07047a
|
24f26275ffcd9324998d7570ea9fda82578eeb9e
|
/ash/assistant/util/assistant_util.cc
|
8875bcacfb89eb36ba52d58dcf45ff080612b194
|
[
"BSD-3-Clause"
] |
permissive
|
Vizionnation/chromenohistory
|
70a51193c8538d7b995000a1b2a654e70603040f
|
146feeb85985a6835f4b8826ad67be9195455402
|
refs/heads/master
| 2022-12-15T07:02:54.461083
| 2019-10-25T15:07:06
| 2019-10-25T15:07:06
| 217,557,501
| 2
| 1
|
BSD-3-Clause
| 2022-11-19T06:53:07
| 2019-10-25T14:58:54
| null |
UTF-8
|
C++
| false
| false
| 3,144
|
cc
|
assistant_util.cc
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/assistant/util/assistant_util.h"
#include <string>
#include "ash/assistant/model/assistant_ui_model.h"
#include "base/strings/string_util.h"
#include "base/system/sys_info.h"
namespace {
constexpr char kEveBoardType[] = "eve";
constexpr char kNocturneBoardType[] = "nocturne";
bool g_override_is_google_device = false;
bool IsBoardType(const std::string& board_name, const std::string& board_type) {
// The sub-types of the board will have the form boardtype-XXX.
// To prevent the possibility of common prefix in board names we check the
// board type with '-' here. For example there might be two board types with
// codename boardtype1 and boardtype123.
return board_name == board_type ||
base::StartsWith(board_name, board_type + '-',
base::CompareCase::SENSITIVE);
}
} // namespace
namespace ash {
namespace assistant {
namespace util {
bool IsStartingSession(AssistantVisibility new_visibility,
AssistantVisibility old_visibility) {
return old_visibility == AssistantVisibility::kClosed &&
new_visibility == AssistantVisibility::kVisible;
}
bool IsFinishingSession(AssistantVisibility new_visibility) {
return new_visibility == AssistantVisibility::kClosed;
}
bool IsVoiceEntryPoint(AssistantEntryPoint entry_point, bool prefer_voice) {
switch (entry_point) {
case AssistantEntryPoint::kHotword:
return true;
case AssistantEntryPoint::kLauncherSearchBoxMic:
case AssistantEntryPoint::kHotkey:
case AssistantEntryPoint::kLauncherSearchBox:
case AssistantEntryPoint::kLongPressLauncher:
return prefer_voice;
case AssistantEntryPoint::kUnspecified:
case AssistantEntryPoint::kDeepLink:
case AssistantEntryPoint::kLauncherSearchResult:
case AssistantEntryPoint::kProactiveSuggestions:
case AssistantEntryPoint::kSetup:
case AssistantEntryPoint::kStylus:
return false;
}
}
bool ShouldAttemptWarmerWelcome(AssistantEntryPoint entry_point) {
switch (entry_point) {
case AssistantEntryPoint::kDeepLink:
case AssistantEntryPoint::kHotword:
case AssistantEntryPoint::kLauncherSearchBoxMic:
case AssistantEntryPoint::kLauncherSearchResult:
case AssistantEntryPoint::kProactiveSuggestions:
case AssistantEntryPoint::kStylus:
return false;
case AssistantEntryPoint::kUnspecified:
case AssistantEntryPoint::kHotkey:
case AssistantEntryPoint::kLauncherSearchBox:
case AssistantEntryPoint::kLongPressLauncher:
case AssistantEntryPoint::kSetup:
return true;
}
}
bool IsGoogleDevice() {
const std::string board_name = base::SysInfo::GetLsbReleaseBoard();
return g_override_is_google_device ||
IsBoardType(board_name, kEveBoardType) ||
IsBoardType(board_name, kNocturneBoardType);
}
void OverrideIsGoogleDeviceForTesting() {
g_override_is_google_device = true;
}
} // namespace util
} // namespace assistant
} // namespace ash
|
4756278c06edee14a3782d1abc8f55bc04145a1c
|
f1847ef548e507e5ee4b5bfd65e5d521b15f2b5c
|
/DX11_Framework_custom/GameView.cpp
|
d27e373d3f5964f492ac891ffe7b22781ddcb3dc
|
[
"Artistic-2.0"
] |
permissive
|
mister51213/EscapeNY
|
0c98425935c896125505d6bea8326d3caf9ca825
|
f537728012a2d9d310d98e8ecbcf7886d2c4755d
|
refs/heads/master
| 2020-04-15T12:47:38.343623
| 2016-12-06T12:33:47
| 2016-12-06T12:33:47
| 63,054,685
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,389
|
cpp
|
GameView.cpp
|
#include "GameView.h"
#include "D3DGraphics.h"
#include "Camera.h"
#include "Graphics.h"
#include "Model_TexturedNM.h"
using namespace DirectX;
using std::vector;
GameView::GameView()
:
m_pGfx( nullptr ),
m_pD3D( nullptr ),
m_pCam( nullptr )
{}
GameView::GameView( Graphics * pGfx, D3DGraphics * pD3D, Camera* pCam )
:
m_pGfx( pGfx ),
m_pD3D( pD3D ),
m_pCam( pCam )
{}
void GameView::Initialize()
{
initModelPool();
initTexturePool();
initNormalMapPool();
initializeShader();
}
void GameView::UpdateView(const vector<Actor*>& actors, const SceneBufferType& SceneLights ) const
{
/*bool result = m_activeShader.UpdateLightBuffer(
m_pD3D->GetDeviceContext(),
&(lightSet[0]));*/
bool result = m_shader_nMap.UpdateLightBuffer(
m_pD3D->GetDeviceContext(),
SceneLights );
// TODO: update the ShaderTEMPLATE to handle MULTPILE LIGHTS
if (!result)
{
MessageBox(nullptr, L"Failed to update light buffer.", L"Problem...", MB_OK);
PostQuitMessage(0);
return;
}
// Transpose the matrices HERE now to adhere to the GPU column matrix convention
MatrixBufferType transforms{};
transforms.view = XMMatrixTranspose(m_pCam->GetViewMatrix());
transforms.projection = XMMatrixTranspose(m_pCam->GetProjectionMatrix());
for each (Actor* actor in actors)
{
drawModel(*actor, transforms);
}
}
void GameView::drawModel( const Actor & actor, MatrixBufferType &Transforms ) const
{
// Prepare the graphics pipeline for this actor
auto pContext = m_pD3D->GetDeviceContext();
auto pTextureView = ( m_TexturePool[ actor.GetTexIndex() ] ).GetTextureView();
Transforms.world = GetWorldMatrix( actor.GetWorldSpecs() );
// Update the vertex shader's constant buffer
bool result = m_shader_nMap.UpdateTransformBuffer( pContext, Transforms );
//bool result = m_activeShader.UpdateTransformBuffer( pContext, Transforms );
if( !result )
{
MessageBox( nullptr, L"Failed to update Matrix buffer.", L"Problem...", MB_OK );
PostQuitMessage( 0 );
return;
}
// TODO: pass an array of Textures instead here:
ID3D11ShaderResourceView* texArray[2];
texArray[0] = ( m_TexturePool[ actor.GetTexIndex() ] ).GetTextureView();
texArray[1] = ( m_NormalPool[ actor.GetTexIndex() ] ).GetTextureView();
// Set the shader and its resources
// m_activeShader.Render( pContext, pTextureView );
//m_activeShader.Render( pContext, texArray );
m_shader_nMap.Render( pContext, texArray );
// DRAW CALL
m_pGfx->RenderModel(*(m_ModelPool[actor.GetModelType()]));
}
void GameView::initModelPool()
{
char numModels = 11;
ModelSpecs_L defaultSpecs;
m_ModelPool.resize(numModels);
PrimitiveFactory prim;
prim.CreateCubeNM(defaultSpecs);
prim.CreateColor(1.f,0.f,0.f,.5f);
m_ModelPool[CUBE].reset(new Model_TexturedNM );
m_ModelPool[CUBE]->Initialize(prim, *m_pGfx);
prim.CreateCubeNM(defaultSpecs);
prim.CreateColor( 1.f, 1.f, 1.f, 1.f );
m_ModelPool[CUBE_TEXTURED].reset(new Model_TexturedNM );
m_ModelPool[CUBE_TEXTURED]->Initialize(prim, *m_pGfx);
prim.CreatePlaneNM(defaultSpecs);
m_ModelPool[PLANE].reset(new Model_TexturedNM );
m_ModelPool[PLANE]->Initialize(prim, *m_pGfx);
prim.CreateSphereNM( defaultSpecs, 1.0f); // TODO: MAKE SURE YOU HAVE UNIVERSAL UNITS TO BE SHARED GLOBALLY
m_ModelPool[SPHERE].reset(new Model_TexturedNM );
m_ModelPool[SPHERE]->Initialize(prim, *m_pGfx);
prim.CreateTriangle(defaultSpecs);
m_ModelPool[POLYGON].reset(new Model_Textured);
m_ModelPool[POLYGON]->Initialize(prim, *m_pGfx);
//prim.CreateMesh(L"Meshes\\Cube.txt");
prim.CreateMeshNM(L"Meshes\\model.BinaryMesh");
m_ModelPool[CUSTOM_MESH].reset(new Model_TexturedNM );
m_ModelPool[CUSTOM_MESH]->Initialize(prim, *m_pGfx);
prim.CreateMesh(L"Meshes\\model2.BinaryMesh");
m_ModelPool[CUSTOM_MESH2].reset(new Model_Textured);
m_ModelPool[CUSTOM_MESH2]->Initialize(prim, *m_pGfx);
prim.CreateMesh(L"Meshes\\model3.BinaryMesh");
m_ModelPool[CUSTOM_MESH3].reset(new Model_Textured);
m_ModelPool[CUSTOM_MESH3]->Initialize(prim, *m_pGfx);
prim.CreateMesh(L"Meshes\\model4.BinaryMesh");
m_ModelPool[CUSTOM_MESH4].reset(new Model_Textured);
m_ModelPool[CUSTOM_MESH4]->Initialize(prim, *m_pGfx);
prim.CreateMeshNM( L"Meshes/cube_inverted.BinaryMesh" );
m_ModelPool[ SOME_EDIFICE ].reset( new Model_TexturedNM );
m_ModelPool[ SOME_EDIFICE ]->Initialize( prim, *m_pGfx );
prim.CreateMeshNM( L"Meshes/car.BinaryMesh" );
m_ModelPool[ CAR ].reset( new Model_TexturedNM );
m_ModelPool[ CAR ]->Initialize( prim, *m_pGfx );
//prim.CreateSphereNM( defaultSpecs, 10.0f );
//prim.CreateColor( 1.f, 0.f, 0.f, 1.f );
//m_ModelPool[ SPHERE ].reset( new Model_TexturedNM );
//m_ModelPool[ SPHERE ]->Initialize( prim, *m_pGfx );
}
void GameView::initTexturePool()
{
// const int numTextures = 19;
const int numTextures = 11;
m_TexturePool.resize( numTextures );
m_TexturePool[ AsphaltFresh ].Initialize( *m_pGfx, L"Textures\\asphaltFresh.jpg" );
m_TexturePool[ waterSHALLOW ].Initialize( *m_pGfx, L"Textures\\waterSHALLOW.jpg" );
m_TexturePool[ AsphaltOld ].Initialize( *m_pGfx, L"Textures\\asphaltOld.jpg" );
m_TexturePool[ Water1 ].Initialize( *m_pGfx, L"Textures\\water1.jpg" );
m_TexturePool[ Underwater1 ].Initialize( *m_pGfx, L"Textures\\underwater1.jpg" );
m_TexturePool[ SharkSkin ].Initialize( *m_pGfx, L"Textures\\sharkskin5.jpg" );
m_TexturePool[ Aluminum ].Initialize( *m_pGfx, L"Textures\\aluminum.jpg" );
m_TexturePool[ Lava ].Initialize( *m_pGfx, L"Textures\\lava5.jpg" );
m_TexturePool[ Lava2 ].Initialize( *m_pGfx, L"Textures\\lava9.jpg" );
m_TexturePool[ Bush ].Initialize( *m_pGfx, L"Textures\\bush.jpg" );
m_TexturePool[ Energy ].Initialize( *m_pGfx, L"Textures\\energy.jpg" );
//m_TexturePool[ Water2 ].Initialize( *m_pGfx, L"Textures\\water2.jpg" );
//m_TexturePool[ Water3 ].Initialize( *m_pGfx, L"Textures\\water3.jpg" );
//m_TexturePool[ Underwater2 ].Initialize( *m_pGfx, L"Textures\\underwater2.jpg" );
//m_TexturePool[ Underwater3 ].Initialize( *m_pGfx, L"Textures\\underwater3.jpg" );
//m_TexturePool[ Underwater4 ].Initialize( *m_pGfx, L"Textures\\underwater4.jpg" );
//m_TexturePool[ Underwater5 ].Initialize( *m_pGfx, L"Textures\\underwater5.jpg" );
//m_TexturePool[ Underwater6 ].Initialize( *m_pGfx, L"Textures\\underwater6.jpg" );
//m_TexturePool[ Underwater7 ].Initialize( *m_pGfx, L"Textures\\underwater7.jpg" );
}
void GameView::initNormalMapPool()
{
// const int numTextures = 19;
const int numTextures = 11;
m_NormalPool.resize( numTextures );
m_NormalPool[ AsphaltFresh ].Initialize( *m_pGfx, L"Textures\\asphaltFreshN.jpg" );
m_NormalPool[ waterSHALLOW ].Initialize( *m_pGfx, L"Textures\\waterSHALLOWN.jpg" );
m_NormalPool[ AsphaltOld ].Initialize( *m_pGfx, L"Textures\\asphaltOldN.jpg" );
m_NormalPool[ Water1 ].Initialize( *m_pGfx, L"Textures\\water1N.jpg" );
m_NormalPool[ Underwater1 ].Initialize( *m_pGfx, L"Textures\\underwater1N.jpg" );
m_NormalPool[ SharkSkin ].Initialize(*m_pGfx, L"Textures\\sharkskin5N.jpg");
m_NormalPool[ Aluminum ].Initialize( *m_pGfx, L"Textures\\aluminumN.jpg" );
m_NormalPool[ Lava ].Initialize( *m_pGfx, L"Textures\\lava5N.jpg" );
m_NormalPool[ Lava2 ].Initialize( *m_pGfx, L"Textures\\lava9N.jpg" );
m_NormalPool[ Bush ].Initialize( *m_pGfx, L"Textures\\bushN.jpg" );
m_NormalPool[ Energy ].Initialize( *m_pGfx, L"Textures\\energyN.jpg" );
/*m_NormalPool[ Water2 ].Initialize( *m_pGfx, L"Textures\\water2N.jpg" );
m_NormalPool[ Water3 ].Initialize( *m_pGfx, L"Textures\\water3N.jpg" );*/
//m_NormalPool[ Underwater2 ].Initialize( *m_pGfx, L"Textures\\underwater2N.jpg" );
//m_NormalPool[ Underwater3 ].Initialize( *m_pGfx, L"Textures\\underwater3N.jpg" );
//m_NormalPool[ Underwater4 ].Initialize( *m_pGfx, L"Textures\\underwater4N.jpg" );
//m_NormalPool[ Underwater5 ].Initialize( *m_pGfx, L"Textures\\underwater5N.jpg" );
//m_NormalPool[ Underwater6 ].Initialize( *m_pGfx, L"Textures\\underwater6N.jpg" );
//m_NormalPool[ Underwater7 ].Initialize( *m_pGfx, L"Textures\\underwater7N.jpg" );
}
void GameView::initializeShader()
{
//m_activeShader.Initialize( m_pD3D->GetDevice() );
m_shader_nMap.Initialize( m_pD3D->GetDevice(), 10 );
}
|
c76bf7a44b3432d073126448aaedcc5825c183b0
|
43d70c3eac5af55e68628c01b3d442c1bda6fb4c
|
/Main.cpp
|
6796340a625e6f0f79e03768e64e515035634973
|
[] |
no_license
|
AlixDeMitchell/OOT3
|
e5b3d7ed7be8ef07e569ea5b1211e15147967312
|
60434a17f54b233584af9c48466e16731b6978e4
|
refs/heads/master
| 2021-01-18T16:42:50.336514
| 2017-04-02T15:12:21
| 2017-04-02T15:12:21
| 86,758,306
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 231
|
cpp
|
Main.cpp
|
#include <iostream>
#include <SDL.h>
#include <time.h>
#include "Application.h"
int main( int argc, char* argv[] )
{
srand( time( 0 ) );
Application app;
app.Run();
system("PAUSE");
return 0;
}
|
ca4cf181b823e300aec0345c2acea6d24885bfea
|
c6b920f08a4615a7471d026005c2ecc3267ddd71
|
/adapters/Lammps/src/Glue/LammpsSimulationAtomTypeEvent.cpp
|
16801a246bb504f928c986d3c3ca294f3db7d026
|
[] |
no_license
|
etomica/legacy-api
|
bcbb285395f27aa9685f02cc7905ab75f87b017c
|
defcfb6650960bf6bf0a3e55cb5ffabb40d76d8b
|
refs/heads/master
| 2021-01-20T14:07:57.547442
| 2010-04-22T21:19:19
| 2010-04-22T21:19:19
| 82,740,861
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 526
|
cpp
|
LammpsSimulationAtomTypeEvent.cpp
|
/*
* LammpsSimulationAtomTypeEvent.cpp
* API Glue
*
*/
#include "stdio.h"
#include "LammpsSimulationAtomTypeEvent.h"
namespace lammpswrappers
{
LammpsSimulationAtomTypeEvent::LammpsSimulationAtomTypeEvent(IAPISimulation *sim, IAPIAtomType *atomType) :
LammpsSimulationEvent(sim) {
mAtomType = atomType;
}
/*
* getAtomType()
*/
IAPIAtomType *LammpsSimulationAtomTypeEvent::getAtomType() {
return mAtomType;
}
}
|
905489ab6f348b1abde9900f9dd1b866087413ba
|
a3633c36af37b55d6edc3c350214bd73ecced955
|
/src/main.cpp
|
3f19abbd3d9e23441364d6803327d9081c09d323
|
[] |
no_license
|
rblack42/cosc1337.LinkedList
|
306935ffd5f5206368010e59be6dcfdd2d37351e
|
84db7a455e86daced40f2e01d2b6e12a29d1ed19
|
refs/heads/master
| 2021-01-10T05:40:40.036654
| 2018-11-27T00:17:08
| 2018-11-27T00:17:08
| 46,250,221
| 1
| 4
| null | 2015-11-29T06:49:28
| 2015-11-16T03:38:15
|
C++
|
UTF-8
|
C++
| false
| false
| 213
|
cpp
|
main.cpp
|
#include <iostream>
using namespace std;
#include "List.h"
int main( int argc, char *argv[] ) {
cout << "I-35 Simulator" << endl;
List list;
list.addItem(1);
list.addItem(2);
list.print();
}
|
6560ef7c4242c886376b4f4bf59f0bc2b74626c6
|
f902d377709a401d6f60e8d31ea4208d553bbaab
|
/kesimoLinear.cpp
|
0a154773741c6072de41d3b9ae4dfddcf22ea6c3
|
[] |
no_license
|
brunoolivieri/paa_pph
|
5453dc66378579d810878f3beedba8609152d6cc
|
f36bda5feca6a49975d972ff7c9b9dc54039de19
|
refs/heads/master
| 2021-05-15T02:12:42.788207
| 2020-04-10T20:27:32
| 2020-04-10T20:27:32
| 10,551,227
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,818
|
cpp
|
kesimoLinear.cpp
|
#include <iostream>
#include <vector>
#include <algorithm>
#include "PPH.hpp"
using namespace std;
vector<parOrdenado> partition(vector<parOrdenado> &val, float chave){
vector<parOrdenado> lDireito; //Lado Direito da chave
unsigned i;
for(i=0; i<val.size();i++){
if(val[i].razao>chave){
lDireito.push_back(val[i]);
}
}
return lDireito;
}
parOrdenado encontraMediana(vector<parOrdenado> vec){
parOrdenado median = vec[(vec.size()/2)];
return median;
}
parOrdenado encontraMedianaDasMedianas(vector<vector<parOrdenado> > values){
vector<parOrdenado> medians;
for (unsigned i = 0; i < values.size(); i++) {
parOrdenado m = encontraMediana(values[i]);
medians.push_back(m);
}
return encontraMediana(medians);
}
float selectionByMedianOfMedians(const vector<parOrdenado> values,unsigned pos){
vector<vector<parOrdenado> > vec2D;
///Divide a entrada em grupos de tamanho 5
unsigned count = 0;
while (count != values.size()) {
int countRow = 0;
vector<parOrdenado> row;
while ((countRow < 5) && (count < values.size())) {
row.push_back(values[count]);
count++; //Aumenta o número total de elementos do vetor já visitado
countRow++; //Garante que seja dividido em grupos de 5
}
vec2D.push_back(row);
}
/*cout<<endl<<endl<<"Printing 2D vector : "<<endl;
for (unsigned i = 0; i < vec2D.size(); i++) {
for (unsigned j = 0; j < vec2D[i].size(); j++) {
cout<<vec2D[i][j].razao<<" ";
}
cout<<endl;
}
cout<<endl;*/
///Calcula a Mediana das Medianas
parOrdenado medianaDaMediana = encontraMedianaDasMedianas(vec2D);
//cout<<"Mediana da Mediana : "<<medianaDaMediana.razao<<endl;
///Divide a entrada em dois grupos:
///Maiores que a mediana
///Menores que a mediana
vector<parOrdenado> L1, L2;
for (unsigned i = 0; i < vec2D.size(); i++) {
for (unsigned j = 0; j < vec2D[i].size(); j++) {
if (vec2D[i][j].razao > medianaDaMediana.razao) {
L1.push_back(vec2D[i][j]);
}else if (vec2D[i][j].razao < medianaDaMediana.razao){
L2.push_back(vec2D[i][j]);
}
}
}
/*cout<<endl<<"Imprimir vetor L1 : "<<endl;
for (int i = 0; i < L1.size(); i++) {
cout<<L1[i].razao<<" ";
}
cout<<endl<<"Imprimir vetor L2 : "<<endl;
for (int i = 0; i < L2.size(); i++) {
cout<<L2[i].razao<<" ";
}*/
if ((pos - 1) == L1.size()) {
return medianaDaMediana.razao;
}else if (pos <= L1.size()) {
return selectionByMedianOfMedians(L1, pos);
}else{
return selectionByMedianOfMedians(L2, pos-((int)L1.size())-1);
}
}
|
a7f1e7dd4f4e179397180adb1e8ccd309021ca7f
|
332ed17335021d727419a0baf7f1e0c4566af3f7
|
/examples/kaleidoscope/src/AST.cpp
|
f17b5e61261604194262b80e62a38285fdcc10b1
|
[
"BSL-1.0"
] |
permissive
|
Ef55/tfl
|
65b96b246ce276c2aaee5ba36a02368d2fd1e105
|
b670c1552181477e61d5e8b1d76263120e836e80
|
refs/heads/main
| 2023-07-27T18:51:18.696409
| 2021-09-12T17:13:47
| 2021-09-12T17:13:47
| 392,842,534
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,690
|
cpp
|
AST.cpp
|
#include "AST.hpp"
ExprAST::ExprAST(internal::ExprASTImpl* ptr): _ast(ptr) {}
ExprAST ExprAST::number(double v) { return ExprAST(new internal::NumberExprAST(v)); }
ExprAST ExprAST::variable(std::string const& name) { return ExprAST(new internal::VariableExprAST(name)); }
ExprAST ExprAST::op(char op, ExprAST const& left, ExprAST const& right) { return ExprAST(new internal::BinaryExprAST(op, std::move(left), std::move(right))); }
ExprAST ExprAST::call(std::string const& callee, std::vector<ExprAST> const& args) { return ExprAST(new internal::CallExprAST(callee, std::move(args))); }
PrototypeAST::PrototypeAST(std::string const& name, std::vector<std::string> const& args): _name(name), _args(args) {}
FunctionAST::FunctionAST(PrototypeAST const& proto, ExprAST const& body): _proto(proto), _body(std::move(body)) {}
internal::NumberExprAST::NumberExprAST(double v): _val(v) {}
void internal::NumberExprAST::visit(ASTVisitor<void>& visitor) const {
visitor.number(_val);
}
internal::VariableExprAST::VariableExprAST(std::string const& name): _name(name) {}
void internal::VariableExprAST::visit(ASTVisitor<void>& visitor) const {
visitor.variable(_name);
}
internal::BinaryExprAST::BinaryExprAST(char op, ExprAST const& left, ExprAST const& right): _op(op), _left(std::move(left)), _right(std::move(right)) {}
void internal::BinaryExprAST::visit(ASTVisitor<void>& visitor) const {
visitor.binary(_op, _left, _right);
}
internal::CallExprAST::CallExprAST(std::string const& callee, std::vector<ExprAST> const& args): _callee(callee), _args(std::move(args)) {}
void internal::CallExprAST::visit(ASTVisitor<void>& visitor) const {
visitor.call(_callee, _args);
}
|
3c82055407f661977782d71cc1907256d2a44252
|
d5ed8054e51064609d7419f2a5c353aae9c05a3d
|
/drzewa_binarne/treap.cpp
|
097bfaa5a01abb7f732192afe3913287ef860562
|
[] |
no_license
|
sytranvn/contest_library
|
fb78656275e8796c6cabda0e59bdc383ca2d7922
|
8366247f7061d3b960a8dff030a69ed066efd734
|
refs/heads/master
| 2021-12-13T19:08:19.878001
| 2017-01-23T13:16:34
| 2017-01-23T13:16:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,262
|
cpp
|
treap.cpp
|
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct node
{
int val, weight,sz;
node *left, * right;
node(){}
node(int val):val(val)
{
weight = rand();
sz=0;
}
};
void update(node * u)
{
if(u==NULL)
return;
u->sz = (u->left!=NULL ? u->left->sz : 0) + (u->right !=NULL ? u->right->sz : 0);
//here place custom updates
}
node * merge(node *u, node*v)
{
if(u==NULL)
return v;
if(v==NULL)
return u;
if(u->weight > v->weight)
{
u->right = merge(u->right,v);
update(u);
return u;
}
else
{
v->left = merge(u,v->left);
update(v);
return v;
}
}
pair<node*,node*> split_after(node *u, int val)
{
if(u==NULL)
return make_pair((node*) NULL,(node*) NULL);
if(u->val < val)
{
pair<node*,node*> t = split_after(u->right,val);
u->right = t.first;
update(u);
update(t.second);
return make_pair(u,t.second);
}
else
{
pair<node*,node*> t = split_after(u->left,val);
u->left = t.second;
update(t.first);
update(u);
return make_pair(t.first,u);
}
}
node * insert(node * root, int val) //returns new root
{
if(root==NULL)
return new node(val);
auto tmp = split_after(root,val);
auto x = merge(tmp.first,new node(val));
return merge(x,tmp.second);
}
void insert_wrapper(node* & root, int val)
{
root = insert(root,val);
}
node * find(node * v, int val)
{
if(v==NULL)
return NULL;
if(v->val==val)
return v;
if(v->val > val)
return find(v->left,val);
return find(v->right,val);
}
void print(node * v)
{
if(v==NULL)
return;
print(v->left);
printf("%d ", v->val);
print(v->right);
}
node * find_kth(node * u, int k)
{
if(u==NULL)
return NULL;
int lsz = u->left!=NULL ? u->left->sz : 0;
if(k <lsz)
return find_kth(u->left,k);
if(k==lsz)
return u;
return find_kth(u->right,k-lsz-1);
}
int main()
{
node * root =NULL;
int v;
while(scanf("%d",&v))
{
insert_wrapper(root,v);
print(root);
}
}
|
c392ec74f02ee24af33e20052e912ce9142c55b0
|
9c43ff060585179340f7473288c584d50bbdc8e6
|
/GenposBackOffice/DialogCashier.h
|
b6fff31066d31fa4ecaeb32649b9fe857623cd68
|
[] |
no_license
|
RichardChambers/genposbackoffice
|
5d28af21cfaae173e7327a1e7629610c3f3f51d7
|
ae009cfa7a9a80a409504f665433a8b118e77146
|
refs/heads/master
| 2023-02-18T14:59:04.752696
| 2023-02-08T22:31:39
| 2023-02-08T22:31:39
| 35,338,609
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 647
|
h
|
DialogCashier.h
|
#pragma once
#include "afxwin.h"
#include "ListerCashier.h"
// CDialogCashier dialog
class CDialogCashier : public CDialog
{
DECLARE_DYNAMIC(CDialogCashier)
public:
CDialogCashier(CWnd* pParent = NULL); // standard constructor
virtual ~CDialogCashier();
CListerCashier *SetListCashier (CListerCashier *p) { CListerCashier *pSave = m_myList; m_myList = p; return pSave; }
// Dialog Data
enum { IDD = IDD_DIALOGCASHIER };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CListBox m_ListBox;
CListerCashier *m_myList;
afx_msg void OnBnClickedButtonEdit();
};
|
3675676349244363a323c5d8eae6f9253189d694
|
3e757627e7d26c7acc02cd0cbba9d4b7d65e2fcb
|
/codes/MexConv3D-master/MexConv3D-master/src/maxpool3d.h
|
f4b3474c40d1580b79ce53f488c6b5419334971c
|
[] |
no_license
|
MalindaVania/Deep-Learning
|
865c3a3c49658bbeff62dde7b2d531c0cdc3bff6
|
234bf7bbe57d70483df4e32507cd5d0f16c3e0e0
|
refs/heads/master
| 2022-12-06T21:25:31.534760
| 2022-11-26T17:42:56
| 2022-11-26T17:42:56
| 88,481,613
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,608
|
h
|
maxpool3d.h
|
#pragma once
#include "wrapperMx.h"
#include <stdexcept>
//// the transformer
struct maxpool3d {
enum CALL_TYPE {FPROP, BPROP}; // way of calling
maxpool3d ();
virtual ~maxpool3d ();
// options
CALL_TYPE ct;
mwSize pad[6];
mwSize pool[3];
mwSize stride[3];
// intermediate data: max elements index
xpuMxArrayTW ind;
// data at input/output port
xpuMxArrayTW X, dX;
xpuMxArrayTW Y, dY;
// forward/backward propagation
virtual void fprop () {};
virtual void bprop () {};
// helper: command
static const char * THE_CMD;
protected:
void check_dY_ind ();
void create_Y ();
void create_ind ();
void create_dX ();
};
//// exception: error message carrier
struct mp3d_ex : public std::runtime_error {
mp3d_ex (const char *msg);
};
//// factory: select implementation
struct factory_mp3d {
virtual maxpool3d* parse_and_create (int no, mxArray *vo[], int ni, mxArray const *vi[]) = 0;
};
struct factory_mp3d_homebrew : public factory_mp3d {
virtual maxpool3d* parse_and_create (int no, mxArray *vo[], int ni, mxArray const *vi[]);
protected:
void set_options(maxpool3d &h, int n_opt, int ni, mxArray const *vi[]);
void set_pool (maxpool3d &h, mxArray const *pa);
void set_stride (maxpool3d &h, mxArray const *pa);
void set_pad (maxpool3d &h, mxArray const *pa);
void check_padpool (const maxpool3d &h);
};
struct factory_mp3d_withcudnn : public factory_mp3d {
// 3D data not implemented in cudnn yet...could be the case in the future?
virtual maxpool3d* parse_and_create (int no, mxArray *vo[], int ni, mxArray const *vi[]);
};
|
64b99a5cbae4d343c247b8fd65b84fb7642b426e
|
287379f12f30c6ebc687c8313966492be11d6750
|
/Source/Rendering/VulkanRenderer.cpp
|
2f57eeaf3049988d7762ff67d031de395cf316e9
|
[] |
no_license
|
kyapp69/Joe-Engine
|
31f6a78354fa27d3ce4b02b90cbd742a6cab354c
|
23ca970bc124bac31598d47bcf383eb445c276d7
|
refs/heads/master
| 2022-03-29T04:24:16.898432
| 2020-01-06T17:28:56
| 2020-01-06T17:28:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 123,118
|
cpp
|
VulkanRenderer.cpp
|
#include <map>
#include <vector>
#include <iostream>
#include "JoeEngineConfig.h"
#include "../EngineInstance.h"
#include "../Utils/ScopedTimer.h"
#include "../Containers/PackedArray.h"
#include "VulkanRenderer.h"
#include "../Scene/SceneManager.h"
#include "../EngineInstance.h"
namespace JoeEngine {
static void JEFramebufferResizeCallback(GLFWwindow* window, int width, int height) {
auto& renderer = reinterpret_cast<JEEngineInstance*>(glfwGetWindowUserPointer(window))->GetRenderSubsystem();
renderer.FramebufferResized();
}
void JEVulkanRenderer::Initialize(RendererSettings rendererSettings, JESceneManager* sceneManager, JEEngineInstance* engineInstance) {
m_enableDeferred = rendererSettings & RendererSettings::EnableDeferred;
m_enableOIT = rendererSettings & RendererSettings::EnableOIT;
m_engineInstance = engineInstance;
m_sceneManager = sceneManager;
// Window (GLFW)
m_vulkanWindow.Initialize(m_width, m_height, "VulkanWindow");
/// Vulkan setup
// Vulkan Instance
CreateVulkanInstance();
// Validation Layers
m_vulkanValidationLayers.SetupDebugCallback(m_instance);
// Window surface
m_vulkanWindow.SetupVulkanSurface(m_instance);
m_vulkanWindow.SetFrameBufferCallback(JEFramebufferResizeCallback);
// Devices
PickPhysicalDevice();
CreateLogicalDevice();
m_shaderManager = JEShaderManager(m_device);
// Swap Chain
m_vulkanSwapChain.Create(m_physicalDevice, m_device, m_vulkanWindow, m_width, m_height);
m_swapChainFramebuffers.resize(m_vulkanSwapChain.GetImageViews().size());
// Command Pool
CreateCommandPool();
// Mesh Buffers
m_meshBufferManager.Initialize(m_physicalDevice, m_device, m_commandPool, m_graphicsQueue);
// Create deferred lighting pass framebuffer attachments
// Add the post processing passes
/*JEPostProcessingPass p;
p.shaderIndex = 0;
m_postProcessingPasses.push_back(p);
p.shaderIndex = 1;
m_postProcessingPasses.push_back(p);*/
// Create the post processing pass(es)
//CreatePostProcessingPassResources();
// Shadow Pass(es)
CreateShadowPassResources();
// Deferred Rendering Passes
CreateDeferredPassGeometryResources();
CreateDeferredPassLightingResources();
// Forward Rendering Pass
CreateForwardPassResources();
// Create the swap chain framebuffers
CreateSwapChainFramebuffers();
// Create the shadow pass shader
m_shadowShaderID = m_shaderManager.CreateShader(m_device, m_physicalDevice, m_vulkanSwapChain, MaterialComponent(), 0,
m_shadowPass.renderPass, JE_SHADER_DIR + "vert_shadow.spv", "", SHADOW);
m_shadowModelMatrixDescriptorID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
{}, {}, {}, { JE_NUM_ENTITIES * sizeof(glm::mat4) },
((JEVulkanShader*)m_shaderManager.GetShaderAt(m_shadowShaderID))->GetDescriptorSetLayout(1), SHADOW, false);
// Forward pass ssbo descriptor
m_forwardModelMatrixDescriptorID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
{}, {}, {}, { JE_NUM_ENTITIES * sizeof(glm::mat4) },
((JEVulkanShader*)m_shaderManager.GetShaderAt(m_shadowShaderID))->GetDescriptorSetLayout(1), FORWARD, false);
// NOTE: that shader ID is obviously wrong, but the descriptor set layout would be the same for any forward shader, as it
// is just a single ssbo for the model matrices.
// Create the deferred geometry shader
if (m_enableDeferred) {
MaterialComponent temp;
temp.m_renderLayer = OPAQUE;
// TODO: deal with this hard-coded number
m_deferredGeometryShaderID = m_shaderManager.CreateShader(m_device, m_physicalDevice, m_vulkanSwapChain, temp, 4,
m_deferredPass.renderPass, JE_SHADER_DIR + "vert_deferred_geom.spv", JE_SHADER_DIR + "frag_deferred_geom_new.spv", DEFERRED_GEOM);
m_deferredGeometryModelMatrixDescriptorID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
{}, {}, {}, { JE_NUM_ENTITIES * sizeof(glm::mat4) },
((JEVulkanShader*)m_shaderManager.GetShaderAt(m_deferredGeometryShaderID))->GetDescriptorSetLayout(1), DEFERRED_GEOM, false);
// TODO: hard-coded number
CreateShader(temp, JE_SHADER_DIR + "vert_deferred_lighting.spv", JE_SHADER_DIR + "frag_deferred_lighting_new.spv");
std::vector<std::vector<VkImageView>> imageViewsList;
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
imageViewsList.push_back({
m_deferredPass.colors[i].imageView,
m_deferredPass.normals[i].imageView,
m_deferredPass.depths[i].imageView,
m_shadowPass.depths[i].imageView });
}
m_deferredLightingDescriptorID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViewsList, { m_deferredPass.sampler, m_deferredPass.sampler, m_deferredPass.sampler, m_shadowPass.depthSampler },
{ sizeof(glm::mat4) * 2, sizeof(glm::mat4) }, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(temp.m_shaderID))->GetDescriptorSetLayout(0), DEFERRED, false);
// ^ These sizes are camera uniform - invView, invProj, then light viewProj
// Create non-shadows variant of this shader
// TODO: store these better
temp.m_materialSettings = NO_SETTINGS;
imageViewsList.clear();
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
imageViewsList.push_back({
m_deferredPass.colors[i].imageView,
m_deferredPass.normals[i].imageView,
m_deferredPass.depths[i].imageView });
}
CreateShader(temp, JE_SHADER_DIR + "vert_deferred_lighting.spv", JE_SHADER_DIR + "frag_deferred_lighting_new_no_shadows.spv");
m_deferredLightingNoShadowsDescriptorID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViewsList, { m_deferredPass.sampler, m_deferredPass.sampler, m_deferredPass.sampler },
{ sizeof(glm::mat4) * 2 }, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(temp.m_shaderID))->GetDescriptorSetLayout(0), DEFERRED, false);
// ^ No shadows, so not light view proj and no shadow map
}
if (m_enableOIT) {
CreateOITResources();
MaterialComponent temp;
temp.m_materialSettings = NO_SETTINGS;
temp.m_renderLayer = TRANSLUCENT;
temp.m_geomType = TRIANGLES;
// Create descriptors and shaders
CreateShader(temp, JE_SHADER_DIR + "vert_forward.spv", JE_SHADER_DIR + "frag_forward_new_oit.spv");
// OIT SSBOs: linked list data, next pointers, head pointers, then atomic counter
m_oitLLDescriptor = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain, {}, {}, {},
{ JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITLinkedListNode), // Linked list data
JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITNextPointerNode), // Next pointer data
m_width * m_height * (uint32_t)sizeof(OITHeadPointerNode), // Head pointer data
(uint32_t)sizeof(OITAtomicCounterData) }, // Atomic counter data
((JEVulkanShader*)m_shaderManager.GetShaderAt(temp.m_shaderID))->GetDescriptorSetLayout(2), TRANSLUCENT_OIT, false);
// OIT sort shader
m_oitSortShader = m_shaderManager.CreateShader(m_device, m_physicalDevice, m_vulkanSwapChain, temp, 0, m_renderPass_deferredLighting,
JE_SHADER_DIR + "vert_oit.spv", JE_SHADER_DIR + "frag_oit_sort.spv", TRANSLUCENT_OIT_SORT);
}
m_textureLibraryGlobal.CreateTexture(m_device, m_physicalDevice, m_graphicsQueue, m_commandPool, JE_TEXTURES_DIR + "fallback.png");
// Sync objects
CreateSemaphoresAndFences();
}
void JEVulkanRenderer::Cleanup() {
CleanupWindowDependentResources();
m_meshBufferManager.Cleanup();
m_textureLibraryGlobal.Cleanup(m_device);
// Cleanup shadow pass
vkDestroySampler(m_device, m_shadowPass.depthSampler, nullptr);
vkDestroyRenderPass(m_device, m_shadowPass.renderPass, nullptr);
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
vkDestroyImage(m_device, m_shadowPass.depths[i].image, nullptr);
vkFreeMemory(m_device, m_shadowPass.depths[i].deviceMemory, nullptr);
vkDestroyImageView(m_device, m_shadowPass.depths[i].imageView, nullptr);
vkDestroyFramebuffer(m_device, m_shadowPass.framebuffers[i], nullptr);
vkDestroySemaphore(m_device, m_shadowPass.semaphores[i], nullptr);
}
vkFreeCommandBuffers(m_device, m_commandPool, m_swapChainFramebuffers.size(), m_shadowPass.commandBuffers.data());
for (uint32_t i = 0; i < m_MAX_FRAMES_IN_FLIGHT; ++i) {
vkDestroySemaphore(m_device, m_renderFinishedSemaphores[i], nullptr);
vkDestroySemaphore(m_device, m_imageAvailableSemaphores[i], nullptr);
vkDestroyFence(m_device, m_inFlightFences[i], nullptr);
}
m_shaderManager.Cleanup();
// Forward Pass
//vkDestroySemaphore(m_device, m_forwardPass.semaphore, nullptr);
vkDestroyCommandPool(m_device, m_commandPool, nullptr);
vkDestroyDevice(m_device, nullptr);
if (m_vulkanValidationLayers.AreValidationLayersEnabled()) {
m_vulkanValidationLayers.DestroyDebugCallback(m_instance);
}
m_vulkanWindow.Cleanup(m_instance);
vkDestroyInstance(m_instance, nullptr);
}
std::vector<const char*> JEVulkanRenderer::GetRequiredExtensions() {
uint32_t glfwExtensionCount = 0;
const char** glfwExtensions;
glfwExtensions = m_vulkanWindow.GetRequiredInstanceExtensions(&glfwExtensionCount);
std::vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
if (m_vulkanValidationLayers.AreValidationLayersEnabled()) {
extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
return extensions;
}
int JEVulkanRenderer::RateDeviceSuitability(VkPhysicalDevice physicalDevice, const JEVulkanWindow& vulkanWindow) {
VkPhysicalDeviceProperties deviceProperties;
VkPhysicalDeviceFeatures deviceFeatures;
vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
vkGetPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
int score = 0;
QueueFamilyIndices indices = FindQueueFamilies(physicalDevice, vulkanWindow.GetSurface());
if (indices.IsComplete()) {
score += 10000;
} else {
return 0;
}
// Discrete GPUs have a significant performance advantage
if (deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
score += 1000;
}
// Maximum possible size of textures affects graphics quality
score += deviceProperties.limits.maxImageDimension2D;
// Require a certain push constant size
// TODO: don't hard code
if (deviceProperties.limits.maxPushConstantsSize < 128) {
return 0;
}
// Application can't function without geometry shaders
// TODO long term: change device requirements as engine develops
/*if (!deviceFeatures.geometryShader) {
return 0;
}*/
bool extensionsSupported = m_vulkanSwapChain.CheckDeviceExtensionSupport(physicalDevice);
bool swapChainAdequate = false;
if (extensionsSupported) {
SwapChainSupportDetails swapChainSupport = m_vulkanSwapChain.QuerySwapChainSupport(physicalDevice, vulkanWindow.GetSurface());
swapChainAdequate = !swapChainSupport.formats.empty() && !swapChainSupport.presentModes.empty();
} else {
return 0;
}
if (!swapChainAdequate) {
return 0;
}
if (!deviceFeatures.samplerAnisotropy) {
return 0;
}
return score;
}
void JEVulkanRenderer::CreateVulkanInstance() {
if (m_vulkanValidationLayers.AreValidationLayersEnabled() && !m_vulkanValidationLayers.CheckValidationLayerSupport()) {
throw std::runtime_error("validation layers requested, but not available!");
}
VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Joe Engine App";
appInfo.applicationVersion = VK_MAKE_VERSION(JOE_ENGINE_VERSION_MAJOR, JOE_ENGINE_VERSION_MINOR, 0);
appInfo.pEngineName = "Joe Engine";
appInfo.engineVersion = VK_MAKE_VERSION(JOE_ENGINE_VERSION_MAJOR, JOE_ENGINE_VERSION_MINOR, 0);
appInfo.apiVersion = VK_API_VERSION_1_0; // TODO: change me?
VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
createInfo.pApplicationInfo = &appInfo;
auto extensions = GetRequiredExtensions();
createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
createInfo.ppEnabledExtensionNames = extensions.data();
if (m_vulkanValidationLayers.AreValidationLayersEnabled()) {
const std::vector<const char*>& validationLayers = m_vulkanValidationLayers.GetValidationLayers();
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
createInfo.ppEnabledLayerNames = validationLayers.data();
} else {
createInfo.enabledLayerCount = 0;
createInfo.ppEnabledLayerNames = nullptr;
}
if (vkCreateInstance(&createInfo, nullptr, &m_instance) != VK_SUCCESS) {
throw std::runtime_error("failed to create instance!");
}
}
void JEVulkanRenderer::PickPhysicalDevice() {
uint32_t deviceCount = 0;
vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr);
if (deviceCount == 0) {
throw std::runtime_error("failed to find GPUs with Vulkan support!");
}
std::vector<VkPhysicalDevice> devices(deviceCount);
vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices.data());
// Use an ordered map to automatically sort candidates by increasing score
std::multimap<int, VkPhysicalDevice> candidates;
for (const auto& device : devices) {
int score = RateDeviceSuitability(device, m_vulkanWindow);
candidates.insert(std::make_pair(score, device));
}
// Check if the best candidate is suitable at all
if (candidates.rbegin()->first > 0) {
m_physicalDevice = candidates.rbegin()->second;
} else {
throw std::runtime_error("failed to find a suitable GPU!");
}
}
void JEVulkanRenderer::CreateLogicalDevice() {
QueueFamilyIndices indices = FindQueueFamilies(m_physicalDevice, m_vulkanWindow.GetSurface());
VkDeviceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
std::set<uint32_t> uniqueQueueFamilies = { indices.graphicsFamily.value(), indices.presentFamily.value() };
float queuePriority = 1.0f;
for (uint32_t queueFamily : uniqueQueueFamilies) {
VkDeviceQueueCreateInfo queueCreateInfo = {};
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfo.queueFamilyIndex = queueFamily;
queueCreateInfo.queueCount = 1;
queueCreateInfo.pQueuePriorities = &queuePriority;
queueCreateInfos.push_back(queueCreateInfo);
}
createInfo.queueCreateInfoCount = static_cast<uint32_t>(queueCreateInfos.size());
createInfo.pQueueCreateInfos = queueCreateInfos.data();
VkPhysicalDeviceFeatures deviceFeatures = {};
deviceFeatures.samplerAnisotropy = VK_TRUE;
deviceFeatures.fragmentStoresAndAtomics = VK_TRUE;
createInfo.pEnabledFeatures = &deviceFeatures;
std::vector<const char*> deviceExtensions = JEVulkanSwapChain::GetDeviceExtensions();
createInfo.enabledExtensionCount = static_cast<uint32_t>(deviceExtensions.size());
createInfo.ppEnabledExtensionNames = deviceExtensions.data();
if (m_vulkanValidationLayers.AreValidationLayersEnabled()) {
const std::vector<const char*>& validationLayers = m_vulkanValidationLayers.GetValidationLayers();
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
createInfo.ppEnabledLayerNames = validationLayers.data();
} else {
createInfo.enabledLayerCount = 0;
}
if (vkCreateDevice(m_physicalDevice, &createInfo, nullptr, &m_device) != VK_SUCCESS) {
throw std::runtime_error("failed to create logical device!");
}
m_graphicsQueue.GetDeviceQueue(m_device, indices.graphicsFamily.value());
m_presentationQueue.GetDeviceQueue(m_device, indices.presentFamily.value());
}
void JEVulkanRenderer::CreateSwapChainFramebuffers() {
const std::vector<VkImageView>& swapChainImageViews = m_vulkanSwapChain.GetImageViews();
for (uint32_t i = 0; i < swapChainImageViews.size(); ++i) {
VkExtent2D extent = m_vulkanSwapChain.GetExtent();
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.width = extent.width;
framebufferInfo.height = extent.height;
framebufferInfo.layers = 1;
if (m_postProcessingPasses.size() > 0) {
framebufferInfo.renderPass = m_postProcessingPasses[m_postProcessingPasses.size() - 1].renderPass;
} else {
if (m_enableDeferred) {
framebufferInfo.renderPass = m_renderPass_deferredLighting;
} else {
framebufferInfo.renderPass = m_forwardPass.renderPass;
}
}
if (m_enableDeferred) {
std::array<VkImageView, 2> attachments = { swapChainImageViews[i], m_deferredPass.depths[i].imageView };
framebufferInfo.attachmentCount = attachments.size();
framebufferInfo.pAttachments = attachments.data();
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_swapChainFramebuffers[i]) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
} else {
std::array<VkImageView, 2> attachments = { swapChainImageViews[i], m_forwardPass.depth.imageView };
framebufferInfo.attachmentCount = attachments.size();
framebufferInfo.pAttachments = attachments.data();
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_swapChainFramebuffers[i]) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
}
}
void JEVulkanRenderer::CreateCommandPool() {
QueueFamilyIndices queueFamilyIndices = FindQueueFamilies(m_physicalDevice, m_vulkanWindow.GetSurface());
VkCommandPoolCreateInfo poolInfo = {};
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily.value();
poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
if (vkCreateCommandPool(m_device, &poolInfo, nullptr, &m_commandPool) != VK_SUCCESS) {
throw std::runtime_error("failed to create command pool!");
}
}
void JEVulkanRenderer::CreateDeferredLightingAndPostProcessingCommandBuffer() {
m_commandBuffers.resize(m_swapChainFramebuffers.size());
VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = m_commandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = (uint32_t)m_commandBuffers.size();
if (vkAllocateCommandBuffers(m_device, &allocInfo, m_commandBuffers.data()) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate command buffers!");
}
}
void JEVulkanRenderer::CreateSemaphoresAndFences() {
m_imageAvailableSemaphores.resize(m_MAX_FRAMES_IN_FLIGHT);
m_renderFinishedSemaphores.resize(m_MAX_FRAMES_IN_FLIGHT);
m_inFlightFences.resize(m_MAX_FRAMES_IN_FLIGHT);
VkSemaphoreCreateInfo semaphoreInfo = {};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo fenceInfo = {};
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
for (uint32_t i = 0; i < m_MAX_FRAMES_IN_FLIGHT; ++i) {
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_imageAvailableSemaphores[i]) != VK_SUCCESS ||
vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_renderFinishedSemaphores[i]) != VK_SUCCESS ||
vkCreateFence(m_device, &fenceInfo, nullptr, &m_inFlightFences[i]) != VK_SUCCESS) {
throw std::runtime_error("failed to create semaphores for a frame!");
}
}
}
void JEVulkanRenderer::CreateFramebufferAttachment(JEFramebufferAttachment& attachment, VkExtent2D extent, VkImageUsageFlagBits usageBits, VkFormat format) {
VkImageAspectFlags aspectMask = 0;
VkImageLayout imageLayout;
if (usageBits & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
if (usageBits & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
}
CreateImage(m_physicalDevice, m_device, extent.width, extent.height, format, VK_IMAGE_TILING_OPTIMAL, usageBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, attachment.image, attachment.deviceMemory);
attachment.imageView = CreateImageView(m_device, attachment.image, format, aspectMask);
TransitionImageLayout(m_device, m_commandPool, m_graphicsQueue, attachment.image, format, VK_IMAGE_LAYOUT_UNDEFINED, imageLayout);
}
void JEVulkanRenderer::CreateFramebufferAttachmentSampler(VkSampler& sampler) {
VkSamplerCreateInfo samplerInfo = {};
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
samplerInfo.magFilter = VK_FILTER_LINEAR;
samplerInfo.minFilter = VK_FILTER_LINEAR;
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.anisotropyEnable = VK_TRUE;
samplerInfo.maxAnisotropy = 1.0f;
samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
samplerInfo.unnormalizedCoordinates = VK_FALSE;
samplerInfo.compareEnable = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerInfo.mipLodBias = 0.0f;
samplerInfo.minLod = 0.0f;
samplerInfo.maxLod = 0.0f;
if (vkCreateSampler(m_device, &samplerInfo, nullptr, &sampler) != VK_SUCCESS) {
throw std::runtime_error("failed to create texture sampler!");
}
}
/// Renderer Functions
void JEVulkanRenderer::UpdateShaderBuffers(const std::vector<MaterialComponent>& materialComponents,
const std::vector<glm::mat4>& transforms, const std::vector<glm::mat4>& transformsSorted, uint32_t imageIndex) {
m_shaderManager.UpdateBuffers(m_device, m_shadowModelMatrixDescriptorID, imageIndex, {}, {},
{ transforms.data() }, { (uint32_t)(transforms.size() * sizeof(glm::mat4)) });
m_shaderManager.UpdateBuffers(m_device, m_deferredGeometryModelMatrixDescriptorID, imageIndex, {}, {},
{ transformsSorted.data() }, { (uint32_t)(transformsSorted.size() * sizeof(glm::mat4)) });
m_shaderManager.UpdateBuffers(m_device, m_forwardModelMatrixDescriptorID, imageIndex, {}, {},
{ transformsSorted.data() }, { (uint32_t)(transformsSorted.size() * sizeof(glm::mat4)) });
if (m_enableOIT) {
const std::array<uint32_t, 4> atomicCounterData = { 0, JE_NUM_OIT_FRAGSPP * m_width * m_height, m_width, 0 };
m_shaderManager.UpdateBuffers(m_device, m_oitLLDescriptor, imageIndex, {}, {},
{ nullptr, nullptr, nullptr, atomicCounterData.data() },
{ JE_NUM_OIT_FRAGSPP * m_width * m_height, JE_NUM_OIT_FRAGSPP * m_width * m_height, (uint32_t)sizeof(uint32_t) * m_width * m_height, sizeof(uint32_t) * 4 });
}
if (m_enableDeferred) {
// Add camera inv view/proj matrices as uniforms
//std::array<glm::mat4, 2> uniformInvViewProjData = { m_sceneManager->m_camera.GetInvProj(), m_sceneManager->m_camera.GetInvView() };
const std::array<glm::mat4, 2> uniformInvViewProjData = { glm::inverse(m_sceneManager->m_camera.GetProj()), glm::inverse(m_sceneManager->m_camera.GetView()) };
// Add light viewProj matrix as uniforms
const std::array<glm::mat4, 1> uniformLightData = { m_sceneManager->m_shadowCamera.GetOrthoViewProj() };
std::vector<const void*> buffers;
std::vector<uint32_t> sizes;
buffers.push_back(uniformInvViewProjData.data());
buffers.push_back(uniformLightData.data());
//buffers.insert(buffers.end(), materialComponents[i].m_uniformData.begin(), materialComponents[i].m_uniformData.end());
sizes.push_back(sizeof(glm::mat4) * uniformInvViewProjData.size());
sizes.push_back(sizeof(glm::mat4) * uniformLightData.size());
//sizes.insert(sizes.end(), materialComponents[i].m_uniformDataSizes.begin(), materialComponents[i].m_uniformDataSizes.end());
//m_shaderManager.UpdateUniformBuffers(materialComponents[i].m_descriptorID, imageIndex, buffers, sizes);
m_shaderManager.UpdateBuffers(m_device, m_deferredLightingDescriptorID, imageIndex, buffers, sizes, {}, {});
}
for (uint32_t i = 0; i < materialComponents.size(); ++i) {
// TODO: Don't do this for every material, ignore duplicates
if (m_enableDeferred) {
// Add light viewProj matrix as uniforms
const std::array<glm::mat4, 1> uniformLightData = { m_sceneManager->m_shadowCamera.GetOrthoViewProj() };
std::vector<const void*> buffers;
std::vector<uint32_t> sizes;
buffers.push_back(uniformLightData.data());
//buffers.insert(buffers.end(), materialComponents[i].m_uniformData.begin(), materialComponents[i].m_uniformData.end());
sizes.push_back(sizeof(glm::mat4) * uniformLightData.size());
//sizes.insert(sizes.end(), materialComponents[i].m_uniformDataSizes.begin(), materialComponents[i].m_uniformDataSizes.end());
m_shaderManager.UpdateBuffers(m_device, materialComponents[i].m_descriptorID, imageIndex, buffers, sizes, {}, {});
} else {
// TODO
}
}
}
const std::vector<BoundingBoxData>& JEVulkanRenderer::GetBoundingBoxData() const {
return m_meshBufferManager.GetBoundingBoxData();
}
MeshComponent JEVulkanRenderer::CreateMesh(const std::string& filepath) {
return m_meshBufferManager.CreateMeshComponent(filepath);
}
uint32_t JEVulkanRenderer::CreateTexture(const std::string& filepath) {
// TODO: specify global/level/etc
const uint32_t textureID = m_textureLibraryGlobal.CreateTexture(m_device, m_physicalDevice, m_graphicsQueue, m_commandPool, filepath);
return textureID;
}
void JEVulkanRenderer::CreateShader(MaterialComponent& materialComponent, const std::string& vertFilepath,
const std::string& fragFilepath) {
VkRenderPass renderPass;
PipelineType type;
if (m_enableDeferred) {
if (materialComponent.m_renderLayer >= TRANSLUCENT) {
if (materialComponent.m_geomType == POINTS) {
type = FORWARD_POINTS;
renderPass = m_renderPass_deferredLighting;
} else {
if (m_enableOIT) {
renderPass = m_oitRenderPass;
} else {
renderPass = m_renderPass_deferredLighting;
}
type = FORWARD;
}
} else {
renderPass = m_renderPass_deferredLighting;
type = DEFERRED;
}
} else {
if (m_enableOIT) {
renderPass = m_oitRenderPass;
} else {
renderPass = m_forwardPass.renderPass;
}
type = FORWARD;
}
uint32_t numTextures = 0;
if (type == DEFERRED) {
numTextures = 3; // 3 G-buffers
} else {
// Forward
numTextures = 4; // 4 material component source textures
}
// Shadow map(s)
if (materialComponent.m_materialSettings & RECEIVES_SHADOWS) {
++numTextures; // One shadow map
}
if (m_enableOIT && type == FORWARD && materialComponent.m_renderLayer >= TRANSLUCENT) {
type = TRANSLUCENT_OIT;
}
materialComponent.m_shaderID = m_shaderManager.CreateShader(m_device, m_physicalDevice, m_vulkanSwapChain,
materialComponent, numTextures, renderPass, vertFilepath, fragFilepath, type);
}
uint32_t JEVulkanRenderer::CreateDescriptor(const MaterialComponent& materialComponent) {
std::vector<std::vector<VkImageView>> imageViews;
std::vector<VkSampler> samplers;
// Source textures
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
std::vector<VkImageView> tempImageViews;
tempImageViews.push_back(m_textureLibraryGlobal.GetImageViewAt(materialComponent.m_texAlbedo));
if (materialComponent.m_geomType == TRIANGLES) {
tempImageViews.push_back(m_textureLibraryGlobal.GetImageViewAt(materialComponent.m_texRoughness));
tempImageViews.push_back(m_textureLibraryGlobal.GetImageViewAt(materialComponent.m_texMetallic));
tempImageViews.push_back(m_textureLibraryGlobal.GetImageViewAt(materialComponent.m_texNormal));
if (materialComponent.m_renderLayer >= TRANSLUCENT) {
// Using forward shader
if (materialComponent.m_materialSettings & RECEIVES_SHADOWS) {
tempImageViews.push_back(m_shadowPass.depths[i].imageView);
}
}
}
imageViews.push_back(tempImageViews);
}
samplers.push_back(m_textureLibraryGlobal.GetSamplerAt(materialComponent.m_texAlbedo));
if (materialComponent.m_geomType == TRIANGLES) {
samplers.push_back(m_textureLibraryGlobal.GetSamplerAt(materialComponent.m_texRoughness));
samplers.push_back(m_textureLibraryGlobal.GetSamplerAt(materialComponent.m_texMetallic));
samplers.push_back(m_textureLibraryGlobal.GetSamplerAt(materialComponent.m_texNormal));
if (materialComponent.m_renderLayer >= TRANSLUCENT) {
if (materialComponent.m_materialSettings & RECEIVES_SHADOWS) {
samplers.push_back(m_shadowPass.depthSampler);
}
}
}
std::vector<uint32_t> uniformBufferSizes;
if (materialComponent.m_materialSettings & RECEIVES_SHADOWS) {
uniformBufferSizes.push_back(sizeof(glm::mat4));
}
uint32_t descrID = 0;
if (m_enableDeferred) {
if (materialComponent.m_renderLayer >= TRANSLUCENT) {
switch (materialComponent.m_geomType) {
case TRIANGLES:
descrID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViews, samplers, uniformBufferSizes, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(materialComponent.m_shaderID))->GetDescriptorSetLayout(0), FORWARD, false);
break;
case LINES:
// TODO
break;
case POINTS:
descrID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViews, samplers, uniformBufferSizes, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(materialComponent.m_shaderID))->GetDescriptorSetLayout(0), FORWARD_POINTS, false);
break;
default:
break;
}
} else {
descrID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViews, samplers, {}, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(m_deferredGeometryShaderID))->GetDescriptorSetLayout(0), DEFERRED_GEOM, false);
}
} else {
descrID = m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViews, samplers, uniformBufferSizes, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(materialComponent.m_shaderID))->GetDescriptorSetLayout(0), FORWARD, false);
}
return descrID;
}
void JEVulkanRenderer::UpdateMesh(const MeshComponent& meshComponent, const std::vector<JEMeshVertex>& vertices, const std::vector<uint32_t>& indices) {
{
//ScopedTimer<float> timer("Copy mesh data to buffer");
m_meshBufferManager.UpdateMeshBuffer(meshComponent.GetVertexHandle(), vertices, indices);
}
}
void JEVulkanRenderer::UpdateMesh(const MeshComponent& meshComponent, const std::vector<JEMeshPointVertex>& vertices, const std::vector<uint32_t>& indices) {
{
//ScopedTimer<float> timer("Copy mesh data to buffer");
m_meshBufferManager.UpdateMeshBuffer(meshComponent.GetVertexHandle(), vertices, indices);
}
}
void JEVulkanRenderer::DrawBoundingBoxMesh(VkCommandBuffer commandBuffer) {
const JESingleMesh& boundingBox = m_meshBufferManager.GetBoundingBoxMesh();
VkBuffer vertexBuffers[] = { boundingBox.vertexBuffer };
VkDeviceSize offsets[] = { 0 };
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
vkCmdBindIndexBuffer(commandBuffer, boundingBox.indexBuffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(commandBuffer, static_cast<uint32_t>(boundingBox.indexList.size()), 1, 0, 0, 0);
}
void JEVulkanRenderer::DrawScreenSpaceTriMesh(VkCommandBuffer commandBuffer) {
const JESingleMesh& postTri = m_meshBufferManager.GetScreenSpaceTriMesh();
VkBuffer vertexBuffers[] = { postTri.vertexBuffer };
VkDeviceSize offsets[] = { 0 };
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
vkCmdBindIndexBuffer(commandBuffer, postTri.indexBuffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(commandBuffer, static_cast<uint32_t>(postTri.indexList.size()), 1, 0, 0, 0);
}
void JEVulkanRenderer::DrawMesh(VkCommandBuffer commandBuffer, const MeshComponent& meshComponent) {
if (meshComponent.GetVertexHandle() == -1 || meshComponent.GetIndexHandle() == -1) {
return;
}
VkBuffer vertexBuffers[] = { m_meshBufferManager.GetVertexBufferAt(meshComponent.GetVertexHandle()) };
VkDeviceSize offsets[] = { 0 };
const int idxHandle = meshComponent.GetIndexHandle();
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
vkCmdBindIndexBuffer(commandBuffer, m_meshBufferManager.GetIndexBufferAt(idxHandle), 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(commandBuffer, static_cast<uint32_t>(m_meshBufferManager.GetIndexListAt(idxHandle).size()), 1, 0, 0, 0);
}
void JEVulkanRenderer::DrawMeshInstanced(VkCommandBuffer commandBuffer, uint32_t numInstances, const MeshComponent& meshComponent) {
if (meshComponent.GetVertexHandle() == -1 || meshComponent.GetIndexHandle() == -1) {
return;
}
VkBuffer vertexBuffers[] = { m_meshBufferManager.GetVertexBufferAt(meshComponent.GetVertexHandle()) };
VkDeviceSize offsets[] = { 0 };
const int idxHandle = meshComponent.GetIndexHandle();
vkCmdBindVertexBuffers(commandBuffer, 0, 1, vertexBuffers, offsets);
vkCmdBindIndexBuffer(commandBuffer, m_meshBufferManager.GetIndexBufferAt(idxHandle), 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(commandBuffer, static_cast<uint32_t>(m_meshBufferManager.GetIndexListAt(idxHandle).size()), numInstances, 0, 0, 0);
}
void JEVulkanRenderer::DrawShadowPass(/*std vector of JELights*/const std::vector<MeshComponent>& meshComponents, const JECamera& camera) {
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
beginInfo.pInheritanceInfo = nullptr;
if (vkBeginCommandBuffer(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], &beginInfo) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording shadow pass command buffer!");
}
/*TODO: for each light source...*/
// Begin render pass
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = m_shadowPass.renderPass;
renderPassInfo.framebuffer = m_shadowPass.framebuffers[m_currSwapChainImageIndex];
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = { m_shadowPass.width, m_shadowPass.height };
VkClearValue clearValue = { 1.0f, 0 };
renderPassInfo.clearValueCount = 1;
renderPassInfo.pClearValues = &clearValue;
vkCmdBeginRenderPass(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
const JEShadowShader* shadowShader = (JEShadowShader*)m_shaderManager.GetShaderAt(m_shadowShaderID);
vkCmdBindPipeline(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, shadowShader->GetPipeline());
m_shaderManager.GetDescriptorAt(m_shadowModelMatrixDescriptorID).BindDescriptorSets(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], shadowShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
shadowShader->BindPushConstants_ViewProj(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], camera.GetOrthoViewProj());
if (meshComponents.size() > 0) {
uint32_t idx = 1;
uint32_t currStartIdx = 0;
int currMesh = meshComponents[currStartIdx].GetVertexHandle();
while (idx <= meshComponents.size()) {
if (idx == meshComponents.size()) {
shadowShader->BindPushConstants_InstancedData(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], idx - currStartIdx, { currMesh, MESH_TRIANGLES });
break;
}
if (meshComponents[idx].GetVertexHandle() == currMesh) {
++idx;
} else {
// Draw instanced mesh using curr material resources
shadowShader->BindPushConstants_InstancedData(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_shadowPass.commandBuffers[m_currSwapChainImageIndex], idx - currStartIdx, { currMesh, MESH_TRIANGLES });
currMesh = meshComponents[idx].GetVertexHandle();
currStartIdx = idx;
}
}
}
vkCmdEndRenderPass(m_shadowPass.commandBuffers[m_currSwapChainImageIndex]);
if (vkEndCommandBuffer(m_shadowPass.commandBuffers[m_currSwapChainImageIndex]) != VK_SUCCESS) {
throw std::runtime_error("failed to record shadow pass command buffer!");
}
}
void JEVulkanRenderer::DrawMeshes(const std::vector<MeshComponent>& meshComponents,
const std::vector<MaterialComponent>& materialComponents,
const JECamera& camera, const std::vector<JEParticleSystem>& particleSystems) {
if (m_enableDeferred) {
/// Construct deferred geometry render pass
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
beginInfo.pInheritanceInfo = nullptr;
if (vkBeginCommandBuffer(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], &beginInfo) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording deferred geometry pass command buffer!");
}
// Begin render pass
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = m_deferredPass.renderPass;
renderPassInfo.framebuffer = m_deferredPass.framebuffers[m_currSwapChainImageIndex];
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = { m_width, m_height };
std::array<VkClearValue, 3> clearValues;
clearValues[0].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
clearValues[1].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
clearValues[2].depthStencil = { 1.0f, 0 };
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
JEDeferredGeometryShader* deferredGeomShader = (JEDeferredGeometryShader*)m_shaderManager.GetShaderAt(m_deferredGeometryShaderID);
vkCmdBindPipeline(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, deferredGeomShader->GetPipeline());
VkViewport viewport = { 0.0f, 0.0f, (float)m_width, (float)m_height, 0.0f, 1.0f };
VkRect2D scissor = { { 0, 0 }, { m_width, m_height } };
vkCmdSetViewport(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
deferredGeomShader->BindPushConstants_ViewProj(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], camera.GetViewProj());
m_shaderManager.GetDescriptorAt(m_deferredGeometryModelMatrixDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], deferredGeomShader->GetPipelineLayout(), 1, m_currSwapChainImageIndex);
// for every opaque material component, bind its descriptor each time it changes
uint32_t idx = 1;
uint32_t currStartIdx = 0;
uint32_t currDescriptorID = 0;
if (materialComponents.size() > 0 && materialComponents[0].m_renderLayer < TRANSLUCENT) {
currDescriptorID = materialComponents[0].m_descriptorID;
m_shaderManager.GetDescriptorAt(currDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], deferredGeomShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
int currMesh = meshComponents[currStartIdx].GetVertexHandle();
while (idx <= materialComponents.size()) {
if (idx == materialComponents.size()) {
deferredGeomShader->BindPushConstants_InstancedData(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], idx - currStartIdx, { currMesh, MESH_TRIANGLES });
break;
}
if (materialComponents[idx].m_renderLayer < TRANSLUCENT &&
materialComponents[idx].m_descriptorID == currDescriptorID &&
meshComponents[idx].GetVertexHandle() == currMesh) {
++idx;
} else {
// Draw instanced mesh using curr material resources
deferredGeomShader->BindPushConstants_InstancedData(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], idx - currStartIdx, { currMesh, MESH_TRIANGLES });
if (materialComponents[idx].m_renderLayer >= TRANSLUCENT) {
currStartIdx = idx;
break;
}
if (materialComponents[idx].m_descriptorID != currDescriptorID) {
m_shaderManager.GetDescriptorAt(materialComponents[idx].m_descriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], deferredGeomShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
currDescriptorID = materialComponents[idx].m_descriptorID;
}
if (meshComponents[idx].GetVertexHandle() != currMesh) {
currMesh = meshComponents[idx].GetVertexHandle();
}
currStartIdx = idx;
}
}
}
vkCmdEndRenderPass(m_deferredPass.commandBuffers[m_currSwapChainImageIndex]);
/*if (vkEndCommandBuffer(m_deferredPass.commandBuffers[m_currSwapChainImageIndex]) != VK_SUCCESS) {
throw std::runtime_error("failed to record deferred geometry pass command buffer!");
}*/
/// Construct OIT first pass
if (m_enableOIT && materialComponents.size() > 0 && materialComponents[currStartIdx].m_renderLayer >= TRANSLUCENT) {
// start a command buffer and render pass that renders all translucent geometry and assembles the linked list data
/*if (vkBeginCommandBuffer(m_oitCommandBuffers[m_currSwapChainImageIndex], &beginInfo) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording oit linked list pass command buffer!");
}*/
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = m_oitRenderPass;
renderPassInfo.framebuffer = m_oitFramebuffers[m_currSwapChainImageIndex];
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = { m_width, m_height };
VkClearValue clearValue = {};
clearValue.depthStencil = { 1.0f, 0 };
renderPassInfo.clearValueCount = 1;
renderPassInfo.pClearValues = &clearValue;
//vkCmdBeginRenderPass(m_oitCommandBuffers[m_currSwapChainImageIndex], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBeginRenderPass(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
uint32_t materialIdx = currStartIdx;
if (materialIdx < materialComponents.size()) {
++materialIdx;
currDescriptorID = materialComponents[currStartIdx].m_descriptorID;
int currMesh = meshComponents[currStartIdx].GetVertexHandle();
uint32_t currShaderID = materialComponents[currStartIdx].m_shaderID;
JEForwardShader* forwardShader = (JEForwardShader*)m_shaderManager.GetShaderAt(currShaderID);
vkCmdBindPipeline(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, forwardShader->GetPipeline());
vkCmdSetViewport(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(currDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
forwardShader->BindPushConstants_ViewProj(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], camera.GetViewProj());
m_shaderManager.GetDescriptorAt(m_forwardModelMatrixDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 1, m_currSwapChainImageIndex);
m_shaderManager.GetDescriptorAt(m_oitLLDescriptor).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 2, m_currSwapChainImageIndex);
while (materialIdx <= materialComponents.size()) {
if (materialIdx == materialComponents.size()) {
forwardShader->BindPushConstants_InstancedData(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], materialIdx - currStartIdx, { currMesh, MESH_TRIANGLES });
break;
}
if (materialComponents[materialIdx].m_shaderID == currShaderID &&
materialComponents[materialIdx].m_descriptorID == currDescriptorID &&
meshComponents[materialIdx].GetVertexHandle() == currMesh) {
++materialIdx;
} else {
// Draw instanced mesh using curr material resources
forwardShader->BindPushConstants_InstancedData(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], materialIdx - currStartIdx, { currMesh, MESH_TRIANGLES });
if (materialComponents[materialIdx].m_shaderID != currShaderID) {
currShaderID = materialComponents[materialIdx].m_shaderID;
forwardShader = (JEForwardShader*)m_shaderManager.GetShaderAt(currShaderID);
vkCmdBindPipeline(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, forwardShader->GetPipeline());
vkCmdSetViewport(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(m_forwardModelMatrixDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 1, m_currSwapChainImageIndex);
}
if (materialComponents[materialIdx].m_descriptorID != currDescriptorID) {
currDescriptorID = materialComponents[materialIdx].m_descriptorID;
m_shaderManager.GetDescriptorAt(currDescriptorID).BindDescriptorSets(m_deferredPass.commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
}
if (meshComponents[materialIdx].GetVertexHandle() != currMesh) {
currMesh = meshComponents[materialIdx].GetVertexHandle();
}
currStartIdx = materialIdx;
}
}
}
//vkCmdEndRenderPass(m_oitCommandBuffers[m_currSwapChainImageIndex]);
vkCmdEndRenderPass(m_deferredPass.commandBuffers[m_currSwapChainImageIndex]);
/*if (vkEndCommandBuffer(m_oitCommandBuffers[m_currSwapChainImageIndex]) != VK_SUCCESS) {
throw std::runtime_error("failed to record oit linked list pass command buffer!");
}*/
}
if (vkEndCommandBuffer(m_deferredPass.commandBuffers[m_currSwapChainImageIndex]) != VK_SUCCESS) {
throw std::runtime_error("failed to record deferred geometry pass command buffer!");
}
/// Construct deferred lighting and post processing passes
// Begin command buffer
VkCommandBufferBeginInfo beginInfoDeferred = {};
beginInfoDeferred.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfoDeferred.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
beginInfoDeferred.pInheritanceInfo = nullptr;
if (vkBeginCommandBuffer(m_commandBuffers[m_currSwapChainImageIndex], &beginInfoDeferred) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording command buffer!");
}
// Begin render pass
VkRenderPassBeginInfo renderPassInfoDeferred = {};
renderPassInfoDeferred.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfoDeferred.renderPass = m_renderPass_deferredLighting;
if (m_postProcessingPasses.size() > 0) {
renderPassInfoDeferred.framebuffer = m_framebuffer_deferredLighting;
} else {
renderPassInfoDeferred.framebuffer = m_swapChainFramebuffers[m_currSwapChainImageIndex];
}
renderPassInfoDeferred.renderArea.offset = { 0, 0 };
renderPassInfoDeferred.renderArea.extent = { m_width, m_height };
std::array<VkClearValue, 2> clearValuesDeferred = {};
clearValuesDeferred[0].color = { 0.0f, 0.0f, 0.0f, 1.0f };
clearValuesDeferred[1].depthStencil = { 1.0f, 0 };
renderPassInfoDeferred.clearValueCount = static_cast<uint32_t>(clearValuesDeferred.size());
renderPassInfoDeferred.pClearValues = clearValuesDeferred.data();
vkCmdBeginRenderPass(m_commandBuffers[m_currSwapChainImageIndex], &renderPassInfoDeferred, VK_SUBPASS_CONTENTS_INLINE);
if (materialComponents.size() > 0) {
// Only do deferred pass if at least one material is opaque
if (materialComponents[0].m_renderLayer < TRANSLUCENT) {
JEDeferredShader* deferredShader = (JEDeferredShader*)m_shaderManager.GetShaderAt(materialComponents[0].m_shaderID);
vkCmdBindPipeline(m_commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, deferredShader->GetPipeline());
vkCmdSetViewport(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
if (materialComponents[0].m_materialSettings & RECEIVES_SHADOWS) {
m_shaderManager.GetDescriptorAt(m_deferredLightingDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], deferredShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
} else {
m_shaderManager.GetDescriptorAt(m_deferredLightingNoShadowsDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], deferredShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
}
DrawScreenSpaceTriMesh(m_commandBuffers[m_currSwapChainImageIndex]);
}
if (!m_enableOIT) {
// Draw transluscent geometry
uint32_t materialIdx = currStartIdx;
if (materialIdx < materialComponents.size() && materialComponents[currStartIdx].m_renderLayer >= TRANSLUCENT) {
++materialIdx;
currDescriptorID = materialComponents[currStartIdx].m_descriptorID;
int currMesh = meshComponents[currStartIdx].GetVertexHandle();
uint32_t currShaderID = materialComponents[currStartIdx].m_shaderID;
JEForwardShader* forwardShader = (JEForwardShader*)m_shaderManager.GetShaderAt(currShaderID);
vkCmdBindPipeline(m_commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, forwardShader->GetPipeline());
vkCmdSetViewport(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(currDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
forwardShader->BindPushConstants_ViewProj(m_commandBuffers[m_currSwapChainImageIndex], camera.GetViewProj());
m_shaderManager.GetDescriptorAt(m_forwardModelMatrixDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 1, m_currSwapChainImageIndex);
while (materialIdx <= materialComponents.size()) {
if (materialIdx == materialComponents.size()) {
forwardShader->BindPushConstants_InstancedData(m_commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_commandBuffers[m_currSwapChainImageIndex], materialIdx - currStartIdx, { currMesh, MESH_TRIANGLES });
break;
}
if (materialComponents[materialIdx].m_shaderID == currShaderID &&
materialComponents[materialIdx].m_descriptorID == currDescriptorID &&
meshComponents[materialIdx].GetVertexHandle() == currMesh) {
++materialIdx;
} else {
// Draw instanced mesh using curr material resources
forwardShader->BindPushConstants_InstancedData(m_commandBuffers[m_currSwapChainImageIndex], { currStartIdx, 0, 0, 0 });
DrawMeshInstanced(m_commandBuffers[m_currSwapChainImageIndex], materialIdx - currStartIdx, { currMesh, MESH_TRIANGLES });
if (materialComponents[materialIdx].m_shaderID != currShaderID) {
currShaderID = materialComponents[materialIdx].m_shaderID;
forwardShader = (JEForwardShader*)m_shaderManager.GetShaderAt(currShaderID);
vkCmdBindPipeline(m_commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, forwardShader->GetPipeline());
vkCmdSetViewport(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(m_forwardModelMatrixDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 1, m_currSwapChainImageIndex);
}
if (materialComponents[materialIdx].m_descriptorID != currDescriptorID) {
currDescriptorID = materialComponents[materialIdx].m_descriptorID;
m_shaderManager.GetDescriptorAt(currDescriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], forwardShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
}
if (meshComponents[materialIdx].GetVertexHandle() != currMesh) {
currMesh = meshComponents[materialIdx].GetVertexHandle();
}
currStartIdx = materialIdx;
}
}
}
} else {
JEOITSortShader* oitSortShader = (JEOITSortShader*)m_shaderManager.GetShaderAt(m_oitSortShader);
vkCmdBindPipeline(m_commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, oitSortShader->GetPipeline());
vkCmdSetViewport(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(m_oitLLDescriptor).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], oitSortShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
DrawScreenSpaceTriMesh(m_commandBuffers[m_currSwapChainImageIndex]);
}
}
if (particleSystems.size() > 0) {
for (const JEParticleSystem& particleSystem : particleSystems) {
JEPointsShader* pointsShader = (JEPointsShader*)m_shaderManager.GetShaderAt(particleSystem.GetMaterialComponent().m_shaderID);
vkCmdBindPipeline(m_commandBuffers[m_currSwapChainImageIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, pointsShader->GetPipeline());
vkCmdSetViewport(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &viewport);
vkCmdSetScissor(m_commandBuffers[m_currSwapChainImageIndex], 0, 1, &scissor);
m_shaderManager.GetDescriptorAt(particleSystem.GetMaterialComponent().m_descriptorID).BindDescriptorSets(m_commandBuffers[m_currSwapChainImageIndex], pointsShader->GetPipelineLayout(), 0, m_currSwapChainImageIndex);
DrawMeshInstanced(m_commandBuffers[m_currSwapChainImageIndex], 1, particleSystem.GetMeshComponent());
}
}
vkCmdEndRenderPass(m_commandBuffers[m_currSwapChainImageIndex]);
// Loop over each post processing pass
/*for (uint32_t p = 0; p < m_postProcessingPasses.size(); ++p) {
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
if (p == m_postProcessingPasses.size() - 1) {
renderPassInfo.framebuffer = m_swapChainFramebuffers[i];
renderPassInfo.renderArea.extent = m_vulkanSwapChain.GetExtent();
} else {
renderPassInfo.framebuffer = m_postProcessingPasses[p].framebuffer;
renderPassInfo.renderArea.extent = { m_width, m_height };
}
renderPassInfo.renderPass = m_postProcessingPasses[p].renderPass;
renderPassInfo.renderArea.offset = { 0, 0 };
std::array<VkClearValue, 1> clearValues = {};
clearValues[0].color = { 0.0f, 0.0f, 0.0f, 1.0f };
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(m_commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(m_commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, m_postProcessingShaders[p].GetPipeline());
m_postProcessingShaders[p].BindDescriptorSets(m_commandBuffers[i], i);
DrawScreenSpaceTriMesh(m_commandBuffers[i]);
vkCmdEndRenderPass(m_commandBuffers[i]);
}*/
if (vkEndCommandBuffer(m_commandBuffers[m_currSwapChainImageIndex]) != VK_SUCCESS) {
throw std::runtime_error("failed to record command buffer!");
}
} else {
/*
for (uint32_t i = 0; i < m_commandBuffers.size(); ++i) {
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
beginInfo.pInheritanceInfo = nullptr;
if (vkBeginCommandBuffer(m_commandBuffers[i], &beginInfo) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording command buffer!");
}
// Begin render pass
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = m_forwardPass.renderPass;
if (m_postProcessingPasses.size() > 0) {
renderPassInfo.framebuffer = m_forwardPass.framebuffer;
} else {
renderPassInfo.framebuffer = m_swapChainFramebuffers[i];
}
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = { m_width, m_height };
std::array<VkClearValue, 2> clearValues = {};
clearValues[0].color = { 0.0f, 0.0f, 0.0f, 1.0f };
clearValues[1].depthStencil = { 1.0f, 0 };
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(m_commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
// Draw mesh components
vkCmdBindPipeline(m_commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, m_forwardShader.GetPipeline());
m_forwardShader.BindPushConstants_ViewProj(m_commandBuffers[i], camera.GetViewProj());
m_forwardShader.BindDescriptorSets(m_commandBuffers[i]);
for (uint32_t j = 0; j < meshComponents.size(); ++j) {
m_forwardShader.BindPushConstants_ModelMatrix(m_commandBuffers[i], transformComponents[j]);
DrawMesh(m_commandBuffers[i], meshComponents[j]);
}
// Draw bounding boxes / debug geometry
vkCmdBindPipeline(m_commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, m_flatShader.GetPipeline());
m_flatShader.BindPushConstants_ViewProj(m_commandBuffers[i], camera.GetViewProj());
vkCmdSetLineWidth(m_commandBuffers[i], 2.0f);
const std::vector<BoundingBoxData> boundingBoxData = m_meshBufferManager.GetBoundingBoxData();
for (uint32_t j = 0; j < transformComponents.size(); ++j) {
const glm::vec3& minPos = boundingBoxData[meshComponents[j].GetVertexHandle()][0];
const glm::vec3& maxPos = boundingBoxData[meshComponents[j].GetVertexHandle()][7];
const glm::vec3 scale = 0.5f * (maxPos - minPos);
const glm::mat4 meshTrans = glm::translate(glm::mat4(1.0f), minPos + scale) * glm::scale(glm::mat4(1.0f), scale);
m_flatShader.BindPushConstants_ModelMatrix(m_commandBuffers[i], transformComponents[j] * meshTrans);
DrawBoundingBoxMesh(m_commandBuffers[i]);
}
vkCmdEndRenderPass(m_commandBuffers[i]);
// Loop over each post processing pass
for (uint32_t p = 0; p < m_postProcessingPasses.size(); ++p) {
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
if (p == m_postProcessingPasses.size() - 1) {
renderPassInfo.framebuffer = m_swapChainFramebuffers[i];
renderPassInfo.renderArea.extent = m_vulkanSwapChain.GetExtent();
} else {
renderPassInfo.framebuffer = m_postProcessingPasses[p].framebuffer;
renderPassInfo.renderArea.extent = { m_width, m_height };
}
renderPassInfo.renderPass = m_postProcessingPasses[p].renderPass;
renderPassInfo.renderArea.offset = { 0, 0 };
std::array<VkClearValue, 1> clearValues = {};
clearValues[0].color = { 0.0f, 0.0f, 0.0f, 1.0f };
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(m_commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(m_commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, m_postProcessingShaders[p].GetPipeline());
m_postProcessingShaders[p].BindDescriptorSets(m_commandBuffers[i], i);
DrawScreenSpaceTriMesh(m_commandBuffers[i]);
vkCmdEndRenderPass(m_commandBuffers[i]);
}
if (vkEndCommandBuffer(m_commandBuffers[i]) != VK_SUCCESS) {
throw std::runtime_error("failed to record command buffer!");
}
}*/
}
}
/// Shadow Pass creation
void JEVulkanRenderer::CreateShadowPassRenderPass() {
VkAttachmentDescription depthAttachment = {};
depthAttachment.format = FindDepthFormat(m_physicalDevice);
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = 0;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 0;
subpass.pColorAttachments = nullptr;
subpass.pDepthStencilAttachment = &depthAttachmentRef;
// Use subpass dependencies for layout transitions
std::array<VkSubpassDependency, 2> dependencies;
dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependencies[0].dstSubpass = 0;
dependencies[0].srcStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
dependencies[0].dstStageMask = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
dependencies[0].srcAccessMask = VK_ACCESS_SHADER_READ_BIT;
dependencies[0].dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
dependencies[1].srcSubpass = 0;
dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
dependencies[1].srcStageMask = VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
dependencies[1].dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
dependencies[1].srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
dependencies[1].dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = 1;
renderPassInfo.pAttachments = &depthAttachment;
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = &subpass;
renderPassInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
renderPassInfo.pDependencies = dependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_shadowPass.renderPass) != VK_SUCCESS) {
throw std::runtime_error("failed to create render pass!");
}
}
void JEVulkanRenderer::CreateShadowPassFramebuffer(uint32_t index) {
VkImageView depthAttachment = m_shadowPass.depths[index].imageView;
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_shadowPass.renderPass;
framebufferInfo.attachmentCount = 1;
framebufferInfo.pAttachments = &depthAttachment;
framebufferInfo.width = m_shadowPass.width;
framebufferInfo.height = m_shadowPass.height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_shadowPass.framebuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
void JEVulkanRenderer::CreateShadowPassCommandBuffer(uint32_t index) {
VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = m_commandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = 1;
if (vkAllocateCommandBuffers(m_device, &allocInfo, &m_shadowPass.commandBuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate shadow pass command buffer!");
}
if (m_shadowPass.semaphores[index] == VK_NULL_HANDLE) {
VkSemaphoreCreateInfo semaphoreInfo = {};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_shadowPass.semaphores[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to create shadow pass semaphore!");
}
}
}
void JEVulkanRenderer::CreateShadowPassResources() {
CreateShadowPassRenderPass();
CreateFramebufferAttachmentSampler(m_shadowPass.depthSampler);
m_shadowPass.framebuffers = std::vector<VkFramebuffer>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
m_shadowPass.depths = std::vector<JEFramebufferAttachment>(m_swapChainFramebuffers.size());
m_shadowPass.commandBuffers = std::vector<VkCommandBuffer>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
m_shadowPass.semaphores = std::vector<VkSemaphore>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
CreateFramebufferAttachment(m_shadowPass.depths[i], { m_shadowPass.width, m_shadowPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), FindDepthFormat(m_physicalDevice));
CreateShadowPassFramebuffer(i);
CreateShadowPassCommandBuffer(i);
}
}
/// Forard Pass creation
void JEVulkanRenderer::CreateForwardPassRenderPass() {
std::array<VkAttachmentDescription, 2> attachmentDescs = {};
for (uint32_t i = 0; i < attachmentDescs.size(); ++i) {
attachmentDescs[i].samples = VK_SAMPLE_COUNT_1_BIT;
attachmentDescs[i].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachmentDescs[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentDescs[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDescs[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
if (i == 1) {
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
} else {
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
}
attachmentDescs[0].format = VK_FORMAT_R8G8B8A8_UNORM;
attachmentDescs[1].format = FindDepthFormat(m_physicalDevice);
std::vector<VkAttachmentReference> colorReferences;
colorReferences.push_back({ 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL });
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = 1;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
std::array<VkSubpassDescription, 1> subpassDescs = {};
subpassDescs[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDescs[0].colorAttachmentCount = static_cast<uint32_t>(colorReferences.size());
subpassDescs[0].pColorAttachments = colorReferences.data();
subpassDescs[0].pDepthStencilAttachment = &depthAttachmentRef;
std::array<VkSubpassDependency, 2> subpassDependencies;
subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[0].dstSubpass = 0;
subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
subpassDependencies[1].srcSubpass = 0;
subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = attachmentDescs.size();
renderPassInfo.pAttachments = attachmentDescs.data();
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = subpassDescs.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassDependencies.size());
renderPassInfo.pDependencies = subpassDependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_forwardPass.renderPass) != VK_SUCCESS) {
throw std::runtime_error("failed to create forward pass render pass!");
}
}
void JEVulkanRenderer::CreateForwardPassFramebuffer() {
std::array<VkImageView, 2> attachments = { m_forwardPass.color.imageView, m_forwardPass.depth.imageView };
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_forwardPass.renderPass;
framebufferInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
framebufferInfo.pAttachments = attachments.data();
framebufferInfo.width = m_forwardPass.width;
framebufferInfo.height = m_forwardPass.height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_forwardPass.framebuffer) != VK_SUCCESS) {
throw std::runtime_error("failed to create forward pass framebuffer!");
}
}
void JEVulkanRenderer::CreateForwardPassCommandBuffer() {
/*VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = m_commandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = 1;
if (vkAllocateCommandBuffers(m_device, &allocInfo, &m_forwardPass.commandBuffer) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate forward pass command buffer!");
}*/
//if (m_forwardPass.semaphore == VK_NULL_HANDLE) {
VkSemaphoreCreateInfo semaphoreInfo = {};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_forwardPass.semaphore) != VK_SUCCESS) {
throw std::runtime_error("failed to create forward pass semaphore!");
}
//}
}
void JEVulkanRenderer::CreateForwardPassResources() {
CreateFramebufferAttachment(m_forwardPass.color, { m_forwardPass.width, m_forwardPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM);
CreateFramebufferAttachment(m_forwardPass.depth, { m_forwardPass.width, m_forwardPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), FindDepthFormat(m_physicalDevice));
CreateFramebufferAttachmentSampler(m_forwardPass.sampler);
CreateForwardPassRenderPass();
CreateForwardPassFramebuffer();
CreateForwardPassCommandBuffer();
}
/// Deferred Rendering Geometry Pass creation
void JEVulkanRenderer::CreateDeferredPassGeometryRenderPass() {
std::array<VkAttachmentDescription, 3> attachmentDescs = {};
for (uint32_t i = 0; i < attachmentDescs.size(); ++i) {
attachmentDescs[i].samples = VK_SAMPLE_COUNT_1_BIT;
attachmentDescs[i].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachmentDescs[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentDescs[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDescs[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
if (i == 2) {
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
} else {
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;;
}
}
attachmentDescs[0].format = VK_FORMAT_R8G8B8A8_UNORM; // VK_FORMAT_R16G16B16A16_SFLOAT;
attachmentDescs[1].format = VK_FORMAT_R8G8B8A8_UNORM; // VK_FORMAT_R16G16B16A16_SFLOAT;
attachmentDescs[2].format = FindDepthFormat(m_physicalDevice);
std::vector<VkAttachmentReference> colorReferences;
colorReferences.push_back({ 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL });
colorReferences.push_back({ 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL });
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = 2;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
std::array<VkSubpassDescription, 1> subpassDescs = {};
subpassDescs[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDescs[0].colorAttachmentCount = static_cast<uint32_t>(colorReferences.size());
subpassDescs[0].pColorAttachments = colorReferences.data();
subpassDescs[0].pDepthStencilAttachment = &depthAttachmentRef;
std::array<VkSubpassDependency, 2> subpassDependencies;
subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[0].dstSubpass = 0;
subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
subpassDependencies[1].srcSubpass = 0;
subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = 3;
renderPassInfo.pAttachments = attachmentDescs.data();
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = subpassDescs.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassDependencies.size());
renderPassInfo.pDependencies = subpassDependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_deferredPass.renderPass) != VK_SUCCESS) {
throw std::runtime_error("failed to create render pass!");
}
}
void JEVulkanRenderer::CreateDeferredPassGeometryFramebuffer(uint32_t index) {
std::array<VkImageView, 3> attachments = { m_deferredPass.colors[index].imageView, m_deferredPass.normals[index].imageView, m_deferredPass.depths[index].imageView };
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_deferredPass.renderPass;
framebufferInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
framebufferInfo.pAttachments = attachments.data();
framebufferInfo.width = m_deferredPass.width;
framebufferInfo.height = m_deferredPass.height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_deferredPass.framebuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
void JEVulkanRenderer::CreateDeferredPassGeometryCommandBuffer(uint32_t index) {
VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = m_commandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = 1;
if (vkAllocateCommandBuffers(m_device, &allocInfo, &m_deferredPass.commandBuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate deferred pass command buffer!");
}
//if (m_deferredPass.semaphores[index] == VK_NULL_HANDLE) {
VkSemaphoreCreateInfo semaphoreInfo = {};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
if (vkCreateSemaphore(m_device, &semaphoreInfo, nullptr, &m_deferredPass.semaphores[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to create deferred pass semaphore!");
}
//}
}
void JEVulkanRenderer::CreateDeferredPassGeometryResources() {
m_deferredPass.framebuffers = std::vector<VkFramebuffer>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
m_deferredPass.colors = std::vector<JEFramebufferAttachment>(m_swapChainFramebuffers.size());
m_deferredPass.normals = std::vector<JEFramebufferAttachment>(m_swapChainFramebuffers.size());
m_deferredPass.depths = std::vector<JEFramebufferAttachment>(m_swapChainFramebuffers.size());
m_deferredPass.commandBuffers = std::vector<VkCommandBuffer>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
m_deferredPass.semaphores = std::vector<VkSemaphore>(m_swapChainFramebuffers.size(), VK_NULL_HANDLE);
CreateDeferredPassGeometryRenderPass();
CreateFramebufferAttachmentSampler(m_deferredPass.sampler);
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
CreateFramebufferAttachment(m_deferredPass.colors[i], { m_deferredPass.width, m_deferredPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM /*VK_FORMAT_R16G16B16A16_SFLOAT*/);
CreateFramebufferAttachment(m_deferredPass.normals[i], { m_deferredPass.width, m_deferredPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM /*VK_FORMAT_R16G16B16A16_SFLOAT*/);
CreateFramebufferAttachment(m_deferredPass.depths[i], { m_deferredPass.width, m_deferredPass.height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), FindDepthFormat(m_physicalDevice));
CreateDeferredPassGeometryFramebuffer(i);
CreateDeferredPassGeometryCommandBuffer(i);
}
}
/// Deferred Rendering Lighting Pass creation
void JEVulkanRenderer::CreateDeferredPassLightingRenderPass() {
std::array<VkAttachmentDescription, 2> attachmentDescs = {};
for (uint32_t i = 0; i < attachmentDescs.size(); ++i) {
attachmentDescs[i].samples = VK_SAMPLE_COUNT_1_BIT;
attachmentDescs[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDescs[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
if (i == 0) {
attachmentDescs[i].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachmentDescs[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (m_postProcessingPasses.size() > 0) {
attachmentDescs[i].format = VK_FORMAT_R8G8B8A8_UNORM;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
} else {
attachmentDescs[i].format = m_vulkanSwapChain.GetFormat();
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
}
} else if (i == 1) {
attachmentDescs[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
attachmentDescs[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentDescs[i].format = FindDepthFormat(m_physicalDevice);
attachmentDescs[i].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
attachmentDescs[i].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
}
}
std::vector<VkAttachmentReference> colorReferences;
colorReferences.push_back({ 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL });
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = 1;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
std::array<VkSubpassDescription, 1> subpassDescs = {};
subpassDescs[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDescs[0].colorAttachmentCount = static_cast<uint32_t>(colorReferences.size());
subpassDescs[0].pColorAttachments = colorReferences.data();
subpassDescs[0].pDepthStencilAttachment = &depthAttachmentRef;
std::array<VkSubpassDependency, 2> subpassDependencies;
subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[0].dstSubpass = 0;
subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
subpassDependencies[1].srcSubpass = 0;
subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = attachmentDescs.size();
renderPassInfo.pAttachments = attachmentDescs.data();
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = subpassDescs.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassDependencies.size());
renderPassInfo.pDependencies = subpassDependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_renderPass_deferredLighting) != VK_SUCCESS) {
throw std::runtime_error("failed to create render pass!");
}
}
void JEVulkanRenderer::CreateDeferredPassLightingFramebuffer() {
VkImageView attachment = m_framebufferAttachment_deferredLighting.imageView;
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_renderPass_deferredLighting;
framebufferInfo.attachmentCount = 1;
framebufferInfo.pAttachments = &attachment;
framebufferInfo.width = m_deferredPass.width;
framebufferInfo.height = m_deferredPass.height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_framebuffer_deferredLighting) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
void JEVulkanRenderer::CreateDeferredPassLightingResources() {
CreateDeferredPassLightingRenderPass();
// If there are no post processing passes, then this pass should render to the screen, meaning no framebuffer should be created
// This also means that we do not need to create buffers for the framebuffer attachment
if (m_postProcessingPasses.size() > 0) {
CreateFramebufferAttachment(m_framebufferAttachment_deferredLighting, { m_width, m_height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM);
CreateDeferredPassLightingFramebuffer();
}
CreateDeferredLightingAndPostProcessingCommandBuffer();
}
/// Post Processing passes creation
void JEVulkanRenderer::CreatePostProcessingPassFramebuffer(uint32_t i) {
VkImageView attachment;
if (i == m_postProcessingPasses.size() - 1) {
return; // This post processing pass will use the swap chain framebuffers, which are already created
} else {
attachment = m_postProcessingPasses[i].texture.imageView;
}
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_postProcessingPasses[i].renderPass;
framebufferInfo.attachmentCount = 1;
framebufferInfo.pAttachments = &attachment;
framebufferInfo.width = m_postProcessingPasses[i].width;
framebufferInfo.height = m_postProcessingPasses[i].height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_postProcessingPasses[i].framebuffer) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
void JEVulkanRenderer::CreatePostProcessingPassRenderPass(uint32_t i) {
VkAttachmentDescription attachmentDesc = {};
attachmentDesc.samples = VK_SAMPLE_COUNT_1_BIT;
attachmentDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachmentDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachmentDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachmentDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (i == m_postProcessingPasses.size() - 1) {
attachmentDesc.format = m_vulkanSwapChain.GetFormat();
attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
} else {
attachmentDesc.format = VK_FORMAT_R8G8B8A8_UNORM;
attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
VkAttachmentReference colorReference;
colorReference.attachment = 0;
colorReference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
std::array<VkSubpassDescription, 1> subpassDescs = {};
subpassDescs[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDescs[0].colorAttachmentCount = 1;
subpassDescs[0].pColorAttachments = &colorReference;
subpassDescs[0].pDepthStencilAttachment = nullptr;
std::array<VkSubpassDependency, 2> subpassDependencies;
subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[0].dstSubpass = 0;
subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
subpassDependencies[1].srcSubpass = 0;
subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = 1;
renderPassInfo.pAttachments = &attachmentDesc;
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = subpassDescs.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassDependencies.size());
renderPassInfo.pDependencies = subpassDependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_postProcessingPasses[i].renderPass) != VK_SUCCESS) {
throw std::runtime_error("failed to create render pass!");
}
}
void JEVulkanRenderer::CreatePostProcessingPassResources() {
for (uint32_t i = 0; i < m_postProcessingPasses.size(); ++i) {
CreateFramebufferAttachmentSampler(m_postProcessingPasses[i].sampler);
if (i == m_postProcessingPasses.size() - 1) {
CreateFramebufferAttachment(m_postProcessingPasses[i].texture, { m_postProcessingPasses[i].width, m_postProcessingPasses[i].height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), m_vulkanSwapChain.GetFormat());
} else {
CreateFramebufferAttachment(m_postProcessingPasses[i].texture, { m_postProcessingPasses[i].width, m_postProcessingPasses[i].height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM);
}
CreatePostProcessingPassRenderPass(i);
CreatePostProcessingPassFramebuffer(i);
}
}
// OIT
void JEVulkanRenderer::CreateOITResources() {
CreateOITRenderPass();
m_oitFramebuffers.resize(m_swapChainFramebuffers.size());
m_oitCommandBuffers.resize(m_swapChainFramebuffers.size());
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
CreateOITFramebuffer(i);
CreateOITCommandBuffer(i);
}
}
void JEVulkanRenderer::CreateOITRenderPass() {
VkAttachmentDescription depthAttachDesc = {};
depthAttachDesc.samples = VK_SAMPLE_COUNT_1_BIT;
depthAttachDesc.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
depthAttachDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
depthAttachDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthAttachDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthAttachDesc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
depthAttachDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
depthAttachDesc.format = FindDepthFormat(m_physicalDevice);
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = 0;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
std::array<VkSubpassDescription, 1> subpassDescs = {};
subpassDescs[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpassDescs[0].colorAttachmentCount = 0;
subpassDescs[0].pColorAttachments = nullptr;
subpassDescs[0].pDepthStencilAttachment = &depthAttachmentRef;
std::array<VkSubpassDependency, 2> subpassDependencies;
subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[0].dstSubpass = 0;
subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
subpassDependencies[1].srcSubpass = 0;
subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
subpassDependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = 1;
renderPassInfo.pAttachments = &depthAttachDesc;
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = subpassDescs.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(subpassDependencies.size());
renderPassInfo.pDependencies = subpassDependencies.data();
if (vkCreateRenderPass(m_device, &renderPassInfo, nullptr, &m_oitRenderPass) != VK_SUCCESS) {
throw std::runtime_error("failed to create render pass!");
}
}
void JEVulkanRenderer::CreateOITFramebuffer(uint32_t index) {
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = m_oitRenderPass;
framebufferInfo.attachmentCount = 1;
framebufferInfo.pAttachments = &m_deferredPass.depths[index].imageView;
framebufferInfo.width = m_width;
framebufferInfo.height = m_height;
framebufferInfo.layers = 1;
if (vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_oitFramebuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to create framebuffer!");
}
}
void JEVulkanRenderer::CreateOITCommandBuffer(uint32_t index) {
VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.commandPool = m_commandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = 1;
if (vkAllocateCommandBuffers(m_device, &allocInfo, &m_oitCommandBuffers[index]) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate deferred pass command buffer!");
}
}
void JEVulkanRenderer::StartFrame() {
vkWaitForFences(m_device, 1, &m_inFlightFences[m_currentFrame], VK_TRUE, std::numeric_limits<uint64_t>::max());
VkResult result = vkAcquireNextImageKHR(m_device, m_vulkanSwapChain.GetSwapChain(), std::numeric_limits<uint64_t>::max(),
m_imageAvailableSemaphores[m_currentFrame], VK_NULL_HANDLE, &m_currSwapChainImageIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
RecreateWindowDependentResources();
return;
} else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
throw std::runtime_error("failed to acquire swap chain image!");
}
}
void JEVulkanRenderer::SubmitFrame(const std::vector<MaterialComponent>& materialComponents,
const std::vector<glm::mat4>& transforms, const std::vector<glm::mat4>& transformsSorted) {
UpdateShaderBuffers(materialComponents, transforms, transformsSorted, m_currSwapChainImageIndex);
// Submit shadow pass command buffer
VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
VkSubmitInfo submitInfo_shadowPass = {};
submitInfo_shadowPass.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo_shadowPass.pNext = nullptr;
submitInfo_shadowPass.pWaitSemaphores = &m_imageAvailableSemaphores[m_currentFrame];
submitInfo_shadowPass.waitSemaphoreCount = 1;
submitInfo_shadowPass.pWaitDstStageMask = waitStages;
submitInfo_shadowPass.pSignalSemaphores = nullptr; //&m_shadowPass.semaphores[m_currSwapChainImageIndex];
submitInfo_shadowPass.signalSemaphoreCount = 0;
submitInfo_shadowPass.commandBufferCount = 1;
submitInfo_shadowPass.pCommandBuffers = &m_shadowPass.commandBuffers[m_currSwapChainImageIndex];
vkResetFences(m_device, 1, &m_inFlightFences[m_currentFrame]);
if (vkQueueSubmit(m_graphicsQueue.GetQueue(), 1, &submitInfo_shadowPass, m_inFlightFences[m_currentFrame]) != VK_SUCCESS) {
throw std::runtime_error("failed to submit shadow pass command buffer!");
}
if (m_enableDeferred) {
// Submit deferred render pass with g-buffers
VkSubmitInfo submitInfo_deferred_gBuffers = {};
submitInfo_deferred_gBuffers.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo_deferred_gBuffers.pNext = nullptr;
submitInfo_deferred_gBuffers.waitSemaphoreCount = 0;
submitInfo_deferred_gBuffers.pWaitSemaphores = nullptr; //&m_shadowPass.semaphore;
submitInfo_deferred_gBuffers.pWaitDstStageMask = waitStages;
submitInfo_deferred_gBuffers.commandBufferCount = 1;
submitInfo_deferred_gBuffers.pCommandBuffers = &m_deferredPass.commandBuffers[m_currSwapChainImageIndex];
submitInfo_deferred_gBuffers.signalSemaphoreCount = 0;
submitInfo_deferred_gBuffers.pSignalSemaphores = nullptr; //&m_deferredPass.semaphore;
vkWaitForFences(m_device, 1, &m_inFlightFences[m_currentFrame], VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(m_device, 1, &m_inFlightFences[m_currentFrame]);
if (vkQueueSubmit(m_graphicsQueue.GetQueue(), 1, &submitInfo_deferred_gBuffers, m_inFlightFences[m_currentFrame]) != VK_SUCCESS) {
throw std::runtime_error("failed to submit deferred geometry command buffer!");
}
}
// Submit render-to-screen command buffer
VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.pNext = nullptr;
submitInfo.waitSemaphoreCount = 0;
submitInfo.pWaitSemaphores = nullptr;
submitInfo.pWaitDstStageMask = waitStages;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_commandBuffers[m_currSwapChainImageIndex];
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &m_renderFinishedSemaphores[m_currentFrame];
vkWaitForFences(m_device, 1, &m_inFlightFences[m_currentFrame], VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(m_device, 1, &m_inFlightFences[m_currentFrame]);
if (vkQueueSubmit(m_graphicsQueue.GetQueue(), 1, &submitInfo, m_inFlightFences[m_currentFrame]) != VK_SUCCESS) {
throw std::runtime_error("failed to submit command buffer!");
}
// Presentation
VkPresentInfoKHR presentInfo = {};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &m_renderFinishedSemaphores[m_currentFrame];
VkSwapchainKHR swapChains[] = { m_vulkanSwapChain.GetSwapChain() };
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = swapChains;
presentInfo.pImageIndices = &m_currSwapChainImageIndex;
presentInfo.pResults = nullptr;
VkResult result = vkQueuePresentKHR(m_presentationQueue.GetQueue(), &presentInfo);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || m_didFramebufferResize) {
m_didFramebufferResize = false;
RecreateWindowDependentResources();
} else if (result != VK_SUCCESS) {
throw std::runtime_error("failed to present swap chain image!");
}
m_currentFrame = (m_currentFrame + 1) % m_MAX_FRAMES_IN_FLIGHT;
}
void JEVulkanRenderer::CleanupWindowDependentResources() {
// Swap Chain Framebuffers
for (auto framebuffer : m_swapChainFramebuffers) {
vkDestroyFramebuffer(m_device, framebuffer, nullptr);
}
// Deferred Pass - Geometry
if (m_enableDeferred) {
vkDestroyRenderPass(m_device, m_deferredPass.renderPass, nullptr);
vkDestroySampler(m_device, m_deferredPass.sampler, nullptr);
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
vkDestroyImage(m_device, m_deferredPass.colors[i].image, nullptr);
vkDestroyImage(m_device, m_deferredPass.normals[i].image, nullptr);
vkDestroyImage(m_device, m_deferredPass.depths[i].image, nullptr);
vkFreeMemory(m_device, m_deferredPass.colors[i].deviceMemory, nullptr);
vkFreeMemory(m_device, m_deferredPass.normals[i].deviceMemory, nullptr);
vkFreeMemory(m_device, m_deferredPass.depths[i].deviceMemory, nullptr);
vkDestroyImageView(m_device, m_deferredPass.colors[i].imageView, nullptr);
vkDestroyImageView(m_device, m_deferredPass.normals[i].imageView, nullptr);
vkDestroyImageView(m_device, m_deferredPass.depths[i].imageView, nullptr);
vkDestroyFramebuffer(m_device, m_deferredPass.framebuffers[i], nullptr);
vkFreeCommandBuffers(m_device, m_commandPool, 1, &m_deferredPass.commandBuffers[i]);
vkDestroySemaphore(m_device, m_deferredPass.semaphores[i], nullptr);
}
}
// Deferred Pass - Lighting
vkDestroyRenderPass(m_device, m_renderPass_deferredLighting, nullptr);
if (m_postProcessingPasses.size() > 0) {
vkDestroyImage(m_device, m_framebufferAttachment_deferredLighting.image, nullptr);
vkFreeMemory(m_device, m_framebufferAttachment_deferredLighting.deviceMemory, nullptr);
vkDestroyImageView(m_device, m_framebufferAttachment_deferredLighting.imageView, nullptr);
vkDestroyFramebuffer(m_device, m_framebuffer_deferredLighting, nullptr);
}
// OIT resources
if (m_enableOIT) {
vkDestroyRenderPass(m_device, m_oitRenderPass, nullptr);
vkFreeCommandBuffers(m_device, m_commandPool, static_cast<uint32_t>(m_oitCommandBuffers.size()), m_oitCommandBuffers.data());
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
vkDestroyFramebuffer(m_device, m_oitFramebuffers[i], nullptr);
}
}
// Forward Pass
vkDestroyImage(m_device, m_forwardPass.color.image, nullptr);
vkDestroyImage(m_device, m_forwardPass.depth.image, nullptr);
vkFreeMemory(m_device, m_forwardPass.color.deviceMemory, nullptr);
vkFreeMemory(m_device, m_forwardPass.depth.deviceMemory, nullptr);
vkDestroyImageView(m_device, m_forwardPass.color.imageView, nullptr);
vkDestroyImageView(m_device, m_forwardPass.depth.imageView, nullptr);
vkDestroyRenderPass(m_device, m_forwardPass.renderPass, nullptr);
vkDestroyFramebuffer(m_device, m_forwardPass.framebuffer, nullptr);
vkDestroySampler(m_device, m_forwardPass.sampler, nullptr);
vkDestroySemaphore(m_device, m_forwardPass.semaphore, nullptr);
// Post Processing
for (uint32_t p = 0; p < m_postProcessingPasses.size(); ++p) {
vkDestroyImage(m_device, m_postProcessingPasses[p].texture.image, nullptr);
vkFreeMemory(m_device, m_postProcessingPasses[p].texture.deviceMemory, nullptr);
vkDestroyImageView(m_device, m_postProcessingPasses[p].texture.imageView, nullptr);
vkDestroyRenderPass(m_device, m_postProcessingPasses[p].renderPass, nullptr);
if (m_postProcessingPasses[p].framebuffer != VK_NULL_HANDLE) {
vkDestroyFramebuffer(m_device, m_postProcessingPasses[p].framebuffer, nullptr);
}
vkDestroySampler(m_device, m_postProcessingPasses[p].sampler, nullptr);
}
vkFreeCommandBuffers(m_device, m_commandPool, static_cast<uint32_t>(m_commandBuffers.size()), m_commandBuffers.data());
m_vulkanSwapChain.Cleanup(m_device);
}
void JEVulkanRenderer::RecreateWindowDependentResources() {
int newWidth = 0, newHeight = 0;
while (newWidth == 0 || newHeight == 0) {
m_vulkanWindow.AwaitMaximize(&newWidth, &newHeight);
}
m_width = newWidth;
m_height = newHeight;
vkDeviceWaitIdle(m_device);
CleanupWindowDependentResources();
m_vulkanSwapChain.Create(m_physicalDevice, m_device, m_vulkanWindow, newWidth, newHeight);
// Forward Pass
m_forwardPass.width = newWidth;
m_forwardPass.height = newHeight;
CreateForwardPassResources();
// Deferred Pass - Geometry
m_deferredPass.width = newWidth;
m_deferredPass.height = newHeight;
CreateDeferredPassGeometryResources();
// Post Processing
m_postProcessingPasses.clear();
/*JEPostProcessingPass p;
p.width = newWidth;
p.height = newHeight;
p.shaderIndex = 0;
m_postProcessingPasses.push_back(p);
p.shaderIndex = 1;
m_postProcessingPasses.push_back(p);*/
// Deferred Pass - Lighting
CreateDeferredPassLightingResources();
/*CreateDeferredPassLightingRenderPass();
if (m_postProcessingPasses.size() > 0) {
CreateFramebufferAttachment(m_framebufferAttachment_deferredLighting, { m_width, m_height }, static_cast<VkImageUsageFlagBits>(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT), VK_FORMAT_R8G8B8A8_UNORM);
CreateDeferredPassLightingFramebuffer();
}*/
CreatePostProcessingPassResources();
if (m_enableOIT) {
CreateOITResources();
}
CreateSwapChainFramebuffers();
const PackedArray<MaterialComponent>& materialComponents = m_engineInstance->GetComponentList<MaterialComponent, JEMaterialComponentManager>();
for (const MaterialComponent& matComp : materialComponents) {
if (m_enableDeferred) {
if (matComp.m_renderLayer < TRANSLUCENT) {
// Only recreate opaque descriptors
std::vector<std::vector<VkImageView>> imageViewsList;
for (uint32_t i = 0; i < m_swapChainFramebuffers.size(); ++i) {
if (matComp.m_materialSettings & RECEIVES_SHADOWS) {
imageViewsList.push_back({
m_deferredPass.colors[i].imageView,
m_deferredPass.normals[i].imageView,
m_deferredPass.depths[i].imageView,
m_shadowPass.depths[i].imageView });
} else {
imageViewsList.push_back({
m_deferredPass.colors[i].imageView,
m_deferredPass.normals[i].imageView,
m_deferredPass.depths[i].imageView });
}
}
if (matComp.m_materialSettings & RECEIVES_SHADOWS) {
m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViewsList, { m_deferredPass.sampler, m_deferredPass.sampler, m_deferredPass.sampler, m_shadowPass.depthSampler },
{ sizeof(glm::mat4) * 2, sizeof(glm::mat4) }, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(matComp.m_shaderID))->GetDescriptorSetLayout(0), DEFERRED, true, m_deferredLightingDescriptorID);
} else {
m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain,
imageViewsList, { m_deferredPass.sampler, m_deferredPass.sampler, m_deferredPass.sampler },
{ sizeof(glm::mat4) * 2 }, {},
((JEVulkanShader*)m_shaderManager.GetShaderAt(matComp.m_shaderID))->GetDescriptorSetLayout(0), DEFERRED, true, m_deferredLightingNoShadowsDescriptorID);
}
}
}
if (m_enableOIT && matComp.m_renderLayer >= TRANSLUCENT) {
// TODO: make a no-shadows variant of the OIT translucent shader
if (matComp.m_materialSettings & RECEIVES_SHADOWS) {
m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain, {}, {}, {},
{ JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITLinkedListNode), // Linked list data
JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITNextPointerNode), // Next pointer data
m_width * m_height * (uint32_t)sizeof(OITHeadPointerNode), // Head pointer data
(uint32_t)sizeof(OITAtomicCounterData) }, // Atomic counter data
((JEVulkanShader*)m_shaderManager.GetShaderAt(matComp.m_shaderID))->GetDescriptorSetLayout(2), TRANSLUCENT_OIT, true, m_oitLLDescriptor);
} else {
m_shaderManager.CreateDescriptor(m_device, m_physicalDevice, m_vulkanSwapChain, {}, {}, {},
{ JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITLinkedListNode), // Linked list data
JE_NUM_OIT_FRAGSPP * m_width * m_height * (uint32_t)sizeof(OITNextPointerNode), // Next pointer data
m_width * m_height * (uint32_t)sizeof(OITHeadPointerNode), // Head pointer data
(uint32_t)sizeof(OITAtomicCounterData) }, // Atomic counter data
((JEVulkanShader*)m_shaderManager.GetShaderAt(matComp.m_shaderID))->GetDescriptorSetLayout(2), TRANSLUCENT_OIT, true, m_oitLLDescriptor);
}
}
}
m_sceneManager->RecreateResources({ m_width, m_height });
}
void JEVulkanRenderer::RegisterCallbacks(JEIOHandler* ioHandler) {}
}
|
c767d369c17ff20adc16524db9d11f5421a60f1e
|
f2b3698dee07b64c5625a4c36958ec15f02efbeb
|
/hw/hw9_12019/12019.cpp
|
5cbe658b7054355562212039ec733202cbd9c0f2
|
[] |
no_license
|
sally11131114/1092_AdvancedPrograming
|
c8736457787be03cfb4b02c72b4c6a1bed485150
|
b35c1ec3a6e0404450542440c386b4d9548be752
|
refs/heads/main
| 2023-05-27T22:36:01.820925
| 2021-06-09T13:11:16
| 2021-06-09T13:11:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,657
|
cpp
|
12019.cpp
|
#include<iostream>
using namespace std;
int main(){
int n;
string A[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
cin >> n;
while(n--){
int m, d;
int sum=0;
cin >> m >> d;
switch(m){
case 1:
sum=((d+5)%7);
cout << A[sum] << endl;
break;
case 2:
sum=((d+1)%7);
cout << A[sum] << endl;
break;
case 3:
sum=((d+1)%7);
cout << A[sum] << endl;
break;
case 4:
sum=((d+4)%7);
cout << A[sum] << endl;
break;
case 5:
sum=((d+6)%7);
cout << A[sum] << endl;
break;
case 6:
sum=((d+2)%7);
cout << A[sum] << endl;
break;
case 7:
sum=((d+4)%7);
cout << A[sum] << endl;
break;
case 8:
sum=((d+0)%7);
cout << A[sum] << endl;
break;
case 9:
sum=((d+3)%7);
cout << A[sum] << endl;
break;
case 10:
sum=((d+5)%7);
cout << A[sum] << endl;
break;
case 11:
sum=((d+1)%7);
cout << A[sum] << endl;
break;
case 12:
sum=((d+3)%7);
cout << A[sum] << endl;
break;
}
}
}
|
c0824e4312be94f6431c628de43037f5f779db4b
|
53f9ff59695c108db968c9540646d5093d46bbd2
|
/src/http/api_request_handler.cpp
|
1229ab49b3b4a090f54385d2e97f33253e5c0bbf
|
[
"MIT"
] |
permissive
|
hadouken/hadouken
|
a752fbf7cff875c9b1c959eb7fe4053eb7bf3ed1
|
bb89164f324bb6a2c4a17c0d39a28f7a7f40bea9
|
refs/heads/develop
| 2023-08-22T11:09:48.046030
| 2018-09-24T14:38:11
| 2018-09-24T14:38:11
| 3,600,587
| 345
| 76
|
MIT
| 2022-10-10T15:38:29
| 2012-03-02T08:52:02
|
C++
|
UTF-8
|
C++
| false
| false
| 1,250
|
cpp
|
api_request_handler.cpp
|
#include <hadouken/http/api_request_handler.hpp>
#include <hadouken/http/connection_handler.hpp>
using namespace hadouken::http;
api_request_handler::api_request_handler(boost::function<std::string(std::string)> const& rpc_callback)
: rpc_callback_(rpc_callback)
{
}
void api_request_handler::execute(std::string virtual_path,
http_server_t::request const &request,
http_server_t::connection_ptr connection)
{
boost::shared_ptr<connection_handler> handler(new connection_handler(request));
handler->set_data_callback(boost::bind(&api_request_handler::handle_incoming_data, this, _1, _2));
(*handler)(connection);
}
void api_request_handler::handle_incoming_data(http_server_t::connection_ptr connection, std::string data)
{
std::string response = rpc_callback_(data);
http_server_t::response_header headers[] =
{
{ "Content-Length", std::to_string(response.size()) },
{ "Content-Type", "application/json" }
};
connection->set_status(http_server_t::connection::status_t::ok);
connection->set_headers(boost::make_iterator_range(headers, headers + 2));
connection->write(response);
}
|
46138cbe86ded5304e13abf1ccc2ea08c01e44af
|
3ff1fe3888e34cd3576d91319bf0f08ca955940f
|
/vpc/include/tencentcloud/vpc/v20170312/model/VpcIpv6Address.h
|
dd3afff9e2fdd57c0d6932646b72f169d32a0bc7
|
[
"Apache-2.0"
] |
permissive
|
TencentCloud/tencentcloud-sdk-cpp
|
9f5df8220eaaf72f7eaee07b2ede94f89313651f
|
42a76b812b81d1b52ec6a217fafc8faa135e06ca
|
refs/heads/master
| 2023-08-30T03:22:45.269556
| 2023-08-30T00:45:39
| 2023-08-30T00:45:39
| 188,991,963
| 55
| 37
|
Apache-2.0
| 2023-08-17T03:13:20
| 2019-05-28T08:56:08
|
C++
|
UTF-8
|
C++
| false
| false
| 5,621
|
h
|
VpcIpv6Address.h
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* 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.
*/
#ifndef TENCENTCLOUD_VPC_V20170312_MODEL_VPCIPV6ADDRESS_H_
#define TENCENTCLOUD_VPC_V20170312_MODEL_VPCIPV6ADDRESS_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Vpc
{
namespace V20170312
{
namespace Model
{
/**
* VPC内网IPv6对象。
*/
class VpcIpv6Address : public AbstractModel
{
public:
VpcIpv6Address();
~VpcIpv6Address() = default;
void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const;
CoreInternalOutcome Deserialize(const rapidjson::Value &value);
/**
* 获取`VPC`内`IPv6`地址。
* @return Ipv6Address `VPC`内`IPv6`地址。
*
*/
std::string GetIpv6Address() const;
/**
* 设置`VPC`内`IPv6`地址。
* @param _ipv6Address `VPC`内`IPv6`地址。
*
*/
void SetIpv6Address(const std::string& _ipv6Address);
/**
* 判断参数 Ipv6Address 是否已赋值
* @return Ipv6Address 是否已赋值
*
*/
bool Ipv6AddressHasBeenSet() const;
/**
* 获取所属子网 `IPv6` `CIDR`。
* @return CidrBlock 所属子网 `IPv6` `CIDR`。
*
*/
std::string GetCidrBlock() const;
/**
* 设置所属子网 `IPv6` `CIDR`。
* @param _cidrBlock 所属子网 `IPv6` `CIDR`。
*
*/
void SetCidrBlock(const std::string& _cidrBlock);
/**
* 判断参数 CidrBlock 是否已赋值
* @return CidrBlock 是否已赋值
*
*/
bool CidrBlockHasBeenSet() const;
/**
* 获取`IPv6`类型。
* @return Ipv6AddressType `IPv6`类型。
*
*/
std::string GetIpv6AddressType() const;
/**
* 设置`IPv6`类型。
* @param _ipv6AddressType `IPv6`类型。
*
*/
void SetIpv6AddressType(const std::string& _ipv6AddressType);
/**
* 判断参数 Ipv6AddressType 是否已赋值
* @return Ipv6AddressType 是否已赋值
*
*/
bool Ipv6AddressTypeHasBeenSet() const;
/**
* 获取`IPv6`申请时间。
* @return CreatedTime `IPv6`申请时间。
*
*/
std::string GetCreatedTime() const;
/**
* 设置`IPv6`申请时间。
* @param _createdTime `IPv6`申请时间。
*
*/
void SetCreatedTime(const std::string& _createdTime);
/**
* 判断参数 CreatedTime 是否已赋值
* @return CreatedTime 是否已赋值
*
*/
bool CreatedTimeHasBeenSet() const;
private:
/**
* `VPC`内`IPv6`地址。
*/
std::string m_ipv6Address;
bool m_ipv6AddressHasBeenSet;
/**
* 所属子网 `IPv6` `CIDR`。
*/
std::string m_cidrBlock;
bool m_cidrBlockHasBeenSet;
/**
* `IPv6`类型。
*/
std::string m_ipv6AddressType;
bool m_ipv6AddressTypeHasBeenSet;
/**
* `IPv6`申请时间。
*/
std::string m_createdTime;
bool m_createdTimeHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_VPC_V20170312_MODEL_VPCIPV6ADDRESS_H_
|
40c4d72e7b7bb7b73ed8385f4ac68624fc4dc652
|
a5a128d1e9b8540fcb89c624d67acd78fa7d5566
|
/Client Base/Other/Module.cpp
|
f714cba5b227c2cf7af8ec249390a37d695d2786
|
[] |
no_license
|
xxAROX/Client-Base
|
950b084a3e7c1174488714296e9f365fd2f4f86a
|
e9d0c9d6e44b1e7f6737051389aa8cfd8a6bae1a
|
refs/heads/main
| 2023-02-05T06:11:41.503651
| 2020-12-27T07:06:52
| 2020-12-27T07:06:52
| 333,624,582
| 5
| 0
| null | 2021-01-28T02:38:52
| 2021-01-28T02:38:52
| null |
UTF-8
|
C++
| false
| false
| 414
|
cpp
|
Module.cpp
|
#include "Module.h"
Module::Module(std::string name, std::string category, std::string description, uint64_t key) {
this->name = name;
this->category = category;
this->description = description;
this->key = key;
}
void Module::onBaseTick() {
onLoop();
if (wasEnabled != isEnabled) {
if (isEnabled) {
onEnable();
}
else {
onDisable();
}
wasEnabled = isEnabled;
}
if (isEnabled) onTick();
}
|
af52a07c6a3cbba72ae11847dc14916714c6d5e9
|
2f1c11174a361f444584bd084d9b4631318aa478
|
/Core/FileRelation.h
|
514ab27b1ffd8a38a7138640946103ec3e83e86e
|
[
"MIT"
] |
permissive
|
jjzhang166/CZPlayer4
|
528a40dd3afbf41c04fb40dcc63d1746ce635128
|
4b290c95f718da1622a18b5aa02a3170b2467982
|
refs/heads/master
| 2021-01-22T20:50:21.532065
| 2016-06-14T14:43:02
| 2016-06-14T14:43:02
| 100,691,706
| 1
| 1
| null | null | null | null |
GB18030
|
C++
| false
| false
| 3,176
|
h
|
FileRelation.h
|
/***************************************************************************
* Copyright (C) 2012-2015 Highway-9 Studio. *
* 787280310@qq.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* CUIT Highway-9 Studio, China. *
***************************************************************************/
/*!
* \file FileRelation.h
* \author chengxuan 787280310@qq.com
* \date 2015-05-01
* \brief 开机自启动头文件。
* \version 3.0.0
*
* \verbatim
* 历史
* 3.0.0 创建,
* 2015-05-01 by chengxuan
*
* \endverbatim
*
*/
#ifndef FILERELATION_H
#define FILERELATION_H
/*! \def FILERELATION_VERSION
* 版本控制宏,对应v3.0.0版本.
*/
#define FILERELATION_VERSION 0x030000
#include <Shlobj.h>
#include <Windows.h>
/*! 文件关联类
*/
class FileRelation
{
public:
/*! 构造函数.*/
FileRelation();
/*! 析构函数.*/
~FileRelation();
public:
/*! 注册文件关联
* \param wExt 要检测的扩展名(例如: ".wav")
* \param wAppPath 要关联的应用程序名(例如: "C:/MyApp/MyApp.exe")
* \param wAppKey wExt扩展名在注册表中的键值(例如: "CZPlayer2.WAV")
* \param wDefaultIcon 扩展名为wAppPath的图标文件(例如: "D:/visual studio 2010 Projects/spectrum/debug/spectrum.exe,0")
* \param wDescribe 文件类型描述
*/
static void registerFileRelation(WCHAR *wExt, WCHAR *wAppPath, WCHAR *wAppKey,
WCHAR *wDefaultIcon, WCHAR *wDescribe);
/*! 取消文件关联
* \param wExt 要检测的扩展名(例如: ".wav")
* \param wAppKey ExeName扩展名在注册表中的键值(例如: "CZPlayer2.0.WAV")
*/
static void cancelFileRelation(WCHAR *wExt, WCHAR *wAppKey);
/*! 判断文件关联
* \param wExt 要检测的扩展名(例如: ".wav")
* \param wAppKey ExeName扩展名在注册表中的键值(例如: "CZPlayer2.0.WAV")
* \return 返回true: 表示已关联,false: 表示未关联
*/
static bool checkFileRelation(const WCHAR* wExt, const WCHAR *wAppKey);
};
#endif //FILERELATION_H
|
1dcdf495e32b75263d5f9546cdd3e96e6bdbeaa0
|
da1500e0d3040497614d5327d2461a22e934b4d8
|
/net/base/hex_utils.cc
|
f6efcbefe16b9ac682cbe833ae4da1a8d7319e4e
|
[
"BSD-3-Clause"
] |
permissive
|
youtube/cobalt
|
34085fc93972ebe05b988b15410e99845efd1968
|
acefdaaadd3ef46f10f63d1acae2259e4024d383
|
refs/heads/main
| 2023-09-01T13:09:47.225174
| 2023-09-01T08:54:54
| 2023-09-01T08:54:54
| 50,049,789
| 169
| 80
|
BSD-3-Clause
| 2023-09-14T21:50:50
| 2016-01-20T18:11:34
| null |
UTF-8
|
C++
| false
| false
| 1,616
|
cc
|
hex_utils.cc
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/base/hex_utils.h"
#include <algorithm>
#include <cstdint>
#include <vector>
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
namespace net {
std::string HexDecode(base::StringPiece input) {
std::vector<uint8_t> output;
std::string result;
if (base::HexStringToBytes(input, &output))
result.assign(reinterpret_cast<const char*>(&output[0]), output.size());
return result;
}
std::string HexDump(base::StringPiece input) {
const int kBytesPerLine = 16; // Maximum bytes dumped per line.
int offset = 0;
const char* buf = input.data();
int bytes_remaining = input.size();
std::string output;
const char* p = buf;
while (bytes_remaining > 0) {
const int line_bytes = std::min(bytes_remaining, kBytesPerLine);
base::StringAppendF(&output, "0x%04x: ", offset);
for (int i = 0; i < kBytesPerLine; ++i) {
if (i < line_bytes) {
base::StringAppendF(&output, "%02x", static_cast<unsigned char>(p[i]));
} else {
output += " ";
}
if (i % 2) {
output += ' ';
}
}
output += ' ';
for (int i = 0; i < line_bytes; ++i) {
// Replace non-printable characters and 0x20 (space) with '.'
output += (p[i] > 0x20 && p[i] < 0x7f) ? p[i] : '.';
}
bytes_remaining -= line_bytes;
offset += line_bytes;
p += line_bytes;
output += '\n';
}
return output;
}
} // namespace net
|
f20f29b52aca243cb16790ca30f56a61a93e45dd
|
6dffe04d4e5ef8737b81acee23515dc4a8d0946d
|
/DirectX9_Base/Source/Direct3D/sprite.h
|
2185be16f8e7197789018d90e1e5eb3a023589e6
|
[] |
no_license
|
konkon317/DirectX9_Base
|
7a43121184dd1f1d8fa971c457fddcd7d3a8ab2a
|
45c1a99480e15789173f895117093b4caf590eb5
|
refs/heads/master
| 2021-01-20T02:47:11.710244
| 2018-02-01T17:44:10
| 2018-02-01T17:44:24
| 89,454,198
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,050
|
h
|
sprite.h
|
#pragma once
#include "Direct3D.h"
struct AnimationNum
{
unsigned int numU;
unsigned int numV;
};
//板ポリゴン頂点情報
//MSDN頂点フォーマットを参照 FVFの設定によって型、数、順番が決まる
struct SpriteVertex
{
float x, y, z; //3次元座標
float rhw; //2D変換済みフラグ スクリーン座標
DWORD colorDefuse;
float u, v; //UV座標
};
class Sprite
{
friend class Direct3D;
public:
//FVF(柔軟な頂点構造体宣言)
static const DWORD SPRITE_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
private:
D3DXVECTOR2 pos;
//スプライトサイズ
int width;
int height;
//回転値(ラジアン)
float rotate;
float alpha;
public :
//コンストラクタ
Sprite();
//~デストラクタ
~Sprite();
void SetPos(float x, float y);
void SetSize(int Width, int Height);
void SetRotate(float Rotate);
float GetAlpha(){ return alpha; }
void SetAlpha(float a);
//void Draw(IDirect3DDevice9* pDevice3D, IDirect3DTexture9* pTexture, bool isTurn = false);
};
|
6b3699012e4a4ab9273cff175a8d1f39d53b5834
|
c9b0dcab4bcffe4315be0df4cd9055819dc469a8
|
/document/program/C or C++/base/C++/C++_pro/╣╣╘ь║п╩¤/main.cpp
|
1ab70698d65bf31fb5a7b7d14595c4caef32c4e8
|
[] |
no_license
|
exuuwen/study
|
83250f1cde1afff937963912fdd026df2cf48bd0
|
c92b937351c2084759cf0a11cc535f5fb97488a3
|
refs/heads/master
| 2023-04-09T21:34:31.042551
| 2023-03-27T09:28:00
| 2023-03-27T09:28:00
| 61,179,598
| 6
| 6
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 154
|
cpp
|
main.cpp
|
#include<iostream.h>
#include"Tdate.h"
void main()
{
Tutorpair tutorpair;
Tutorpair newone(12,3.7);
cout<<"back in main"<<endl;
}
|
c07ad1270f1e04e4aeb57b48654ff3b37833dda5
|
7cd1c18ff71e7e2d4f63dd48a543ff9469281cf0
|
/src/timer.cc
|
058b50be474f2e2064e501cd4fe37880bb45f56e
|
[
"MIT"
] |
permissive
|
jl2922/hci
|
84eba44ca1209d3139f26f5ac94001cbb8aeef98
|
2806ad1f2cc0e100632eaaaf491670f928c9feec
|
refs/heads/master
| 2021-01-11T16:10:59.773475
| 2017-12-22T18:26:31
| 2017-12-22T18:26:31
| 105,282,813
| 1
| 0
|
MIT
| 2017-12-22T18:26:33
| 2017-09-29T14:39:36
|
C++
|
UTF-8
|
C++
| false
| false
| 3,366
|
cc
|
timer.cc
|
#include "timer.h"
#include <chrono>
#include <cstdio>
#include <ctime>
#include <thread>
#include "injector.h"
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
class TimerImpl : public Timer {
public:
TimerImpl(Parallel* const parallel) : Timer(parallel) {
verbose = parallel->is_master();
}
void init() override;
void start(const std::string& event) override;
void checkpoint(const std::string& msg) override;
void end() override;
private:
bool verbose = false;
std::chrono::high_resolution_clock::time_point init_time;
std::chrono::high_resolution_clock::time_point prev_time;
std::vector<
std::pair<std::string, std::chrono::high_resolution_clock::time_point>>
start_times;
void barrier() { parallel->barrier(); }
void print_event_path() const;
void print_time() const;
double get_duration(
const std::chrono::high_resolution_clock::time_point start,
const std::chrono::high_resolution_clock::time_point end) const {
return (std::chrono::duration_cast<std::chrono::duration<double>>(
end - start))
.count();
}
};
void TimerImpl::init() {
barrier();
const auto& now = std::chrono::high_resolution_clock::now();
init_time = prev_time = now;
if (verbose) {
const time_t start_time = std::chrono::system_clock::to_time_t(now);
printf("\nStart time: %s", asctime(localtime(&start_time)));
printf("Format: " ANSI_COLOR_YELLOW "[DIFF/SECTION/TOTAL]" ANSI_COLOR_RESET
"\n");
}
barrier();
}
void TimerImpl::start(const std::string& event) {
barrier();
const auto& now = std::chrono::high_resolution_clock::now();
start_times.push_back(std::make_pair(event, now));
if (verbose) {
printf("\n" ANSI_COLOR_GREEN "[START] " ANSI_COLOR_RESET);
print_event_path();
printf(" ");
print_time();
printf("\n");
}
prev_time = now;
barrier();
}
void TimerImpl::checkpoint(const std::string& msg) {
barrier();
const auto& now = std::chrono::high_resolution_clock::now();
if (verbose) {
printf(ANSI_COLOR_GREEN "[-CHK-] " ANSI_COLOR_RESET "%s ", msg.c_str());
print_time();
printf("\n");
}
prev_time = now;
barrier();
}
void TimerImpl::end() {
barrier();
const auto& now = std::chrono::high_resolution_clock::now();
if (verbose) {
printf(ANSI_COLOR_GREEN "[=END=] " ANSI_COLOR_RESET);
print_event_path();
printf(" ");
print_time();
printf("\n");
}
start_times.pop_back();
prev_time = now;
barrier();
}
void TimerImpl::print_event_path() const {
for (size_t i = 0; i < start_times.size() - 1; i++) {
printf("%s >> ", start_times[i].first.c_str());
}
printf("%s", start_times.back().first.c_str());
}
void TimerImpl::print_time() const {
const auto& now = std::chrono::high_resolution_clock::now();
const auto& event_start_time = start_times.back().second;
printf(
ANSI_COLOR_YELLOW "[%.3f/%.3f/%.3f]" ANSI_COLOR_RESET,
get_duration(prev_time, now),
get_duration(event_start_time, now),
get_duration(init_time, now));
}
Timer* Injector::new_timer(Parallel* const parallel) {
return new TimerImpl(parallel);
}
|
387f1d8d9ec9273b3f4bf7009fc7d4ff36460383
|
b77217e0eee439f4d29d3937055853d6256b48e1
|
/Source/SamsAdventure/TotemTrap.cpp
|
ee6a1f7cf7cf812ce5559ba3e8941ef1f941b3e0
|
[] |
no_license
|
AppliedOnce/SamsAdventure
|
af92428bb177beb2f3e5ed9e52c840c6ecfd3ebb
|
969355b19d4ca0f1722f73947cd04f0895f3c288
|
refs/heads/main
| 2023-05-04T17:07:28.924701
| 2021-05-21T07:11:22
| 2021-05-21T07:11:22
| 347,060,113
| 1
| 0
| null | 2021-05-21T07:11:23
| 2021-03-12T12:33:51
|
C++
|
UTF-8
|
C++
| false
| false
| 2,383
|
cpp
|
TotemTrap.cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "TotemTrap.h"
#include "AIController.h"
#include "MainCharacter.h"
#include "Components/SphereComponent.h"
#include "EnemyBullet.h"
ATotemTrap::ATotemTrap()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
OurCollider = CreateDefaultSubobject<USphereComponent>(TEXT("MyCollider"));
RootComponent = OurCollider;
OurVisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
OurVisibleComponent->SetupAttachment(RootComponent);
}
// Called when the game starts or when spawned
void ATotemTrap::BeginPlay()
{
Super::BeginPlay();
AIController = Cast<AAIController>(GetController());
Cast<USphereComponent>(RootComponent)->OnComponentBeginOverlap.AddDynamic(this, &ATotemTrap::OnOverlap);
Cast<USphereComponent>(RootComponent)->OnComponentEndOverlap.AddDynamic(this, &ATotemTrap::OnOverlapEnd);
}
// Called every frame
void ATotemTrap::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ShootingRythm += DeltaTime;
Shooting();
}
// Called to bind functionality to input
void ATotemTrap::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void ATotemTrap::OnOverlap(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor, UPrimitiveComponent* OtherComponent,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
AMainCharacter* Player = Cast<AMainCharacter>(OtherActor);
if (Player)
{
UE_LOG(LogTemp, Warning, TEXT("I see you"))
AIController->SetFocus(Player);
}
if (OtherActor->IsA(AMainCharacter::StaticClass()))
{
InRange = true;
}
}
void ATotemTrap::OnOverlapEnd(UPrimitiveComponent* OverlappedComponent,
AActor* OtherActor, UPrimitiveComponent* OtherComponent,
int32 OtherBodyIndex)
{
if (OtherActor->IsA(AMainCharacter::StaticClass()))
{
InRange = false;
}
}
void ATotemTrap::Shooting() {
UWorld* SamsWorld = GetWorld();
if (InRange != false) {
if (ShootingRythm >= 1) {
UE_LOG(LogTemp, Warning, TEXT("Attack"));
if (SamsWorld)
{
SamsWorld->SpawnActor<AEnemyBullet>(AttackBlueprint, GetActorLocation() + AttackSpawnPoint, GetActorRotation());
}
ShootingRythm = 0;
}
}
}
|
1fcefb5e0d326480987e220d21d41265c8a3fc42
|
10ccd1db2028f183aa8faff25058405731cdfd47
|
/src/programs/SingleColorSweepEndToStart.h
|
6c2b86af386d3de76c68ee0538ffbbf3f6dbcce7
|
[] |
no_license
|
KevinVanthuyne/arduino-rgb-led-tubes-controller
|
41b945df4efd196d59ea455ec08fabfd2c3cc8af
|
bf0e83bfd8a89a8aa2bb6adb1e71a75f62854771
|
refs/heads/master
| 2020-09-21T02:09:05.464369
| 2019-12-06T21:25:38
| 2019-12-06T21:25:38
| 224,649,353
| 1
| 0
| null | 2019-12-06T21:25:40
| 2019-11-28T12:32:27
|
C++
|
UTF-8
|
C++
| false
| false
| 2,088
|
h
|
SingleColorSweepEndToStart.h
|
#pragma once
#include "Globals.h"
#include "Program.h"
#include "../Utils.h"
class SingleColorSweepEndToStart : public Program
{
public:
SingleColorSweepEndToStart() : Program(),
currentCycle(0),
currentColor(getRandomNumber(0, amountOfColors())),
previousColor(0),
currentPos(pixelsPerTube - 1),
isFadingOut(true) {}
int runIteration(uint8_t speed)
{
fadeSteps = map(speed, 0, 255, 8, 0);
cyclesToChangeColor = map(speed, 0, 255, 4, 20);
// reset everything after a full sweep
if (currentPos == 0)
{
currentIteration = 0;
currentPos = pixelsPerTube - 1;
if (isFadingOut && currentCycle % cyclesToChangeColor == 0)
{
previousColor = currentColor;
currentColor = getRandomNumber(0, 8, previousColor);
currentCycle = 0;
}
currentCycle++;
if (isFadingOut)
FastLED.clear(); // to get rid of the last few pixels if any remain
isFadingOut = !isFadingOut;
}
if (!isFadingOut)
{
for (CRGB *ledStrip : ledStrips)
{
if (fadeSteps > 0)
{
CRGB fadedColor = colors[currentColor];
fadedColor /= fadeSteps;
ledStrip[currentPos] += fadedColor;
}
else
ledStrip[currentPos] = colors[currentColor];
}
}
else
{
for (CRGB *ledStrip : ledStrips)
{
if (fadeSteps > 1)
{
CRGB fadedColor = colors[currentColor];
fadedColor /= fadeSteps;
ledStrip[currentPos] -= fadedColor;
}
else
ledStrip[currentPos] = CRGB::Black;
}
}
currentIteration++;
if (fadeSteps == 0 || currentIteration % fadeSteps == 0)
currentPos--;
FastLED.show();
return 0;
}
private:
uint8_t currentCycle;
uint8_t cyclesToChangeColor;
int fadeSteps;
int currentColor;
int previousColor;
int currentPos;
bool isFadingOut;
};
|
b305fbfb46ad93b199f0dd7034bbf9aca693845a
|
04721d03a4bf0bdefcdd527d2d1c845af7850a14
|
/Codeforces/514/C.cpp
|
173f33e019198ce5dcdbe3e3d38d0c3ef3c0c4fd
|
[] |
no_license
|
ArielGarciaM/CompetitiveProgramming
|
81e3808fdb14372f14e54d1e69c582be9ba44893
|
c7115c38b988b6bc053850f1024a8005eb24fcee
|
refs/heads/master
| 2020-03-28T15:19:55.788844
| 2019-08-09T20:54:25
| 2019-08-09T20:54:25
| 148,581,397
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 551
|
cpp
|
C.cpp
|
#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int n, int f = 1)
{
if(n == 1)
{
vector<int> v = {f};
return v;
}
if(n == 3)
{
vector<int> v = {f, f, 3*f};
return v;
}
vector<int> res;
for(int i = 1; i <= (n + 1)/2; i++)
res.push_back(f);
vector<int> ppend = solve(n/2, 2*f);
for(int x : ppend)
res.push_back(x);
return res;
}
int main()
{
int n;
cin >> n;
vector<int> v = solve(n);
for(int x : v)
cout << x << " ";
}
|
3118f1a1a6361af648edf9d88eec8c35a47aae62
|
cd7ac6bed7dd48522bbea7e9b2fd54b11f930bc7
|
/treap.h
|
7f79194a76867b38373b74c91b787a9f18042053
|
[
"Unlicense"
] |
permissive
|
elsantodel90/treap
|
0397c3d48cfd4d071722829317c759a3160e1378
|
20503c0575dc8914e25d7c836442d3b63f6ebe48
|
refs/heads/master
| 2021-01-10T12:35:40.138209
| 2015-10-26T02:52:14
| 2015-10-26T02:52:14
| 43,730,503
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,182
|
h
|
treap.h
|
#include <iostream>
#include <cassert>
#include <cstdlib>
using namespace std;
// Convencion: esta la funcion foo(const T&), y su amiguita fooPointer(Nodo<T>*), que en general es llamada por la otra (y se puede usar de una perfectamente)
// Antes las sobrecargaba ambas como foo, pero en c++ un literal int=0 se convierte a puntero null sin aviso ni warning ni nada,
// y esa posibilidad oculta me parece demasiado peligrosa (ocurrio sutilmente mientras escribia los tests).
template <typename T>
struct Nodo
{
T dat;
Nodo *padre;
Nodo *_h[2]; // 0: hijo izquierdo (los menores). 1: hijo derecho (los mayores)
int p;
// Al insertar aqui la propagacion lazy, se hace automaticamente en cualquier recorrida del arbol
// (si se miran los hijos con h en lugar de _h). Es lindo pero duele en la constante abusar del h() vs _h[i].
// Como "regla de eficiencia", cuando uno habla varias veces seguidas de los hijos de un nodo sin hacer ningun cambio
// en el medio, puede usar h() la primera vez, y luego usar _h directamente porque ya fue propagado.
Nodo * & h(int i)
{
dat.lazyPropagation(this);
return _h[i];
}
// Va desde nodo hasta la raiz updateando
void fullUpdate()
{
Nodo<T> *nodo = this;
while (nodo)
{
nodo->dat.update(nodo);
nodo = nodo->padre;
}
}
// *****************************************************************************
// Estas que vienen aca son (deberian ser) las unicas funciones donde se hacen cambios estructurales al arbol
// Se crea un nuevo nodo sueltito, aislado, raiz de su propio arbol.
Nodo () { padre = _h[0] = _h[1] = NULL; p = rand(); }
Nodo (const T &d) : dat(d) { padre = _h[0] = _h[1] = NULL; p = rand(); }
// Rota un nodo X (this) con su padre Z (this->padre)
// En los Treap, es la *unica* rotacion :D
// Todos los nodos en el dibujo pueden ser NULL salvo X y Z.
/*
Si childIndex == 0:
P P
| |
Z X
/ \ ---> / \
X Q Y Z
/ \ / \
Y W W Q
Si childIndex == 1:
P P
| |
Z X
/ \ ---> / \
Q X Z W
/ \ / \
Y W Q Y
*/
void rotar()
{
assert(padre);
int childIndex = padre->_h[1] == this;
Nodo *oldDad = padre;
padre = oldDad->padre;
if (padre) padre->_h[padre->_h[1] == oldDad] = this;
oldDad->_h[childIndex] = _h[childIndex ^ 1];
if (oldDad->_h[childIndex]) oldDad->_h[childIndex]->padre = oldDad;
_h[childIndex ^ 1] = oldDad;
oldDad->padre = this;
}
// Cuelga un hijo de este padre.
void hang(int pos, Nodo *child)
{
_h[pos] = child;
child->padre = this;
}
// Descuelga este hijo de su padre.
void chop()
{
padre->_h[padre->_h[1] == this] = NULL;
padre = NULL;
}
// Fin de funciones que hacen cambios estructurales
// ************************************************************************
// Flota y actualiza
void flotar()
{
h(0);
while (padre && p >= padre->p)
{
Nodo<T> *aux = padre;
rotar();
aux->dat.update(aux);
}
fullUpdate();
}
void hundir()
{
h(0);
while ((_h[0] && _h[0]->p > p) || (_h[1] && _h[1]->p > p))
{
int childToRotate = _h[0] == NULL || (_h[1] && _h[1]->p > _h[0]->p);
_h[childToRotate]->h(0);
_h[childToRotate]->rotar();
}
}
};
template <typename T>
struct Treap
{
Nodo<T> *root;
Treap() : root(NULL) {}
Nodo<T>* treapify(T v[], int N, int levelP, int STEP)
{
if (N)
{
int rootIndex = N/2;
Nodo<T>*node = new Nodo<T>(v[rootIndex]);
node->p = levelP;
node->_h[0] = treapify(v,rootIndex, levelP - STEP, STEP);
if (node->_h[0]) node->_h[0]->padre = node;
node->_h[1] = treapify(v+rootIndex+1,N-rootIndex-1, levelP - STEP, STEP);
if (node->_h[1]) node->_h[1]->padre = node;
node->dat.update(node);
return node;
}
else
return NULL;
}
// Arma un treap con los N elementos en el orden dado en O(N), vs N lg N que tomaria irlos insertando.
Treap(T v[], int N)
{
int niveles = 0;
int k=1; while(k <= N) k *= 2, niveles++;
root = treapify(v, N, RAND_MAX, max(1, RAND_MAX / max(1, niveles-1)));
}
void reroot() { while (root->padre) root = root->padre; }
// Estas 7 funciones que vienen a continuacion muchas veces no se usan.
// Asumen que los elementos de T tienen comparadores (usa ==, <, >=. etc)
// Las funciones posteriores no asumen tal cosa (preservan el ordenamiento que los elementos ya tienen en el arbol, asi que no necesitan comparar).
// Trabajan el Treap como si fuera un set (sin repetidos).
Nodo<T>* lowerBound(const T&x)
{
Nodo<T> *res = NULL, *p = root;
while (p)
{
if (p->dat >= x) res = p;
p = p->h(x > p->dat);
}
return res;
}
Nodo<T>* upperBound(const T&x)
{
Nodo<T> *res = NULL, *p = root;
while (p)
{
if (p->dat > x) res = p;
p = p->h(x >= p->dat);
}
return res;
}
Nodo<T>* insertionPoint(const T&x)
{
Nodo<T>* res = root, *prev = NULL;
while (res)
{
prev = res;
if (res->dat == x) return res;
res = res->h(x > res->dat);
}
return prev;
}
bool esta(const T&x)
{
Nodo<T>* p = insertionPoint(x);
return p && p->dat == x;
}
// True si se inserto el nodo. Si ya estaba, el puntero es al nodo que ya estaba (sino, es al nodo nuevo que se acaba de meter).
pair<Nodo<T>*, bool> insertarPointer(Nodo<T> *nodo)
{
if (!root) return make_pair(root = nodo, true);
Nodo<T> *p = insertionPoint(nodo->dat);
if (p->dat == nodo->dat) return make_pair(p, false);
p->hang(nodo->dat > p->dat, nodo);
nodo->flotar();
reroot();
return make_pair(nodo, true);
}
pair<Nodo<T>*, bool> insertar(const T&x)
{
Nodo<T> *nuevo = new Nodo<T>(x);
pair<Nodo<T>*, bool> par = insertarPointer(nuevo);
if (!par.second) delete nuevo;
return par;
}
bool erase(const T&x)
{
Nodo<T> *nodo = insertionPoint(x);
if (nodo && nodo->dat == x)
{
erasePointer(nodo);
return true;
}
else
return false;
}
// Siempre inserta el nodo, como si fuera el menor / mayor (segun indique lado). No mira los valores.
void insertarAUnLadoPointer(int lado, Nodo<T> *nodo)
{
if (!root) root = nodo;
else
{
Nodo<T> *p = root;
while (p->h(lado)) p = p->_h[lado];
p->hang(lado, nodo);
nodo->flotar();
reroot();
}
}
Nodo<T>* insertarAUnLado(int lado, const T&x)
{
Nodo<T>* nuevo = new Nodo<T>(x);
insertarAUnLadoPointer(lado, nuevo);
return nuevo;
}
void erasePointer(Nodo<T> *p)
{
p->p = -1;
p->hundir();
Nodo<T> *parent = p->padre;
if (parent)
{
reroot();
p->chop();
parent->fullUpdate();
}
else
root = NULL;
delete p;
}
void internalSplit(pair<Nodo<T> *, bool> par, Treap &larger)
{
Nodo<T>* p = par.first;
p->p = RAND_MAX;
p->flotar();
assert(p->padre == NULL);
liberar(larger.root);
root = p->h(0);
if (root) root->chop();
larger.root = p->_h[1]; // Ya propagamos arriba
if (par.second)
{
if (larger.root) larger.root->chop();
delete p;
}
else
{
p->p = rand();
p->hundir();
if (!p->padre) larger.root = p;
p->fullUpdate();
}
}
// Toma los datos de this, destruye lo que hubiera en larger
// Deja los (-inf, x) en this
// Deja los [x, +inf) en larger
void splitPointer(Nodo<T> *p, Treap &larger) { internalSplit(make_pair(p, false), larger); }
void split(const T&x , Treap &larger) { internalSplit(insertar(x), larger); }
// Mergea this con larger (Debe ser *this < larger en todos sus elementos)
// Vacia larger y deja el resultado en this
void merge(Treap &larger)
{
Nodo<T>*p1 = root, *p2 = larger.root;
larger.root = NULL;
root = new Nodo<T>;
if (p1) root->hang(0, p1);
if (p2) root->hang(1, p2);
erasePointer(root);
}
// Generalmente esto no lo vamos a usar, porque no copiamos Treaps...
// Pero tener en cuenta que los "default" definitivamente no andan si los usamos.
// (Generan aliasing, y si tenemos el destructor puede ser particularmente desastroso).
static void copiar(Nodo<T>* parent, Nodo<T>* &destino, Nodo<T>*origen)
{
if (origen)
{
destino = new Nodo<T>(origen->dat);
destino->padre = parent;
destino->p = origen->p;
copiar(destino, destino->_h[0], origen->_h[0]);
copiar(destino, destino->_h[1], origen->_h[1]);
}
else
destino = NULL;
}
Treap(const Treap &o) {
copiar(NULL, root, o.root);
}
Treap &operator =(const Treap &o) {
liberar(root);
copiar(NULL, root, o.root);
return *this;
}
// Si liberar la memoria nos importa tres carajos
// (por ejemplo, si usamos un solo Treap grande, y hay un solo caso de prueba en la corrida)
// esto se puede obviar.
static void liberar(Nodo<T> *p)
{
if (p)
{
liberar(p->_h[0]);
liberar(p->_h[1]);
delete p;
}
}
~Treap() { liberar(root); }
// Unicamente para debugging
void printNode(Nodo<T> *p)
{
cerr << p << "(padre: " << p->padre << " )" << endl;
cerr << "Datos:" << endl;
cerr << p->dat << endl;
cerr << "Hijos:" << p->_h[0] << " " << p->_h[1] << endl;
if (p->_h[0]) printNode(p->_h[0]);
if (p->_h[1]) printNode(p->_h[1]);
}
void printTreap()
{
if (root)
printNode(root);
else
cerr << "<EMPTY TREAP>" << endl;
}
};
|
061f01f36f18e1c05c1f55e630d31ace0360a361
|
f5ca6974e6686b20518073befdb3234ed062e82c
|
/plugins/zling/squash-zling.cpp
|
23194cd3c57dd8f84451124c49e2d97948b753f5
|
[
"MIT"
] |
permissive
|
Dead2/squash
|
dff96c557cd6121e29ae723842a600a6d716d0db
|
249c109b2afe39f7d529179b6a057821a3823447
|
refs/heads/master
| 2020-04-16T23:56:37.552138
| 2019-01-16T14:03:59
| 2019-01-16T14:03:59
| 166,031,371
| 0
| 1
| null | 2019-01-16T11:47:55
| 2019-01-16T11:47:54
| null |
UTF-8
|
C++
| false
| false
| 6,132
|
cpp
|
squash-zling.cpp
|
/* Copyright (c) 2013-2016 The Squash Authors
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Evan Nemerson <evan@nemerson.com>
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <squash/squash.h>
#include "libzling.h"
#define SQUASH_ZLING_DEFAULT_LEVEL 0
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
enum SquashZlingOptIndex {
SQUASH_ZLING_OPT_LEVEL = 0
};
static SquashOptionInfo squash_zling_options[] = {
{ (char*) "level",
SQUASH_OPTION_TYPE_RANGE_INT, },
{ NULL, SQUASH_OPTION_TYPE_NONE, }
};
typedef struct _SquashZlingStream SquashZlingStream;
#define SQUASH_ZLING_BUFFER_UNUSED INT_MAX
struct SquashZlingIO: public baidu::zling::Inputter, public baidu::zling::Outputter {
public:
void* user_data_;
SquashReadFunc reader_;
SquashWriteFunc writer_;
SquashZlingIO(void* user_data, SquashReadFunc reader, SquashWriteFunc writer) :
user_data_ (user_data),
reader_ (reader),
writer_ (writer),
eof (false),
last_res (SQUASH_OK),
buffer (SQUASH_ZLING_BUFFER_UNUSED) { }
bool eof;
SquashStatus last_res;
int buffer;
size_t GetData(unsigned char* buf, size_t len);
size_t PutData(unsigned char* buf, size_t len);
bool IsEnd();
bool IsErr();
};
extern "C" SQUASH_PLUGIN_EXPORT
SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl);
extern "C" SQUASH_PLUGIN_EXPORT
SquashStatus squash_plugin_init_plugin (SquashPlugin* plugin);
size_t
SquashZlingIO::GetData (unsigned char* buf, size_t len) {
size_t bytes_read = 0;
if (this->IsErr ())
return 0;
if (this->buffer != SQUASH_ZLING_BUFFER_UNUSED) {
assert (this->buffer >= 0x00 && this->buffer <= 0xff);
buf[0] = (char) this->buffer;
bytes_read = 1;
this->buffer = SQUASH_ZLING_BUFFER_UNUSED;
len--;
if (len == 0)
return 1;
}
this->last_res = this->reader_ (&len, (uint8_t*) buf + bytes_read, this->user_data_);
if (this->last_res == SQUASH_END_OF_STREAM)
this->eof = true;
bytes_read += len;
return bytes_read;
}
size_t
SquashZlingIO::PutData(unsigned char* buf, size_t len) {
const size_t requested = len;
if (this->IsErr())
return 0;
this->last_res = this->writer_ (&len, (const uint8_t*) buf, this->user_data_);
/* zling will just keep trying to write if we return 0, so pretend
we wrote what it asked. Set EOF so at least we don't read any
more. */
if (len == 0 && this->last_res == SQUASH_END_OF_STREAM) {
this->eof = true;
return requested;
}
if (this->last_res != SQUASH_OK)
return 0;
return len;
}
bool
SquashZlingIO::IsEnd() {
if (this->eof)
return true;
if (this->buffer != SQUASH_ZLING_BUFFER_UNUSED)
return false;
size_t l = 1;
uint8_t buf;
this->last_res = this->reader_ (&l, &buf, this->user_data_);
if (this->last_res == SQUASH_END_OF_STREAM) {
this->eof = true;
} else if (this->last_res > 0) {
assert (!this->eof);
this->buffer = buf;
}
return this->eof;
}
bool
SquashZlingIO::IsErr() {
return this->last_res < 0;
}
static SquashStatus
squash_zling_splice (SquashCodec* codec,
SquashOptions* options,
SquashStreamType stream_type,
SquashReadFunc read_cb,
SquashWriteFunc write_cb,
void* user_data) {
try {
SquashZlingIO stream(user_data, read_cb, write_cb);
int zres = 0;
if (stream_type == SQUASH_STREAM_COMPRESS) {
zres = baidu::zling::Encode(&stream, &stream, NULL, squash_options_get_int_at (options, codec, SQUASH_ZLING_OPT_LEVEL));
} else {
zres = baidu::zling::Decode(&stream, &stream, NULL);
}
if (zres == 0)
return SQUASH_OK;
else if (HEDLEY_LIKELY(stream.last_res < 0))
return stream.last_res;
else
return squash_error (SQUASH_FAILED);
} catch (const std::bad_alloc& e) {
return squash_error (SQUASH_MEMORY);
} catch (const SquashStatus e) {
return e;
} catch (...) {
return squash_error (SQUASH_FAILED);
}
HEDLEY_UNREACHABLE ();
}
static size_t
squash_zling_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size) {
return
uncompressed_size + 288 + (uncompressed_size / 8);
}
extern "C" SquashStatus
squash_plugin_init_plugin (SquashPlugin* plugin) {
const SquashOptionInfoRangeInt level_range = { 0, 4, 0, false };
squash_zling_options[SQUASH_ZLING_OPT_LEVEL].default_value.int_value = 0;
squash_zling_options[SQUASH_ZLING_OPT_LEVEL].info.range_int = level_range;
return SQUASH_OK;
}
extern "C" SquashStatus
squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) {
const char* name = squash_codec_get_name (codec);
if (HEDLEY_LIKELY(strcmp ("zling", name) == 0)) {
impl->options = squash_zling_options;
impl->splice = squash_zling_splice;
impl->get_max_compressed_size = squash_zling_get_max_compressed_size;
} else {
return squash_error (SQUASH_UNABLE_TO_LOAD);
}
return SQUASH_OK;
}
|
8568dd567cf0246569a87288c4dbad70ce375906
|
f082493a8cbf47dc9f44b390f3a96df850123e25
|
/maxQOriginalCode/release/lib/table.h
|
e462fa7032fa5f28352b8df6ad10190055d58bbe
|
[] |
no_license
|
nakulgopalan/amdpTestRepo
|
37d18372112378d85387537228137020e0518a3c
|
a4cc0d93943c8979b59439ef18027d5906dc7ba0
|
refs/heads/master
| 2020-02-26T15:27:36.730210
| 2016-07-21T16:18:58
| 2016-07-21T16:18:58
| 63,868,710
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 20,904
|
h
|
table.h
|
//======================================================================
// File: table.h
// Author: Timothy A. Budd
// Description: This file contains the interface and implementation
// of the dictionary and table template classes.
//
// Copyright (c) 1992 by Timothy A. Budd. All Rights Reserved.
// may be reproduced for any non-commercial purpose
//======================================================================
#ifndef TABLE_H
#define TABLE_H
#include <iterator.h>
#include <vector.h>
#include <list.h>
#include <hash.h>
//
// in trying to get this to work with g++ it appears some
// template functions must be given in the class description
// I don't understand why.
//----------------------------------------------------------------------
// class association
// A single key/value pair,
// usually maintained in a dictionary
//----------------------------------------------------------------------
template <class K, class V> class association
{
public:
// value field is publically accessible
V valueField;
// constructor
association(K initialKey, V initialValue);
association(const association & x);
// assignment can be either to association or value
V operator =(association & anAssociation);
V operator =(V val);
// accessor methods for key and value
K key() const;
V value() const;
protected:
friend int operator == <> (association<K, V> & l, association<K, V> & r);
friend int operator == <> (association<K, V> & l, K r);
// key field cannot be altered
const K keyField;
};
//----------------------------------------------------------------------
// class cAssociation
// a form of association that allows elements to be compared
//----------------------------------------------------------------------
template <class K, class V> class cAssociation
: public association<K, V>
{
public:
// constructor
cAssociation(K initialKey, V initialValue);
friend int operator == <> (cAssociation<K, V> & l, cAssociation<K, V> & r);
friend int operator == <> (cAssociation<K, V> & l, K & r);
friend int operator < <> (cAssociation<K, V> & l, cAssociation<K, V> & r);
friend int operator < <> (cAssociation<K, V> & l, K & r);
};
//----------------------------------------------------------------------
// class dictionary
// A collection of key/value pairs
// implemented as a list of associations
//----------------------------------------------------------------------
template <class K, class V> class dictionaryIterator;
template <class K, class V> class table;
template <class K, class V> class dictionary
{
public:
// constructors
dictionary();
dictionary(V initialValue);
dictionary(const dictionary & v);
// destructor
virtual ~dictionary();
// find association with given key
association<K, V> * associatedWith(K);
// dictionary protocol
V & operator [](K key);
void deleteAllValues();
int includesKey(K key);
int isEmpty() const;
void removeKey(K key);
void setInitial(V initialValue);
dictionary<K, V> * Duplicate();
public:
// data is maintained in a list of associations
list<association<K, V> *> * data;
V initialValue;
// friends
friend class dictionaryIterator<K, V>;
friend class table<K, V>;
};
//----------------------------------------------------------------------
// class table
// dictionary collection of key/value pairs
// implemented using hash tables
//----------------------------------------------------------------------
template <class K, class V> class table
: public hashTable<dictionary<K, V>, K, association<K, V> *>
{
public:
// constructors
table(unsigned int max, unsigned int (*f)(const K &));
table(unsigned int max, unsigned int (*f)(const K &), V &);
// new table operators
V & operator [](K key);
void removeKey(K key);
void setInitial(V initialValue);
int includesKey(K key); // tgd added
protected:
iterator<association<K, V> *> * makeIterator(unsigned int i);
};
//----------------------------------------------------------------------
// class tableIterator
// iterator protocol for tables
//----------------------------------------------------------------------
template <class K, class V> class tableIterator
: public hashTableIterator<dictionary<K, V>, K, association<K, V> *>
{
public:
// constructor
tableIterator(table<K, V> & v);
};
//----------------------------------------------------------------------
// class orderedDictionary
// A ordered collection of key/value pairs
// implemented as a list of associations
//----------------------------------------------------------------------
template <class K, class V> class orderedDictionaryIterator;
template <class K, class V> class orderedDictionary
{
public:
// constructors
orderedDictionary();
orderedDictionary(V initialValue);
orderedDictionary(orderedDictionary<K, V> & v);
// dictionary protocol
V & operator [](K key);
void deleteAllValues();
int includesKey(K key);
int isEmpty() const;
void removeKey(K key);
void setInitial(V initialValue);
private:
// data is maintained in a list of associations
orderedList<cAssociation<K, V> &> data;
V initialValue;
// friends
friend class orderedDictionaryIterator<K, V>;
friend class table<K, V>;
// find association with given key
cAssociation<K, V> * associatedWith (K key);
};
//----------------------------------------------------------------------
// class dictionaryIterator
// implementation of iterator protocol for dictionaries
//
//----------------------------------------------------------------------
template <class K, class V> class dictionaryIterator
: public listIterator<association<K, V> *>
{
public:
// constructor
dictionaryIterator(dictionary<K, V> & dict);
};
//----------------------------------------------------------------------
// class orderedDictionaryIterator
// implementation of iterator protocol for
// ordered dictionaries
//----------------------------------------------------------------------
template <class K, class V> class orderedDictionaryIterator
: public listIterator<cAssociation<K, V> &>
{
public:
// constructor
orderedDictionaryIterator(orderedDictionary<K, V> & dict);
};
//----------------------------------------------------------------------
// class sparseMatrix
// two dimensional matrix using dictionaries to store rows
//----------------------------------------------------------------------
template <class T> class sparseMatrix
{
public:
// constructors
sparseMatrix(unsigned int n, unsigned int m);
sparseMatrix(unsigned int n, unsigned int m, T initial);
// only operation is subscript
dictionary<int, T> & operator [](unsigned int n);
private:
vector< dictionary<int,T> > data;
};
//----------------------------------------------------------------------
// class sparseMatrix2
// second form of sparse matrix,
// uses dictionaries for both rows and columns
//----------------------------------------------------------------------
template <class T> class sparseMatrix2
{
public:
// constructors
sparseMatrix2(unsigned int n, unsigned int m);
sparseMatrix2(unsigned int n, unsigned int m, T init);
dictionary<int,T> & operator [] (unsigned int n);
private:
// data areas
T initialValue;
dictionary< int, dictionary<int, T> > data;
};
//----------------------------------------------------------------------
// class association implementation
//----------------------------------------------------------------------
template <class K, class V> association<K, V>::
association(K initialKey, V initialValue)
: keyField(initialKey), valueField(initialValue)
{
// no further initialization
}
template <class K, class V> association<K, V>::
association(const association<K, V> & x)
: keyField(x.keyField), valueField(x.valueField)
{
// no further initialization
}
template <class K, class V> V association<K, V>::
operator = (association<K, V> & anAssociation)
{
// assignment from an association
valueField = anAssociation.valueField;
return valueField;
}
template <class K, class V> V association<K, V>::
operator = (V val)
{
// assignment from a value
valueField = val;
return valueField;
}
template <class K, class V> K association<K, V>::key() const
{
// return key
return keyField;
}
template <class K, class V> V association<K, V>::value() const
{
// return value
return valueField;
}
template <class K, class V> int operator ==
(association<K, V> & left, association<K, V> & right)
{
// compare the key values for two associations
return left.key() == right.key();
}
template <class K, class V> int operator ==
(association<K, V> & left, K rightKey)
{
// compare the key values for two associations
return left.key() == rightKey;
}
//----------------------------------------------------------------------
// class dictionary implementation
//----------------------------------------------------------------------
template <class K, class V> dictionary<K, V>::dictionary():
initialValue((V) 0)
{
data = new list<association<K, V> *>;
}
template <class K, class V> dictionary<K, V>::dictionary(V val)
{
data = new list<association<K, V> *>;
// set initial value
initialValue = val;
}
template <class K, class V> dictionary<K, V>::
dictionary(const dictionary<K, V> & v)
: data(v.data->duplicate()), initialValue (v.initialValue)
{
// the above duplicate() of data causes a copy of the BuddLink's in
// the list. Now we need to copy the association records too.
listIterator<association<K, V> *> itr(*data);
for(itr.init(); !itr; ++itr) {
// copy each association too
itr() = new association<K,V>(*itr());
}
}
// Tue Dec 21 22:20:02 1999 tgd: Why did this have an argument? (V val)
// Perhaps to get the template to instantiate properly?
// egcs objects to this. The arg was not used, so I have deleted it.
template <class K, class V> dictionary<K, V>::~dictionary()
{
// we do deep deletion of the assocations, because list delete just
// deletes the buddlink's but not their contents.
listIterator<association<K, V> *> itr(*data);
for (itr.init(); !itr; ++itr) {
delete itr();
}
// now delete the list itself and its buddlinks.
delete data;
}
template <class K, class V> association<K, V> * dictionary<K, V>::
associatedWith(K key)
{
// return the association with the given key
// or the null pointer if no association yet exists
listIterator<association<K, V> *> itr(*data);
// loop over the elements, looking for a match
for (itr.init(); ! itr; ++itr)
if (itr()->key() == key)
{
// address of a reference is a pointer
return itr();
}
// not found, return null pointer
return 0;
}
template <class K, class V> V & dictionary<K, V>::operator [] (K key)
{
// return value of association specified by key
// first look to see if association is there already
association<K, V> * newassoc = associatedWith(key);
// if not there, make a new one
if (!newassoc)
{
newassoc = new association<K, V>(key, initialValue);
assert(newassoc != 0);
data->add(newassoc);
}
// return reference to value field
return newassoc->valueField;
}
template <class K, class V> void dictionary<K, V>::deleteAllValues()
{
data->deleteAllValues();
}
template <class K, class V> int dictionary<K, V>::includesKey(K key)
{
// if there is an association, then element is in the dictionary
return associatedWith(key) != 0;
}
template <class K, class V> int dictionary<K, V>::isEmpty() const
{
return data->isEmpty();
}
template <class K, class V> void dictionary<K, V>::removeKey(K key)
{
// loop over the elements looking for key
listIterator<association<K, V> *> itr(*data);
for (itr.init(); ! itr; ++itr) {
if (itr()->key() == key) {
delete itr(); // release the association*
itr.removeCurrent(); // remove the BuddLink
}
}
}
template <class K, class V> void dictionary<K, V>::setInitial(V val)
{
initialValue = val;
}
template <class K, class V>
dictionary<K, V> * dictionary<K, V>::Duplicate()
{
dictionary<K, V> * result = new dictionary<K,V>(initialValue);
result->data = data->duplicate();
// now copy the association records too.
listIterator<association<K, V> *> itr(*data);
for(itr.init(); !itr; ++itr) {
// copy each association too
itr() = new association<K,V>(*itr());
}
return result;
}
//----------------------------------------------------------------------
// class orderedDictionary implementation
//----------------------------------------------------------------------
template <class K, class V> orderedDictionary<K, V>::orderedDictionary()
{
// nothing to initialize
}
template <class K, class V> orderedDictionary<K, V>::
orderedDictionary(V val)
{
// set initial value
initialValue = val;
}
template <class K, class V> orderedDictionary<K, V>::
orderedDictionary(orderedDictionary<K, V> & v)
{
initialValue = v.initialValue;
data.deleteAllValues();
listIterator<cAssociation<K, V> &> itr(v.data);
for (itr.init(); !itr; ++itr)
data.add(itr());
}
template <class K, class V> V & orderedDictionary<K, V>::
operator [] (K key)
{
// return value of association specified by key
// first look to see if association is there already
cAssociation<K, V> * newassoc = associatedWith(key);
// if not there, make a new one
if (!newassoc)
{
newassoc = new cAssociation<K, V>(key, initialValue);
assert(newassoc != 0);
data.add(*newassoc);
}
// return reference to value field
return newassoc->valueField;
}
template <class K, class V> void orderedDictionary<K, V>::deleteAllValues()
{
data.deleteAllValues();
}
template <class K, class V> int orderedDictionary<K, V>::includesKey(K key)
{
// if there is an association, then element is in the dictionary
return associatedWith(key) != 0;
}
template <class K, class V> int orderedDictionary<K, V>::isEmpty() const
{
return data.isEmpty();
}
template <class K, class V> void orderedDictionary<K, V>::removeKey(K key)
{
// loop over the elements looking for key
listIterator<cAssociation<K, V> &> itr(data);
for (itr.init(); ! itr; ++itr)
if (itr().key() == key)
itr.removeCurrent();
}
template <class K, class V> void orderedDictionary<K, V>::setInitial(V val)
{
initialValue = val;
}
template <class K, class V> cAssociation<K, V> * orderedDictionary<K, V>::
associatedWith(K key)
{
// return the association with the given key
// or the null pointer if no association yet exists
listIterator<cAssociation<K, V> &> itr(data);
// loop over the elements, looking for a match
for (itr.init(); ! itr; ++itr)
if (itr().key() == key)
{
// address of a reference is a pointer
cAssociation<K, V> & theAssociation = itr();
return &theAssociation;
}
// not found, return null pointer
return 0;
}
//----------------------------------------------------------------------
// class dictionaryIterator implementation
//----------------------------------------------------------------------
template <class K, class V> dictionaryIterator<K, V>::
dictionaryIterator(dictionary<K, V> & dict)
: listIterator<association<K, V> *>(*dict.data)
{
// no further initialization
}
//----------------------------------------------------------------------
// class orderedDictionaryIterator implementation
//----------------------------------------------------------------------
template <class K, class V> orderedDictionaryIterator<K, V>::
orderedDictionaryIterator(orderedDictionary<K, V> & dict)
: listIterator<cAssociation<K, V> &>(dict.data)
{
// no further initialization
}
//----------------------------------------------------------------------
// class sparseMatrix implementation
//----------------------------------------------------------------------
template <class T> sparseMatrix<T>::
sparseMatrix(unsigned int n, unsigned int m)
: data(n)
{
// no further initialization
}
template <class T> sparseMatrix<T>::
sparseMatrix(unsigned int n, unsigned int m, T initial)
: data(n)
{
// set the initial value for each dictionary
for (unsigned int i = 0; i < n; i++)
data[i].setInitial(initial);
}
template <class T> dictionary<int,T> & sparseMatrix<T>
::operator [](unsigned int n)
{
// simply return the appropriate dictionary
return data[n];
}
//----------------------------------------------------------------------
// class sparseMatrix2 implementation
//----------------------------------------------------------------------
template <class T> sparseMatrix2<T>::
sparseMatrix2(unsigned int n, unsigned int m)
: data(n)
{
// no further initialization
}
template <class T> sparseMatrix2<T>::
sparseMatrix2(unsigned int n, unsigned int m, T initial)
: data(n)
{
// set the initial value for each dictionary
for (unsigned int i = 0; i < n; i++)
data[i].setInitial(initial);
}
template <class T> dictionary<int, T> & sparseMatrix2<T>::
operator [] (unsigned int n)
{
// subscript operator for sparse matrices
// if we already have a row, just return it
if (data.includesKey(n))
return data[n];
// else make a new entry and set initial value
data[n].setInitial(initialValue);
return data[n];
}
//----------------------------------------------------------------------
// class cAssociation implementation
//----------------------------------------------------------------------
template <class K, class V> cAssociation<K, V>::cAssociation(K n, V m)
: association<K, V>(n, m)
{
// no further initialization
}
template <class K, class V>
int operator == (cAssociation<K, V> & left, cAssociation<K, V> & right)
{
// compare the key values for two associations
return left.key() == right.key();
}
template <class K, class V>
int operator == (cAssociation<K, V> & left, K & rightKey)
{
// compare the key values for two associations
return left.key() == rightKey;
}
template <class K, class V>
int operator < (cAssociation<K, V> & left, cAssociation<K, V> & right)
{
// compare the key values for two associations
return left.key() < right.key();
}
template <class K, class V>
int operator < (cAssociation<K, V> & left, K & rightKey)
{
// compare the key value of an associations to a key value
return left.key() < rightKey;
}
//----------------------------------------------------------------------
// class table implementation
//----------------------------------------------------------------------
template <class K, class V> table<K, V>::
table(unsigned int max, unsigned int (*f)(const K &))
: hashTable<dictionary<K, V>, K, association<K, V> *>(max, f)
{
// no further initialization
}
template <class K, class V> table<K, V>::
table(unsigned int max, unsigned int (*f)(const K &), V & v)
: hashTable<dictionary<K, V>, K, association<K, V> *>(max, f)
{
// set the initial value in each bucket
setInitial(v);
}
// tgd added
template <class K, class V> int table<K, V>::includesKey(K key)
{
return buckets[hash(key)].includesKey(key);
}
template <class K, class V> V & table<K, V>::operator [](K key)
{
// find right dictionary, then subscript dictionary
return buckets[hash(key)][key];
}
template <class K, class V> void table<K, V>::removeKey(K key)
{
// find the right bucket, then remove the key
buckets[hash(key)].removeKey(key);
}
template <class K, class V> void table<K, V>::setInitial(V val)
{
// set the initial value in each bucket
for (int i = 0; i < tablesize; i++)
buckets[i].initialValue = val;
}
template <class K, class V> iterator<association<K, V> *> * table<K, V>::
makeIterator(unsigned int i)
{
return new dictionaryIterator<K, V>(buckets[i]);
}
//----------------------------------------------------------------------
// class tableIterator implementation
//----------------------------------------------------------------------
template <class K, class V> tableIterator<K, V>::
tableIterator(table<K, V> & v)
: hashTableIterator<dictionary<K, V>, K, association<K, V> *>(v)
{
// no further initialization
}
#endif
|
f5da47f3b9826a4cd5f14851566fafa313baf242
|
067a54a335d900fbcb01c77205d1d45eb38fe7dd
|
/LightOJ/1421.cxx
|
aaae166a334203ca4a77ff973eab2ab87e54c7e3
|
[] |
no_license
|
pallab-gain/LightOJ
|
997cf858d5af79f8de34fb8237a79e54f7f706f4
|
867186dcfcf9501797f8467c7ffa8cab87a7b197
|
refs/heads/master
| 2020-04-07T05:20:46.855100
| 2013-01-25T07:57:45
| 2013-01-25T07:57:45
| 3,844,699
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,584
|
cxx
|
1421.cxx
|
/*
* Author : Pallab
* Program : 1421.cxx
*
* 2012-03-05 23:23:34
* I have not failed, I have just found 10000 ways that won't work.
*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>
using namespace std;
#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")
inline void debug(int _x) {
cout<<_x<<'\n';
}
inline void debug(int _x,int _y) {
cout<<_x<<' '<<_y<<'\n';
}
inline void debug(int _x,int _y,int _z) {
cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
inline void debug(int _x,int _y,int _z,int _zz) {
cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
inline bool CI(int &_x) {
return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}
enum {
maxn=(int)1e5+10
};
int n;
int numbers[maxn];
inline void Read() {
CI(n);
fo(i,n) {
CI(numbers[i]);
}
}
int LIS[2][maxn];
int B[maxn];
inline void lis(int id) {
LIS[id][0]=1;
B[0]=numbers[0];
int maxLen=1;
for (int i=1;i<n;++i) {
int number=numbers[i];
int lowerbound=lower_bound(B,B+maxLen,number)-B;
LIS[id][i]=lowerbound+1;
if (lowerbound==maxLen) {
B[maxLen++]=number;
}
else {
B[lowerbound]=number;
}
}
}
inline void Proc() {
lis(0);
reverse(numbers,numbers+n);
lis(1);
int best=0;
fo(i,n) {
//debug(i,LIS[0][i],LIS[1][i]);
best=max(best, min(LIS[0][i],LIS[1][(n-1)-i]) );
}
cout<<(best<<1)-1;
line;
}
int main() {
int tt;
CI(tt);
foE(i,1,tt) {
Read();
cout<<"Case "<<i<<": ";
Proc();
}
}
|
378f78eb8c80df6f35264b4f249c45d4b949aa9c
|
d13f4cf44fd53377a851198c9af825fbcf9197f9
|
/adrival/utility/Optional.h
|
b8c5f7c127f7dd888ee21ccc03017fab388a2514
|
[] |
no_license
|
EndofDeath/Adrival
|
5f311dec92a42df715b192e2087155cafcf627d5
|
38ad73f55bc54b66bf93f8b0aa845b03de60811b
|
refs/heads/master
| 2020-06-08T12:30:01.380174
| 2019-10-13T09:23:20
| 2019-10-13T09:23:20
| 193,228,336
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,404
|
h
|
Optional.h
|
#ifndef ADRIVAL_OPTIONAL_H
#define ADRIVAL_OPTIONAL_H
#pragma once
#include <type_traits>
#include <exception>
namespace adrival {
template<typename T>
class optional
{
using data_t = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
public:
optional() : has_value_(false) {}
optional(const T& v)
{
Create(v);
}
optional(T&& v) : has_value_(false)
{
Create(std::move(v));
}
~optional()
{
Destroy();
}
optional(const optional& other) : has_value_(false)
{
if (other.has_value_)
Assign(other);
}
optional(optional&& other) : has_value_(false)
{
if (other.has_value_)
{
Assign(std::move(other));
other.Destroy();
}
}
template<class T2 = T, class = std::enable_if < std::is_same < T, std::decay<T2>::type > ::value > ::type >
optional& operator=(T2&& v)
{
if (has_value_)
*(T*)(&data_) = std::forward<T>(v);
else
Create(std::forward<T>(v));
return *this;
}
optional& operator=(optional &&other) noexcept
{
Assign(std::move(other));
return *this;
}
optional& operator=(const optional &other)
{
Assign(other);
return *this;
}
template<class... Args>
T& emplace(Args&&... args)
{
Destroy();
Create(std::forward<Args>(args)...);
return value();
}
bool has_value() const { return has_value_; }
explicit operator bool() const {
return has_value();
}
T& operator*()
{
return value();
}
T const& operator*() const
{
return value();
}
T* operator->()
{
return ((T*)(&data_));
}
const T* operator->() const
{
return ((T*)(&data_));
}
bool operator == (const optional<T>& rhs) const
{
return (!bool(*this)) != (!rhs) ? false : (!bool(*this) ? true : (*(*this)) == (*rhs));
}
bool operator < (const optional<T>& rhs) const
{
return !rhs ? false : (!bool(*this) ? true : (*(*this) < (*rhs)));
}
bool operator != (const optional<T>& rhs)
{
return !(*this == (rhs));
}
void reset()
{
Destroy();
}
T& value()
{
if (has_value_)
{
return *(T*)(&data_);
}
throw std::exception("accessing an optional object that does not contain a value.");
}
const T& value() const
{
if (has_value_)
{
return *(T*)(&data_);
}
throw std::exception("accessing an optional object that does not contain a value.");
}
void swap(optional& other)
{
if (!has_value_ && !other.has_value_)
return;
if (!has_value_ && other.has_value_)
{
Assign(std::move(other));
}
else if (has_value_ && !other.has_value_)
{
other.Assign(std::move(*this));
}
else
std::swap(**this, *other);
}
private:
template<class... Args>
void Create(Args&&... args)
{
new (&data_) T(std::forward<Args>(args)...);
has_value_ = true;
}
void Destroy()
{
if (has_value_)
{
has_value_ = false;
if(std::is_class<T>::value)
((T*)(&data_))->~T();
}
}
void Assign(const optional& other)
{
if (other.has_value_)
{
Copy(other.data_);
has_value_ = true;
}
else
{
Destroy();
}
}
void Assign(optional&& other)
{
if (other.has_value_)
{
Move(std::move(other.data_));
has_value_ = true;
other.Destroy();
}
else
{
Destroy();
}
}
void Move(data_t&& val)
{
Destroy();
new (&data_) T(std::move(*((T*)(&val))));
}
void Copy(const data_t& val)
{
Destroy();
new (&data_) T(*((T*)(&val)));
}
private:
data_t data_{};
bool has_value_;
};
}
#endif // !ADRIVAL_OPTIONAL_H
|
1023a332c32b226eec9b939464a3fd309faa538f
|
552c39141dab7cbc0c34245000291a46cdb41495
|
/lte_enb/src/tenb_commonplatform/software/libs/common/mib-common/ValidatorT304ExpWaitTmr.cpp
|
b4030e8f18d03374e9987867fbccdf250a4b876a
|
[] |
no_license
|
cmjeong/rashmi_oai_epc
|
a0d6c19d12b292e4da5d34b409c63e3dec28bd20
|
6ec1784eb786ab6faa4f7c4f1c76cc23438c5b90
|
refs/heads/master
| 2021-04-06T01:48:10.060300
| 2017-08-10T02:04:34
| 2017-08-10T02:04:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,664
|
cpp
|
ValidatorT304ExpWaitTmr.cpp
|
///////////////////////////////////////////////////////////////////////////////
//
// ValidatorT304ExpWaitTmr.cpp
//
// See header file for documentation.
//
// Copyright Radisys Limited
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// System Includes
///////////////////////////////////////////////////////////////////////////////
#include <sstream>
#include <system/Trace.h>
///////////////////////////////////////////////////////////////////////////////
// Local Includes
///////////////////////////////////////////////////////////////////////////////
#include "ValidatorT304ExpWaitTmr.h"
#include "mib-common/ValidationReferences.h"
#define DELAY 100
using namespace std;
///////////////////////////////////////////////////////////////////////////////
// Class Functions
///////////////////////////////////////////////////////////////////////////////
bool ValidatorT304ExpWaitTmr::ValidateU32(MibDN fapLteDn, u32 value, u32 min, u32 max, ValidationFailureDescriptor& failureDescriptor)
{
ENTER();
ValidationReferences::GetInstance().getParameterValue(PARAM_ID_LTE_T304IRAT, t304Irat, fapLteDn);
bool isValid = ValidatorU32::ValidateU32(value, min, max, failureDescriptor);
if( isValid )
{
if( value < t304Irat.at(0) + DELAY )
{
isValid = false;
ostringstream description;
description << "LTE_GERAN_T304_EXP_WAIT_TMR should be atleast 100 + LTE_T304IRAT ";
failureDescriptor.Set(ValidationFailureDescriptor::CAUSE_OTHER, description.str());
}
}
RETURN(isValid);
}
|
3f4596d9ee969132134aae2f3d6aaec1da285008
|
8e08d5352668b8c425f2d59c0ff31107307e7c91
|
/dashp2p/deprecated/AdaptationMultihomed.h
|
67661a00e1e1adc50776aedcadf80a6506dca652
|
[] |
no_license
|
konstantinmiller/dashp2p
|
8d31bc5e0c1426b63dc3951cc6796451f8a209ae
|
756e482478deaddaa1161c2afc6af76f7dd776dc
|
refs/heads/master
| 2020-12-24T16:32:52.906072
| 2017-11-08T13:45:19
| 2017-11-08T13:45:19
| 6,349,015
| 4
| 5
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,566
|
h
|
AdaptationMultihomed.h
|
/****************************************************************************
* AdaptationMultihomed.h *
****************************************************************************
* Copyright (C) 2012 Technische Universitaet Berlin *
* *
* Created on: Sep 19, 2012 *
* Authors: Konstantin Miller <konstantin.miller@tu-berlin.de> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#ifndef ADAPTATIONMULTIHOMED_H_
#define ADAPTATIONMULTIHOMED_H_
#include <string>
#include <vector>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
class AdaptationMultihomed
{
/* Public methods */
public:
AdaptationMultihomed(const std::string& config);
virtual ~AdaptationMultihomed(){}
struct sockaddr_in getPrimarySockAddr() const;
struct sockaddr_in getSecondarySockAddr() const;
/* Private types */
private:
class IfData {
public:
IfData(): initialized(false), name(), sockaddr_in(), primary(false) {}
~IfData(){}
bool initialized;
std::string name;
struct sockaddr_in sockaddr_in;
bool primary;
};
/* Public members */
private:
std::vector<IfData> ifData;
/* Private methods */
private:
const IfData& getPrimaryIf() const;
const IfData& getSecondaryIf() const;
};
#endif /* ADAPTATIONMULTIHOMED_H_ */
|
dfa56563b745dfa9f40dd31815346a31b4be577d
|
737406e92b4ea6d6249c54f7e1854d806bb04c12
|
/Image360/include/image360/StereoSphere.h
|
f64dec3e4f9f4902da29159744686a54587548dd
|
[] |
no_license
|
sushilmiitb/coresdk
|
0cd022821f74e959562f9b9ba35303d7db504f15
|
0a97a222408d58f33d5fd1c88af89c68d2c230fb
|
refs/heads/master
| 2020-04-09T10:58:43.635289
| 2017-08-04T07:35:50
| 2017-08-04T07:35:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,251
|
h
|
StereoSphere.h
|
#ifndef IMAGE360_STEREOSPHERE_H
#define IMAGE360_STEREOSPHERE_H
/*
* This class is responsible to creating two spheres with 360 equirectangular
* stereo image texture mapped to it. These two image textures correspond to the
* left and right eye and are either Computer Generated or Captured with a
* stereo camera
*/
// renderable objects
#include <coreEngine/renderObjects/Material.h>
#include <coreEngine/renderObjects/Model.h>
#include <coreEngine/renderObjects/Scene.h>
#include <coreEngine/renderObjects/Shader.h>
#include <coreEngine/renderObjects/Texture.h>
// modifier
#include <coreEngine/modifier/Image.h>
// model builders
#include <coreEngine/modelBuilder/UVSphereBuilder.h>
// factory declarations
#include <coreEngine/components/transformTree/ITransformTreeFactory.h>
#include <coreEngine/factory/IDiffuseTextureFactory.h>
#include <coreEngine/factory/IModelFactory.h>
// utils
#include <coreEngine/util/ILogger.h>
#include <coreEngine/util/ILoggerFactory.h>
#include <image360/Constants.h>
#include <image360/ApplicationObject.h>
#include <image360/StereoObject.h>
namespace cl {
class StereoSphere : public ApplicationObject, public StereoObject {
public:
StereoSphere(ILoggerFactory &loggerFactory, IModelFactory &modelFactory,
IDiffuseTextureFactory &diffuseTextureFactory,
ITransformTreeFactory &transformTreeFactory,
std::unique_ptr<Image> textureImage);
~StereoSphere();
void initialize(Scene &scene);
void preDrawLeft();
void preDrawRight();
private:
// stereo rendering component
Shader *stereoShader;
Material *stereoMaterial;
Texture *stereoImageTexture;
Model *stereoImageContainer[2]; // 0->left, 1->right
std::unique_ptr<Image> textureImage;
// logging util
std::unique_ptr<ILogger> logger;
// factories
IModelFactory *modelFactory;
IDiffuseTextureFactory *diffuseTextureFactory;
ITransformTreeFactory *transformTreeFactory;
// CONSTANTS
CL_Vec3 LEFT_SPHERE_POSITION = CL_Vec3(0.0f, 0.0f, 0.0f);
CL_Vec3 LEFT_SPHERE_SCALE = CL_Vec3(100.0f, 100.0f, 100.0f);
CL_Vec3 RIGHT_SPHERE_POSITION = CL_Vec3(0.0f, 0.0f, 0.0f);
CL_Vec3 RIGHT_SPHERE_SCALE = CL_Vec3(100.0f, 100.0f, 100.0f);
};
}
#endif // IMAGE360_STEREOSPHERE_H
|
3b411b75ed62e71cee10f9c14e7f94154c099d26
|
d998c866dc5e16d7c63dbcaf38cea7ad99354fd0
|
/Enemy.cpp
|
632fd7babf63a19e0374ef730d1f08d310b0fe3d
|
[] |
no_license
|
valnica/MyReository
|
6dc9e9e890fbfa8165a87554ae967a1a0bac7193
|
760595509ef5c18a2192a160a80c8eddcf446edd
|
refs/heads/master
| 2021-01-12T07:05:48.187326
| 2017-01-10T16:22:26
| 2017-01-10T16:22:26
| 76,908,994
| 0
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 4,570
|
cpp
|
Enemy.cpp
|
//////////////////////////////////////////////
// Name : Enemy
//
// Author : 山田 聖弥
//
// Date : 2017/1/10
//////////////////////////////////////////////
#include "Enemy.h"
#include "GameManager.h"
#include "Player.h"
#include "CollisionManager.h"
#include "Debug.h"
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
using namespace DirectX::SimpleMath;
//////////////////////////////////////////////
// Name : Enemy
//
// Over View : コンストラクタ
//
// Argument : 無し
//////////////////////////////////////////////
Enemy::Enemy()
{
}
//////////////////////////////////////////////
// Name : ~Enemy
//
// Over View : デストラクタ
//
// Argument : 無し
//////////////////////////////////////////////
Enemy::~Enemy()
{
movePoint_.DataAllDelete();
}
//////////////////////////////////////////////
// Name : Initialize
//
// Over View : 初期化処理
//
// Argument : 無し
//
// Return : 無し
//////////////////////////////////////////////
void Enemy::Initialize()
{
//空のオブジェクト
parts_[EMPTY].SetTrans(movePoint_.Top()->GetData());
parts_[EMPTY].SetRotate(Vector3(0.0f, 0.0f, 0.0f));
parts_[EMPTY].SetScale(Vector3(1.0f, 1.0f, 1.0f));
parts_[BODY].LoadModelFromFile(L"Resources\\cModels\\PlayerBody.cmo");
parts_[BODY].SetTrans(Vector3(0.0f, 0.0f, 0.0f));
parts_[BODY].SetRotate(Vector3(0.0f, 0.0f, 0.0f));
parts_[BODY].SetScale(Vector3(1.0f, 1.0f, 1.0f));
parts_[BODY].SetParentWorld(&parts_[EMPTY].GetWorld());
parts_[HEAD].LoadModelFromFile(L"Resources\\cModels\\PlayerHead.cmo");
parts_[HEAD].SetTrans(Vector3(0.0f, 1.3f, 0.3f));
parts_[HEAD].SetRotate(Vector3(0.0f, 0.0f, 0.0f));
parts_[HEAD].SetScale(Vector3(1.0f, 1.0f, 1.0f));
parts_[HEAD].SetParentWorld(&parts_[BODY].GetWorld());
//AIの初期処理
now_ = movePoint_.Top();
moveCount_ =(int)((now_->next_->GetData() - now_->GetData()).Length() / moveSpeed_ * 60);
waitTime_ = 60;
currentCount_ = 0;
//視野の設定
viewAngle_ = 45.0f;
viewDistance_ = 30.0f;
}
//////////////////////////////////////////////
// Name : Update
//
// Over View : 更新処理
//
// Argument : 無し
//
// Return : 無し
//////////////////////////////////////////////
void Enemy::Update()
{
currentCount_++;
//適正時間を計算
float time = (float)currentCount_ / moveCount_;
if (time > 1.0f)
time = 1.0f;
//線形補間で移動
Vector3 vec = now_->GetData() + time * (now_->next_->GetData() - now_->GetData());
parts_[EMPTY].SetTrans(vec);
for (int i = 0; i < NUM_PARTS; i++)
{
parts_[i].Calc();
}
//キャラクターの回転
vec = now_->next_->GetData() - now_->GetData();
float rad = atan2f(-vec.x, -vec.z);
parts_[EMPTY].SetRotate(Vector3(0.0f, rad * 180.0f /3.14f , 0.0f));
//次の目標座標更新
if (currentCount_ >= moveCount_ + waitTime_)
{
currentCount_ = 0;
now_ = now_->next_;
moveCount_ = (int)((now_->next_->GetData() - now_->GetData()).Length() / moveSpeed_ * 60);
}
//当たり判定に登録
CollisionManager::GetInstance()->Entry(this);
}
//////////////////////////////////////////////
// Name : Render
//
// Over View : 描画処理
//
// Argument : 無し
//
// Return : 無し
//////////////////////////////////////////////
void Enemy::Render()
{
//描画
for (int i = 0; i < NUM_PARTS; i++)
{
parts_[i].Draw();
}
#ifdef DEBUG
//プレイヤーが視野内にいるかどうかのデバッグ
{
//デバッグ 向いている方向を描画
Vector3 dir(0.0f, 0.0f, -viewDistance_);
Matrix rot = Matrix::CreateRotationY(parts_[EMPTY].GetRotate().y * 3.14f / 180);
Vector3 vec = Vector3::TransformNormal(dir, rot);
Debug::GetInstance()->DrawLine(parts_[EMPTY].GetTrans(), parts_[EMPTY].GetTrans() + vec);
//視野のデバッグ
rot = Matrix::CreateRotationY((parts_[EMPTY].GetRotate().y + viewAngle_) * 3.14f / 180.0f);
vec = Vector3::TransformNormal(dir, rot);
Debug::GetInstance()->DrawLine(parts_[EMPTY].GetTrans(), parts_[EMPTY].GetTrans() + vec);
rot = Matrix::CreateRotationY((parts_[EMPTY].GetRotate().y - viewAngle_) * 3.14f / 180.0f);
vec = Vector3::TransformNormal(dir, rot);
Debug::GetInstance()->DrawLine(parts_[EMPTY].GetTrans(),parts_[EMPTY].GetTrans() + vec);
}
#endif
}
//////////////////////////////////////////////
// Name : SetMovePoint
//
// Over View : 巡回場所のリストの設定
//
// Argument : 巡回場所を保存してあるリスト
//
// Return : 無し
//////////////////////////////////////////////
void Enemy::SetMovePoint(List<DirectX::SimpleMath::Vector3> movePoint)
{
movePoint_ = movePoint;
}
|
b54018201ed165016719fe1a814996b0c0a8222b
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/coreclr/pal/src/locale/unicodedata.cpp
|
74ae79819bb6641a7b68ecc7f9b2bcef7eb20c93
|
[
"MIT"
] |
permissive
|
dotnet/runtime
|
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
|
47bb554d298e1e34c4e3895d7731e18ad1c47d02
|
refs/heads/main
| 2023-09-03T15:35:46.493337
| 2023-09-03T08:13:23
| 2023-09-03T08:13:23
| 210,716,005
| 13,765
| 5,179
|
MIT
| 2023-09-14T21:58:52
| 2019-09-24T23:36:39
|
C#
|
UTF-8
|
C++
| false
| false
| 78,525
|
cpp
|
unicodedata.cpp
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "pal/unicodedata.h"
//
// THIS FILE IS GENERATED. DO NOT HAND EDIT.
// IF YOU NEED TO UPDATE UNICODE VERSION FOLLOW THE GUIDE AT src/libraries/System.Private.CoreLib/Tools/GenUnicodeProp/Updating-Unicode-Versions.md
//
CONST UnicodeDataRec UnicodeData[] = {
{ 0x41, UPPER_CASE, 0x61 },
{ 0x42, UPPER_CASE, 0x62 },
{ 0x43, UPPER_CASE, 0x63 },
{ 0x44, UPPER_CASE, 0x64 },
{ 0x45, UPPER_CASE, 0x65 },
{ 0x46, UPPER_CASE, 0x66 },
{ 0x47, UPPER_CASE, 0x67 },
{ 0x48, UPPER_CASE, 0x68 },
{ 0x49, UPPER_CASE, 0x69 },
{ 0x4A, UPPER_CASE, 0x6A },
{ 0x4B, UPPER_CASE, 0x6B },
{ 0x4C, UPPER_CASE, 0x6C },
{ 0x4D, UPPER_CASE, 0x6D },
{ 0x4E, UPPER_CASE, 0x6E },
{ 0x4F, UPPER_CASE, 0x6F },
{ 0x50, UPPER_CASE, 0x70 },
{ 0x51, UPPER_CASE, 0x71 },
{ 0x52, UPPER_CASE, 0x72 },
{ 0x53, UPPER_CASE, 0x73 },
{ 0x54, UPPER_CASE, 0x74 },
{ 0x55, UPPER_CASE, 0x75 },
{ 0x56, UPPER_CASE, 0x76 },
{ 0x57, UPPER_CASE, 0x77 },
{ 0x58, UPPER_CASE, 0x78 },
{ 0x59, UPPER_CASE, 0x79 },
{ 0x5A, UPPER_CASE, 0x7A },
{ 0x61, LOWER_CASE, 0x41 },
{ 0x62, LOWER_CASE, 0x42 },
{ 0x63, LOWER_CASE, 0x43 },
{ 0x64, LOWER_CASE, 0x44 },
{ 0x65, LOWER_CASE, 0x45 },
{ 0x66, LOWER_CASE, 0x46 },
{ 0x67, LOWER_CASE, 0x47 },
{ 0x68, LOWER_CASE, 0x48 },
{ 0x69, LOWER_CASE, 0x49 },
{ 0x6A, LOWER_CASE, 0x4A },
{ 0x6B, LOWER_CASE, 0x4B },
{ 0x6C, LOWER_CASE, 0x4C },
{ 0x6D, LOWER_CASE, 0x4D },
{ 0x6E, LOWER_CASE, 0x4E },
{ 0x6F, LOWER_CASE, 0x4F },
{ 0x70, LOWER_CASE, 0x50 },
{ 0x71, LOWER_CASE, 0x51 },
{ 0x72, LOWER_CASE, 0x52 },
{ 0x73, LOWER_CASE, 0x53 },
{ 0x74, LOWER_CASE, 0x54 },
{ 0x75, LOWER_CASE, 0x55 },
{ 0x76, LOWER_CASE, 0x56 },
{ 0x77, LOWER_CASE, 0x57 },
{ 0x78, LOWER_CASE, 0x58 },
{ 0x79, LOWER_CASE, 0x59 },
{ 0x7A, LOWER_CASE, 0x5A },
{ 0xB5, LOWER_CASE, 0x39C },
{ 0xC0, UPPER_CASE, 0xE0 },
{ 0xC1, UPPER_CASE, 0xE1 },
{ 0xC2, UPPER_CASE, 0xE2 },
{ 0xC3, UPPER_CASE, 0xE3 },
{ 0xC4, UPPER_CASE, 0xE4 },
{ 0xC5, UPPER_CASE, 0xE5 },
{ 0xC6, UPPER_CASE, 0xE6 },
{ 0xC7, UPPER_CASE, 0xE7 },
{ 0xC8, UPPER_CASE, 0xE8 },
{ 0xC9, UPPER_CASE, 0xE9 },
{ 0xCA, UPPER_CASE, 0xEA },
{ 0xCB, UPPER_CASE, 0xEB },
{ 0xCC, UPPER_CASE, 0xEC },
{ 0xCD, UPPER_CASE, 0xED },
{ 0xCE, UPPER_CASE, 0xEE },
{ 0xCF, UPPER_CASE, 0xEF },
{ 0xD0, UPPER_CASE, 0xF0 },
{ 0xD1, UPPER_CASE, 0xF1 },
{ 0xD2, UPPER_CASE, 0xF2 },
{ 0xD3, UPPER_CASE, 0xF3 },
{ 0xD4, UPPER_CASE, 0xF4 },
{ 0xD5, UPPER_CASE, 0xF5 },
{ 0xD6, UPPER_CASE, 0xF6 },
{ 0xD8, UPPER_CASE, 0xF8 },
{ 0xD9, UPPER_CASE, 0xF9 },
{ 0xDA, UPPER_CASE, 0xFA },
{ 0xDB, UPPER_CASE, 0xFB },
{ 0xDC, UPPER_CASE, 0xFC },
{ 0xDD, UPPER_CASE, 0xFD },
{ 0xDE, UPPER_CASE, 0xFE },
{ 0xE0, LOWER_CASE, 0xC0 },
{ 0xE1, LOWER_CASE, 0xC1 },
{ 0xE2, LOWER_CASE, 0xC2 },
{ 0xE3, LOWER_CASE, 0xC3 },
{ 0xE4, LOWER_CASE, 0xC4 },
{ 0xE5, LOWER_CASE, 0xC5 },
{ 0xE6, LOWER_CASE, 0xC6 },
{ 0xE7, LOWER_CASE, 0xC7 },
{ 0xE8, LOWER_CASE, 0xC8 },
{ 0xE9, LOWER_CASE, 0xC9 },
{ 0xEA, LOWER_CASE, 0xCA },
{ 0xEB, LOWER_CASE, 0xCB },
{ 0xEC, LOWER_CASE, 0xCC },
{ 0xED, LOWER_CASE, 0xCD },
{ 0xEE, LOWER_CASE, 0xCE },
{ 0xEF, LOWER_CASE, 0xCF },
{ 0xF0, LOWER_CASE, 0xD0 },
{ 0xF1, LOWER_CASE, 0xD1 },
{ 0xF2, LOWER_CASE, 0xD2 },
{ 0xF3, LOWER_CASE, 0xD3 },
{ 0xF4, LOWER_CASE, 0xD4 },
{ 0xF5, LOWER_CASE, 0xD5 },
{ 0xF6, LOWER_CASE, 0xD6 },
{ 0xF8, LOWER_CASE, 0xD8 },
{ 0xF9, LOWER_CASE, 0xD9 },
{ 0xFA, LOWER_CASE, 0xDA },
{ 0xFB, LOWER_CASE, 0xDB },
{ 0xFC, LOWER_CASE, 0xDC },
{ 0xFD, LOWER_CASE, 0xDD },
{ 0xFE, LOWER_CASE, 0xDE },
{ 0xFF, LOWER_CASE, 0x178 },
{ 0x100, UPPER_CASE, 0x101 },
{ 0x101, LOWER_CASE, 0x100 },
{ 0x102, UPPER_CASE, 0x103 },
{ 0x103, LOWER_CASE, 0x102 },
{ 0x104, UPPER_CASE, 0x105 },
{ 0x105, LOWER_CASE, 0x104 },
{ 0x106, UPPER_CASE, 0x107 },
{ 0x107, LOWER_CASE, 0x106 },
{ 0x108, UPPER_CASE, 0x109 },
{ 0x109, LOWER_CASE, 0x108 },
{ 0x10A, UPPER_CASE, 0x10B },
{ 0x10B, LOWER_CASE, 0x10A },
{ 0x10C, UPPER_CASE, 0x10D },
{ 0x10D, LOWER_CASE, 0x10C },
{ 0x10E, UPPER_CASE, 0x10F },
{ 0x10F, LOWER_CASE, 0x10E },
{ 0x110, UPPER_CASE, 0x111 },
{ 0x111, LOWER_CASE, 0x110 },
{ 0x112, UPPER_CASE, 0x113 },
{ 0x113, LOWER_CASE, 0x112 },
{ 0x114, UPPER_CASE, 0x115 },
{ 0x115, LOWER_CASE, 0x114 },
{ 0x116, UPPER_CASE, 0x117 },
{ 0x117, LOWER_CASE, 0x116 },
{ 0x118, UPPER_CASE, 0x119 },
{ 0x119, LOWER_CASE, 0x118 },
{ 0x11A, UPPER_CASE, 0x11B },
{ 0x11B, LOWER_CASE, 0x11A },
{ 0x11C, UPPER_CASE, 0x11D },
{ 0x11D, LOWER_CASE, 0x11C },
{ 0x11E, UPPER_CASE, 0x11F },
{ 0x11F, LOWER_CASE, 0x11E },
{ 0x120, UPPER_CASE, 0x121 },
{ 0x121, LOWER_CASE, 0x120 },
{ 0x122, UPPER_CASE, 0x123 },
{ 0x123, LOWER_CASE, 0x122 },
{ 0x124, UPPER_CASE, 0x125 },
{ 0x125, LOWER_CASE, 0x124 },
{ 0x126, UPPER_CASE, 0x127 },
{ 0x127, LOWER_CASE, 0x126 },
{ 0x128, UPPER_CASE, 0x129 },
{ 0x129, LOWER_CASE, 0x128 },
{ 0x12A, UPPER_CASE, 0x12B },
{ 0x12B, LOWER_CASE, 0x12A },
{ 0x12C, UPPER_CASE, 0x12D },
{ 0x12D, LOWER_CASE, 0x12C },
{ 0x12E, UPPER_CASE, 0x12F },
{ 0x12F, LOWER_CASE, 0x12E },
{ 0x130, UPPER_CASE, 0x69 },
{ 0x131, LOWER_CASE, 0x49 },
{ 0x132, UPPER_CASE, 0x133 },
{ 0x133, LOWER_CASE, 0x132 },
{ 0x134, UPPER_CASE, 0x135 },
{ 0x135, LOWER_CASE, 0x134 },
{ 0x136, UPPER_CASE, 0x137 },
{ 0x137, LOWER_CASE, 0x136 },
{ 0x139, UPPER_CASE, 0x13A },
{ 0x13A, LOWER_CASE, 0x139 },
{ 0x13B, UPPER_CASE, 0x13C },
{ 0x13C, LOWER_CASE, 0x13B },
{ 0x13D, UPPER_CASE, 0x13E },
{ 0x13E, LOWER_CASE, 0x13D },
{ 0x13F, UPPER_CASE, 0x140 },
{ 0x140, LOWER_CASE, 0x13F },
{ 0x141, UPPER_CASE, 0x142 },
{ 0x142, LOWER_CASE, 0x141 },
{ 0x143, UPPER_CASE, 0x144 },
{ 0x144, LOWER_CASE, 0x143 },
{ 0x145, UPPER_CASE, 0x146 },
{ 0x146, LOWER_CASE, 0x145 },
{ 0x147, UPPER_CASE, 0x148 },
{ 0x148, LOWER_CASE, 0x147 },
{ 0x14A, UPPER_CASE, 0x14B },
{ 0x14B, LOWER_CASE, 0x14A },
{ 0x14C, UPPER_CASE, 0x14D },
{ 0x14D, LOWER_CASE, 0x14C },
{ 0x14E, UPPER_CASE, 0x14F },
{ 0x14F, LOWER_CASE, 0x14E },
{ 0x150, UPPER_CASE, 0x151 },
{ 0x151, LOWER_CASE, 0x150 },
{ 0x152, UPPER_CASE, 0x153 },
{ 0x153, LOWER_CASE, 0x152 },
{ 0x154, UPPER_CASE, 0x155 },
{ 0x155, LOWER_CASE, 0x154 },
{ 0x156, UPPER_CASE, 0x157 },
{ 0x157, LOWER_CASE, 0x156 },
{ 0x158, UPPER_CASE, 0x159 },
{ 0x159, LOWER_CASE, 0x158 },
{ 0x15A, UPPER_CASE, 0x15B },
{ 0x15B, LOWER_CASE, 0x15A },
{ 0x15C, UPPER_CASE, 0x15D },
{ 0x15D, LOWER_CASE, 0x15C },
{ 0x15E, UPPER_CASE, 0x15F },
{ 0x15F, LOWER_CASE, 0x15E },
{ 0x160, UPPER_CASE, 0x161 },
{ 0x161, LOWER_CASE, 0x160 },
{ 0x162, UPPER_CASE, 0x163 },
{ 0x163, LOWER_CASE, 0x162 },
{ 0x164, UPPER_CASE, 0x165 },
{ 0x165, LOWER_CASE, 0x164 },
{ 0x166, UPPER_CASE, 0x167 },
{ 0x167, LOWER_CASE, 0x166 },
{ 0x168, UPPER_CASE, 0x169 },
{ 0x169, LOWER_CASE, 0x168 },
{ 0x16A, UPPER_CASE, 0x16B },
{ 0x16B, LOWER_CASE, 0x16A },
{ 0x16C, UPPER_CASE, 0x16D },
{ 0x16D, LOWER_CASE, 0x16C },
{ 0x16E, UPPER_CASE, 0x16F },
{ 0x16F, LOWER_CASE, 0x16E },
{ 0x170, UPPER_CASE, 0x171 },
{ 0x171, LOWER_CASE, 0x170 },
{ 0x172, UPPER_CASE, 0x173 },
{ 0x173, LOWER_CASE, 0x172 },
{ 0x174, UPPER_CASE, 0x175 },
{ 0x175, LOWER_CASE, 0x174 },
{ 0x176, UPPER_CASE, 0x177 },
{ 0x177, LOWER_CASE, 0x176 },
{ 0x178, UPPER_CASE, 0xFF },
{ 0x179, UPPER_CASE, 0x17A },
{ 0x17A, LOWER_CASE, 0x179 },
{ 0x17B, UPPER_CASE, 0x17C },
{ 0x17C, LOWER_CASE, 0x17B },
{ 0x17D, UPPER_CASE, 0x17E },
{ 0x17E, LOWER_CASE, 0x17D },
{ 0x17F, LOWER_CASE, 0x53 },
{ 0x180, LOWER_CASE, 0x243 },
{ 0x181, UPPER_CASE, 0x253 },
{ 0x182, UPPER_CASE, 0x183 },
{ 0x183, LOWER_CASE, 0x182 },
{ 0x184, UPPER_CASE, 0x185 },
{ 0x185, LOWER_CASE, 0x184 },
{ 0x186, UPPER_CASE, 0x254 },
{ 0x187, UPPER_CASE, 0x188 },
{ 0x188, LOWER_CASE, 0x187 },
{ 0x189, UPPER_CASE, 0x256 },
{ 0x18A, UPPER_CASE, 0x257 },
{ 0x18B, UPPER_CASE, 0x18C },
{ 0x18C, LOWER_CASE, 0x18B },
{ 0x18E, UPPER_CASE, 0x1DD },
{ 0x18F, UPPER_CASE, 0x259 },
{ 0x190, UPPER_CASE, 0x25B },
{ 0x191, UPPER_CASE, 0x192 },
{ 0x192, LOWER_CASE, 0x191 },
{ 0x193, UPPER_CASE, 0x260 },
{ 0x194, UPPER_CASE, 0x263 },
{ 0x195, LOWER_CASE, 0x1F6 },
{ 0x196, UPPER_CASE, 0x269 },
{ 0x197, UPPER_CASE, 0x268 },
{ 0x198, UPPER_CASE, 0x199 },
{ 0x199, LOWER_CASE, 0x198 },
{ 0x19A, LOWER_CASE, 0x23D },
{ 0x19C, UPPER_CASE, 0x26F },
{ 0x19D, UPPER_CASE, 0x272 },
{ 0x19E, LOWER_CASE, 0x220 },
{ 0x19F, UPPER_CASE, 0x275 },
{ 0x1A0, UPPER_CASE, 0x1A1 },
{ 0x1A1, LOWER_CASE, 0x1A0 },
{ 0x1A2, UPPER_CASE, 0x1A3 },
{ 0x1A3, LOWER_CASE, 0x1A2 },
{ 0x1A4, UPPER_CASE, 0x1A5 },
{ 0x1A5, LOWER_CASE, 0x1A4 },
{ 0x1A6, UPPER_CASE, 0x280 },
{ 0x1A7, UPPER_CASE, 0x1A8 },
{ 0x1A8, LOWER_CASE, 0x1A7 },
{ 0x1A9, UPPER_CASE, 0x283 },
{ 0x1AC, UPPER_CASE, 0x1AD },
{ 0x1AD, LOWER_CASE, 0x1AC },
{ 0x1AE, UPPER_CASE, 0x288 },
{ 0x1AF, UPPER_CASE, 0x1B0 },
{ 0x1B0, LOWER_CASE, 0x1AF },
{ 0x1B1, UPPER_CASE, 0x28A },
{ 0x1B2, UPPER_CASE, 0x28B },
{ 0x1B3, UPPER_CASE, 0x1B4 },
{ 0x1B4, LOWER_CASE, 0x1B3 },
{ 0x1B5, UPPER_CASE, 0x1B6 },
{ 0x1B6, LOWER_CASE, 0x1B5 },
{ 0x1B7, UPPER_CASE, 0x292 },
{ 0x1B8, UPPER_CASE, 0x1B9 },
{ 0x1B9, LOWER_CASE, 0x1B8 },
{ 0x1BC, UPPER_CASE, 0x1BD },
{ 0x1BD, LOWER_CASE, 0x1BC },
{ 0x1BF, LOWER_CASE, 0x1F7 },
{ 0x1C4, UPPER_CASE, 0x1C6 },
{ 0x1C5, LOWER_CASE, 0x1C4 },
{ 0x1C6, LOWER_CASE, 0x1C4 },
{ 0x1C7, UPPER_CASE, 0x1C9 },
{ 0x1C8, LOWER_CASE, 0x1C7 },
{ 0x1C9, LOWER_CASE, 0x1C7 },
{ 0x1CA, UPPER_CASE, 0x1CC },
{ 0x1CB, LOWER_CASE, 0x1CA },
{ 0x1CC, LOWER_CASE, 0x1CA },
{ 0x1CD, UPPER_CASE, 0x1CE },
{ 0x1CE, LOWER_CASE, 0x1CD },
{ 0x1CF, UPPER_CASE, 0x1D0 },
{ 0x1D0, LOWER_CASE, 0x1CF },
{ 0x1D1, UPPER_CASE, 0x1D2 },
{ 0x1D2, LOWER_CASE, 0x1D1 },
{ 0x1D3, UPPER_CASE, 0x1D4 },
{ 0x1D4, LOWER_CASE, 0x1D3 },
{ 0x1D5, UPPER_CASE, 0x1D6 },
{ 0x1D6, LOWER_CASE, 0x1D5 },
{ 0x1D7, UPPER_CASE, 0x1D8 },
{ 0x1D8, LOWER_CASE, 0x1D7 },
{ 0x1D9, UPPER_CASE, 0x1DA },
{ 0x1DA, LOWER_CASE, 0x1D9 },
{ 0x1DB, UPPER_CASE, 0x1DC },
{ 0x1DC, LOWER_CASE, 0x1DB },
{ 0x1DD, LOWER_CASE, 0x18E },
{ 0x1DE, UPPER_CASE, 0x1DF },
{ 0x1DF, LOWER_CASE, 0x1DE },
{ 0x1E0, UPPER_CASE, 0x1E1 },
{ 0x1E1, LOWER_CASE, 0x1E0 },
{ 0x1E2, UPPER_CASE, 0x1E3 },
{ 0x1E3, LOWER_CASE, 0x1E2 },
{ 0x1E4, UPPER_CASE, 0x1E5 },
{ 0x1E5, LOWER_CASE, 0x1E4 },
{ 0x1E6, UPPER_CASE, 0x1E7 },
{ 0x1E7, LOWER_CASE, 0x1E6 },
{ 0x1E8, UPPER_CASE, 0x1E9 },
{ 0x1E9, LOWER_CASE, 0x1E8 },
{ 0x1EA, UPPER_CASE, 0x1EB },
{ 0x1EB, LOWER_CASE, 0x1EA },
{ 0x1EC, UPPER_CASE, 0x1ED },
{ 0x1ED, LOWER_CASE, 0x1EC },
{ 0x1EE, UPPER_CASE, 0x1EF },
{ 0x1EF, LOWER_CASE, 0x1EE },
{ 0x1F1, UPPER_CASE, 0x1F3 },
{ 0x1F2, LOWER_CASE, 0x1F1 },
{ 0x1F3, LOWER_CASE, 0x1F1 },
{ 0x1F4, UPPER_CASE, 0x1F5 },
{ 0x1F5, LOWER_CASE, 0x1F4 },
{ 0x1F6, UPPER_CASE, 0x195 },
{ 0x1F7, UPPER_CASE, 0x1BF },
{ 0x1F8, UPPER_CASE, 0x1F9 },
{ 0x1F9, LOWER_CASE, 0x1F8 },
{ 0x1FA, UPPER_CASE, 0x1FB },
{ 0x1FB, LOWER_CASE, 0x1FA },
{ 0x1FC, UPPER_CASE, 0x1FD },
{ 0x1FD, LOWER_CASE, 0x1FC },
{ 0x1FE, UPPER_CASE, 0x1FF },
{ 0x1FF, LOWER_CASE, 0x1FE },
{ 0x200, UPPER_CASE, 0x201 },
{ 0x201, LOWER_CASE, 0x200 },
{ 0x202, UPPER_CASE, 0x203 },
{ 0x203, LOWER_CASE, 0x202 },
{ 0x204, UPPER_CASE, 0x205 },
{ 0x205, LOWER_CASE, 0x204 },
{ 0x206, UPPER_CASE, 0x207 },
{ 0x207, LOWER_CASE, 0x206 },
{ 0x208, UPPER_CASE, 0x209 },
{ 0x209, LOWER_CASE, 0x208 },
{ 0x20A, UPPER_CASE, 0x20B },
{ 0x20B, LOWER_CASE, 0x20A },
{ 0x20C, UPPER_CASE, 0x20D },
{ 0x20D, LOWER_CASE, 0x20C },
{ 0x20E, UPPER_CASE, 0x20F },
{ 0x20F, LOWER_CASE, 0x20E },
{ 0x210, UPPER_CASE, 0x211 },
{ 0x211, LOWER_CASE, 0x210 },
{ 0x212, UPPER_CASE, 0x213 },
{ 0x213, LOWER_CASE, 0x212 },
{ 0x214, UPPER_CASE, 0x215 },
{ 0x215, LOWER_CASE, 0x214 },
{ 0x216, UPPER_CASE, 0x217 },
{ 0x217, LOWER_CASE, 0x216 },
{ 0x218, UPPER_CASE, 0x219 },
{ 0x219, LOWER_CASE, 0x218 },
{ 0x21A, UPPER_CASE, 0x21B },
{ 0x21B, LOWER_CASE, 0x21A },
{ 0x21C, UPPER_CASE, 0x21D },
{ 0x21D, LOWER_CASE, 0x21C },
{ 0x21E, UPPER_CASE, 0x21F },
{ 0x21F, LOWER_CASE, 0x21E },
{ 0x220, UPPER_CASE, 0x19E },
{ 0x222, UPPER_CASE, 0x223 },
{ 0x223, LOWER_CASE, 0x222 },
{ 0x224, UPPER_CASE, 0x225 },
{ 0x225, LOWER_CASE, 0x224 },
{ 0x226, UPPER_CASE, 0x227 },
{ 0x227, LOWER_CASE, 0x226 },
{ 0x228, UPPER_CASE, 0x229 },
{ 0x229, LOWER_CASE, 0x228 },
{ 0x22A, UPPER_CASE, 0x22B },
{ 0x22B, LOWER_CASE, 0x22A },
{ 0x22C, UPPER_CASE, 0x22D },
{ 0x22D, LOWER_CASE, 0x22C },
{ 0x22E, UPPER_CASE, 0x22F },
{ 0x22F, LOWER_CASE, 0x22E },
{ 0x230, UPPER_CASE, 0x231 },
{ 0x231, LOWER_CASE, 0x230 },
{ 0x232, UPPER_CASE, 0x233 },
{ 0x233, LOWER_CASE, 0x232 },
{ 0x23A, UPPER_CASE, 0x2C65 },
{ 0x23B, UPPER_CASE, 0x23C },
{ 0x23C, LOWER_CASE, 0x23B },
{ 0x23D, UPPER_CASE, 0x19A },
{ 0x23E, UPPER_CASE, 0x2C66 },
{ 0x23F, LOWER_CASE, 0x2C7E },
{ 0x240, LOWER_CASE, 0x2C7F },
{ 0x241, UPPER_CASE, 0x242 },
{ 0x242, LOWER_CASE, 0x241 },
{ 0x243, UPPER_CASE, 0x180 },
{ 0x244, UPPER_CASE, 0x289 },
{ 0x245, UPPER_CASE, 0x28C },
{ 0x246, UPPER_CASE, 0x247 },
{ 0x247, LOWER_CASE, 0x246 },
{ 0x248, UPPER_CASE, 0x249 },
{ 0x249, LOWER_CASE, 0x248 },
{ 0x24A, UPPER_CASE, 0x24B },
{ 0x24B, LOWER_CASE, 0x24A },
{ 0x24C, UPPER_CASE, 0x24D },
{ 0x24D, LOWER_CASE, 0x24C },
{ 0x24E, UPPER_CASE, 0x24F },
{ 0x24F, LOWER_CASE, 0x24E },
{ 0x250, LOWER_CASE, 0x2C6F },
{ 0x251, LOWER_CASE, 0x2C6D },
{ 0x252, LOWER_CASE, 0x2C70 },
{ 0x253, LOWER_CASE, 0x181 },
{ 0x254, LOWER_CASE, 0x186 },
{ 0x256, LOWER_CASE, 0x189 },
{ 0x257, LOWER_CASE, 0x18A },
{ 0x259, LOWER_CASE, 0x18F },
{ 0x25B, LOWER_CASE, 0x190 },
{ 0x25C, LOWER_CASE, 0xA7AB },
{ 0x260, LOWER_CASE, 0x193 },
{ 0x261, LOWER_CASE, 0xA7AC },
{ 0x263, LOWER_CASE, 0x194 },
{ 0x265, LOWER_CASE, 0xA78D },
{ 0x266, LOWER_CASE, 0xA7AA },
{ 0x268, LOWER_CASE, 0x197 },
{ 0x269, LOWER_CASE, 0x196 },
{ 0x26A, LOWER_CASE, 0xA7AE },
{ 0x26B, LOWER_CASE, 0x2C62 },
{ 0x26C, LOWER_CASE, 0xA7AD },
{ 0x26F, LOWER_CASE, 0x19C },
{ 0x271, LOWER_CASE, 0x2C6E },
{ 0x272, LOWER_CASE, 0x19D },
{ 0x275, LOWER_CASE, 0x19F },
{ 0x27D, LOWER_CASE, 0x2C64 },
{ 0x280, LOWER_CASE, 0x1A6 },
{ 0x282, LOWER_CASE, 0xA7C5 },
{ 0x283, LOWER_CASE, 0x1A9 },
{ 0x287, LOWER_CASE, 0xA7B1 },
{ 0x288, LOWER_CASE, 0x1AE },
{ 0x289, LOWER_CASE, 0x244 },
{ 0x28A, LOWER_CASE, 0x1B1 },
{ 0x28B, LOWER_CASE, 0x1B2 },
{ 0x28C, LOWER_CASE, 0x245 },
{ 0x292, LOWER_CASE, 0x1B7 },
{ 0x29D, LOWER_CASE, 0xA7B2 },
{ 0x29E, LOWER_CASE, 0xA7B0 },
{ 0x345, LOWER_CASE, 0x399 },
{ 0x370, UPPER_CASE, 0x371 },
{ 0x371, LOWER_CASE, 0x370 },
{ 0x372, UPPER_CASE, 0x373 },
{ 0x373, LOWER_CASE, 0x372 },
{ 0x376, UPPER_CASE, 0x377 },
{ 0x377, LOWER_CASE, 0x376 },
{ 0x37B, LOWER_CASE, 0x3FD },
{ 0x37C, LOWER_CASE, 0x3FE },
{ 0x37D, LOWER_CASE, 0x3FF },
{ 0x37F, UPPER_CASE, 0x3F3 },
{ 0x386, UPPER_CASE, 0x3AC },
{ 0x388, UPPER_CASE, 0x3AD },
{ 0x389, UPPER_CASE, 0x3AE },
{ 0x38A, UPPER_CASE, 0x3AF },
{ 0x38C, UPPER_CASE, 0x3CC },
{ 0x38E, UPPER_CASE, 0x3CD },
{ 0x38F, UPPER_CASE, 0x3CE },
{ 0x391, UPPER_CASE, 0x3B1 },
{ 0x392, UPPER_CASE, 0x3B2 },
{ 0x393, UPPER_CASE, 0x3B3 },
{ 0x394, UPPER_CASE, 0x3B4 },
{ 0x395, UPPER_CASE, 0x3B5 },
{ 0x396, UPPER_CASE, 0x3B6 },
{ 0x397, UPPER_CASE, 0x3B7 },
{ 0x398, UPPER_CASE, 0x3B8 },
{ 0x399, UPPER_CASE, 0x3B9 },
{ 0x39A, UPPER_CASE, 0x3BA },
{ 0x39B, UPPER_CASE, 0x3BB },
{ 0x39C, UPPER_CASE, 0x3BC },
{ 0x39D, UPPER_CASE, 0x3BD },
{ 0x39E, UPPER_CASE, 0x3BE },
{ 0x39F, UPPER_CASE, 0x3BF },
{ 0x3A0, UPPER_CASE, 0x3C0 },
{ 0x3A1, UPPER_CASE, 0x3C1 },
{ 0x3A3, UPPER_CASE, 0x3C3 },
{ 0x3A4, UPPER_CASE, 0x3C4 },
{ 0x3A5, UPPER_CASE, 0x3C5 },
{ 0x3A6, UPPER_CASE, 0x3C6 },
{ 0x3A7, UPPER_CASE, 0x3C7 },
{ 0x3A8, UPPER_CASE, 0x3C8 },
{ 0x3A9, UPPER_CASE, 0x3C9 },
{ 0x3AA, UPPER_CASE, 0x3CA },
{ 0x3AB, UPPER_CASE, 0x3CB },
{ 0x3AC, LOWER_CASE, 0x386 },
{ 0x3AD, LOWER_CASE, 0x388 },
{ 0x3AE, LOWER_CASE, 0x389 },
{ 0x3AF, LOWER_CASE, 0x38A },
{ 0x3B1, LOWER_CASE, 0x391 },
{ 0x3B2, LOWER_CASE, 0x392 },
{ 0x3B3, LOWER_CASE, 0x393 },
{ 0x3B4, LOWER_CASE, 0x394 },
{ 0x3B5, LOWER_CASE, 0x395 },
{ 0x3B6, LOWER_CASE, 0x396 },
{ 0x3B7, LOWER_CASE, 0x397 },
{ 0x3B8, LOWER_CASE, 0x398 },
{ 0x3B9, LOWER_CASE, 0x399 },
{ 0x3BA, LOWER_CASE, 0x39A },
{ 0x3BB, LOWER_CASE, 0x39B },
{ 0x3BC, LOWER_CASE, 0x39C },
{ 0x3BD, LOWER_CASE, 0x39D },
{ 0x3BE, LOWER_CASE, 0x39E },
{ 0x3BF, LOWER_CASE, 0x39F },
{ 0x3C0, LOWER_CASE, 0x3A0 },
{ 0x3C1, LOWER_CASE, 0x3A1 },
{ 0x3C2, LOWER_CASE, 0x3A3 },
{ 0x3C3, LOWER_CASE, 0x3A3 },
{ 0x3C4, LOWER_CASE, 0x3A4 },
{ 0x3C5, LOWER_CASE, 0x3A5 },
{ 0x3C6, LOWER_CASE, 0x3A6 },
{ 0x3C7, LOWER_CASE, 0x3A7 },
{ 0x3C8, LOWER_CASE, 0x3A8 },
{ 0x3C9, LOWER_CASE, 0x3A9 },
{ 0x3CA, LOWER_CASE, 0x3AA },
{ 0x3CB, LOWER_CASE, 0x3AB },
{ 0x3CC, LOWER_CASE, 0x38C },
{ 0x3CD, LOWER_CASE, 0x38E },
{ 0x3CE, LOWER_CASE, 0x38F },
{ 0x3CF, UPPER_CASE, 0x3D7 },
{ 0x3D0, LOWER_CASE, 0x392 },
{ 0x3D1, LOWER_CASE, 0x398 },
{ 0x3D5, LOWER_CASE, 0x3A6 },
{ 0x3D6, LOWER_CASE, 0x3A0 },
{ 0x3D7, LOWER_CASE, 0x3CF },
{ 0x3D8, UPPER_CASE, 0x3D9 },
{ 0x3D9, LOWER_CASE, 0x3D8 },
{ 0x3DA, UPPER_CASE, 0x3DB },
{ 0x3DB, LOWER_CASE, 0x3DA },
{ 0x3DC, UPPER_CASE, 0x3DD },
{ 0x3DD, LOWER_CASE, 0x3DC },
{ 0x3DE, UPPER_CASE, 0x3DF },
{ 0x3DF, LOWER_CASE, 0x3DE },
{ 0x3E0, UPPER_CASE, 0x3E1 },
{ 0x3E1, LOWER_CASE, 0x3E0 },
{ 0x3E2, UPPER_CASE, 0x3E3 },
{ 0x3E3, LOWER_CASE, 0x3E2 },
{ 0x3E4, UPPER_CASE, 0x3E5 },
{ 0x3E5, LOWER_CASE, 0x3E4 },
{ 0x3E6, UPPER_CASE, 0x3E7 },
{ 0x3E7, LOWER_CASE, 0x3E6 },
{ 0x3E8, UPPER_CASE, 0x3E9 },
{ 0x3E9, LOWER_CASE, 0x3E8 },
{ 0x3EA, UPPER_CASE, 0x3EB },
{ 0x3EB, LOWER_CASE, 0x3EA },
{ 0x3EC, UPPER_CASE, 0x3ED },
{ 0x3ED, LOWER_CASE, 0x3EC },
{ 0x3EE, UPPER_CASE, 0x3EF },
{ 0x3EF, LOWER_CASE, 0x3EE },
{ 0x3F0, LOWER_CASE, 0x39A },
{ 0x3F1, LOWER_CASE, 0x3A1 },
{ 0x3F2, LOWER_CASE, 0x3F9 },
{ 0x3F3, LOWER_CASE, 0x37F },
{ 0x3F4, UPPER_CASE, 0x3B8 },
{ 0x3F5, LOWER_CASE, 0x395 },
{ 0x3F7, UPPER_CASE, 0x3F8 },
{ 0x3F8, LOWER_CASE, 0x3F7 },
{ 0x3F9, UPPER_CASE, 0x3F2 },
{ 0x3FA, UPPER_CASE, 0x3FB },
{ 0x3FB, LOWER_CASE, 0x3FA },
{ 0x3FD, UPPER_CASE, 0x37B },
{ 0x3FE, UPPER_CASE, 0x37C },
{ 0x3FF, UPPER_CASE, 0x37D },
{ 0x400, UPPER_CASE, 0x450 },
{ 0x401, UPPER_CASE, 0x451 },
{ 0x402, UPPER_CASE, 0x452 },
{ 0x403, UPPER_CASE, 0x453 },
{ 0x404, UPPER_CASE, 0x454 },
{ 0x405, UPPER_CASE, 0x455 },
{ 0x406, UPPER_CASE, 0x456 },
{ 0x407, UPPER_CASE, 0x457 },
{ 0x408, UPPER_CASE, 0x458 },
{ 0x409, UPPER_CASE, 0x459 },
{ 0x40A, UPPER_CASE, 0x45A },
{ 0x40B, UPPER_CASE, 0x45B },
{ 0x40C, UPPER_CASE, 0x45C },
{ 0x40D, UPPER_CASE, 0x45D },
{ 0x40E, UPPER_CASE, 0x45E },
{ 0x40F, UPPER_CASE, 0x45F },
{ 0x410, UPPER_CASE, 0x430 },
{ 0x411, UPPER_CASE, 0x431 },
{ 0x412, UPPER_CASE, 0x432 },
{ 0x413, UPPER_CASE, 0x433 },
{ 0x414, UPPER_CASE, 0x434 },
{ 0x415, UPPER_CASE, 0x435 },
{ 0x416, UPPER_CASE, 0x436 },
{ 0x417, UPPER_CASE, 0x437 },
{ 0x418, UPPER_CASE, 0x438 },
{ 0x419, UPPER_CASE, 0x439 },
{ 0x41A, UPPER_CASE, 0x43A },
{ 0x41B, UPPER_CASE, 0x43B },
{ 0x41C, UPPER_CASE, 0x43C },
{ 0x41D, UPPER_CASE, 0x43D },
{ 0x41E, UPPER_CASE, 0x43E },
{ 0x41F, UPPER_CASE, 0x43F },
{ 0x420, UPPER_CASE, 0x440 },
{ 0x421, UPPER_CASE, 0x441 },
{ 0x422, UPPER_CASE, 0x442 },
{ 0x423, UPPER_CASE, 0x443 },
{ 0x424, UPPER_CASE, 0x444 },
{ 0x425, UPPER_CASE, 0x445 },
{ 0x426, UPPER_CASE, 0x446 },
{ 0x427, UPPER_CASE, 0x447 },
{ 0x428, UPPER_CASE, 0x448 },
{ 0x429, UPPER_CASE, 0x449 },
{ 0x42A, UPPER_CASE, 0x44A },
{ 0x42B, UPPER_CASE, 0x44B },
{ 0x42C, UPPER_CASE, 0x44C },
{ 0x42D, UPPER_CASE, 0x44D },
{ 0x42E, UPPER_CASE, 0x44E },
{ 0x42F, UPPER_CASE, 0x44F },
{ 0x430, LOWER_CASE, 0x410 },
{ 0x431, LOWER_CASE, 0x411 },
{ 0x432, LOWER_CASE, 0x412 },
{ 0x433, LOWER_CASE, 0x413 },
{ 0x434, LOWER_CASE, 0x414 },
{ 0x435, LOWER_CASE, 0x415 },
{ 0x436, LOWER_CASE, 0x416 },
{ 0x437, LOWER_CASE, 0x417 },
{ 0x438, LOWER_CASE, 0x418 },
{ 0x439, LOWER_CASE, 0x419 },
{ 0x43A, LOWER_CASE, 0x41A },
{ 0x43B, LOWER_CASE, 0x41B },
{ 0x43C, LOWER_CASE, 0x41C },
{ 0x43D, LOWER_CASE, 0x41D },
{ 0x43E, LOWER_CASE, 0x41E },
{ 0x43F, LOWER_CASE, 0x41F },
{ 0x440, LOWER_CASE, 0x420 },
{ 0x441, LOWER_CASE, 0x421 },
{ 0x442, LOWER_CASE, 0x422 },
{ 0x443, LOWER_CASE, 0x423 },
{ 0x444, LOWER_CASE, 0x424 },
{ 0x445, LOWER_CASE, 0x425 },
{ 0x446, LOWER_CASE, 0x426 },
{ 0x447, LOWER_CASE, 0x427 },
{ 0x448, LOWER_CASE, 0x428 },
{ 0x449, LOWER_CASE, 0x429 },
{ 0x44A, LOWER_CASE, 0x42A },
{ 0x44B, LOWER_CASE, 0x42B },
{ 0x44C, LOWER_CASE, 0x42C },
{ 0x44D, LOWER_CASE, 0x42D },
{ 0x44E, LOWER_CASE, 0x42E },
{ 0x44F, LOWER_CASE, 0x42F },
{ 0x450, LOWER_CASE, 0x400 },
{ 0x451, LOWER_CASE, 0x401 },
{ 0x452, LOWER_CASE, 0x402 },
{ 0x453, LOWER_CASE, 0x403 },
{ 0x454, LOWER_CASE, 0x404 },
{ 0x455, LOWER_CASE, 0x405 },
{ 0x456, LOWER_CASE, 0x406 },
{ 0x457, LOWER_CASE, 0x407 },
{ 0x458, LOWER_CASE, 0x408 },
{ 0x459, LOWER_CASE, 0x409 },
{ 0x45A, LOWER_CASE, 0x40A },
{ 0x45B, LOWER_CASE, 0x40B },
{ 0x45C, LOWER_CASE, 0x40C },
{ 0x45D, LOWER_CASE, 0x40D },
{ 0x45E, LOWER_CASE, 0x40E },
{ 0x45F, LOWER_CASE, 0x40F },
{ 0x460, UPPER_CASE, 0x461 },
{ 0x461, LOWER_CASE, 0x460 },
{ 0x462, UPPER_CASE, 0x463 },
{ 0x463, LOWER_CASE, 0x462 },
{ 0x464, UPPER_CASE, 0x465 },
{ 0x465, LOWER_CASE, 0x464 },
{ 0x466, UPPER_CASE, 0x467 },
{ 0x467, LOWER_CASE, 0x466 },
{ 0x468, UPPER_CASE, 0x469 },
{ 0x469, LOWER_CASE, 0x468 },
{ 0x46A, UPPER_CASE, 0x46B },
{ 0x46B, LOWER_CASE, 0x46A },
{ 0x46C, UPPER_CASE, 0x46D },
{ 0x46D, LOWER_CASE, 0x46C },
{ 0x46E, UPPER_CASE, 0x46F },
{ 0x46F, LOWER_CASE, 0x46E },
{ 0x470, UPPER_CASE, 0x471 },
{ 0x471, LOWER_CASE, 0x470 },
{ 0x472, UPPER_CASE, 0x473 },
{ 0x473, LOWER_CASE, 0x472 },
{ 0x474, UPPER_CASE, 0x475 },
{ 0x475, LOWER_CASE, 0x474 },
{ 0x476, UPPER_CASE, 0x477 },
{ 0x477, LOWER_CASE, 0x476 },
{ 0x478, UPPER_CASE, 0x479 },
{ 0x479, LOWER_CASE, 0x478 },
{ 0x47A, UPPER_CASE, 0x47B },
{ 0x47B, LOWER_CASE, 0x47A },
{ 0x47C, UPPER_CASE, 0x47D },
{ 0x47D, LOWER_CASE, 0x47C },
{ 0x47E, UPPER_CASE, 0x47F },
{ 0x47F, LOWER_CASE, 0x47E },
{ 0x480, UPPER_CASE, 0x481 },
{ 0x481, LOWER_CASE, 0x480 },
{ 0x48A, UPPER_CASE, 0x48B },
{ 0x48B, LOWER_CASE, 0x48A },
{ 0x48C, UPPER_CASE, 0x48D },
{ 0x48D, LOWER_CASE, 0x48C },
{ 0x48E, UPPER_CASE, 0x48F },
{ 0x48F, LOWER_CASE, 0x48E },
{ 0x490, UPPER_CASE, 0x491 },
{ 0x491, LOWER_CASE, 0x490 },
{ 0x492, UPPER_CASE, 0x493 },
{ 0x493, LOWER_CASE, 0x492 },
{ 0x494, UPPER_CASE, 0x495 },
{ 0x495, LOWER_CASE, 0x494 },
{ 0x496, UPPER_CASE, 0x497 },
{ 0x497, LOWER_CASE, 0x496 },
{ 0x498, UPPER_CASE, 0x499 },
{ 0x499, LOWER_CASE, 0x498 },
{ 0x49A, UPPER_CASE, 0x49B },
{ 0x49B, LOWER_CASE, 0x49A },
{ 0x49C, UPPER_CASE, 0x49D },
{ 0x49D, LOWER_CASE, 0x49C },
{ 0x49E, UPPER_CASE, 0x49F },
{ 0x49F, LOWER_CASE, 0x49E },
{ 0x4A0, UPPER_CASE, 0x4A1 },
{ 0x4A1, LOWER_CASE, 0x4A0 },
{ 0x4A2, UPPER_CASE, 0x4A3 },
{ 0x4A3, LOWER_CASE, 0x4A2 },
{ 0x4A4, UPPER_CASE, 0x4A5 },
{ 0x4A5, LOWER_CASE, 0x4A4 },
{ 0x4A6, UPPER_CASE, 0x4A7 },
{ 0x4A7, LOWER_CASE, 0x4A6 },
{ 0x4A8, UPPER_CASE, 0x4A9 },
{ 0x4A9, LOWER_CASE, 0x4A8 },
{ 0x4AA, UPPER_CASE, 0x4AB },
{ 0x4AB, LOWER_CASE, 0x4AA },
{ 0x4AC, UPPER_CASE, 0x4AD },
{ 0x4AD, LOWER_CASE, 0x4AC },
{ 0x4AE, UPPER_CASE, 0x4AF },
{ 0x4AF, LOWER_CASE, 0x4AE },
{ 0x4B0, UPPER_CASE, 0x4B1 },
{ 0x4B1, LOWER_CASE, 0x4B0 },
{ 0x4B2, UPPER_CASE, 0x4B3 },
{ 0x4B3, LOWER_CASE, 0x4B2 },
{ 0x4B4, UPPER_CASE, 0x4B5 },
{ 0x4B5, LOWER_CASE, 0x4B4 },
{ 0x4B6, UPPER_CASE, 0x4B7 },
{ 0x4B7, LOWER_CASE, 0x4B6 },
{ 0x4B8, UPPER_CASE, 0x4B9 },
{ 0x4B9, LOWER_CASE, 0x4B8 },
{ 0x4BA, UPPER_CASE, 0x4BB },
{ 0x4BB, LOWER_CASE, 0x4BA },
{ 0x4BC, UPPER_CASE, 0x4BD },
{ 0x4BD, LOWER_CASE, 0x4BC },
{ 0x4BE, UPPER_CASE, 0x4BF },
{ 0x4BF, LOWER_CASE, 0x4BE },
{ 0x4C0, UPPER_CASE, 0x4CF },
{ 0x4C1, UPPER_CASE, 0x4C2 },
{ 0x4C2, LOWER_CASE, 0x4C1 },
{ 0x4C3, UPPER_CASE, 0x4C4 },
{ 0x4C4, LOWER_CASE, 0x4C3 },
{ 0x4C5, UPPER_CASE, 0x4C6 },
{ 0x4C6, LOWER_CASE, 0x4C5 },
{ 0x4C7, UPPER_CASE, 0x4C8 },
{ 0x4C8, LOWER_CASE, 0x4C7 },
{ 0x4C9, UPPER_CASE, 0x4CA },
{ 0x4CA, LOWER_CASE, 0x4C9 },
{ 0x4CB, UPPER_CASE, 0x4CC },
{ 0x4CC, LOWER_CASE, 0x4CB },
{ 0x4CD, UPPER_CASE, 0x4CE },
{ 0x4CE, LOWER_CASE, 0x4CD },
{ 0x4CF, LOWER_CASE, 0x4C0 },
{ 0x4D0, UPPER_CASE, 0x4D1 },
{ 0x4D1, LOWER_CASE, 0x4D0 },
{ 0x4D2, UPPER_CASE, 0x4D3 },
{ 0x4D3, LOWER_CASE, 0x4D2 },
{ 0x4D4, UPPER_CASE, 0x4D5 },
{ 0x4D5, LOWER_CASE, 0x4D4 },
{ 0x4D6, UPPER_CASE, 0x4D7 },
{ 0x4D7, LOWER_CASE, 0x4D6 },
{ 0x4D8, UPPER_CASE, 0x4D9 },
{ 0x4D9, LOWER_CASE, 0x4D8 },
{ 0x4DA, UPPER_CASE, 0x4DB },
{ 0x4DB, LOWER_CASE, 0x4DA },
{ 0x4DC, UPPER_CASE, 0x4DD },
{ 0x4DD, LOWER_CASE, 0x4DC },
{ 0x4DE, UPPER_CASE, 0x4DF },
{ 0x4DF, LOWER_CASE, 0x4DE },
{ 0x4E0, UPPER_CASE, 0x4E1 },
{ 0x4E1, LOWER_CASE, 0x4E0 },
{ 0x4E2, UPPER_CASE, 0x4E3 },
{ 0x4E3, LOWER_CASE, 0x4E2 },
{ 0x4E4, UPPER_CASE, 0x4E5 },
{ 0x4E5, LOWER_CASE, 0x4E4 },
{ 0x4E6, UPPER_CASE, 0x4E7 },
{ 0x4E7, LOWER_CASE, 0x4E6 },
{ 0x4E8, UPPER_CASE, 0x4E9 },
{ 0x4E9, LOWER_CASE, 0x4E8 },
{ 0x4EA, UPPER_CASE, 0x4EB },
{ 0x4EB, LOWER_CASE, 0x4EA },
{ 0x4EC, UPPER_CASE, 0x4ED },
{ 0x4ED, LOWER_CASE, 0x4EC },
{ 0x4EE, UPPER_CASE, 0x4EF },
{ 0x4EF, LOWER_CASE, 0x4EE },
{ 0x4F0, UPPER_CASE, 0x4F1 },
{ 0x4F1, LOWER_CASE, 0x4F0 },
{ 0x4F2, UPPER_CASE, 0x4F3 },
{ 0x4F3, LOWER_CASE, 0x4F2 },
{ 0x4F4, UPPER_CASE, 0x4F5 },
{ 0x4F5, LOWER_CASE, 0x4F4 },
{ 0x4F6, UPPER_CASE, 0x4F7 },
{ 0x4F7, LOWER_CASE, 0x4F6 },
{ 0x4F8, UPPER_CASE, 0x4F9 },
{ 0x4F9, LOWER_CASE, 0x4F8 },
{ 0x4FA, UPPER_CASE, 0x4FB },
{ 0x4FB, LOWER_CASE, 0x4FA },
{ 0x4FC, UPPER_CASE, 0x4FD },
{ 0x4FD, LOWER_CASE, 0x4FC },
{ 0x4FE, UPPER_CASE, 0x4FF },
{ 0x4FF, LOWER_CASE, 0x4FE },
{ 0x500, UPPER_CASE, 0x501 },
{ 0x501, LOWER_CASE, 0x500 },
{ 0x502, UPPER_CASE, 0x503 },
{ 0x503, LOWER_CASE, 0x502 },
{ 0x504, UPPER_CASE, 0x505 },
{ 0x505, LOWER_CASE, 0x504 },
{ 0x506, UPPER_CASE, 0x507 },
{ 0x507, LOWER_CASE, 0x506 },
{ 0x508, UPPER_CASE, 0x509 },
{ 0x509, LOWER_CASE, 0x508 },
{ 0x50A, UPPER_CASE, 0x50B },
{ 0x50B, LOWER_CASE, 0x50A },
{ 0x50C, UPPER_CASE, 0x50D },
{ 0x50D, LOWER_CASE, 0x50C },
{ 0x50E, UPPER_CASE, 0x50F },
{ 0x50F, LOWER_CASE, 0x50E },
{ 0x510, UPPER_CASE, 0x511 },
{ 0x511, LOWER_CASE, 0x510 },
{ 0x512, UPPER_CASE, 0x513 },
{ 0x513, LOWER_CASE, 0x512 },
{ 0x514, UPPER_CASE, 0x515 },
{ 0x515, LOWER_CASE, 0x514 },
{ 0x516, UPPER_CASE, 0x517 },
{ 0x517, LOWER_CASE, 0x516 },
{ 0x518, UPPER_CASE, 0x519 },
{ 0x519, LOWER_CASE, 0x518 },
{ 0x51A, UPPER_CASE, 0x51B },
{ 0x51B, LOWER_CASE, 0x51A },
{ 0x51C, UPPER_CASE, 0x51D },
{ 0x51D, LOWER_CASE, 0x51C },
{ 0x51E, UPPER_CASE, 0x51F },
{ 0x51F, LOWER_CASE, 0x51E },
{ 0x520, UPPER_CASE, 0x521 },
{ 0x521, LOWER_CASE, 0x520 },
{ 0x522, UPPER_CASE, 0x523 },
{ 0x523, LOWER_CASE, 0x522 },
{ 0x524, UPPER_CASE, 0x525 },
{ 0x525, LOWER_CASE, 0x524 },
{ 0x526, UPPER_CASE, 0x527 },
{ 0x527, LOWER_CASE, 0x526 },
{ 0x528, UPPER_CASE, 0x529 },
{ 0x529, LOWER_CASE, 0x528 },
{ 0x52A, UPPER_CASE, 0x52B },
{ 0x52B, LOWER_CASE, 0x52A },
{ 0x52C, UPPER_CASE, 0x52D },
{ 0x52D, LOWER_CASE, 0x52C },
{ 0x52E, UPPER_CASE, 0x52F },
{ 0x52F, LOWER_CASE, 0x52E },
{ 0x531, UPPER_CASE, 0x561 },
{ 0x532, UPPER_CASE, 0x562 },
{ 0x533, UPPER_CASE, 0x563 },
{ 0x534, UPPER_CASE, 0x564 },
{ 0x535, UPPER_CASE, 0x565 },
{ 0x536, UPPER_CASE, 0x566 },
{ 0x537, UPPER_CASE, 0x567 },
{ 0x538, UPPER_CASE, 0x568 },
{ 0x539, UPPER_CASE, 0x569 },
{ 0x53A, UPPER_CASE, 0x56A },
{ 0x53B, UPPER_CASE, 0x56B },
{ 0x53C, UPPER_CASE, 0x56C },
{ 0x53D, UPPER_CASE, 0x56D },
{ 0x53E, UPPER_CASE, 0x56E },
{ 0x53F, UPPER_CASE, 0x56F },
{ 0x540, UPPER_CASE, 0x570 },
{ 0x541, UPPER_CASE, 0x571 },
{ 0x542, UPPER_CASE, 0x572 },
{ 0x543, UPPER_CASE, 0x573 },
{ 0x544, UPPER_CASE, 0x574 },
{ 0x545, UPPER_CASE, 0x575 },
{ 0x546, UPPER_CASE, 0x576 },
{ 0x547, UPPER_CASE, 0x577 },
{ 0x548, UPPER_CASE, 0x578 },
{ 0x549, UPPER_CASE, 0x579 },
{ 0x54A, UPPER_CASE, 0x57A },
{ 0x54B, UPPER_CASE, 0x57B },
{ 0x54C, UPPER_CASE, 0x57C },
{ 0x54D, UPPER_CASE, 0x57D },
{ 0x54E, UPPER_CASE, 0x57E },
{ 0x54F, UPPER_CASE, 0x57F },
{ 0x550, UPPER_CASE, 0x580 },
{ 0x551, UPPER_CASE, 0x581 },
{ 0x552, UPPER_CASE, 0x582 },
{ 0x553, UPPER_CASE, 0x583 },
{ 0x554, UPPER_CASE, 0x584 },
{ 0x555, UPPER_CASE, 0x585 },
{ 0x556, UPPER_CASE, 0x586 },
{ 0x561, LOWER_CASE, 0x531 },
{ 0x562, LOWER_CASE, 0x532 },
{ 0x563, LOWER_CASE, 0x533 },
{ 0x564, LOWER_CASE, 0x534 },
{ 0x565, LOWER_CASE, 0x535 },
{ 0x566, LOWER_CASE, 0x536 },
{ 0x567, LOWER_CASE, 0x537 },
{ 0x568, LOWER_CASE, 0x538 },
{ 0x569, LOWER_CASE, 0x539 },
{ 0x56A, LOWER_CASE, 0x53A },
{ 0x56B, LOWER_CASE, 0x53B },
{ 0x56C, LOWER_CASE, 0x53C },
{ 0x56D, LOWER_CASE, 0x53D },
{ 0x56E, LOWER_CASE, 0x53E },
{ 0x56F, LOWER_CASE, 0x53F },
{ 0x570, LOWER_CASE, 0x540 },
{ 0x571, LOWER_CASE, 0x541 },
{ 0x572, LOWER_CASE, 0x542 },
{ 0x573, LOWER_CASE, 0x543 },
{ 0x574, LOWER_CASE, 0x544 },
{ 0x575, LOWER_CASE, 0x545 },
{ 0x576, LOWER_CASE, 0x546 },
{ 0x577, LOWER_CASE, 0x547 },
{ 0x578, LOWER_CASE, 0x548 },
{ 0x579, LOWER_CASE, 0x549 },
{ 0x57A, LOWER_CASE, 0x54A },
{ 0x57B, LOWER_CASE, 0x54B },
{ 0x57C, LOWER_CASE, 0x54C },
{ 0x57D, LOWER_CASE, 0x54D },
{ 0x57E, LOWER_CASE, 0x54E },
{ 0x57F, LOWER_CASE, 0x54F },
{ 0x580, LOWER_CASE, 0x550 },
{ 0x581, LOWER_CASE, 0x551 },
{ 0x582, LOWER_CASE, 0x552 },
{ 0x583, LOWER_CASE, 0x553 },
{ 0x584, LOWER_CASE, 0x554 },
{ 0x585, LOWER_CASE, 0x555 },
{ 0x586, LOWER_CASE, 0x556 },
{ 0x10A0, UPPER_CASE, 0x2D00 },
{ 0x10A1, UPPER_CASE, 0x2D01 },
{ 0x10A2, UPPER_CASE, 0x2D02 },
{ 0x10A3, UPPER_CASE, 0x2D03 },
{ 0x10A4, UPPER_CASE, 0x2D04 },
{ 0x10A5, UPPER_CASE, 0x2D05 },
{ 0x10A6, UPPER_CASE, 0x2D06 },
{ 0x10A7, UPPER_CASE, 0x2D07 },
{ 0x10A8, UPPER_CASE, 0x2D08 },
{ 0x10A9, UPPER_CASE, 0x2D09 },
{ 0x10AA, UPPER_CASE, 0x2D0A },
{ 0x10AB, UPPER_CASE, 0x2D0B },
{ 0x10AC, UPPER_CASE, 0x2D0C },
{ 0x10AD, UPPER_CASE, 0x2D0D },
{ 0x10AE, UPPER_CASE, 0x2D0E },
{ 0x10AF, UPPER_CASE, 0x2D0F },
{ 0x10B0, UPPER_CASE, 0x2D10 },
{ 0x10B1, UPPER_CASE, 0x2D11 },
{ 0x10B2, UPPER_CASE, 0x2D12 },
{ 0x10B3, UPPER_CASE, 0x2D13 },
{ 0x10B4, UPPER_CASE, 0x2D14 },
{ 0x10B5, UPPER_CASE, 0x2D15 },
{ 0x10B6, UPPER_CASE, 0x2D16 },
{ 0x10B7, UPPER_CASE, 0x2D17 },
{ 0x10B8, UPPER_CASE, 0x2D18 },
{ 0x10B9, UPPER_CASE, 0x2D19 },
{ 0x10BA, UPPER_CASE, 0x2D1A },
{ 0x10BB, UPPER_CASE, 0x2D1B },
{ 0x10BC, UPPER_CASE, 0x2D1C },
{ 0x10BD, UPPER_CASE, 0x2D1D },
{ 0x10BE, UPPER_CASE, 0x2D1E },
{ 0x10BF, UPPER_CASE, 0x2D1F },
{ 0x10C0, UPPER_CASE, 0x2D20 },
{ 0x10C1, UPPER_CASE, 0x2D21 },
{ 0x10C2, UPPER_CASE, 0x2D22 },
{ 0x10C3, UPPER_CASE, 0x2D23 },
{ 0x10C4, UPPER_CASE, 0x2D24 },
{ 0x10C5, UPPER_CASE, 0x2D25 },
{ 0x10C7, UPPER_CASE, 0x2D27 },
{ 0x10CD, UPPER_CASE, 0x2D2D },
{ 0x10D0, LOWER_CASE, 0x1C90 },
{ 0x10D1, LOWER_CASE, 0x1C91 },
{ 0x10D2, LOWER_CASE, 0x1C92 },
{ 0x10D3, LOWER_CASE, 0x1C93 },
{ 0x10D4, LOWER_CASE, 0x1C94 },
{ 0x10D5, LOWER_CASE, 0x1C95 },
{ 0x10D6, LOWER_CASE, 0x1C96 },
{ 0x10D7, LOWER_CASE, 0x1C97 },
{ 0x10D8, LOWER_CASE, 0x1C98 },
{ 0x10D9, LOWER_CASE, 0x1C99 },
{ 0x10DA, LOWER_CASE, 0x1C9A },
{ 0x10DB, LOWER_CASE, 0x1C9B },
{ 0x10DC, LOWER_CASE, 0x1C9C },
{ 0x10DD, LOWER_CASE, 0x1C9D },
{ 0x10DE, LOWER_CASE, 0x1C9E },
{ 0x10DF, LOWER_CASE, 0x1C9F },
{ 0x10E0, LOWER_CASE, 0x1CA0 },
{ 0x10E1, LOWER_CASE, 0x1CA1 },
{ 0x10E2, LOWER_CASE, 0x1CA2 },
{ 0x10E3, LOWER_CASE, 0x1CA3 },
{ 0x10E4, LOWER_CASE, 0x1CA4 },
{ 0x10E5, LOWER_CASE, 0x1CA5 },
{ 0x10E6, LOWER_CASE, 0x1CA6 },
{ 0x10E7, LOWER_CASE, 0x1CA7 },
{ 0x10E8, LOWER_CASE, 0x1CA8 },
{ 0x10E9, LOWER_CASE, 0x1CA9 },
{ 0x10EA, LOWER_CASE, 0x1CAA },
{ 0x10EB, LOWER_CASE, 0x1CAB },
{ 0x10EC, LOWER_CASE, 0x1CAC },
{ 0x10ED, LOWER_CASE, 0x1CAD },
{ 0x10EE, LOWER_CASE, 0x1CAE },
{ 0x10EF, LOWER_CASE, 0x1CAF },
{ 0x10F0, LOWER_CASE, 0x1CB0 },
{ 0x10F1, LOWER_CASE, 0x1CB1 },
{ 0x10F2, LOWER_CASE, 0x1CB2 },
{ 0x10F3, LOWER_CASE, 0x1CB3 },
{ 0x10F4, LOWER_CASE, 0x1CB4 },
{ 0x10F5, LOWER_CASE, 0x1CB5 },
{ 0x10F6, LOWER_CASE, 0x1CB6 },
{ 0x10F7, LOWER_CASE, 0x1CB7 },
{ 0x10F8, LOWER_CASE, 0x1CB8 },
{ 0x10F9, LOWER_CASE, 0x1CB9 },
{ 0x10FA, LOWER_CASE, 0x1CBA },
{ 0x10FD, LOWER_CASE, 0x1CBD },
{ 0x10FE, LOWER_CASE, 0x1CBE },
{ 0x10FF, LOWER_CASE, 0x1CBF },
{ 0x13A0, UPPER_CASE, 0xAB70 },
{ 0x13A1, UPPER_CASE, 0xAB71 },
{ 0x13A2, UPPER_CASE, 0xAB72 },
{ 0x13A3, UPPER_CASE, 0xAB73 },
{ 0x13A4, UPPER_CASE, 0xAB74 },
{ 0x13A5, UPPER_CASE, 0xAB75 },
{ 0x13A6, UPPER_CASE, 0xAB76 },
{ 0x13A7, UPPER_CASE, 0xAB77 },
{ 0x13A8, UPPER_CASE, 0xAB78 },
{ 0x13A9, UPPER_CASE, 0xAB79 },
{ 0x13AA, UPPER_CASE, 0xAB7A },
{ 0x13AB, UPPER_CASE, 0xAB7B },
{ 0x13AC, UPPER_CASE, 0xAB7C },
{ 0x13AD, UPPER_CASE, 0xAB7D },
{ 0x13AE, UPPER_CASE, 0xAB7E },
{ 0x13AF, UPPER_CASE, 0xAB7F },
{ 0x13B0, UPPER_CASE, 0xAB80 },
{ 0x13B1, UPPER_CASE, 0xAB81 },
{ 0x13B2, UPPER_CASE, 0xAB82 },
{ 0x13B3, UPPER_CASE, 0xAB83 },
{ 0x13B4, UPPER_CASE, 0xAB84 },
{ 0x13B5, UPPER_CASE, 0xAB85 },
{ 0x13B6, UPPER_CASE, 0xAB86 },
{ 0x13B7, UPPER_CASE, 0xAB87 },
{ 0x13B8, UPPER_CASE, 0xAB88 },
{ 0x13B9, UPPER_CASE, 0xAB89 },
{ 0x13BA, UPPER_CASE, 0xAB8A },
{ 0x13BB, UPPER_CASE, 0xAB8B },
{ 0x13BC, UPPER_CASE, 0xAB8C },
{ 0x13BD, UPPER_CASE, 0xAB8D },
{ 0x13BE, UPPER_CASE, 0xAB8E },
{ 0x13BF, UPPER_CASE, 0xAB8F },
{ 0x13C0, UPPER_CASE, 0xAB90 },
{ 0x13C1, UPPER_CASE, 0xAB91 },
{ 0x13C2, UPPER_CASE, 0xAB92 },
{ 0x13C3, UPPER_CASE, 0xAB93 },
{ 0x13C4, UPPER_CASE, 0xAB94 },
{ 0x13C5, UPPER_CASE, 0xAB95 },
{ 0x13C6, UPPER_CASE, 0xAB96 },
{ 0x13C7, UPPER_CASE, 0xAB97 },
{ 0x13C8, UPPER_CASE, 0xAB98 },
{ 0x13C9, UPPER_CASE, 0xAB99 },
{ 0x13CA, UPPER_CASE, 0xAB9A },
{ 0x13CB, UPPER_CASE, 0xAB9B },
{ 0x13CC, UPPER_CASE, 0xAB9C },
{ 0x13CD, UPPER_CASE, 0xAB9D },
{ 0x13CE, UPPER_CASE, 0xAB9E },
{ 0x13CF, UPPER_CASE, 0xAB9F },
{ 0x13D0, UPPER_CASE, 0xABA0 },
{ 0x13D1, UPPER_CASE, 0xABA1 },
{ 0x13D2, UPPER_CASE, 0xABA2 },
{ 0x13D3, UPPER_CASE, 0xABA3 },
{ 0x13D4, UPPER_CASE, 0xABA4 },
{ 0x13D5, UPPER_CASE, 0xABA5 },
{ 0x13D6, UPPER_CASE, 0xABA6 },
{ 0x13D7, UPPER_CASE, 0xABA7 },
{ 0x13D8, UPPER_CASE, 0xABA8 },
{ 0x13D9, UPPER_CASE, 0xABA9 },
{ 0x13DA, UPPER_CASE, 0xABAA },
{ 0x13DB, UPPER_CASE, 0xABAB },
{ 0x13DC, UPPER_CASE, 0xABAC },
{ 0x13DD, UPPER_CASE, 0xABAD },
{ 0x13DE, UPPER_CASE, 0xABAE },
{ 0x13DF, UPPER_CASE, 0xABAF },
{ 0x13E0, UPPER_CASE, 0xABB0 },
{ 0x13E1, UPPER_CASE, 0xABB1 },
{ 0x13E2, UPPER_CASE, 0xABB2 },
{ 0x13E3, UPPER_CASE, 0xABB3 },
{ 0x13E4, UPPER_CASE, 0xABB4 },
{ 0x13E5, UPPER_CASE, 0xABB5 },
{ 0x13E6, UPPER_CASE, 0xABB6 },
{ 0x13E7, UPPER_CASE, 0xABB7 },
{ 0x13E8, UPPER_CASE, 0xABB8 },
{ 0x13E9, UPPER_CASE, 0xABB9 },
{ 0x13EA, UPPER_CASE, 0xABBA },
{ 0x13EB, UPPER_CASE, 0xABBB },
{ 0x13EC, UPPER_CASE, 0xABBC },
{ 0x13ED, UPPER_CASE, 0xABBD },
{ 0x13EE, UPPER_CASE, 0xABBE },
{ 0x13EF, UPPER_CASE, 0xABBF },
{ 0x13F0, UPPER_CASE, 0x13F8 },
{ 0x13F1, UPPER_CASE, 0x13F9 },
{ 0x13F2, UPPER_CASE, 0x13FA },
{ 0x13F3, UPPER_CASE, 0x13FB },
{ 0x13F4, UPPER_CASE, 0x13FC },
{ 0x13F5, UPPER_CASE, 0x13FD },
{ 0x13F8, LOWER_CASE, 0x13F0 },
{ 0x13F9, LOWER_CASE, 0x13F1 },
{ 0x13FA, LOWER_CASE, 0x13F2 },
{ 0x13FB, LOWER_CASE, 0x13F3 },
{ 0x13FC, LOWER_CASE, 0x13F4 },
{ 0x13FD, LOWER_CASE, 0x13F5 },
{ 0x1C80, LOWER_CASE, 0x412 },
{ 0x1C81, LOWER_CASE, 0x414 },
{ 0x1C82, LOWER_CASE, 0x41E },
{ 0x1C83, LOWER_CASE, 0x421 },
{ 0x1C84, LOWER_CASE, 0x422 },
{ 0x1C85, LOWER_CASE, 0x422 },
{ 0x1C86, LOWER_CASE, 0x42A },
{ 0x1C87, LOWER_CASE, 0x462 },
{ 0x1C88, LOWER_CASE, 0xA64A },
{ 0x1C90, UPPER_CASE, 0x10D0 },
{ 0x1C91, UPPER_CASE, 0x10D1 },
{ 0x1C92, UPPER_CASE, 0x10D2 },
{ 0x1C93, UPPER_CASE, 0x10D3 },
{ 0x1C94, UPPER_CASE, 0x10D4 },
{ 0x1C95, UPPER_CASE, 0x10D5 },
{ 0x1C96, UPPER_CASE, 0x10D6 },
{ 0x1C97, UPPER_CASE, 0x10D7 },
{ 0x1C98, UPPER_CASE, 0x10D8 },
{ 0x1C99, UPPER_CASE, 0x10D9 },
{ 0x1C9A, UPPER_CASE, 0x10DA },
{ 0x1C9B, UPPER_CASE, 0x10DB },
{ 0x1C9C, UPPER_CASE, 0x10DC },
{ 0x1C9D, UPPER_CASE, 0x10DD },
{ 0x1C9E, UPPER_CASE, 0x10DE },
{ 0x1C9F, UPPER_CASE, 0x10DF },
{ 0x1CA0, UPPER_CASE, 0x10E0 },
{ 0x1CA1, UPPER_CASE, 0x10E1 },
{ 0x1CA2, UPPER_CASE, 0x10E2 },
{ 0x1CA3, UPPER_CASE, 0x10E3 },
{ 0x1CA4, UPPER_CASE, 0x10E4 },
{ 0x1CA5, UPPER_CASE, 0x10E5 },
{ 0x1CA6, UPPER_CASE, 0x10E6 },
{ 0x1CA7, UPPER_CASE, 0x10E7 },
{ 0x1CA8, UPPER_CASE, 0x10E8 },
{ 0x1CA9, UPPER_CASE, 0x10E9 },
{ 0x1CAA, UPPER_CASE, 0x10EA },
{ 0x1CAB, UPPER_CASE, 0x10EB },
{ 0x1CAC, UPPER_CASE, 0x10EC },
{ 0x1CAD, UPPER_CASE, 0x10ED },
{ 0x1CAE, UPPER_CASE, 0x10EE },
{ 0x1CAF, UPPER_CASE, 0x10EF },
{ 0x1CB0, UPPER_CASE, 0x10F0 },
{ 0x1CB1, UPPER_CASE, 0x10F1 },
{ 0x1CB2, UPPER_CASE, 0x10F2 },
{ 0x1CB3, UPPER_CASE, 0x10F3 },
{ 0x1CB4, UPPER_CASE, 0x10F4 },
{ 0x1CB5, UPPER_CASE, 0x10F5 },
{ 0x1CB6, UPPER_CASE, 0x10F6 },
{ 0x1CB7, UPPER_CASE, 0x10F7 },
{ 0x1CB8, UPPER_CASE, 0x10F8 },
{ 0x1CB9, UPPER_CASE, 0x10F9 },
{ 0x1CBA, UPPER_CASE, 0x10FA },
{ 0x1CBD, UPPER_CASE, 0x10FD },
{ 0x1CBE, UPPER_CASE, 0x10FE },
{ 0x1CBF, UPPER_CASE, 0x10FF },
{ 0x1D79, LOWER_CASE, 0xA77D },
{ 0x1D7D, LOWER_CASE, 0x2C63 },
{ 0x1D8E, LOWER_CASE, 0xA7C6 },
{ 0x1E00, UPPER_CASE, 0x1E01 },
{ 0x1E01, LOWER_CASE, 0x1E00 },
{ 0x1E02, UPPER_CASE, 0x1E03 },
{ 0x1E03, LOWER_CASE, 0x1E02 },
{ 0x1E04, UPPER_CASE, 0x1E05 },
{ 0x1E05, LOWER_CASE, 0x1E04 },
{ 0x1E06, UPPER_CASE, 0x1E07 },
{ 0x1E07, LOWER_CASE, 0x1E06 },
{ 0x1E08, UPPER_CASE, 0x1E09 },
{ 0x1E09, LOWER_CASE, 0x1E08 },
{ 0x1E0A, UPPER_CASE, 0x1E0B },
{ 0x1E0B, LOWER_CASE, 0x1E0A },
{ 0x1E0C, UPPER_CASE, 0x1E0D },
{ 0x1E0D, LOWER_CASE, 0x1E0C },
{ 0x1E0E, UPPER_CASE, 0x1E0F },
{ 0x1E0F, LOWER_CASE, 0x1E0E },
{ 0x1E10, UPPER_CASE, 0x1E11 },
{ 0x1E11, LOWER_CASE, 0x1E10 },
{ 0x1E12, UPPER_CASE, 0x1E13 },
{ 0x1E13, LOWER_CASE, 0x1E12 },
{ 0x1E14, UPPER_CASE, 0x1E15 },
{ 0x1E15, LOWER_CASE, 0x1E14 },
{ 0x1E16, UPPER_CASE, 0x1E17 },
{ 0x1E17, LOWER_CASE, 0x1E16 },
{ 0x1E18, UPPER_CASE, 0x1E19 },
{ 0x1E19, LOWER_CASE, 0x1E18 },
{ 0x1E1A, UPPER_CASE, 0x1E1B },
{ 0x1E1B, LOWER_CASE, 0x1E1A },
{ 0x1E1C, UPPER_CASE, 0x1E1D },
{ 0x1E1D, LOWER_CASE, 0x1E1C },
{ 0x1E1E, UPPER_CASE, 0x1E1F },
{ 0x1E1F, LOWER_CASE, 0x1E1E },
{ 0x1E20, UPPER_CASE, 0x1E21 },
{ 0x1E21, LOWER_CASE, 0x1E20 },
{ 0x1E22, UPPER_CASE, 0x1E23 },
{ 0x1E23, LOWER_CASE, 0x1E22 },
{ 0x1E24, UPPER_CASE, 0x1E25 },
{ 0x1E25, LOWER_CASE, 0x1E24 },
{ 0x1E26, UPPER_CASE, 0x1E27 },
{ 0x1E27, LOWER_CASE, 0x1E26 },
{ 0x1E28, UPPER_CASE, 0x1E29 },
{ 0x1E29, LOWER_CASE, 0x1E28 },
{ 0x1E2A, UPPER_CASE, 0x1E2B },
{ 0x1E2B, LOWER_CASE, 0x1E2A },
{ 0x1E2C, UPPER_CASE, 0x1E2D },
{ 0x1E2D, LOWER_CASE, 0x1E2C },
{ 0x1E2E, UPPER_CASE, 0x1E2F },
{ 0x1E2F, LOWER_CASE, 0x1E2E },
{ 0x1E30, UPPER_CASE, 0x1E31 },
{ 0x1E31, LOWER_CASE, 0x1E30 },
{ 0x1E32, UPPER_CASE, 0x1E33 },
{ 0x1E33, LOWER_CASE, 0x1E32 },
{ 0x1E34, UPPER_CASE, 0x1E35 },
{ 0x1E35, LOWER_CASE, 0x1E34 },
{ 0x1E36, UPPER_CASE, 0x1E37 },
{ 0x1E37, LOWER_CASE, 0x1E36 },
{ 0x1E38, UPPER_CASE, 0x1E39 },
{ 0x1E39, LOWER_CASE, 0x1E38 },
{ 0x1E3A, UPPER_CASE, 0x1E3B },
{ 0x1E3B, LOWER_CASE, 0x1E3A },
{ 0x1E3C, UPPER_CASE, 0x1E3D },
{ 0x1E3D, LOWER_CASE, 0x1E3C },
{ 0x1E3E, UPPER_CASE, 0x1E3F },
{ 0x1E3F, LOWER_CASE, 0x1E3E },
{ 0x1E40, UPPER_CASE, 0x1E41 },
{ 0x1E41, LOWER_CASE, 0x1E40 },
{ 0x1E42, UPPER_CASE, 0x1E43 },
{ 0x1E43, LOWER_CASE, 0x1E42 },
{ 0x1E44, UPPER_CASE, 0x1E45 },
{ 0x1E45, LOWER_CASE, 0x1E44 },
{ 0x1E46, UPPER_CASE, 0x1E47 },
{ 0x1E47, LOWER_CASE, 0x1E46 },
{ 0x1E48, UPPER_CASE, 0x1E49 },
{ 0x1E49, LOWER_CASE, 0x1E48 },
{ 0x1E4A, UPPER_CASE, 0x1E4B },
{ 0x1E4B, LOWER_CASE, 0x1E4A },
{ 0x1E4C, UPPER_CASE, 0x1E4D },
{ 0x1E4D, LOWER_CASE, 0x1E4C },
{ 0x1E4E, UPPER_CASE, 0x1E4F },
{ 0x1E4F, LOWER_CASE, 0x1E4E },
{ 0x1E50, UPPER_CASE, 0x1E51 },
{ 0x1E51, LOWER_CASE, 0x1E50 },
{ 0x1E52, UPPER_CASE, 0x1E53 },
{ 0x1E53, LOWER_CASE, 0x1E52 },
{ 0x1E54, UPPER_CASE, 0x1E55 },
{ 0x1E55, LOWER_CASE, 0x1E54 },
{ 0x1E56, UPPER_CASE, 0x1E57 },
{ 0x1E57, LOWER_CASE, 0x1E56 },
{ 0x1E58, UPPER_CASE, 0x1E59 },
{ 0x1E59, LOWER_CASE, 0x1E58 },
{ 0x1E5A, UPPER_CASE, 0x1E5B },
{ 0x1E5B, LOWER_CASE, 0x1E5A },
{ 0x1E5C, UPPER_CASE, 0x1E5D },
{ 0x1E5D, LOWER_CASE, 0x1E5C },
{ 0x1E5E, UPPER_CASE, 0x1E5F },
{ 0x1E5F, LOWER_CASE, 0x1E5E },
{ 0x1E60, UPPER_CASE, 0x1E61 },
{ 0x1E61, LOWER_CASE, 0x1E60 },
{ 0x1E62, UPPER_CASE, 0x1E63 },
{ 0x1E63, LOWER_CASE, 0x1E62 },
{ 0x1E64, UPPER_CASE, 0x1E65 },
{ 0x1E65, LOWER_CASE, 0x1E64 },
{ 0x1E66, UPPER_CASE, 0x1E67 },
{ 0x1E67, LOWER_CASE, 0x1E66 },
{ 0x1E68, UPPER_CASE, 0x1E69 },
{ 0x1E69, LOWER_CASE, 0x1E68 },
{ 0x1E6A, UPPER_CASE, 0x1E6B },
{ 0x1E6B, LOWER_CASE, 0x1E6A },
{ 0x1E6C, UPPER_CASE, 0x1E6D },
{ 0x1E6D, LOWER_CASE, 0x1E6C },
{ 0x1E6E, UPPER_CASE, 0x1E6F },
{ 0x1E6F, LOWER_CASE, 0x1E6E },
{ 0x1E70, UPPER_CASE, 0x1E71 },
{ 0x1E71, LOWER_CASE, 0x1E70 },
{ 0x1E72, UPPER_CASE, 0x1E73 },
{ 0x1E73, LOWER_CASE, 0x1E72 },
{ 0x1E74, UPPER_CASE, 0x1E75 },
{ 0x1E75, LOWER_CASE, 0x1E74 },
{ 0x1E76, UPPER_CASE, 0x1E77 },
{ 0x1E77, LOWER_CASE, 0x1E76 },
{ 0x1E78, UPPER_CASE, 0x1E79 },
{ 0x1E79, LOWER_CASE, 0x1E78 },
{ 0x1E7A, UPPER_CASE, 0x1E7B },
{ 0x1E7B, LOWER_CASE, 0x1E7A },
{ 0x1E7C, UPPER_CASE, 0x1E7D },
{ 0x1E7D, LOWER_CASE, 0x1E7C },
{ 0x1E7E, UPPER_CASE, 0x1E7F },
{ 0x1E7F, LOWER_CASE, 0x1E7E },
{ 0x1E80, UPPER_CASE, 0x1E81 },
{ 0x1E81, LOWER_CASE, 0x1E80 },
{ 0x1E82, UPPER_CASE, 0x1E83 },
{ 0x1E83, LOWER_CASE, 0x1E82 },
{ 0x1E84, UPPER_CASE, 0x1E85 },
{ 0x1E85, LOWER_CASE, 0x1E84 },
{ 0x1E86, UPPER_CASE, 0x1E87 },
{ 0x1E87, LOWER_CASE, 0x1E86 },
{ 0x1E88, UPPER_CASE, 0x1E89 },
{ 0x1E89, LOWER_CASE, 0x1E88 },
{ 0x1E8A, UPPER_CASE, 0x1E8B },
{ 0x1E8B, LOWER_CASE, 0x1E8A },
{ 0x1E8C, UPPER_CASE, 0x1E8D },
{ 0x1E8D, LOWER_CASE, 0x1E8C },
{ 0x1E8E, UPPER_CASE, 0x1E8F },
{ 0x1E8F, LOWER_CASE, 0x1E8E },
{ 0x1E90, UPPER_CASE, 0x1E91 },
{ 0x1E91, LOWER_CASE, 0x1E90 },
{ 0x1E92, UPPER_CASE, 0x1E93 },
{ 0x1E93, LOWER_CASE, 0x1E92 },
{ 0x1E94, UPPER_CASE, 0x1E95 },
{ 0x1E95, LOWER_CASE, 0x1E94 },
{ 0x1E9B, LOWER_CASE, 0x1E60 },
{ 0x1E9E, UPPER_CASE, 0xDF },
{ 0x1EA0, UPPER_CASE, 0x1EA1 },
{ 0x1EA1, LOWER_CASE, 0x1EA0 },
{ 0x1EA2, UPPER_CASE, 0x1EA3 },
{ 0x1EA3, LOWER_CASE, 0x1EA2 },
{ 0x1EA4, UPPER_CASE, 0x1EA5 },
{ 0x1EA5, LOWER_CASE, 0x1EA4 },
{ 0x1EA6, UPPER_CASE, 0x1EA7 },
{ 0x1EA7, LOWER_CASE, 0x1EA6 },
{ 0x1EA8, UPPER_CASE, 0x1EA9 },
{ 0x1EA9, LOWER_CASE, 0x1EA8 },
{ 0x1EAA, UPPER_CASE, 0x1EAB },
{ 0x1EAB, LOWER_CASE, 0x1EAA },
{ 0x1EAC, UPPER_CASE, 0x1EAD },
{ 0x1EAD, LOWER_CASE, 0x1EAC },
{ 0x1EAE, UPPER_CASE, 0x1EAF },
{ 0x1EAF, LOWER_CASE, 0x1EAE },
{ 0x1EB0, UPPER_CASE, 0x1EB1 },
{ 0x1EB1, LOWER_CASE, 0x1EB0 },
{ 0x1EB2, UPPER_CASE, 0x1EB3 },
{ 0x1EB3, LOWER_CASE, 0x1EB2 },
{ 0x1EB4, UPPER_CASE, 0x1EB5 },
{ 0x1EB5, LOWER_CASE, 0x1EB4 },
{ 0x1EB6, UPPER_CASE, 0x1EB7 },
{ 0x1EB7, LOWER_CASE, 0x1EB6 },
{ 0x1EB8, UPPER_CASE, 0x1EB9 },
{ 0x1EB9, LOWER_CASE, 0x1EB8 },
{ 0x1EBA, UPPER_CASE, 0x1EBB },
{ 0x1EBB, LOWER_CASE, 0x1EBA },
{ 0x1EBC, UPPER_CASE, 0x1EBD },
{ 0x1EBD, LOWER_CASE, 0x1EBC },
{ 0x1EBE, UPPER_CASE, 0x1EBF },
{ 0x1EBF, LOWER_CASE, 0x1EBE },
{ 0x1EC0, UPPER_CASE, 0x1EC1 },
{ 0x1EC1, LOWER_CASE, 0x1EC0 },
{ 0x1EC2, UPPER_CASE, 0x1EC3 },
{ 0x1EC3, LOWER_CASE, 0x1EC2 },
{ 0x1EC4, UPPER_CASE, 0x1EC5 },
{ 0x1EC5, LOWER_CASE, 0x1EC4 },
{ 0x1EC6, UPPER_CASE, 0x1EC7 },
{ 0x1EC7, LOWER_CASE, 0x1EC6 },
{ 0x1EC8, UPPER_CASE, 0x1EC9 },
{ 0x1EC9, LOWER_CASE, 0x1EC8 },
{ 0x1ECA, UPPER_CASE, 0x1ECB },
{ 0x1ECB, LOWER_CASE, 0x1ECA },
{ 0x1ECC, UPPER_CASE, 0x1ECD },
{ 0x1ECD, LOWER_CASE, 0x1ECC },
{ 0x1ECE, UPPER_CASE, 0x1ECF },
{ 0x1ECF, LOWER_CASE, 0x1ECE },
{ 0x1ED0, UPPER_CASE, 0x1ED1 },
{ 0x1ED1, LOWER_CASE, 0x1ED0 },
{ 0x1ED2, UPPER_CASE, 0x1ED3 },
{ 0x1ED3, LOWER_CASE, 0x1ED2 },
{ 0x1ED4, UPPER_CASE, 0x1ED5 },
{ 0x1ED5, LOWER_CASE, 0x1ED4 },
{ 0x1ED6, UPPER_CASE, 0x1ED7 },
{ 0x1ED7, LOWER_CASE, 0x1ED6 },
{ 0x1ED8, UPPER_CASE, 0x1ED9 },
{ 0x1ED9, LOWER_CASE, 0x1ED8 },
{ 0x1EDA, UPPER_CASE, 0x1EDB },
{ 0x1EDB, LOWER_CASE, 0x1EDA },
{ 0x1EDC, UPPER_CASE, 0x1EDD },
{ 0x1EDD, LOWER_CASE, 0x1EDC },
{ 0x1EDE, UPPER_CASE, 0x1EDF },
{ 0x1EDF, LOWER_CASE, 0x1EDE },
{ 0x1EE0, UPPER_CASE, 0x1EE1 },
{ 0x1EE1, LOWER_CASE, 0x1EE0 },
{ 0x1EE2, UPPER_CASE, 0x1EE3 },
{ 0x1EE3, LOWER_CASE, 0x1EE2 },
{ 0x1EE4, UPPER_CASE, 0x1EE5 },
{ 0x1EE5, LOWER_CASE, 0x1EE4 },
{ 0x1EE6, UPPER_CASE, 0x1EE7 },
{ 0x1EE7, LOWER_CASE, 0x1EE6 },
{ 0x1EE8, UPPER_CASE, 0x1EE9 },
{ 0x1EE9, LOWER_CASE, 0x1EE8 },
{ 0x1EEA, UPPER_CASE, 0x1EEB },
{ 0x1EEB, LOWER_CASE, 0x1EEA },
{ 0x1EEC, UPPER_CASE, 0x1EED },
{ 0x1EED, LOWER_CASE, 0x1EEC },
{ 0x1EEE, UPPER_CASE, 0x1EEF },
{ 0x1EEF, LOWER_CASE, 0x1EEE },
{ 0x1EF0, UPPER_CASE, 0x1EF1 },
{ 0x1EF1, LOWER_CASE, 0x1EF0 },
{ 0x1EF2, UPPER_CASE, 0x1EF3 },
{ 0x1EF3, LOWER_CASE, 0x1EF2 },
{ 0x1EF4, UPPER_CASE, 0x1EF5 },
{ 0x1EF5, LOWER_CASE, 0x1EF4 },
{ 0x1EF6, UPPER_CASE, 0x1EF7 },
{ 0x1EF7, LOWER_CASE, 0x1EF6 },
{ 0x1EF8, UPPER_CASE, 0x1EF9 },
{ 0x1EF9, LOWER_CASE, 0x1EF8 },
{ 0x1EFA, UPPER_CASE, 0x1EFB },
{ 0x1EFB, LOWER_CASE, 0x1EFA },
{ 0x1EFC, UPPER_CASE, 0x1EFD },
{ 0x1EFD, LOWER_CASE, 0x1EFC },
{ 0x1EFE, UPPER_CASE, 0x1EFF },
{ 0x1EFF, LOWER_CASE, 0x1EFE },
{ 0x1F00, LOWER_CASE, 0x1F08 },
{ 0x1F01, LOWER_CASE, 0x1F09 },
{ 0x1F02, LOWER_CASE, 0x1F0A },
{ 0x1F03, LOWER_CASE, 0x1F0B },
{ 0x1F04, LOWER_CASE, 0x1F0C },
{ 0x1F05, LOWER_CASE, 0x1F0D },
{ 0x1F06, LOWER_CASE, 0x1F0E },
{ 0x1F07, LOWER_CASE, 0x1F0F },
{ 0x1F08, UPPER_CASE, 0x1F00 },
{ 0x1F09, UPPER_CASE, 0x1F01 },
{ 0x1F0A, UPPER_CASE, 0x1F02 },
{ 0x1F0B, UPPER_CASE, 0x1F03 },
{ 0x1F0C, UPPER_CASE, 0x1F04 },
{ 0x1F0D, UPPER_CASE, 0x1F05 },
{ 0x1F0E, UPPER_CASE, 0x1F06 },
{ 0x1F0F, UPPER_CASE, 0x1F07 },
{ 0x1F10, LOWER_CASE, 0x1F18 },
{ 0x1F11, LOWER_CASE, 0x1F19 },
{ 0x1F12, LOWER_CASE, 0x1F1A },
{ 0x1F13, LOWER_CASE, 0x1F1B },
{ 0x1F14, LOWER_CASE, 0x1F1C },
{ 0x1F15, LOWER_CASE, 0x1F1D },
{ 0x1F18, UPPER_CASE, 0x1F10 },
{ 0x1F19, UPPER_CASE, 0x1F11 },
{ 0x1F1A, UPPER_CASE, 0x1F12 },
{ 0x1F1B, UPPER_CASE, 0x1F13 },
{ 0x1F1C, UPPER_CASE, 0x1F14 },
{ 0x1F1D, UPPER_CASE, 0x1F15 },
{ 0x1F20, LOWER_CASE, 0x1F28 },
{ 0x1F21, LOWER_CASE, 0x1F29 },
{ 0x1F22, LOWER_CASE, 0x1F2A },
{ 0x1F23, LOWER_CASE, 0x1F2B },
{ 0x1F24, LOWER_CASE, 0x1F2C },
{ 0x1F25, LOWER_CASE, 0x1F2D },
{ 0x1F26, LOWER_CASE, 0x1F2E },
{ 0x1F27, LOWER_CASE, 0x1F2F },
{ 0x1F28, UPPER_CASE, 0x1F20 },
{ 0x1F29, UPPER_CASE, 0x1F21 },
{ 0x1F2A, UPPER_CASE, 0x1F22 },
{ 0x1F2B, UPPER_CASE, 0x1F23 },
{ 0x1F2C, UPPER_CASE, 0x1F24 },
{ 0x1F2D, UPPER_CASE, 0x1F25 },
{ 0x1F2E, UPPER_CASE, 0x1F26 },
{ 0x1F2F, UPPER_CASE, 0x1F27 },
{ 0x1F30, LOWER_CASE, 0x1F38 },
{ 0x1F31, LOWER_CASE, 0x1F39 },
{ 0x1F32, LOWER_CASE, 0x1F3A },
{ 0x1F33, LOWER_CASE, 0x1F3B },
{ 0x1F34, LOWER_CASE, 0x1F3C },
{ 0x1F35, LOWER_CASE, 0x1F3D },
{ 0x1F36, LOWER_CASE, 0x1F3E },
{ 0x1F37, LOWER_CASE, 0x1F3F },
{ 0x1F38, UPPER_CASE, 0x1F30 },
{ 0x1F39, UPPER_CASE, 0x1F31 },
{ 0x1F3A, UPPER_CASE, 0x1F32 },
{ 0x1F3B, UPPER_CASE, 0x1F33 },
{ 0x1F3C, UPPER_CASE, 0x1F34 },
{ 0x1F3D, UPPER_CASE, 0x1F35 },
{ 0x1F3E, UPPER_CASE, 0x1F36 },
{ 0x1F3F, UPPER_CASE, 0x1F37 },
{ 0x1F40, LOWER_CASE, 0x1F48 },
{ 0x1F41, LOWER_CASE, 0x1F49 },
{ 0x1F42, LOWER_CASE, 0x1F4A },
{ 0x1F43, LOWER_CASE, 0x1F4B },
{ 0x1F44, LOWER_CASE, 0x1F4C },
{ 0x1F45, LOWER_CASE, 0x1F4D },
{ 0x1F48, UPPER_CASE, 0x1F40 },
{ 0x1F49, UPPER_CASE, 0x1F41 },
{ 0x1F4A, UPPER_CASE, 0x1F42 },
{ 0x1F4B, UPPER_CASE, 0x1F43 },
{ 0x1F4C, UPPER_CASE, 0x1F44 },
{ 0x1F4D, UPPER_CASE, 0x1F45 },
{ 0x1F51, LOWER_CASE, 0x1F59 },
{ 0x1F53, LOWER_CASE, 0x1F5B },
{ 0x1F55, LOWER_CASE, 0x1F5D },
{ 0x1F57, LOWER_CASE, 0x1F5F },
{ 0x1F59, UPPER_CASE, 0x1F51 },
{ 0x1F5B, UPPER_CASE, 0x1F53 },
{ 0x1F5D, UPPER_CASE, 0x1F55 },
{ 0x1F5F, UPPER_CASE, 0x1F57 },
{ 0x1F60, LOWER_CASE, 0x1F68 },
{ 0x1F61, LOWER_CASE, 0x1F69 },
{ 0x1F62, LOWER_CASE, 0x1F6A },
{ 0x1F63, LOWER_CASE, 0x1F6B },
{ 0x1F64, LOWER_CASE, 0x1F6C },
{ 0x1F65, LOWER_CASE, 0x1F6D },
{ 0x1F66, LOWER_CASE, 0x1F6E },
{ 0x1F67, LOWER_CASE, 0x1F6F },
{ 0x1F68, UPPER_CASE, 0x1F60 },
{ 0x1F69, UPPER_CASE, 0x1F61 },
{ 0x1F6A, UPPER_CASE, 0x1F62 },
{ 0x1F6B, UPPER_CASE, 0x1F63 },
{ 0x1F6C, UPPER_CASE, 0x1F64 },
{ 0x1F6D, UPPER_CASE, 0x1F65 },
{ 0x1F6E, UPPER_CASE, 0x1F66 },
{ 0x1F6F, UPPER_CASE, 0x1F67 },
{ 0x1F70, LOWER_CASE, 0x1FBA },
{ 0x1F71, LOWER_CASE, 0x1FBB },
{ 0x1F72, LOWER_CASE, 0x1FC8 },
{ 0x1F73, LOWER_CASE, 0x1FC9 },
{ 0x1F74, LOWER_CASE, 0x1FCA },
{ 0x1F75, LOWER_CASE, 0x1FCB },
{ 0x1F76, LOWER_CASE, 0x1FDA },
{ 0x1F77, LOWER_CASE, 0x1FDB },
{ 0x1F78, LOWER_CASE, 0x1FF8 },
{ 0x1F79, LOWER_CASE, 0x1FF9 },
{ 0x1F7A, LOWER_CASE, 0x1FEA },
{ 0x1F7B, LOWER_CASE, 0x1FEB },
{ 0x1F7C, LOWER_CASE, 0x1FFA },
{ 0x1F7D, LOWER_CASE, 0x1FFB },
{ 0x1F80, LOWER_CASE, 0x1F88 },
{ 0x1F81, LOWER_CASE, 0x1F89 },
{ 0x1F82, LOWER_CASE, 0x1F8A },
{ 0x1F83, LOWER_CASE, 0x1F8B },
{ 0x1F84, LOWER_CASE, 0x1F8C },
{ 0x1F85, LOWER_CASE, 0x1F8D },
{ 0x1F86, LOWER_CASE, 0x1F8E },
{ 0x1F87, LOWER_CASE, 0x1F8F },
{ 0x1F88, UPPER_CASE, 0x1F80 },
{ 0x1F89, UPPER_CASE, 0x1F81 },
{ 0x1F8A, UPPER_CASE, 0x1F82 },
{ 0x1F8B, UPPER_CASE, 0x1F83 },
{ 0x1F8C, UPPER_CASE, 0x1F84 },
{ 0x1F8D, UPPER_CASE, 0x1F85 },
{ 0x1F8E, UPPER_CASE, 0x1F86 },
{ 0x1F8F, UPPER_CASE, 0x1F87 },
{ 0x1F90, LOWER_CASE, 0x1F98 },
{ 0x1F91, LOWER_CASE, 0x1F99 },
{ 0x1F92, LOWER_CASE, 0x1F9A },
{ 0x1F93, LOWER_CASE, 0x1F9B },
{ 0x1F94, LOWER_CASE, 0x1F9C },
{ 0x1F95, LOWER_CASE, 0x1F9D },
{ 0x1F96, LOWER_CASE, 0x1F9E },
{ 0x1F97, LOWER_CASE, 0x1F9F },
{ 0x1F98, UPPER_CASE, 0x1F90 },
{ 0x1F99, UPPER_CASE, 0x1F91 },
{ 0x1F9A, UPPER_CASE, 0x1F92 },
{ 0x1F9B, UPPER_CASE, 0x1F93 },
{ 0x1F9C, UPPER_CASE, 0x1F94 },
{ 0x1F9D, UPPER_CASE, 0x1F95 },
{ 0x1F9E, UPPER_CASE, 0x1F96 },
{ 0x1F9F, UPPER_CASE, 0x1F97 },
{ 0x1FA0, LOWER_CASE, 0x1FA8 },
{ 0x1FA1, LOWER_CASE, 0x1FA9 },
{ 0x1FA2, LOWER_CASE, 0x1FAA },
{ 0x1FA3, LOWER_CASE, 0x1FAB },
{ 0x1FA4, LOWER_CASE, 0x1FAC },
{ 0x1FA5, LOWER_CASE, 0x1FAD },
{ 0x1FA6, LOWER_CASE, 0x1FAE },
{ 0x1FA7, LOWER_CASE, 0x1FAF },
{ 0x1FA8, UPPER_CASE, 0x1FA0 },
{ 0x1FA9, UPPER_CASE, 0x1FA1 },
{ 0x1FAA, UPPER_CASE, 0x1FA2 },
{ 0x1FAB, UPPER_CASE, 0x1FA3 },
{ 0x1FAC, UPPER_CASE, 0x1FA4 },
{ 0x1FAD, UPPER_CASE, 0x1FA5 },
{ 0x1FAE, UPPER_CASE, 0x1FA6 },
{ 0x1FAF, UPPER_CASE, 0x1FA7 },
{ 0x1FB0, LOWER_CASE, 0x1FB8 },
{ 0x1FB1, LOWER_CASE, 0x1FB9 },
{ 0x1FB3, LOWER_CASE, 0x1FBC },
{ 0x1FB8, UPPER_CASE, 0x1FB0 },
{ 0x1FB9, UPPER_CASE, 0x1FB1 },
{ 0x1FBA, UPPER_CASE, 0x1F70 },
{ 0x1FBB, UPPER_CASE, 0x1F71 },
{ 0x1FBC, UPPER_CASE, 0x1FB3 },
{ 0x1FBE, LOWER_CASE, 0x399 },
{ 0x1FC3, LOWER_CASE, 0x1FCC },
{ 0x1FC8, UPPER_CASE, 0x1F72 },
{ 0x1FC9, UPPER_CASE, 0x1F73 },
{ 0x1FCA, UPPER_CASE, 0x1F74 },
{ 0x1FCB, UPPER_CASE, 0x1F75 },
{ 0x1FCC, UPPER_CASE, 0x1FC3 },
{ 0x1FD0, LOWER_CASE, 0x1FD8 },
{ 0x1FD1, LOWER_CASE, 0x1FD9 },
{ 0x1FD8, UPPER_CASE, 0x1FD0 },
{ 0x1FD9, UPPER_CASE, 0x1FD1 },
{ 0x1FDA, UPPER_CASE, 0x1F76 },
{ 0x1FDB, UPPER_CASE, 0x1F77 },
{ 0x1FE0, LOWER_CASE, 0x1FE8 },
{ 0x1FE1, LOWER_CASE, 0x1FE9 },
{ 0x1FE5, LOWER_CASE, 0x1FEC },
{ 0x1FE8, UPPER_CASE, 0x1FE0 },
{ 0x1FE9, UPPER_CASE, 0x1FE1 },
{ 0x1FEA, UPPER_CASE, 0x1F7A },
{ 0x1FEB, UPPER_CASE, 0x1F7B },
{ 0x1FEC, UPPER_CASE, 0x1FE5 },
{ 0x1FF3, LOWER_CASE, 0x1FFC },
{ 0x1FF8, UPPER_CASE, 0x1F78 },
{ 0x1FF9, UPPER_CASE, 0x1F79 },
{ 0x1FFA, UPPER_CASE, 0x1F7C },
{ 0x1FFB, UPPER_CASE, 0x1F7D },
{ 0x1FFC, UPPER_CASE, 0x1FF3 },
{ 0x2126, UPPER_CASE, 0x3C9 },
{ 0x212A, UPPER_CASE, 0x6B },
{ 0x212B, UPPER_CASE, 0xE5 },
{ 0x2132, UPPER_CASE, 0x214E },
{ 0x214E, LOWER_CASE, 0x2132 },
{ 0x2160, UPPER_CASE, 0x2170 },
{ 0x2161, UPPER_CASE, 0x2171 },
{ 0x2162, UPPER_CASE, 0x2172 },
{ 0x2163, UPPER_CASE, 0x2173 },
{ 0x2164, UPPER_CASE, 0x2174 },
{ 0x2165, UPPER_CASE, 0x2175 },
{ 0x2166, UPPER_CASE, 0x2176 },
{ 0x2167, UPPER_CASE, 0x2177 },
{ 0x2168, UPPER_CASE, 0x2178 },
{ 0x2169, UPPER_CASE, 0x2179 },
{ 0x216A, UPPER_CASE, 0x217A },
{ 0x216B, UPPER_CASE, 0x217B },
{ 0x216C, UPPER_CASE, 0x217C },
{ 0x216D, UPPER_CASE, 0x217D },
{ 0x216E, UPPER_CASE, 0x217E },
{ 0x216F, UPPER_CASE, 0x217F },
{ 0x2170, LOWER_CASE, 0x2160 },
{ 0x2171, LOWER_CASE, 0x2161 },
{ 0x2172, LOWER_CASE, 0x2162 },
{ 0x2173, LOWER_CASE, 0x2163 },
{ 0x2174, LOWER_CASE, 0x2164 },
{ 0x2175, LOWER_CASE, 0x2165 },
{ 0x2176, LOWER_CASE, 0x2166 },
{ 0x2177, LOWER_CASE, 0x2167 },
{ 0x2178, LOWER_CASE, 0x2168 },
{ 0x2179, LOWER_CASE, 0x2169 },
{ 0x217A, LOWER_CASE, 0x216A },
{ 0x217B, LOWER_CASE, 0x216B },
{ 0x217C, LOWER_CASE, 0x216C },
{ 0x217D, LOWER_CASE, 0x216D },
{ 0x217E, LOWER_CASE, 0x216E },
{ 0x217F, LOWER_CASE, 0x216F },
{ 0x2183, UPPER_CASE, 0x2184 },
{ 0x2184, LOWER_CASE, 0x2183 },
{ 0x24B6, UPPER_CASE, 0x24D0 },
{ 0x24B7, UPPER_CASE, 0x24D1 },
{ 0x24B8, UPPER_CASE, 0x24D2 },
{ 0x24B9, UPPER_CASE, 0x24D3 },
{ 0x24BA, UPPER_CASE, 0x24D4 },
{ 0x24BB, UPPER_CASE, 0x24D5 },
{ 0x24BC, UPPER_CASE, 0x24D6 },
{ 0x24BD, UPPER_CASE, 0x24D7 },
{ 0x24BE, UPPER_CASE, 0x24D8 },
{ 0x24BF, UPPER_CASE, 0x24D9 },
{ 0x24C0, UPPER_CASE, 0x24DA },
{ 0x24C1, UPPER_CASE, 0x24DB },
{ 0x24C2, UPPER_CASE, 0x24DC },
{ 0x24C3, UPPER_CASE, 0x24DD },
{ 0x24C4, UPPER_CASE, 0x24DE },
{ 0x24C5, UPPER_CASE, 0x24DF },
{ 0x24C6, UPPER_CASE, 0x24E0 },
{ 0x24C7, UPPER_CASE, 0x24E1 },
{ 0x24C8, UPPER_CASE, 0x24E2 },
{ 0x24C9, UPPER_CASE, 0x24E3 },
{ 0x24CA, UPPER_CASE, 0x24E4 },
{ 0x24CB, UPPER_CASE, 0x24E5 },
{ 0x24CC, UPPER_CASE, 0x24E6 },
{ 0x24CD, UPPER_CASE, 0x24E7 },
{ 0x24CE, UPPER_CASE, 0x24E8 },
{ 0x24CF, UPPER_CASE, 0x24E9 },
{ 0x24D0, LOWER_CASE, 0x24B6 },
{ 0x24D1, LOWER_CASE, 0x24B7 },
{ 0x24D2, LOWER_CASE, 0x24B8 },
{ 0x24D3, LOWER_CASE, 0x24B9 },
{ 0x24D4, LOWER_CASE, 0x24BA },
{ 0x24D5, LOWER_CASE, 0x24BB },
{ 0x24D6, LOWER_CASE, 0x24BC },
{ 0x24D7, LOWER_CASE, 0x24BD },
{ 0x24D8, LOWER_CASE, 0x24BE },
{ 0x24D9, LOWER_CASE, 0x24BF },
{ 0x24DA, LOWER_CASE, 0x24C0 },
{ 0x24DB, LOWER_CASE, 0x24C1 },
{ 0x24DC, LOWER_CASE, 0x24C2 },
{ 0x24DD, LOWER_CASE, 0x24C3 },
{ 0x24DE, LOWER_CASE, 0x24C4 },
{ 0x24DF, LOWER_CASE, 0x24C5 },
{ 0x24E0, LOWER_CASE, 0x24C6 },
{ 0x24E1, LOWER_CASE, 0x24C7 },
{ 0x24E2, LOWER_CASE, 0x24C8 },
{ 0x24E3, LOWER_CASE, 0x24C9 },
{ 0x24E4, LOWER_CASE, 0x24CA },
{ 0x24E5, LOWER_CASE, 0x24CB },
{ 0x24E6, LOWER_CASE, 0x24CC },
{ 0x24E7, LOWER_CASE, 0x24CD },
{ 0x24E8, LOWER_CASE, 0x24CE },
{ 0x24E9, LOWER_CASE, 0x24CF },
{ 0x2C00, UPPER_CASE, 0x2C30 },
{ 0x2C01, UPPER_CASE, 0x2C31 },
{ 0x2C02, UPPER_CASE, 0x2C32 },
{ 0x2C03, UPPER_CASE, 0x2C33 },
{ 0x2C04, UPPER_CASE, 0x2C34 },
{ 0x2C05, UPPER_CASE, 0x2C35 },
{ 0x2C06, UPPER_CASE, 0x2C36 },
{ 0x2C07, UPPER_CASE, 0x2C37 },
{ 0x2C08, UPPER_CASE, 0x2C38 },
{ 0x2C09, UPPER_CASE, 0x2C39 },
{ 0x2C0A, UPPER_CASE, 0x2C3A },
{ 0x2C0B, UPPER_CASE, 0x2C3B },
{ 0x2C0C, UPPER_CASE, 0x2C3C },
{ 0x2C0D, UPPER_CASE, 0x2C3D },
{ 0x2C0E, UPPER_CASE, 0x2C3E },
{ 0x2C0F, UPPER_CASE, 0x2C3F },
{ 0x2C10, UPPER_CASE, 0x2C40 },
{ 0x2C11, UPPER_CASE, 0x2C41 },
{ 0x2C12, UPPER_CASE, 0x2C42 },
{ 0x2C13, UPPER_CASE, 0x2C43 },
{ 0x2C14, UPPER_CASE, 0x2C44 },
{ 0x2C15, UPPER_CASE, 0x2C45 },
{ 0x2C16, UPPER_CASE, 0x2C46 },
{ 0x2C17, UPPER_CASE, 0x2C47 },
{ 0x2C18, UPPER_CASE, 0x2C48 },
{ 0x2C19, UPPER_CASE, 0x2C49 },
{ 0x2C1A, UPPER_CASE, 0x2C4A },
{ 0x2C1B, UPPER_CASE, 0x2C4B },
{ 0x2C1C, UPPER_CASE, 0x2C4C },
{ 0x2C1D, UPPER_CASE, 0x2C4D },
{ 0x2C1E, UPPER_CASE, 0x2C4E },
{ 0x2C1F, UPPER_CASE, 0x2C4F },
{ 0x2C20, UPPER_CASE, 0x2C50 },
{ 0x2C21, UPPER_CASE, 0x2C51 },
{ 0x2C22, UPPER_CASE, 0x2C52 },
{ 0x2C23, UPPER_CASE, 0x2C53 },
{ 0x2C24, UPPER_CASE, 0x2C54 },
{ 0x2C25, UPPER_CASE, 0x2C55 },
{ 0x2C26, UPPER_CASE, 0x2C56 },
{ 0x2C27, UPPER_CASE, 0x2C57 },
{ 0x2C28, UPPER_CASE, 0x2C58 },
{ 0x2C29, UPPER_CASE, 0x2C59 },
{ 0x2C2A, UPPER_CASE, 0x2C5A },
{ 0x2C2B, UPPER_CASE, 0x2C5B },
{ 0x2C2C, UPPER_CASE, 0x2C5C },
{ 0x2C2D, UPPER_CASE, 0x2C5D },
{ 0x2C2E, UPPER_CASE, 0x2C5E },
{ 0x2C2F, UPPER_CASE, 0x2C5F },
{ 0x2C30, LOWER_CASE, 0x2C00 },
{ 0x2C31, LOWER_CASE, 0x2C01 },
{ 0x2C32, LOWER_CASE, 0x2C02 },
{ 0x2C33, LOWER_CASE, 0x2C03 },
{ 0x2C34, LOWER_CASE, 0x2C04 },
{ 0x2C35, LOWER_CASE, 0x2C05 },
{ 0x2C36, LOWER_CASE, 0x2C06 },
{ 0x2C37, LOWER_CASE, 0x2C07 },
{ 0x2C38, LOWER_CASE, 0x2C08 },
{ 0x2C39, LOWER_CASE, 0x2C09 },
{ 0x2C3A, LOWER_CASE, 0x2C0A },
{ 0x2C3B, LOWER_CASE, 0x2C0B },
{ 0x2C3C, LOWER_CASE, 0x2C0C },
{ 0x2C3D, LOWER_CASE, 0x2C0D },
{ 0x2C3E, LOWER_CASE, 0x2C0E },
{ 0x2C3F, LOWER_CASE, 0x2C0F },
{ 0x2C40, LOWER_CASE, 0x2C10 },
{ 0x2C41, LOWER_CASE, 0x2C11 },
{ 0x2C42, LOWER_CASE, 0x2C12 },
{ 0x2C43, LOWER_CASE, 0x2C13 },
{ 0x2C44, LOWER_CASE, 0x2C14 },
{ 0x2C45, LOWER_CASE, 0x2C15 },
{ 0x2C46, LOWER_CASE, 0x2C16 },
{ 0x2C47, LOWER_CASE, 0x2C17 },
{ 0x2C48, LOWER_CASE, 0x2C18 },
{ 0x2C49, LOWER_CASE, 0x2C19 },
{ 0x2C4A, LOWER_CASE, 0x2C1A },
{ 0x2C4B, LOWER_CASE, 0x2C1B },
{ 0x2C4C, LOWER_CASE, 0x2C1C },
{ 0x2C4D, LOWER_CASE, 0x2C1D },
{ 0x2C4E, LOWER_CASE, 0x2C1E },
{ 0x2C4F, LOWER_CASE, 0x2C1F },
{ 0x2C50, LOWER_CASE, 0x2C20 },
{ 0x2C51, LOWER_CASE, 0x2C21 },
{ 0x2C52, LOWER_CASE, 0x2C22 },
{ 0x2C53, LOWER_CASE, 0x2C23 },
{ 0x2C54, LOWER_CASE, 0x2C24 },
{ 0x2C55, LOWER_CASE, 0x2C25 },
{ 0x2C56, LOWER_CASE, 0x2C26 },
{ 0x2C57, LOWER_CASE, 0x2C27 },
{ 0x2C58, LOWER_CASE, 0x2C28 },
{ 0x2C59, LOWER_CASE, 0x2C29 },
{ 0x2C5A, LOWER_CASE, 0x2C2A },
{ 0x2C5B, LOWER_CASE, 0x2C2B },
{ 0x2C5C, LOWER_CASE, 0x2C2C },
{ 0x2C5D, LOWER_CASE, 0x2C2D },
{ 0x2C5E, LOWER_CASE, 0x2C2E },
{ 0x2C5F, LOWER_CASE, 0x2C2F },
{ 0x2C60, UPPER_CASE, 0x2C61 },
{ 0x2C61, LOWER_CASE, 0x2C60 },
{ 0x2C62, UPPER_CASE, 0x26B },
{ 0x2C63, UPPER_CASE, 0x1D7D },
{ 0x2C64, UPPER_CASE, 0x27D },
{ 0x2C65, LOWER_CASE, 0x23A },
{ 0x2C66, LOWER_CASE, 0x23E },
{ 0x2C67, UPPER_CASE, 0x2C68 },
{ 0x2C68, LOWER_CASE, 0x2C67 },
{ 0x2C69, UPPER_CASE, 0x2C6A },
{ 0x2C6A, LOWER_CASE, 0x2C69 },
{ 0x2C6B, UPPER_CASE, 0x2C6C },
{ 0x2C6C, LOWER_CASE, 0x2C6B },
{ 0x2C6D, UPPER_CASE, 0x251 },
{ 0x2C6E, UPPER_CASE, 0x271 },
{ 0x2C6F, UPPER_CASE, 0x250 },
{ 0x2C70, UPPER_CASE, 0x252 },
{ 0x2C72, UPPER_CASE, 0x2C73 },
{ 0x2C73, LOWER_CASE, 0x2C72 },
{ 0x2C75, UPPER_CASE, 0x2C76 },
{ 0x2C76, LOWER_CASE, 0x2C75 },
{ 0x2C7E, UPPER_CASE, 0x23F },
{ 0x2C7F, UPPER_CASE, 0x240 },
{ 0x2C80, UPPER_CASE, 0x2C81 },
{ 0x2C81, LOWER_CASE, 0x2C80 },
{ 0x2C82, UPPER_CASE, 0x2C83 },
{ 0x2C83, LOWER_CASE, 0x2C82 },
{ 0x2C84, UPPER_CASE, 0x2C85 },
{ 0x2C85, LOWER_CASE, 0x2C84 },
{ 0x2C86, UPPER_CASE, 0x2C87 },
{ 0x2C87, LOWER_CASE, 0x2C86 },
{ 0x2C88, UPPER_CASE, 0x2C89 },
{ 0x2C89, LOWER_CASE, 0x2C88 },
{ 0x2C8A, UPPER_CASE, 0x2C8B },
{ 0x2C8B, LOWER_CASE, 0x2C8A },
{ 0x2C8C, UPPER_CASE, 0x2C8D },
{ 0x2C8D, LOWER_CASE, 0x2C8C },
{ 0x2C8E, UPPER_CASE, 0x2C8F },
{ 0x2C8F, LOWER_CASE, 0x2C8E },
{ 0x2C90, UPPER_CASE, 0x2C91 },
{ 0x2C91, LOWER_CASE, 0x2C90 },
{ 0x2C92, UPPER_CASE, 0x2C93 },
{ 0x2C93, LOWER_CASE, 0x2C92 },
{ 0x2C94, UPPER_CASE, 0x2C95 },
{ 0x2C95, LOWER_CASE, 0x2C94 },
{ 0x2C96, UPPER_CASE, 0x2C97 },
{ 0x2C97, LOWER_CASE, 0x2C96 },
{ 0x2C98, UPPER_CASE, 0x2C99 },
{ 0x2C99, LOWER_CASE, 0x2C98 },
{ 0x2C9A, UPPER_CASE, 0x2C9B },
{ 0x2C9B, LOWER_CASE, 0x2C9A },
{ 0x2C9C, UPPER_CASE, 0x2C9D },
{ 0x2C9D, LOWER_CASE, 0x2C9C },
{ 0x2C9E, UPPER_CASE, 0x2C9F },
{ 0x2C9F, LOWER_CASE, 0x2C9E },
{ 0x2CA0, UPPER_CASE, 0x2CA1 },
{ 0x2CA1, LOWER_CASE, 0x2CA0 },
{ 0x2CA2, UPPER_CASE, 0x2CA3 },
{ 0x2CA3, LOWER_CASE, 0x2CA2 },
{ 0x2CA4, UPPER_CASE, 0x2CA5 },
{ 0x2CA5, LOWER_CASE, 0x2CA4 },
{ 0x2CA6, UPPER_CASE, 0x2CA7 },
{ 0x2CA7, LOWER_CASE, 0x2CA6 },
{ 0x2CA8, UPPER_CASE, 0x2CA9 },
{ 0x2CA9, LOWER_CASE, 0x2CA8 },
{ 0x2CAA, UPPER_CASE, 0x2CAB },
{ 0x2CAB, LOWER_CASE, 0x2CAA },
{ 0x2CAC, UPPER_CASE, 0x2CAD },
{ 0x2CAD, LOWER_CASE, 0x2CAC },
{ 0x2CAE, UPPER_CASE, 0x2CAF },
{ 0x2CAF, LOWER_CASE, 0x2CAE },
{ 0x2CB0, UPPER_CASE, 0x2CB1 },
{ 0x2CB1, LOWER_CASE, 0x2CB0 },
{ 0x2CB2, UPPER_CASE, 0x2CB3 },
{ 0x2CB3, LOWER_CASE, 0x2CB2 },
{ 0x2CB4, UPPER_CASE, 0x2CB5 },
{ 0x2CB5, LOWER_CASE, 0x2CB4 },
{ 0x2CB6, UPPER_CASE, 0x2CB7 },
{ 0x2CB7, LOWER_CASE, 0x2CB6 },
{ 0x2CB8, UPPER_CASE, 0x2CB9 },
{ 0x2CB9, LOWER_CASE, 0x2CB8 },
{ 0x2CBA, UPPER_CASE, 0x2CBB },
{ 0x2CBB, LOWER_CASE, 0x2CBA },
{ 0x2CBC, UPPER_CASE, 0x2CBD },
{ 0x2CBD, LOWER_CASE, 0x2CBC },
{ 0x2CBE, UPPER_CASE, 0x2CBF },
{ 0x2CBF, LOWER_CASE, 0x2CBE },
{ 0x2CC0, UPPER_CASE, 0x2CC1 },
{ 0x2CC1, LOWER_CASE, 0x2CC0 },
{ 0x2CC2, UPPER_CASE, 0x2CC3 },
{ 0x2CC3, LOWER_CASE, 0x2CC2 },
{ 0x2CC4, UPPER_CASE, 0x2CC5 },
{ 0x2CC5, LOWER_CASE, 0x2CC4 },
{ 0x2CC6, UPPER_CASE, 0x2CC7 },
{ 0x2CC7, LOWER_CASE, 0x2CC6 },
{ 0x2CC8, UPPER_CASE, 0x2CC9 },
{ 0x2CC9, LOWER_CASE, 0x2CC8 },
{ 0x2CCA, UPPER_CASE, 0x2CCB },
{ 0x2CCB, LOWER_CASE, 0x2CCA },
{ 0x2CCC, UPPER_CASE, 0x2CCD },
{ 0x2CCD, LOWER_CASE, 0x2CCC },
{ 0x2CCE, UPPER_CASE, 0x2CCF },
{ 0x2CCF, LOWER_CASE, 0x2CCE },
{ 0x2CD0, UPPER_CASE, 0x2CD1 },
{ 0x2CD1, LOWER_CASE, 0x2CD0 },
{ 0x2CD2, UPPER_CASE, 0x2CD3 },
{ 0x2CD3, LOWER_CASE, 0x2CD2 },
{ 0x2CD4, UPPER_CASE, 0x2CD5 },
{ 0x2CD5, LOWER_CASE, 0x2CD4 },
{ 0x2CD6, UPPER_CASE, 0x2CD7 },
{ 0x2CD7, LOWER_CASE, 0x2CD6 },
{ 0x2CD8, UPPER_CASE, 0x2CD9 },
{ 0x2CD9, LOWER_CASE, 0x2CD8 },
{ 0x2CDA, UPPER_CASE, 0x2CDB },
{ 0x2CDB, LOWER_CASE, 0x2CDA },
{ 0x2CDC, UPPER_CASE, 0x2CDD },
{ 0x2CDD, LOWER_CASE, 0x2CDC },
{ 0x2CDE, UPPER_CASE, 0x2CDF },
{ 0x2CDF, LOWER_CASE, 0x2CDE },
{ 0x2CE0, UPPER_CASE, 0x2CE1 },
{ 0x2CE1, LOWER_CASE, 0x2CE0 },
{ 0x2CE2, UPPER_CASE, 0x2CE3 },
{ 0x2CE3, LOWER_CASE, 0x2CE2 },
{ 0x2CEB, UPPER_CASE, 0x2CEC },
{ 0x2CEC, LOWER_CASE, 0x2CEB },
{ 0x2CED, UPPER_CASE, 0x2CEE },
{ 0x2CEE, LOWER_CASE, 0x2CED },
{ 0x2CF2, UPPER_CASE, 0x2CF3 },
{ 0x2CF3, LOWER_CASE, 0x2CF2 },
{ 0x2D00, LOWER_CASE, 0x10A0 },
{ 0x2D01, LOWER_CASE, 0x10A1 },
{ 0x2D02, LOWER_CASE, 0x10A2 },
{ 0x2D03, LOWER_CASE, 0x10A3 },
{ 0x2D04, LOWER_CASE, 0x10A4 },
{ 0x2D05, LOWER_CASE, 0x10A5 },
{ 0x2D06, LOWER_CASE, 0x10A6 },
{ 0x2D07, LOWER_CASE, 0x10A7 },
{ 0x2D08, LOWER_CASE, 0x10A8 },
{ 0x2D09, LOWER_CASE, 0x10A9 },
{ 0x2D0A, LOWER_CASE, 0x10AA },
{ 0x2D0B, LOWER_CASE, 0x10AB },
{ 0x2D0C, LOWER_CASE, 0x10AC },
{ 0x2D0D, LOWER_CASE, 0x10AD },
{ 0x2D0E, LOWER_CASE, 0x10AE },
{ 0x2D0F, LOWER_CASE, 0x10AF },
{ 0x2D10, LOWER_CASE, 0x10B0 },
{ 0x2D11, LOWER_CASE, 0x10B1 },
{ 0x2D12, LOWER_CASE, 0x10B2 },
{ 0x2D13, LOWER_CASE, 0x10B3 },
{ 0x2D14, LOWER_CASE, 0x10B4 },
{ 0x2D15, LOWER_CASE, 0x10B5 },
{ 0x2D16, LOWER_CASE, 0x10B6 },
{ 0x2D17, LOWER_CASE, 0x10B7 },
{ 0x2D18, LOWER_CASE, 0x10B8 },
{ 0x2D19, LOWER_CASE, 0x10B9 },
{ 0x2D1A, LOWER_CASE, 0x10BA },
{ 0x2D1B, LOWER_CASE, 0x10BB },
{ 0x2D1C, LOWER_CASE, 0x10BC },
{ 0x2D1D, LOWER_CASE, 0x10BD },
{ 0x2D1E, LOWER_CASE, 0x10BE },
{ 0x2D1F, LOWER_CASE, 0x10BF },
{ 0x2D20, LOWER_CASE, 0x10C0 },
{ 0x2D21, LOWER_CASE, 0x10C1 },
{ 0x2D22, LOWER_CASE, 0x10C2 },
{ 0x2D23, LOWER_CASE, 0x10C3 },
{ 0x2D24, LOWER_CASE, 0x10C4 },
{ 0x2D25, LOWER_CASE, 0x10C5 },
{ 0x2D27, LOWER_CASE, 0x10C7 },
{ 0x2D2D, LOWER_CASE, 0x10CD },
{ 0xA640, UPPER_CASE, 0xA641 },
{ 0xA641, LOWER_CASE, 0xA640 },
{ 0xA642, UPPER_CASE, 0xA643 },
{ 0xA643, LOWER_CASE, 0xA642 },
{ 0xA644, UPPER_CASE, 0xA645 },
{ 0xA645, LOWER_CASE, 0xA644 },
{ 0xA646, UPPER_CASE, 0xA647 },
{ 0xA647, LOWER_CASE, 0xA646 },
{ 0xA648, UPPER_CASE, 0xA649 },
{ 0xA649, LOWER_CASE, 0xA648 },
{ 0xA64A, UPPER_CASE, 0xA64B },
{ 0xA64B, LOWER_CASE, 0xA64A },
{ 0xA64C, UPPER_CASE, 0xA64D },
{ 0xA64D, LOWER_CASE, 0xA64C },
{ 0xA64E, UPPER_CASE, 0xA64F },
{ 0xA64F, LOWER_CASE, 0xA64E },
{ 0xA650, UPPER_CASE, 0xA651 },
{ 0xA651, LOWER_CASE, 0xA650 },
{ 0xA652, UPPER_CASE, 0xA653 },
{ 0xA653, LOWER_CASE, 0xA652 },
{ 0xA654, UPPER_CASE, 0xA655 },
{ 0xA655, LOWER_CASE, 0xA654 },
{ 0xA656, UPPER_CASE, 0xA657 },
{ 0xA657, LOWER_CASE, 0xA656 },
{ 0xA658, UPPER_CASE, 0xA659 },
{ 0xA659, LOWER_CASE, 0xA658 },
{ 0xA65A, UPPER_CASE, 0xA65B },
{ 0xA65B, LOWER_CASE, 0xA65A },
{ 0xA65C, UPPER_CASE, 0xA65D },
{ 0xA65D, LOWER_CASE, 0xA65C },
{ 0xA65E, UPPER_CASE, 0xA65F },
{ 0xA65F, LOWER_CASE, 0xA65E },
{ 0xA660, UPPER_CASE, 0xA661 },
{ 0xA661, LOWER_CASE, 0xA660 },
{ 0xA662, UPPER_CASE, 0xA663 },
{ 0xA663, LOWER_CASE, 0xA662 },
{ 0xA664, UPPER_CASE, 0xA665 },
{ 0xA665, LOWER_CASE, 0xA664 },
{ 0xA666, UPPER_CASE, 0xA667 },
{ 0xA667, LOWER_CASE, 0xA666 },
{ 0xA668, UPPER_CASE, 0xA669 },
{ 0xA669, LOWER_CASE, 0xA668 },
{ 0xA66A, UPPER_CASE, 0xA66B },
{ 0xA66B, LOWER_CASE, 0xA66A },
{ 0xA66C, UPPER_CASE, 0xA66D },
{ 0xA66D, LOWER_CASE, 0xA66C },
{ 0xA680, UPPER_CASE, 0xA681 },
{ 0xA681, LOWER_CASE, 0xA680 },
{ 0xA682, UPPER_CASE, 0xA683 },
{ 0xA683, LOWER_CASE, 0xA682 },
{ 0xA684, UPPER_CASE, 0xA685 },
{ 0xA685, LOWER_CASE, 0xA684 },
{ 0xA686, UPPER_CASE, 0xA687 },
{ 0xA687, LOWER_CASE, 0xA686 },
{ 0xA688, UPPER_CASE, 0xA689 },
{ 0xA689, LOWER_CASE, 0xA688 },
{ 0xA68A, UPPER_CASE, 0xA68B },
{ 0xA68B, LOWER_CASE, 0xA68A },
{ 0xA68C, UPPER_CASE, 0xA68D },
{ 0xA68D, LOWER_CASE, 0xA68C },
{ 0xA68E, UPPER_CASE, 0xA68F },
{ 0xA68F, LOWER_CASE, 0xA68E },
{ 0xA690, UPPER_CASE, 0xA691 },
{ 0xA691, LOWER_CASE, 0xA690 },
{ 0xA692, UPPER_CASE, 0xA693 },
{ 0xA693, LOWER_CASE, 0xA692 },
{ 0xA694, UPPER_CASE, 0xA695 },
{ 0xA695, LOWER_CASE, 0xA694 },
{ 0xA696, UPPER_CASE, 0xA697 },
{ 0xA697, LOWER_CASE, 0xA696 },
{ 0xA698, UPPER_CASE, 0xA699 },
{ 0xA699, LOWER_CASE, 0xA698 },
{ 0xA69A, UPPER_CASE, 0xA69B },
{ 0xA69B, LOWER_CASE, 0xA69A },
{ 0xA722, UPPER_CASE, 0xA723 },
{ 0xA723, LOWER_CASE, 0xA722 },
{ 0xA724, UPPER_CASE, 0xA725 },
{ 0xA725, LOWER_CASE, 0xA724 },
{ 0xA726, UPPER_CASE, 0xA727 },
{ 0xA727, LOWER_CASE, 0xA726 },
{ 0xA728, UPPER_CASE, 0xA729 },
{ 0xA729, LOWER_CASE, 0xA728 },
{ 0xA72A, UPPER_CASE, 0xA72B },
{ 0xA72B, LOWER_CASE, 0xA72A },
{ 0xA72C, UPPER_CASE, 0xA72D },
{ 0xA72D, LOWER_CASE, 0xA72C },
{ 0xA72E, UPPER_CASE, 0xA72F },
{ 0xA72F, LOWER_CASE, 0xA72E },
{ 0xA732, UPPER_CASE, 0xA733 },
{ 0xA733, LOWER_CASE, 0xA732 },
{ 0xA734, UPPER_CASE, 0xA735 },
{ 0xA735, LOWER_CASE, 0xA734 },
{ 0xA736, UPPER_CASE, 0xA737 },
{ 0xA737, LOWER_CASE, 0xA736 },
{ 0xA738, UPPER_CASE, 0xA739 },
{ 0xA739, LOWER_CASE, 0xA738 },
{ 0xA73A, UPPER_CASE, 0xA73B },
{ 0xA73B, LOWER_CASE, 0xA73A },
{ 0xA73C, UPPER_CASE, 0xA73D },
{ 0xA73D, LOWER_CASE, 0xA73C },
{ 0xA73E, UPPER_CASE, 0xA73F },
{ 0xA73F, LOWER_CASE, 0xA73E },
{ 0xA740, UPPER_CASE, 0xA741 },
{ 0xA741, LOWER_CASE, 0xA740 },
{ 0xA742, UPPER_CASE, 0xA743 },
{ 0xA743, LOWER_CASE, 0xA742 },
{ 0xA744, UPPER_CASE, 0xA745 },
{ 0xA745, LOWER_CASE, 0xA744 },
{ 0xA746, UPPER_CASE, 0xA747 },
{ 0xA747, LOWER_CASE, 0xA746 },
{ 0xA748, UPPER_CASE, 0xA749 },
{ 0xA749, LOWER_CASE, 0xA748 },
{ 0xA74A, UPPER_CASE, 0xA74B },
{ 0xA74B, LOWER_CASE, 0xA74A },
{ 0xA74C, UPPER_CASE, 0xA74D },
{ 0xA74D, LOWER_CASE, 0xA74C },
{ 0xA74E, UPPER_CASE, 0xA74F },
{ 0xA74F, LOWER_CASE, 0xA74E },
{ 0xA750, UPPER_CASE, 0xA751 },
{ 0xA751, LOWER_CASE, 0xA750 },
{ 0xA752, UPPER_CASE, 0xA753 },
{ 0xA753, LOWER_CASE, 0xA752 },
{ 0xA754, UPPER_CASE, 0xA755 },
{ 0xA755, LOWER_CASE, 0xA754 },
{ 0xA756, UPPER_CASE, 0xA757 },
{ 0xA757, LOWER_CASE, 0xA756 },
{ 0xA758, UPPER_CASE, 0xA759 },
{ 0xA759, LOWER_CASE, 0xA758 },
{ 0xA75A, UPPER_CASE, 0xA75B },
{ 0xA75B, LOWER_CASE, 0xA75A },
{ 0xA75C, UPPER_CASE, 0xA75D },
{ 0xA75D, LOWER_CASE, 0xA75C },
{ 0xA75E, UPPER_CASE, 0xA75F },
{ 0xA75F, LOWER_CASE, 0xA75E },
{ 0xA760, UPPER_CASE, 0xA761 },
{ 0xA761, LOWER_CASE, 0xA760 },
{ 0xA762, UPPER_CASE, 0xA763 },
{ 0xA763, LOWER_CASE, 0xA762 },
{ 0xA764, UPPER_CASE, 0xA765 },
{ 0xA765, LOWER_CASE, 0xA764 },
{ 0xA766, UPPER_CASE, 0xA767 },
{ 0xA767, LOWER_CASE, 0xA766 },
{ 0xA768, UPPER_CASE, 0xA769 },
{ 0xA769, LOWER_CASE, 0xA768 },
{ 0xA76A, UPPER_CASE, 0xA76B },
{ 0xA76B, LOWER_CASE, 0xA76A },
{ 0xA76C, UPPER_CASE, 0xA76D },
{ 0xA76D, LOWER_CASE, 0xA76C },
{ 0xA76E, UPPER_CASE, 0xA76F },
{ 0xA76F, LOWER_CASE, 0xA76E },
{ 0xA779, UPPER_CASE, 0xA77A },
{ 0xA77A, LOWER_CASE, 0xA779 },
{ 0xA77B, UPPER_CASE, 0xA77C },
{ 0xA77C, LOWER_CASE, 0xA77B },
{ 0xA77D, UPPER_CASE, 0x1D79 },
{ 0xA77E, UPPER_CASE, 0xA77F },
{ 0xA77F, LOWER_CASE, 0xA77E },
{ 0xA780, UPPER_CASE, 0xA781 },
{ 0xA781, LOWER_CASE, 0xA780 },
{ 0xA782, UPPER_CASE, 0xA783 },
{ 0xA783, LOWER_CASE, 0xA782 },
{ 0xA784, UPPER_CASE, 0xA785 },
{ 0xA785, LOWER_CASE, 0xA784 },
{ 0xA786, UPPER_CASE, 0xA787 },
{ 0xA787, LOWER_CASE, 0xA786 },
{ 0xA78B, UPPER_CASE, 0xA78C },
{ 0xA78C, LOWER_CASE, 0xA78B },
{ 0xA78D, UPPER_CASE, 0x265 },
{ 0xA790, UPPER_CASE, 0xA791 },
{ 0xA791, LOWER_CASE, 0xA790 },
{ 0xA792, UPPER_CASE, 0xA793 },
{ 0xA793, LOWER_CASE, 0xA792 },
{ 0xA794, LOWER_CASE, 0xA7C4 },
{ 0xA796, UPPER_CASE, 0xA797 },
{ 0xA797, LOWER_CASE, 0xA796 },
{ 0xA798, UPPER_CASE, 0xA799 },
{ 0xA799, LOWER_CASE, 0xA798 },
{ 0xA79A, UPPER_CASE, 0xA79B },
{ 0xA79B, LOWER_CASE, 0xA79A },
{ 0xA79C, UPPER_CASE, 0xA79D },
{ 0xA79D, LOWER_CASE, 0xA79C },
{ 0xA79E, UPPER_CASE, 0xA79F },
{ 0xA79F, LOWER_CASE, 0xA79E },
{ 0xA7A0, UPPER_CASE, 0xA7A1 },
{ 0xA7A1, LOWER_CASE, 0xA7A0 },
{ 0xA7A2, UPPER_CASE, 0xA7A3 },
{ 0xA7A3, LOWER_CASE, 0xA7A2 },
{ 0xA7A4, UPPER_CASE, 0xA7A5 },
{ 0xA7A5, LOWER_CASE, 0xA7A4 },
{ 0xA7A6, UPPER_CASE, 0xA7A7 },
{ 0xA7A7, LOWER_CASE, 0xA7A6 },
{ 0xA7A8, UPPER_CASE, 0xA7A9 },
{ 0xA7A9, LOWER_CASE, 0xA7A8 },
{ 0xA7AA, UPPER_CASE, 0x266 },
{ 0xA7AB, UPPER_CASE, 0x25C },
{ 0xA7AC, UPPER_CASE, 0x261 },
{ 0xA7AD, UPPER_CASE, 0x26C },
{ 0xA7AE, UPPER_CASE, 0x26A },
{ 0xA7B0, UPPER_CASE, 0x29E },
{ 0xA7B1, UPPER_CASE, 0x287 },
{ 0xA7B2, UPPER_CASE, 0x29D },
{ 0xA7B3, UPPER_CASE, 0xAB53 },
{ 0xA7B4, UPPER_CASE, 0xA7B5 },
{ 0xA7B5, LOWER_CASE, 0xA7B4 },
{ 0xA7B6, UPPER_CASE, 0xA7B7 },
{ 0xA7B7, LOWER_CASE, 0xA7B6 },
{ 0xA7B8, UPPER_CASE, 0xA7B9 },
{ 0xA7B9, LOWER_CASE, 0xA7B8 },
{ 0xA7BA, UPPER_CASE, 0xA7BB },
{ 0xA7BB, LOWER_CASE, 0xA7BA },
{ 0xA7BC, UPPER_CASE, 0xA7BD },
{ 0xA7BD, LOWER_CASE, 0xA7BC },
{ 0xA7BE, UPPER_CASE, 0xA7BF },
{ 0xA7BF, LOWER_CASE, 0xA7BE },
{ 0xA7C0, UPPER_CASE, 0xA7C1 },
{ 0xA7C1, LOWER_CASE, 0xA7C0 },
{ 0xA7C2, UPPER_CASE, 0xA7C3 },
{ 0xA7C3, LOWER_CASE, 0xA7C2 },
{ 0xA7C4, UPPER_CASE, 0xA794 },
{ 0xA7C5, UPPER_CASE, 0x282 },
{ 0xA7C6, UPPER_CASE, 0x1D8E },
{ 0xA7C7, UPPER_CASE, 0xA7C8 },
{ 0xA7C8, LOWER_CASE, 0xA7C7 },
{ 0xA7C9, UPPER_CASE, 0xA7CA },
{ 0xA7CA, LOWER_CASE, 0xA7C9 },
{ 0xA7D0, UPPER_CASE, 0xA7D1 },
{ 0xA7D1, LOWER_CASE, 0xA7D0 },
{ 0xA7D6, UPPER_CASE, 0xA7D7 },
{ 0xA7D7, LOWER_CASE, 0xA7D6 },
{ 0xA7D8, UPPER_CASE, 0xA7D9 },
{ 0xA7D9, LOWER_CASE, 0xA7D8 },
{ 0xA7F5, UPPER_CASE, 0xA7F6 },
{ 0xA7F6, LOWER_CASE, 0xA7F5 },
{ 0xAB53, LOWER_CASE, 0xA7B3 },
{ 0xAB70, LOWER_CASE, 0x13A0 },
{ 0xAB71, LOWER_CASE, 0x13A1 },
{ 0xAB72, LOWER_CASE, 0x13A2 },
{ 0xAB73, LOWER_CASE, 0x13A3 },
{ 0xAB74, LOWER_CASE, 0x13A4 },
{ 0xAB75, LOWER_CASE, 0x13A5 },
{ 0xAB76, LOWER_CASE, 0x13A6 },
{ 0xAB77, LOWER_CASE, 0x13A7 },
{ 0xAB78, LOWER_CASE, 0x13A8 },
{ 0xAB79, LOWER_CASE, 0x13A9 },
{ 0xAB7A, LOWER_CASE, 0x13AA },
{ 0xAB7B, LOWER_CASE, 0x13AB },
{ 0xAB7C, LOWER_CASE, 0x13AC },
{ 0xAB7D, LOWER_CASE, 0x13AD },
{ 0xAB7E, LOWER_CASE, 0x13AE },
{ 0xAB7F, LOWER_CASE, 0x13AF },
{ 0xAB80, LOWER_CASE, 0x13B0 },
{ 0xAB81, LOWER_CASE, 0x13B1 },
{ 0xAB82, LOWER_CASE, 0x13B2 },
{ 0xAB83, LOWER_CASE, 0x13B3 },
{ 0xAB84, LOWER_CASE, 0x13B4 },
{ 0xAB85, LOWER_CASE, 0x13B5 },
{ 0xAB86, LOWER_CASE, 0x13B6 },
{ 0xAB87, LOWER_CASE, 0x13B7 },
{ 0xAB88, LOWER_CASE, 0x13B8 },
{ 0xAB89, LOWER_CASE, 0x13B9 },
{ 0xAB8A, LOWER_CASE, 0x13BA },
{ 0xAB8B, LOWER_CASE, 0x13BB },
{ 0xAB8C, LOWER_CASE, 0x13BC },
{ 0xAB8D, LOWER_CASE, 0x13BD },
{ 0xAB8E, LOWER_CASE, 0x13BE },
{ 0xAB8F, LOWER_CASE, 0x13BF },
{ 0xAB90, LOWER_CASE, 0x13C0 },
{ 0xAB91, LOWER_CASE, 0x13C1 },
{ 0xAB92, LOWER_CASE, 0x13C2 },
{ 0xAB93, LOWER_CASE, 0x13C3 },
{ 0xAB94, LOWER_CASE, 0x13C4 },
{ 0xAB95, LOWER_CASE, 0x13C5 },
{ 0xAB96, LOWER_CASE, 0x13C6 },
{ 0xAB97, LOWER_CASE, 0x13C7 },
{ 0xAB98, LOWER_CASE, 0x13C8 },
{ 0xAB99, LOWER_CASE, 0x13C9 },
{ 0xAB9A, LOWER_CASE, 0x13CA },
{ 0xAB9B, LOWER_CASE, 0x13CB },
{ 0xAB9C, LOWER_CASE, 0x13CC },
{ 0xAB9D, LOWER_CASE, 0x13CD },
{ 0xAB9E, LOWER_CASE, 0x13CE },
{ 0xAB9F, LOWER_CASE, 0x13CF },
{ 0xABA0, LOWER_CASE, 0x13D0 },
{ 0xABA1, LOWER_CASE, 0x13D1 },
{ 0xABA2, LOWER_CASE, 0x13D2 },
{ 0xABA3, LOWER_CASE, 0x13D3 },
{ 0xABA4, LOWER_CASE, 0x13D4 },
{ 0xABA5, LOWER_CASE, 0x13D5 },
{ 0xABA6, LOWER_CASE, 0x13D6 },
{ 0xABA7, LOWER_CASE, 0x13D7 },
{ 0xABA8, LOWER_CASE, 0x13D8 },
{ 0xABA9, LOWER_CASE, 0x13D9 },
{ 0xABAA, LOWER_CASE, 0x13DA },
{ 0xABAB, LOWER_CASE, 0x13DB },
{ 0xABAC, LOWER_CASE, 0x13DC },
{ 0xABAD, LOWER_CASE, 0x13DD },
{ 0xABAE, LOWER_CASE, 0x13DE },
{ 0xABAF, LOWER_CASE, 0x13DF },
{ 0xABB0, LOWER_CASE, 0x13E0 },
{ 0xABB1, LOWER_CASE, 0x13E1 },
{ 0xABB2, LOWER_CASE, 0x13E2 },
{ 0xABB3, LOWER_CASE, 0x13E3 },
{ 0xABB4, LOWER_CASE, 0x13E4 },
{ 0xABB5, LOWER_CASE, 0x13E5 },
{ 0xABB6, LOWER_CASE, 0x13E6 },
{ 0xABB7, LOWER_CASE, 0x13E7 },
{ 0xABB8, LOWER_CASE, 0x13E8 },
{ 0xABB9, LOWER_CASE, 0x13E9 },
{ 0xABBA, LOWER_CASE, 0x13EA },
{ 0xABBB, LOWER_CASE, 0x13EB },
{ 0xABBC, LOWER_CASE, 0x13EC },
{ 0xABBD, LOWER_CASE, 0x13ED },
{ 0xABBE, LOWER_CASE, 0x13EE },
{ 0xABBF, LOWER_CASE, 0x13EF },
{ 0xFF21, UPPER_CASE, 0xFF41 },
{ 0xFF22, UPPER_CASE, 0xFF42 },
{ 0xFF23, UPPER_CASE, 0xFF43 },
{ 0xFF24, UPPER_CASE, 0xFF44 },
{ 0xFF25, UPPER_CASE, 0xFF45 },
{ 0xFF26, UPPER_CASE, 0xFF46 },
{ 0xFF27, UPPER_CASE, 0xFF47 },
{ 0xFF28, UPPER_CASE, 0xFF48 },
{ 0xFF29, UPPER_CASE, 0xFF49 },
{ 0xFF2A, UPPER_CASE, 0xFF4A },
{ 0xFF2B, UPPER_CASE, 0xFF4B },
{ 0xFF2C, UPPER_CASE, 0xFF4C },
{ 0xFF2D, UPPER_CASE, 0xFF4D },
{ 0xFF2E, UPPER_CASE, 0xFF4E },
{ 0xFF2F, UPPER_CASE, 0xFF4F },
{ 0xFF30, UPPER_CASE, 0xFF50 },
{ 0xFF31, UPPER_CASE, 0xFF51 },
{ 0xFF32, UPPER_CASE, 0xFF52 },
{ 0xFF33, UPPER_CASE, 0xFF53 },
{ 0xFF34, UPPER_CASE, 0xFF54 },
{ 0xFF35, UPPER_CASE, 0xFF55 },
{ 0xFF36, UPPER_CASE, 0xFF56 },
{ 0xFF37, UPPER_CASE, 0xFF57 },
{ 0xFF38, UPPER_CASE, 0xFF58 },
{ 0xFF39, UPPER_CASE, 0xFF59 },
{ 0xFF3A, UPPER_CASE, 0xFF5A },
{ 0xFF41, LOWER_CASE, 0xFF21 },
{ 0xFF42, LOWER_CASE, 0xFF22 },
{ 0xFF43, LOWER_CASE, 0xFF23 },
{ 0xFF44, LOWER_CASE, 0xFF24 },
{ 0xFF45, LOWER_CASE, 0xFF25 },
{ 0xFF46, LOWER_CASE, 0xFF26 },
{ 0xFF47, LOWER_CASE, 0xFF27 },
{ 0xFF48, LOWER_CASE, 0xFF28 },
{ 0xFF49, LOWER_CASE, 0xFF29 },
{ 0xFF4A, LOWER_CASE, 0xFF2A },
{ 0xFF4B, LOWER_CASE, 0xFF2B },
{ 0xFF4C, LOWER_CASE, 0xFF2C },
{ 0xFF4D, LOWER_CASE, 0xFF2D },
{ 0xFF4E, LOWER_CASE, 0xFF2E },
{ 0xFF4F, LOWER_CASE, 0xFF2F },
{ 0xFF50, LOWER_CASE, 0xFF30 },
{ 0xFF51, LOWER_CASE, 0xFF31 },
{ 0xFF52, LOWER_CASE, 0xFF32 },
{ 0xFF53, LOWER_CASE, 0xFF33 },
{ 0xFF54, LOWER_CASE, 0xFF34 },
{ 0xFF55, LOWER_CASE, 0xFF35 },
{ 0xFF56, LOWER_CASE, 0xFF36 },
{ 0xFF57, LOWER_CASE, 0xFF37 },
{ 0xFF58, LOWER_CASE, 0xFF38 },
{ 0xFF59, LOWER_CASE, 0xFF39 },
{ 0xFF5A, LOWER_CASE, 0xFF3A },
};
CONST UINT UNICODE_DATA_SIZE = sizeof(UnicodeData)/sizeof(UnicodeDataRec);
|
507eb226ef145fc60e176d79aa13f4c24c71632f
|
18f4fd21430bce43ab76503d8743d8c9a3123823
|
/Beginners Problems/1387 - Setu.cpp
|
a70b1691a698a01d679d91454b62de836f19f574
|
[] |
no_license
|
tiny656/LightOJ
|
1318fc258657f791c9fa386887ea19d101f803e4
|
a712f943de1d9530a0ec7620cce2c50ad2653667
|
refs/heads/master
| 2021-05-05T05:55:54.548943
| 2019-10-07T02:58:30
| 2019-10-07T02:58:30
| 118,726,674
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,121
|
cpp
|
1387 - Setu.cpp
|
1387 - Setu
#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:66777216")
#define _USE_MATH_DEFINES
#include <algorithm>
#include <string>
#include <complex>
#include <cassert>
#include <memory>
#include <set>
#include <stack>
#include <map>
#include <list>
#include <deque>
#include <numeric>
#include <cctype>
#include <cstddef>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <ctime>
#include <cstring>
#include <functional>
#include <bitset>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int t, n, money;
string op;
cin >> t;
for (int cas = 1; cas <= t; cas++) {
cin >> n;
int amount = 0;
cout << "Case " << cas << ":" << endl;
for (int i = 0; i < n; i++) {
cin >> op;
if (op == "report") cout << amount << endl;
else {
cin >> money;
amount += money;
}
}
}
return 0;
}
|
3ec443f4d456c27817102e79559393ac28a51208
|
9d303fa2c0b486620fa02aa9cd581eab12c59550
|
/pointerAndArrDiff/main.cpp
|
c548c09beb4a033045ddbb16e41a7113fc77484c
|
[] |
no_license
|
coolkyo0/CPP_STUDY
|
e56cfb24d45bcfaa61e86fe3ef8e5009a1c4f9ca
|
a32566230c6bcfd0c5d69a26ea0149e6ef37b2df
|
refs/heads/master
| 2021-06-20T11:40:38.074932
| 2017-07-22T02:37:13
| 2017-07-22T02:37:13
| 98,001,784
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 5,176
|
cpp
|
main.cpp
|
/**
* 本例主要是为了比较指针与数组的区别,以及不同定义方式的数组是指针还是数组
*
*/
#include <iostream>
#include <stdlib.h>
using namespace std;
void charArrPointerDiff()
{
char arr1[] = "Hello World";
char arr2[20] = "Hello World";
char* parr1 = arr1;
char* parr2 = arr2;
char* parr1Incre = arr1 + 4;
char* parr2Incre = arr2 + 4;
cout << "parr1 = " << parr1 << " parr1 + 4 = " << parr1Incre << endl;
cout << "parr2 = " << parr2 << " parr2 + 4 = " << parr2Incre << endl;
cout << "arr1 = " << arr1 << " arr1 + 4 = " << arr1 + 4 << endl;
cout << "arr2 = " << arr2 << " arr2 + 4 = " << arr2 + 4 << endl;
int arr1IncreLen = (int)(arr1 + 4) - (int)(arr1);
int arr2IncreLen = (int)(arr2 + 4) - (int)(arr2);
}
void intArrPointerDiff()
{
int arr1[] = {0, 1, 2, 3, 4};
int arr2[5];
int* parr1 = arr1;
int* parr2 = arr2;
int* parr1Incre = arr1 + 4;
int* parr2Incre = arr2 + 4;
cout << "parr1 = " << parr1 << " parr1 + 4 = " << parr1Incre << endl;
cout << "parr2 = " << parr2 << " parr2 + 4 = " << parr2Incre << endl;
cout << "arr1 = " << arr1 << " arr1 + 4 = " << arr1 + 4 << endl;
cout << "arr2 = " << arr2 << " arr2 + 4 = " << arr2 + 4 << endl;
}
/**
* 学习数组的特性
* @定义 int arr1[] = {0, 1, 2, 3, 4, 5}; int arr2[5];
*
* @结论 除了初始化部分,arr1和arr2都是指代数组名,并非arr1[]的定义方式就说arr1是指针。
* @结论 arr1 + 1、arr2 + 1的结构是数组地址增加一个元素步长。
* @结论
*
*/
void intArrPointerPoniterDiff()
{
/**
* 非字符串数组定义的理解
*/
int iArr1[] = { 0, 1, 2, 3, 4 };
int iArr2[5];
cout << "sizeof(iArr1) = " << sizeof(iArr1) << endl;
cout << "sizeof(iArr1) = " << sizeof(iArr2) << endl;
cout << "下面的输出为十六进制:" << endl;
cout << "iArr1 = " << iArr1 << ", iArr1 + 1 = " << iArr1 + 1 << ", &iArr1 + 1 = " << &iArr1 + 1 << endl;
cout << "iArr2 = " << iArr2 << ", iArr2 + 1 = " << iArr2 + 1 << ", &iArr2 + 1 = " << &iArr2 + 1 << endl;
/**
* 字符串数组定义的理解
*
* @定义 char cArr1[] = "Hello"; char cArr2[10];
* @结论 数组名cArr1与cArr2具有相同的特征,cArr1 + 1、cArr2 + 1效果一样,得到的结果都是数组地址增加一个元素步长的距离
* @结论 size在计算字符串时会计算字符串结束符'\0',strlen计算的是字符串的长度,从名字也可以理解他们的含义,sizeof是该数据对象占有的空大小,strlen只是计算字符串的长度,因为字符串是不含有'\0'的。
*/
char cArr1[] = "Hello";
char cArr2[10];
cout << "sizeof(cArr1) = " << sizeof(cArr1) << endl;
cout << "sizeof(cArr2) = " << sizeof(cArr2) << endl;
cout << "下面的输出为十进制:" << endl;
cout << "cArr1 = " << (int)cArr1 << ", cArr1 + 1 = " << (int)(cArr1 + 1) << ", &cArr1 + 1 = " << (int)(&cArr1 + 1) << endl;
cout << "cArr2 = " << (int)cArr1 << ", cArr2 + 1 = " << (int)(cArr2 + 1) << ", &cArr2 + 1 = " << (int)(&cArr2 + 1) << endl;
// int arr1Addr = (int)arr1;
// int arr2Addr = (int)arr2;
//sizeof(数组)的大小
// int arr1Size = sizeof(arr1);
// int arr2Size = sizeof(arr2);
//
// int stepLen1 = (int)(arr1Addr + arr1Size * power);
// int stepLen2 = (int)(arr2Addr + arr2Size * power);
//
// int stepLen3 = (int)(arr1Addr + arr1Size * power);
// int stepLen4 = (int)(arr2Addr + arr2Size * power);
//
// cout << arr1Addr << " " << (int)(&arr1 + power) << " " << stepLen1 << endl;
// cout << arr2Addr << " " << (int)(&arr2 + power) << " " << stepLen2 << endl;
// char chArr1[] = "Hello World";
// char chArr2[16] = "Hello World";
//
// cout << (int)chArr1 << " " << (int)(&chArr1 + power) << " " << (int)(chArr1 + sizeof(chArr1) * power) << endl;
// cout << (int)chArr2 << " " << (int)(&chArr2 + power) << " " << (int)(chArr2 + sizeof(chArr2) * power) << endl;
}
/**
* 意外的收货, 十六进制 + 十进制 * 系数 = ??, 得到的值有点诡异啊!!!!
* 懵逼了啊,为什么写了个hexAddDec函数又变得正常了?
*
*
*/
void hexAddDec()
{
int hex = 0x10; /** 16 */
int dec = 10;
int hexRt = hex + hex * 10; /** 176 */
int decRt = int(hex) + dec * 10; /** 116 */
}
void main()
{
//intArrPointerPoniterDiff();
/**
* 从intArrPointerDiff、charArrPointerDiff、intArrPointerPoniterDiff三个函数我们可知 char arr1[] = "Hello World";与char arr2[20] = "Hello World";的效果一样,
* arr1[]、arr2[20]方式定义时arr1和arr2都是数组指针,以前我一直认为arr1[]的定义方式会把arr1当成指针(指针和数组是有区别的),
* 数组名 + 常量 = 数组[常量 - 1]; 我曾经认为:数组名 + 常量 = 数组[sizeof(数组) * sizeof(数组元素的宽度)],其实我这么认为一直都是错误的,哎呀!!!!!!!
* 取数组地址 + 常量 = 数组[sizeof(数组) * sizeof(数组元素的宽度)], 这个才是对的呀!!!!!!一定要记住数组名只是一个单纯的指针,指针指向数组元素的首地址,
* 而&arr1才是真正指向整个数组。
*/
//intArrPointerDiff();
//charArrPointerDiff();
hexAddDec();
system("pause");
}
|
d94cb03e3aabe9e44df2677b804cc00721160dc5
|
e016b0b04a6db80b0218a4f095e6aa4ea6fcd01c
|
/Classes/Native/System_Xml_System_Xml_XmlParserInput_XmlParserInputS25800784.h
|
aa5b4f4488650ac1a01708087af33dfa84287f07
|
[
"MIT"
] |
permissive
|
rockarts/MountainTopo3D
|
5a39905c66da87db42f1d94afa0ec20576ea68de
|
2994b28dabb4e4f61189274a030b0710075306ea
|
refs/heads/master
| 2021-01-13T06:03:01.054404
| 2017-06-22T01:12:52
| 2017-06-22T01:12:52
| 95,056,244
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,344
|
h
|
System_Xml_System_Xml_XmlParserInput_XmlParserInputS25800784.h
|
#pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Object2689449295.h"
// System.String
struct String_t;
// System.IO.TextReader
struct TextReader_t1561828458;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Xml.XmlParserInput/XmlParserInputSource
struct XmlParserInputSource_t25800784 : public Il2CppObject
{
public:
// System.String System.Xml.XmlParserInput/XmlParserInputSource::BaseURI
String_t* ___BaseURI_0;
// System.IO.TextReader System.Xml.XmlParserInput/XmlParserInputSource::reader
TextReader_t1561828458 * ___reader_1;
// System.Int32 System.Xml.XmlParserInput/XmlParserInputSource::state
int32_t ___state_2;
// System.Boolean System.Xml.XmlParserInput/XmlParserInputSource::isPE
bool ___isPE_3;
// System.Int32 System.Xml.XmlParserInput/XmlParserInputSource::line
int32_t ___line_4;
// System.Int32 System.Xml.XmlParserInput/XmlParserInputSource::column
int32_t ___column_5;
public:
inline static int32_t get_offset_of_BaseURI_0() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___BaseURI_0)); }
inline String_t* get_BaseURI_0() const { return ___BaseURI_0; }
inline String_t** get_address_of_BaseURI_0() { return &___BaseURI_0; }
inline void set_BaseURI_0(String_t* value)
{
___BaseURI_0 = value;
Il2CppCodeGenWriteBarrier(&___BaseURI_0, value);
}
inline static int32_t get_offset_of_reader_1() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___reader_1)); }
inline TextReader_t1561828458 * get_reader_1() const { return ___reader_1; }
inline TextReader_t1561828458 ** get_address_of_reader_1() { return &___reader_1; }
inline void set_reader_1(TextReader_t1561828458 * value)
{
___reader_1 = value;
Il2CppCodeGenWriteBarrier(&___reader_1, value);
}
inline static int32_t get_offset_of_state_2() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___state_2)); }
inline int32_t get_state_2() const { return ___state_2; }
inline int32_t* get_address_of_state_2() { return &___state_2; }
inline void set_state_2(int32_t value)
{
___state_2 = value;
}
inline static int32_t get_offset_of_isPE_3() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___isPE_3)); }
inline bool get_isPE_3() const { return ___isPE_3; }
inline bool* get_address_of_isPE_3() { return &___isPE_3; }
inline void set_isPE_3(bool value)
{
___isPE_3 = value;
}
inline static int32_t get_offset_of_line_4() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___line_4)); }
inline int32_t get_line_4() const { return ___line_4; }
inline int32_t* get_address_of_line_4() { return &___line_4; }
inline void set_line_4(int32_t value)
{
___line_4 = value;
}
inline static int32_t get_offset_of_column_5() { return static_cast<int32_t>(offsetof(XmlParserInputSource_t25800784, ___column_5)); }
inline int32_t get_column_5() const { return ___column_5; }
inline int32_t* get_address_of_column_5() { return &___column_5; }
inline void set_column_5(int32_t value)
{
___column_5 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
ce4d880e28dee921f52b7e9d72a9e686c10263c6
|
c97f0fce14725df8be7c15684d21eeecbf714d4f
|
/iDom_server_OOP/src/iDomTools/test/testJSON.h
|
f4267bedce4bada566a11e2c1295679315fcd975
|
[] |
no_license
|
cyniu88/malina
|
c806114b366ea7838bd878918c8ba90fa821f0e3
|
0d12dce8cadda1226bf78f6b9581b3ee68b89da6
|
refs/heads/master
| 2023-07-22T01:09:15.681678
| 2023-07-18T14:44:08
| 2023-07-18T14:44:08
| 42,704,120
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 31,756
|
h
|
testJSON.h
|
#include "json.hpp"
class TEST_JSON
{
public:
nlohmann::json jj_noLightning = nlohmann::json::parse(R"({"success":true,"error":{"code":"warn_no_data","description":"No data was returned for the request."},"response":[]})");
nlohmann::json jj_lightning = nlohmann::json::parse(R"({"success":true,"error":null,"response":[{"id":"5b0e49471788b069371f8319","loc":{"long":10.17842,"lat":52.5329},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-10943,"numSensors":13,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":34.339,"distanceMI":21.337}},{"id":"5b0e49471788b069371f8317","loc":{"long":10.14298,"lat":52.52253},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-21503,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":31.746,"distanceMI":19.726}},{"id":"5b0e48fd1788b069371f6e5b","loc":{"long":10.15956,"lat":52.54143},"ob":{"timestamp":1527662831,"dateTimeISO":"2018-05-30T06:47:11+00:00","age":126,"pulse":{"type":"cg","peakamp":-3869,"numSensors":16,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662845,"recISO":"2018-05-30T06:47:25+00:00","age":126,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":33.337,"distanceMI":20.715}},{"id":"5b0e48d61788b069371f62d2","loc":{"long":10.2544,"lat":52.47834},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-14706,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":38.612,"distanceMI":23.992}},{"id":"5b0e48d61788b069371f62d0","loc":{"long":10.25678,"lat":52.47881},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-20186,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":38.776,"distanceMI":24.094}},{"id":"5b0e48cd1788b069371f6073","loc":{"long":10.20136,"lat":52.52286},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-24573,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":79,"bearingENG":"E","distanceKM":35.623,"distanceMI":22.135}},{"id":"5b0e48cd1788b069371f6071","loc":{"long":10.15373,"lat":52.51353},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-31132,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":80,"bearingENG":"E","distanceKM":32.264,"distanceMI":20.048}},{"id":"5b0e48b41788b069371f58ef","loc":{"long":9.96746,"lat":52.76288},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-5242,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":30,"bearingENG":"NNE","distanceKM":38.598,"distanceMI":23.984}},{"id":"5b0e48b41788b069371f58ed","loc":{"long":9.91152,"lat":52.72203},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-27572,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":28,"bearingENG":"NNE","distanceKM":32.803,"distanceMI":20.383}},{"id":"5b0e48a81788b069371f5598","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-12744,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":33.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5595","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-15833,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":33.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5591","loc":{"long":10.17823,"lat":52.54339},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-24107,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":34.613,"distanceMI":21.508}},{"id":"5b0e48a81788b069371f558f","loc":{"long":10.17099,"lat":52.52844},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-21812,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":33.738,"distanceMI":20.964}},{"id":"5b0e48941788b069371f5003","loc":{"long":10.17256,"lat":52.52851},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-14400,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":33.843,"distanceMI":21.029}},{"id":"5b0e48941788b069371f5001","loc":{"long":10.1675,"lat":52.5423},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-21828,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":33.881,"distanceMI":21.053}},{"id":"5b0e48941788b069371f4fff","loc":{"long":10.20254,"lat":52.49207},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-30292,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":85,"bearingENG":"E","distanceKM":35.215,"distanceMI":21.882}},{"id":"5b0e48941788b069371f4ffd","loc":{"long":10.14078,"lat":52.52711},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-42701,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":31.713,"distanceMI":19.706}},{"id":"5b0e48941788b069371f4ffb","loc":{"long":10.17937,"lat":52.52588},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-22424,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":34.231,"distanceMI":21.27}},{"id":"5b0e486c1788b069371f4527","loc":{"long":10.1151,"lat":52.53317},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-6976,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":30.195,"distanceMI":18.762}},{"id":"5b0e486e1788b069371f456d","loc":{"long":10.00265,"lat":52.62304},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":39500,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662702,"recISO":"2018-05-30T06:45:02+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":50,"bearingENG":"NE","distanceKM":28.029,"distanceMI":17.416}},{"id":"5b0e486c1788b069371f4523","loc":{"long":10.14069,"lat":52.49329},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-13099,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":84,"bearingENG":"E","distanceKM":31.064,"distanceMI":19.302}},{"id":"5b0e486c1788b069371f4520","loc":{"long":10.14185,"lat":52.49571},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-20753,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":31.173,"distanceMI":19.37}},{"id":"5b0e486c1788b069371f451d","loc":{"long":10.23725,"lat":52.55675},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-10549,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":74,"bearingENG":"ENE","distanceKM":38.855,"distanceMI":24.143}},{"id":"5b0e486c1788b069371f451b","loc":{"long":10.14205,"lat":52.49592},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-34106,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":31.19,"distanceMI":19.381}}]})");
nlohmann::json jj_lightning_lt15km = nlohmann::json::parse(R"({"success":true,"error":null,"response":[{"id":"5b0e49471788b069371f8319","loc":{"long":10.17842,"lat":52.5329},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-10943,"numSensors":13,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":4.339,"distanceMI":21.337}},{"id":"5b0e49471788b069371f8317","loc":{"long":10.14298,"lat":52.52253},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-21503,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":1.746,"distanceMI":19.726}},{"id":"5b0e48fd1788b069371f6e5b","loc":{"long":10.15956,"lat":52.54143},"ob":{"timestamp":1527662831,"dateTimeISO":"2018-05-30T06:47:11+00:00","age":126,"pulse":{"type":"cg","peakamp":-3869,"numSensors":16,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662845,"recISO":"2018-05-30T06:47:25+00:00","age":126,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":3.337,"distanceMI":20.715}},{"id":"5b0e48d61788b069371f62d2","loc":{"long":10.2544,"lat":52.47834},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-14706,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":8.612,"distanceMI":23.992}},{"id":"5b0e48d61788b069371f62d0","loc":{"long":10.25678,"lat":52.47881},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-20186,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":8.776,"distanceMI":24.094}},{"id":"5b0e48cd1788b069371f6073","loc":{"long":10.20136,"lat":52.52286},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-24573,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":79,"bearingENG":"E","distanceKM":5.623,"distanceMI":22.135}},{"id":"5b0e48cd1788b069371f6071","loc":{"long":10.15373,"lat":52.51353},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-31132,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":80,"bearingENG":"E","distanceKM":2.264,"distanceMI":20.048}},{"id":"5b0e48b41788b069371f58ef","loc":{"long":9.96746,"lat":52.76288},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-5242,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":30,"bearingENG":"NNE","distanceKM":8.598,"distanceMI":23.984}},{"id":"5b0e48b41788b069371f58ed","loc":{"long":9.91152,"lat":52.72203},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-27572,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":28,"bearingENG":"NNE","distanceKM":2.803,"distanceMI":20.383}},{"id":"5b0e48a81788b069371f5598","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-12744,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":3.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5595","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-15833,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":3.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5591","loc":{"long":10.17823,"lat":52.54339},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-24107,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":4.613,"distanceMI":21.508}},{"id":"5b0e48a81788b069371f558f","loc":{"long":10.17099,"lat":52.52844},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-21812,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":3.738,"distanceMI":20.964}},{"id":"5b0e48941788b069371f5003","loc":{"long":10.17256,"lat":52.52851},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-14400,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":3.843,"distanceMI":21.029}},{"id":"5b0e48941788b069371f5001","loc":{"long":10.1675,"lat":52.5423},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-21828,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":3.881,"distanceMI":21.053}},{"id":"5b0e48941788b069371f4fff","loc":{"long":10.20254,"lat":52.49207},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-30292,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":85,"bearingENG":"E","distanceKM":5.215,"distanceMI":21.882}},{"id":"5b0e48941788b069371f4ffd","loc":{"long":10.14078,"lat":52.52711},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-42701,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":1.713,"distanceMI":19.706}},{"id":"5b0e48941788b069371f4ffb","loc":{"long":10.17937,"lat":52.52588},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-22424,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":4.231,"distanceMI":21.27}},{"id":"5b0e486c1788b069371f4527","loc":{"long":10.1151,"lat":52.53317},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-6976,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":0.195,"distanceMI":18.762}},{"id":"5b0e486e1788b069371f456d","loc":{"long":10.00265,"lat":52.62304},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":39500,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662702,"recISO":"2018-05-30T06:45:02+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":50,"bearingENG":"NE","distanceKM":28.029,"distanceMI":17.416}},{"id":"5b0e486c1788b069371f4523","loc":{"long":10.14069,"lat":52.49329},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-13099,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":84,"bearingENG":"E","distanceKM":1.064,"distanceMI":19.302}},{"id":"5b0e486c1788b069371f4520","loc":{"long":10.14185,"lat":52.49571},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-20753,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":1.173,"distanceMI":19.37}},{"id":"5b0e486c1788b069371f451d","loc":{"long":10.23725,"lat":52.55675},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-10549,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":74,"bearingENG":"ENE","distanceKM":8.855,"distanceMI":24.143}},{"id":"5b0e486c1788b069371f451b","loc":{"long":10.14205,"lat":52.49592},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-34106,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":1.19,"distanceMI":19.381}}]})");
nlohmann::json jj_lightning_lt14_5km = nlohmann::json::parse(R"({"success":true,"error":null,"response":[{"id":"5b0e49471788b069371f8319","loc":{"long":10.17842,"lat":52.5329},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-10943,"numSensors":13,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":4.139,"distanceMI":21.337}},{"id":"5b0e49471788b069371f8317","loc":{"long":10.14298,"lat":52.52253},"ob":{"timestamp":1527662907,"dateTimeISO":"2018-05-30T06:48:27+00:00","age":50,"pulse":{"type":"cg","peakamp":-21503,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662919,"recISO":"2018-05-30T06:48:39+00:00","age":50,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":1.746,"distanceMI":19.726}},{"id":"5b0e48fd1788b069371f6e5b","loc":{"long":10.15956,"lat":52.54143},"ob":{"timestamp":1527662831,"dateTimeISO":"2018-05-30T06:47:11+00:00","age":126,"pulse":{"type":"cg","peakamp":-3869,"numSensors":16,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662845,"recISO":"2018-05-30T06:47:25+00:00","age":126,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":3.337,"distanceMI":20.715}},{"id":"5b0e48d61788b069371f62d2","loc":{"long":10.2544,"lat":52.47834},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-14706,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":8.612,"distanceMI":23.992}},{"id":"5b0e48d61788b069371f62d0","loc":{"long":10.25678,"lat":52.47881},"ob":{"timestamp":1527662793,"dateTimeISO":"2018-05-30T06:46:33+00:00","age":164,"pulse":{"type":"cg","peakamp":-20186,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662806,"recISO":"2018-05-30T06:46:46+00:00","age":164,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":87,"bearingENG":"E","distanceKM":8.776,"distanceMI":24.094}},{"id":"5b0e48cd1788b069371f6073","loc":{"long":10.20136,"lat":52.52286},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-24573,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":79,"bearingENG":"E","distanceKM":5.623,"distanceMI":22.135}},{"id":"5b0e48cd1788b069371f6071","loc":{"long":10.15373,"lat":52.51353},"ob":{"timestamp":1527662784,"dateTimeISO":"2018-05-30T06:46:24+00:00","age":173,"pulse":{"type":"cg","peakamp":-31132,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662797,"recISO":"2018-05-30T06:46:37+00:00","age":173,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":80,"bearingENG":"E","distanceKM":2.264,"distanceMI":20.048}},{"id":"5b0e48b41788b069371f58ef","loc":{"long":9.96746,"lat":52.76288},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-5242,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":30,"bearingENG":"NNE","distanceKM":8.598,"distanceMI":23.984}},{"id":"5b0e48b41788b069371f58ed","loc":{"long":9.91152,"lat":52.72203},"ob":{"timestamp":1527662759,"dateTimeISO":"2018-05-30T06:45:59+00:00","age":198,"pulse":{"type":"cg","peakamp":-27572,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662772,"recISO":"2018-05-30T06:46:12+00:00","age":198,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":28,"bearingENG":"NNE","distanceKM":2.803,"distanceMI":20.383}},{"id":"5b0e48a81788b069371f5598","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-12744,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":3.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5595","loc":{"long":10.16221,"lat":52.53359},"ob":{"timestamp":1527662748,"dateTimeISO":"2018-05-30T06:45:48+00:00","age":209,"pulse":{"type":"cg","peakamp":-15833,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":209,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":76,"bearingENG":"ENE","distanceKM":3.291,"distanceMI":20.686}},{"id":"5b0e48a81788b069371f5591","loc":{"long":10.17823,"lat":52.54339},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-24107,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":4.613,"distanceMI":21.508}},{"id":"5b0e48a81788b069371f558f","loc":{"long":10.17099,"lat":52.52844},"ob":{"timestamp":1527662747,"dateTimeISO":"2018-05-30T06:45:47+00:00","age":210,"pulse":{"type":"cg","peakamp":-21812,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662760,"recISO":"2018-05-30T06:46:00+00:00","age":210,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":3.738,"distanceMI":20.964}},{"id":"5b0e48941788b069371f5003","loc":{"long":10.17256,"lat":52.52851},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-14400,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":3.843,"distanceMI":21.029}},{"id":"5b0e48941788b069371f5001","loc":{"long":10.1675,"lat":52.5423},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-21828,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":3.881,"distanceMI":21.053}},{"id":"5b0e48941788b069371f4fff","loc":{"long":10.20254,"lat":52.49207},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-30292,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":85,"bearingENG":"E","distanceKM":5.215,"distanceMI":21.882}},{"id":"5b0e48941788b069371f4ffd","loc":{"long":10.14078,"lat":52.52711},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-42701,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":77,"bearingENG":"ENE","distanceKM":1.713,"distanceMI":19.706}},{"id":"5b0e48941788b069371f4ffb","loc":{"long":10.17937,"lat":52.52588},"ob":{"timestamp":1527662727,"dateTimeISO":"2018-05-30T06:45:27+00:00","age":230,"pulse":{"type":"cg","peakamp":-22424,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662740,"recISO":"2018-05-30T06:45:40+00:00","age":230,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":78,"bearingENG":"ENE","distanceKM":4.231,"distanceMI":21.27}},{"id":"5b0e486c1788b069371f4527","loc":{"long":10.1151,"lat":52.53317},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-6976,"numSensors":7,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":75,"bearingENG":"ENE","distanceKM":0.195,"distanceMI":18.762}},{"id":"5b0e486e1788b069371f456d","loc":{"long":10.00265,"lat":52.62304},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":39500,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662702,"recISO":"2018-05-30T06:45:02+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":50,"bearingENG":"NE","distanceKM":28.029,"distanceMI":17.416}},{"id":"5b0e486c1788b069371f4523","loc":{"long":10.14069,"lat":52.49329},"ob":{"timestamp":1527662689,"dateTimeISO":"2018-05-30T06:44:49+00:00","age":268,"pulse":{"type":"cg","peakamp":-13099,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":268,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":84,"bearingENG":"E","distanceKM":1.064,"distanceMI":19.302}},{"id":"5b0e486c1788b069371f4520","loc":{"long":10.14185,"lat":52.49571},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-20753,"numSensors":8,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":1.173,"distanceMI":19.37}},{"id":"5b0e486c1788b069371f451d","loc":{"long":10.23725,"lat":52.55675},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-10549,"numSensors":5,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":74,"bearingENG":"ENE","distanceKM":8.855,"distanceMI":24.143}},{"id":"5b0e486c1788b069371f451b","loc":{"long":10.14205,"lat":52.49592},"ob":{"timestamp":1527662688,"dateTimeISO":"2018-05-30T06:44:48+00:00","age":269,"pulse":{"type":"cg","peakamp":-34106,"numSensors":6,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1527662700,"recISO":"2018-05-30T06:45:00+00:00","age":269,"relativeTo":{"lat":52.46106,"long":9.68508,"bearing":83,"bearingENG":"E","distanceKM":1.19,"distanceMI":19.381}}]})");
nlohmann::json jj_oneLightning = R"({"success":true,"error":null,"response":[{"id":"5b1f4e6bc17d4e3b0501df0f","loc":{"long":19.42167,"lat":49.95794},"ob":{"timestamp":1528778334,"dateTimeISO":"2018-06-12T04:38:54+00:00","age":230,"pulse":{"type":"cg","peakamp":-11528,"numSensors":10,"icHeightM":0,"icHeightFT":0}},"recTimestamp":1528778347,"recISO":"2018-06-12T04:39:07+00:00","age":230,"relativeTo":{"lat":50.08333,"long":19.91667,"bearing":248,"bearingENG":"WSW","distanceKM":38.014,"distanceMI":23.621}}]})";
};
|
84171b7a03ae65dbc85aa8eead37913bacf24071
|
67f690395fa1023cb834bfe8b87d013900dbadf2
|
/ZYBO/zybo_vivado_proj/zybo_vivado_proj.sdk/zyboApp/src/Screen/ScrSweepSettings.cpp
|
08deb2fba792fb982765395734c0caf13cae4d17
|
[] |
no_license
|
eusebiuburlacu/WWS
|
a835f3fcba64e48d4d40afe0f52288cce3b1b1b9
|
fe3fc4313021109937f2c5a2ebcf6df0c77ffee5
|
refs/heads/master
| 2021-01-10T12:06:55.445683
| 2016-05-03T19:02:46
| 2016-05-03T19:02:46
| 50,795,847
| 1
| 4
| null | 2016-02-19T11:58:09
| 2016-01-31T21:18:57
|
C++
|
UTF-8
|
C++
| false
| false
| 936
|
cpp
|
ScrSweepSettings.cpp
|
/*
* ScrSweepSettings.h
*
* Created on: 12.03.2016
* Author: Sebi
*/
#include "Screen/ScrSweepSettings.h"
#include "stdio.h"
#include "RF/mrf24j.h"
extern int arrayIdx;
extern Mrf24j RF;
extern unsigned long measuringFreq;
unsigned long freqSet = 5000;
ScrSweepSettings::ScrSweepSettings()
{
}
ScrSweepSettings::~ScrSweepSettings()
{
}
void ScrSweepSettings::sendIncCmd()
{
freqSet += 100;
if(freqSet > 50000)
freqSet = 0;
}
void ScrSweepSettings::sendDecrCmd()
{
freqSet -= 100;
if(freqSet <= 1000)
freqSet = 50000;
}
void ScrSweepSettings::sendChScrCmd()
{
}
void ScrSweepSettings::sendConfirmCmd()
{
arrayIdx = -1;
RF.sendData( 0x6001, 2, freqSet );
}
void ScrSweepSettings::printData()
{
OLED.setCursor(0, 1);
char data[20];
sprintf(data, "%d Hz", freqSet);
OLED.putString("set frequency");
if( 0 == arrayIdx )
{
OLED.setCursor(3, 3);
OLED.putString(data);
}
OLED.updateDisplay();
}
|
0b0da5376c4cd5774dc3a74cc1c82c65fcef75c0
|
bda2f1a7b6db60444047c6930720440c2ed59599
|
/C++_Base/src/showBits2.cpp
|
255b42c66098f2f56ed1654525680a2b7fd7cbc5
|
[] |
no_license
|
Ansonjo/cpp
|
c9c7322c485d0b901762bd150f847c116639dc01
|
823d3f4acd5c702f557b0baf21130133f043e0f0
|
refs/heads/master
| 2021-06-14T06:30:05.667068
| 2020-06-09T07:50:54
| 2020-06-09T07:50:54
| 90,263,941
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 483
|
cpp
|
showBits2.cpp
|
#include <iostream>
using namespace std;
void showbits(int var)
{
typedef unsigned char uc;
uc* p = (uc*)&var;//得到第一个字节
for(int j = 0;j < 4;j++,p++)
{
uc byte = *p;
for(int i = 0;i < 8;i++)
{
cout << (0x80 & byte ? '1' : '0');
byte = byte << 1;
}
cout << ' ';
}
}//打印出来的是0x64 0x63 0x62 0x61,这就是小端系统
//否则就是大端系统
int main( )
{
int x ;
cout << "请输入一个数: ";
cin >> x;
showbits(x);
return 0;
}
|
375cbd480a2ef1f64c2aedf92e5e222f3681e919
|
fc56d34ba1cbf28fe55c7a20c9895d580fc91418
|
/metaengine.cpp
|
f615568070cbce709ea79adabe322398dc37a72f
|
[] |
no_license
|
Deledrius/scummvm-asylum
|
a2d842ebac7536264e09b8dd210d24a7feb26387
|
ccff8974a87a9a6116393dbf1c295b9c2ed0c7a5
|
refs/heads/master
| 2021-07-17T14:19:24.988585
| 2021-03-22T12:00:56
| 2021-03-22T12:00:56
| 102,463,478
| 8
| 3
| null | 2021-02-12T12:35:46
| 2017-09-05T09:41:21
|
C++
|
UTF-8
|
C++
| false
| false
| 2,892
|
cpp
|
metaengine.cpp
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "engines/advancedDetector.h"
#include "base/plugins.h"
#include "asylum/asylum.h"
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
virtual const char *getName() const override {
return "asylum";
}
virtual const char *getOriginalCopyright() const {
return "Sanitarium (c) ASC Games";
}
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
virtual bool hasFeature(MetaEngineFeature f) const override;
virtual SaveStateList listSaves(const char *target) const override;
virtual int getMaximumSaveSlot() const override;
virtual void removeSaveState(const char *target, int slot) const override;
};
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime) ||
(f == kSupportsSubtitleOptions);
}
Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Asylum::AsylumEngine(syst, desc);
}
return desc ? Common::kNoError : Common::kUnsupportedGameidError;
}
SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
error("[AsylumMetaEngine::listSaves] Not implemented");
}
int AsylumMetaEngine::getMaximumSaveSlot() const {
error("[AsylumMetaEngine::getMaximumSaveSlot] Not implemented");
}
void AsylumMetaEngine::removeSaveState(const char * /*target*/, int /*slot*/) const {
error("[AsylumMetaEngine::removeSaveState] Not implemented");
}
#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#else
REGISTER_PLUGIN_STATIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#endif
|
bde4a7447e0924fdccf7bc67033efc64461ee87c
|
5e50fcdef7ac87b11e61c27613b73b2e9891271e
|
/Iterator for Lsll/Iterator for Lsll/Node.h
|
e50f0b456622cc345ffb50a641bb0955bb891331
|
[] |
no_license
|
BilalAli181999/Data-Structures-in-C_Plus_Plus
|
70dfd4b8d7dc72a69ff1d797f584517b3e4f80a1
|
bbe6dad9763cd863c53086791f8b6bc4be09eaa7
|
refs/heads/master
| 2020-07-16T05:02:04.436346
| 2019-09-01T20:03:11
| 2019-09-01T20:03:11
| 205,724,906
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 182
|
h
|
Node.h
|
#ifndef NODE_H
#define NODE_H
template <typename T>
class Node
{
public:
T info;
Node<T> *next;
Node()
{
next = 0;
}
Node(T val)
{
info = val;
next = 0;
}
};
#endif
|
60e6eb3cb897f39c94452cc242340aa79512f267
|
4fd97ff64e457d41820348aebaea704ca4abc48b
|
/src/layers/legacy/medCoreLegacy/gui/commonWidgets/medComboBox.h
|
de336394c02114e53999a274037bf748b2ff0824
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
Florent2305/medInria-public
|
c075b2064b2fe96081197ce300777be5be18a339
|
595a2ce62c8864c4ecb8acbf0d50e32aa734ed8f
|
refs/heads/master
| 2023-08-08T00:41:51.671245
| 2023-04-12T07:46:33
| 2023-04-12T07:46:33
| 98,999,842
| 1
| 1
|
BSD-4-Clause
| 2021-05-31T08:38:28
| 2017-08-01T12:39:01
|
C++
|
UTF-8
|
C++
| false
| false
| 886
|
h
|
medComboBox.h
|
#pragma once
/*=========================================================================
medInria
Copyright (c) INRIA 2013 - 2020. All rights reserved.
See LICENSE.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#include <QComboBox>
#include <medCoreLegacyExport.h>
/**
* @brief The medComboBox class is based on QComboBox. It deactivates the wheelEvent.
*/
class MEDCORELEGACY_EXPORT medComboBox: public QComboBox
{
Q_OBJECT
public:
medComboBox(QWidget* parent = nullptr): QComboBox(parent)
{
this->setFocusPolicy(Qt::StrongFocus);
}
// No wheel event for these QCombobox to avoid changes during a scroll
void wheelEvent(QWheelEvent*){}
};
|
cbf348bfe80ec1f4804a97c8b53dbd6d953632db
|
00add89b1c9712db1a29a73f34864854a7738686
|
/packages/utility/distribution/src/Utility_NormalDistribution_def.hpp
|
16c4e65300201412211c219c82320675044351c1
|
[
"BSD-3-Clause"
] |
permissive
|
FRENSIE/FRENSIE
|
a4f533faa02e456ec641815886bc530a53f525f9
|
1735b1c8841f23d415a4998743515c56f980f654
|
refs/heads/master
| 2021-11-19T02:37:26.311426
| 2021-09-08T11:51:24
| 2021-09-08T11:51:24
| 7,826,404
| 11
| 6
|
NOASSERTION
| 2021-09-08T11:51:25
| 2013-01-25T19:03:09
|
C++
|
UTF-8
|
C++
| false
| false
| 18,439
|
hpp
|
Utility_NormalDistribution_def.hpp
|
//---------------------------------------------------------------------------//
//!
//! \file Utility_NormalDistribution_def.hpp
//! \author Alex Robinson
//! \brief Normal distribution class declaration.
//!
//---------------------------------------------------------------------------//
#ifndef UTILITY_NORMAL_DISTRIBUTION_DEF_HPP
#define UTILITY_NORMAL_DISTRIBUTION_DEF_HPP
// FRENSIE Includes
#include "Utility_RandomNumberGenerator.hpp"
#include "Utility_PhysicalConstants.hpp"
#include "Utility_ExceptionTestMacros.hpp"
#include "Utility_ExceptionCatchMacros.hpp"
#include "Utility_DesignByContract.hpp"
BOOST_SERIALIZATION_DISTRIBUTION2_EXPORT_IMPLEMENT( UnitAwareNormalDistribution );
namespace Utility{
// Initialize the constant norm factor
template<typename IndependentUnit, typename DependentUnit>
const double UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::constant_norm_factor = 1.0/sqrt( 2*PhysicalConstants::pi );
// Constructor
/*! \details This constructor will explicitly cast the input quantities to
* the distribution quantity (which includes any unit-conversion). The
* dimension type must match and there must be a unit-conversion defined using
* the boost methodology.
*/
template<typename IndependentUnit, typename DependentUnit>
template<typename InputDepQuantity,
typename InputIndepQuantityA,
typename InputIndepQuantityB,
typename InputIndepQuantityC>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::UnitAwareNormalDistribution(
const InputIndepQuantityA mean,
const InputIndepQuantityB standard_deviation,
const InputDepQuantity constant_multiplier,
const InputIndepQuantityC min_independent_value,
const InputIndepQuantityC max_independent_value )
: d_constant_multiplier( constant_multiplier ),
d_mean( mean ),
d_standard_deviation( standard_deviation ),
d_min_independent_value( min_independent_value ),
d_max_independent_value( max_independent_value )
{
// Verify that the shape parameters are valid
this->verifyValidShapeParameters( d_constant_multiplier,
d_mean,
d_standard_deviation,
d_min_independent_value,
d_max_independent_value );
BOOST_SERIALIZATION_CLASS_EXPORT_IMPLEMENT_FINALIZE( ThisType );
}
// Copy constructor
/*! \details Just like boost::units::quantity objects, the unit-aware
* distribution can be explicitly cast to a distribution with compatible
* units. If the units are not compatible, this function will not compile. Note
* that this allows distributions to be scaled safely (unit conversions
* are completely taken care of by boost::units)!
*/
template<typename IndependentUnit, typename DependentUnit>
template<typename InputIndepUnit, typename InputDepUnit>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::UnitAwareNormalDistribution(
const UnitAwareNormalDistribution<InputIndepUnit,InputDepUnit>& dist_instance )
: d_constant_multiplier( dist_instance.d_constant_multiplier ),
d_mean( dist_instance.d_mean ),
d_standard_deviation( dist_instance.d_standard_deviation ),
d_min_independent_value( dist_instance.d_min_independent_value ),
d_max_independent_value( dist_instance.d_max_independent_value )
{
BOOST_SERIALIZATION_CLASS_EXPORT_IMPLEMENT_FINALIZE( ThisType );
}
// Copy constructor (copying from unitless distribution only)
template<typename IndependentUnit, typename DependentUnit>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::UnitAwareNormalDistribution( const UnitAwareNormalDistribution<void,void>& unitless_dist_instance, int )
: d_constant_multiplier( DQT::initializeQuantity( unitless_dist_instance.d_constant_multiplier ) ),
d_mean( IQT::initializeQuantity( unitless_dist_instance.d_mean ) ),
d_standard_deviation( IQT::initializeQuantity( unitless_dist_instance.d_standard_deviation ) ),
d_min_independent_value( IQT::initializeQuantity( unitless_dist_instance.d_min_independent_value ) ),
d_max_independent_value( IQT::initializeQuantity( unitless_dist_instance.d_max_independent_value ) )
{
BOOST_SERIALIZATION_CLASS_EXPORT_IMPLEMENT_FINALIZE( ThisType );
}
// Construct distribution from a unitless dist. (potentially dangerous)
/*! \details Constructing a unit-aware distribution from a unitless
* distribution is potentially dangerous. By forcing users to construct objects
* using this method instead of a standard constructor we are trying to make
* sure users are aware of the danger. This is designed to mimic the interface
* of the boost::units::quantity, which also has to deal with this issue.
*/
template<typename IndependentUnit, typename DependentUnit>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::fromUnitlessDistribution( const UnitAwareNormalDistribution<void,void>& unitless_distribution )
{
return ThisType( unitless_distribution, 0 );
}
// Assignment operator
template<typename IndependentUnit, typename DependentUnit>
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>&
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::operator=(
const UnitAwareNormalDistribution<IndependentUnit,DependentUnit>& dist_instance )
{
if( this != &dist_instance )
{
d_constant_multiplier = dist_instance.d_constant_multiplier;
d_mean = dist_instance.d_mean;
d_standard_deviation = dist_instance.d_standard_deviation;
d_min_independent_value = dist_instance.d_min_independent_value;
d_max_independent_value = dist_instance.d_max_independent_value;
}
return *this;
}
// Evaluate the distribution
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::DepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::evaluate( const UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity indep_var_value ) const
{
if( indep_var_value < d_min_independent_value )
return DQT::zero();
else if( indep_var_value > d_max_independent_value )
return DQT::zero();
else
{
double argument = -(indep_var_value-d_mean)*(indep_var_value-d_mean)/
(2.0*d_standard_deviation*d_standard_deviation);
return d_constant_multiplier*exp( argument );
}
}
// Evaluate the PDF
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::InverseIndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::evaluatePDF( const UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity indep_var_value ) const
{
if( indep_var_value < d_min_independent_value )
return IIQT::zero();
else if( indep_var_value > d_max_independent_value )
return IIQT::zero();
else
{
double argument = -(indep_var_value-d_mean)*(indep_var_value-d_mean)/
(2.0*d_standard_deviation*d_standard_deviation);
return UnitAwareNormalDistribution::constant_norm_factor*exp( argument )/
d_standard_deviation;
}
}
// Return a random sample from the distribution
template<typename IndependentUnit, typename DependentUnit>
inline typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::sample(
const IndepQuantity mean,
const IndepQuantity standard_deviation,
const IndepQuantity min_independent_value,
const IndepQuantity max_independent_value )
{
DistributionTraits::Counter number_of_trials;
return ThisType::sampleAndRecordTrials( number_of_trials,
mean,
standard_deviation,
min_independent_value,
max_independent_value );
}
// Return a random sample from the distribution
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::sample() const
{
return ThisType::sample( d_mean,
d_standard_deviation,
d_min_independent_value,
d_max_independent_value );
}
// Return a random sample from the distribution
template<typename IndependentUnit, typename DependentUnit>
inline typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::sampleAndRecordTrials(
DistributionTraits::Counter& trials,
const IndepQuantity mean,
const IndepQuantity standard_deviation,
const IndepQuantity min_independent_value,
const IndepQuantity max_independent_value )
{
double random_number_1, random_number_2;
double x, y;
IndepQuantity sample;
while( true )
{
// Use the rejection sampling technique outlined by Kahn in "Applications
// of Monte Carlo" (1954)
while( true )
{
++trials;
random_number_1 = RandomNumberGenerator::getRandomNumber<double>();
random_number_2 = RandomNumberGenerator::getRandomNumber<double>();
x = -log( random_number_1 );
y = -log( random_number_2 );
if( 0.5*(x - 1)*(x - 1) <= y )
break;
}
if( RandomNumberGenerator::getRandomNumber<double>() < 0.5 )
x *= -1.0;
// stretch and shift the sampled value
sample = standard_deviation*x+mean;
if( sample >= min_independent_value &&
sample <= max_independent_value )
break;
}
return sample;
}
// Return a random sample from the corresponding CDF and record the number of trials
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::sampleAndRecordTrials( DistributionTraits::Counter& trials ) const
{
return ThisType::sampleAndRecordTrials( trials,
d_mean,
d_standard_deviation,
d_min_independent_value,
d_max_independent_value );
}
// Return the upper bound of the distribution independent variable
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::getUpperBoundOfIndepVar() const
{
return d_max_independent_value;
}
// Return the lower bound of the distribution independent variable
template<typename IndependentUnit, typename DependentUnit>
typename UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::IndepQuantity
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::getLowerBoundOfIndepVar() const
{
return d_min_independent_value;
}
// Return the distribution type
template<typename IndependentUnit, typename DependentUnit>
UnivariateDistributionType
UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::getDistributionType() const
{
return ThisType::distribution_type;
}
// Test if the distribution is continuous
template<typename IndependentUnit, typename DependentUnit>
bool UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::isContinuous() const
{
return true;
}
// Method for placing the object in an output stream
template<typename IndependentUnit, typename DependentUnit>
void UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::toStream( std::ostream& os ) const
{
this->toStreamWithLimitsDistImpl( os,
std::make_pair( "mean", d_mean ),
std::make_pair( "standard dev", d_standard_deviation ),
std::make_pair( "multiplier", d_constant_multiplier ) );
}
// Save the distribution to an archive
template<typename IndependentUnit, typename DependentUnit>
template<typename Archive>
void UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::save( Archive& ar, const unsigned version ) const
{
// Save the base class first
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( BaseType );
// Save the local member data
ar & BOOST_SERIALIZATION_NVP( d_constant_multiplier );
ar & BOOST_SERIALIZATION_NVP( d_mean );
ar & BOOST_SERIALIZATION_NVP( d_standard_deviation );
// We cannot safely serialize -inf to all archive types - create a flag that
// records if the lower limit is -inf
const bool __lower_limit_is_neg_inf__ =
(d_min_independent_value == -IQT::inf());
ar & BOOST_SERIALIZATION_NVP( __lower_limit_is_neg_inf__ );
if( __lower_limit_is_neg_inf__ )
{
IndepQuantity tmp_lower_limit = IQT::lowest();
ar & boost::serialization::make_nvp( "d_min_independent_value", tmp_lower_limit );
}
else
{
ar & BOOST_SERIALIZATION_NVP( d_min_independent_value );
}
// We cannot safely serialize inf to all archive types - create a flag that
// records if the upper limit is inf
const bool __upper_limit_is_inf__ = (d_max_independent_value == IQT::inf());
ar & BOOST_SERIALIZATION_NVP( __upper_limit_is_inf__ );
if( __upper_limit_is_inf__ )
{
IndepQuantity tmp_upper_limit = IQT::max();
ar & boost::serialization::make_nvp( "d_max_independent_value", tmp_upper_limit );
}
else
{
ar & BOOST_SERIALIZATION_NVP( d_max_independent_value );
}
}
// Load the distribution from an archive
template<typename IndependentUnit, typename DependentUnit>
template<typename Archive>
void UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::load( Archive& ar, const unsigned version )
{
// Load the base class first
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( BaseType );
// Load the local member data
ar & BOOST_SERIALIZATION_NVP( d_constant_multiplier );
ar & BOOST_SERIALIZATION_NVP( d_mean );
ar & BOOST_SERIALIZATION_NVP( d_standard_deviation );
// Load the lower limit inf flag
bool __lower_limit_is_neg_inf__;
ar & BOOST_SERIALIZATION_NVP( __lower_limit_is_neg_inf__ );
ar & BOOST_SERIALIZATION_NVP( d_min_independent_value );
// Restore the neg inf value of the lower limit
if( __lower_limit_is_neg_inf__ )
d_min_independent_value = -IQT::inf();
// Load the upper limit inf flag
bool __upper_limit_is_inf__;
ar & BOOST_SERIALIZATION_NVP( __upper_limit_is_inf__ );
ar & BOOST_SERIALIZATION_NVP( d_max_independent_value );
if( __upper_limit_is_inf__ )
d_max_independent_value = IQT::inf();
}
// Method for testing if two objects are equivalent
template<typename IndependentUnit, typename DependentUnit>
bool UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::operator==( const UnitAwareNormalDistribution& other ) const
{
return d_constant_multiplier == other.d_constant_multiplier &&
d_mean == other.d_mean &&
d_standard_deviation == other.d_standard_deviation &&
d_min_independent_value == other.d_min_independent_value &&
d_max_independent_value == other.d_max_independent_value;
}
// Method for testing if two objects are different
template<typename IndependentUnit, typename DependentUnit>
bool UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::operator!=( const UnitAwareNormalDistribution& other ) const
{
return d_constant_multiplier != other.d_constant_multiplier ||
d_mean != other.d_mean ||
d_standard_deviation != other.d_standard_deviation ||
d_min_independent_value != other.d_min_independent_value ||
d_max_independent_value != other.d_max_independent_value;
}
// Test if the dependent variable can be zero within the indep bounds
/*! \details If the absolute value of the lower or upper limit is Inf then it
* is possible for the distribution to return 0.0 from one of the evaluate
* methods. However, the 0.0 value will only occur if the distribution is
* evaluated at +/- Inf, which should never actually be done in practice, so we
* will return false from this method.
*/
template<typename IndependentUnit, typename DependentUnit>
bool UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::canDepVarBeZeroInIndepBounds() const
{
return false;
}
// Verify that the shape parameters are valid
template<typename IndependentUnit, typename DependentUnit>
void UnitAwareNormalDistribution<IndependentUnit,DependentUnit>::verifyValidShapeParameters(
const DepQuantity& const_multiplier,
const IndepQuantity& mean,
const IndepQuantity& standard_deviation,
const IndepQuantity& min_independent_value,
const IndepQuantity& max_independent_value )
{
TEST_FOR_EXCEPTION( DQT::isnaninf( const_multiplier ),
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed "
"because of the multiplier is invalid!" );
TEST_FOR_EXCEPTION( const_multiplier == DQT::zero(),
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed "
"because of the multiplier is invalid!" );
TEST_FOR_EXCEPTION( IQT::isnaninf( mean ),
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed "
"because the mean is invalid!" );
TEST_FOR_EXCEPTION( IQT::isnaninf( standard_deviation ),
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed "
"because the standard deviation is invalid!" );
TEST_FOR_EXCEPTION( standard_deviation <= IQT::zero(),
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed "
"because the standard deviation is invalid!" );
TEST_FOR_EXCEPTION( max_independent_value <= min_independent_value,
Utility::BadUnivariateDistributionParameter,
"The normal distribution cannot be constructed because "
"the upper limit is invalid!" );
}
} // end Utility namespace
EXTERN_EXPLICIT_TEMPLATE_CLASS_INST( Utility::UnitAwareNormalDistribution<void,void> );
EXTERN_EXPLICIT_CLASS_SAVE_LOAD_INST( Utility, UnitAwareNormalDistribution<void,void> );
#endif // end UTILITY_NORMAL_DISTRIBUTION_DEF_HPP
//---------------------------------------------------------------------------//
// end Utility_NormalDistribution_def.hpp
//---------------------------------------------------------------------------//
|
2065098c9d97501084dcd475ca3ffb94ceaf37aa
|
27168267643fa2e7b1ac347ed2b4d5cc9de8bdbf
|
/Libraries/ObjectItems/cObject_Channel.cpp
|
a9809485b17bdb55a665bbcfe66ce97eb9466567
|
[] |
no_license
|
hvanhorik-GDP/Master
|
f8c2b74c862963f78ee7ab987eec1e0a5b7860bd
|
0ec2e27c306959ff19d0358cbe40878a8564f0dc
|
refs/heads/master
| 2020-07-20T20:54:43.031754
| 2019-11-10T04:15:37
| 2019-11-10T04:15:37
| 206,706,071
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,157
|
cpp
|
cObject_Channel.cpp
|
#include "cObject_Channel.h"
#include "AudioEngine/cAudio_System.h"
#include "AudioEngine/cAudio_System_FMOD.h"
#include "AssetItems/cItem_Audio.h"
#include <iostream>
cObject_Channel::cObject_Channel()
: cObject_Common() // Need common items
, cObject_ChannelControl() // Full channel control
, cObject_3d() // This is a 3d Object
, cObject_Physics() // and physics applies to it
{
cAudio_System audio;
iAudio_System* impl = audio.Get_impl();
m_system = dynamic_cast<cAudio_System_FMOD*>(impl);
m_sound = new cAudio_Sound_FMOD();
m_channel = new cAudio_Channel_FMOD();
}
cObject_Channel::~cObject_Channel()
{
delete m_sound;
delete m_channel;
}
iObject* cObject_Channel::Clone(const std::string& newName)
{
// Copy everything and change the name
cObject_Channel* ret =
new cObject_Channel(*this);
ret->m_name = newName;
ret->m_node = NULL; // No XML so it won't update
ret->m_channel = new cAudio_Channel_FMOD();
ret->m_sound = new cAudio_Sound_FMOD();
return ret;
}
void cObject_Channel::playSound( bool paused )
{
assert(m_channel);
assert(m_system);
assert(m_sound);
cItem_Audio* item = dynamic_cast<cItem_Audio*>(m_Item);
assert(item);
FMOD_MODE mode = FMOD_CREATESTREAM;
m_system->CreateSound(*m_sound, item->m_fullPath, mode);
m_system->PlaySound(*m_sound, m_channel_group, paused, *m_channel);
std::cout << "Playing " << m_sound->m_sound << " channel ID: " << m_channel->m_channel << std::endl;
}
void cObject_Channel::IntegrationStep(float deltaTime)
{
assert(false);
}
// For debugging purposes - dumps the contents in human readable form
std::ostream& operator<<(std::ostream& stream, const cObject_Channel& val)
{
stream << "std::ostream& operator<<(std::ostream& stream, const cObject_Channel& val)" << "Not Implemented" << std::endl;
return stream;
}
//TODO - for now just implement them here.
// need to implement them in every class of iObject
// Recieve a message
bool cObject_Channel::RecieveMessage(const iMessage& message)
{
return false;
}
// Recieve a message and reply
bool cObject_Channel::RecieveAndRespond(const iMessage& in, iMessage& reply)
{
return false;
}
|
ef29241395c8d44fb76cc62074487e2d7dfd5992
|
81028f0cf4e470303c95f94be1189c59e416f95f
|
/URI/1552b.cpp
|
143d20c62197d3dab828ea0325495e7f6be89a80
|
[] |
no_license
|
vandersonmr/ProgrammingContest
|
d82a1a429abd58773eebc83bc238430c649004f2
|
10936bd030c16efdc7cb59b3eb961287f6102cc0
|
refs/heads/master
| 2021-01-18T07:51:50.419599
| 2015-08-03T01:34:55
| 2015-08-03T01:34:55
| 12,670,094
| 3
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,288
|
cpp
|
1552b.cpp
|
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <set>
#define MAX 505
using namespace std;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<double,ii> dii;
int pai[MAX], ranking[MAX];
set<dii> adj;
void unir(int a, int b){
if(ranking[a] >= ranking[b]){
pai[b] = a;
if(ranking[a] == ranking[b])
ranking[a]++;
}else
pai[a] = b;
}
int encontrar(int n){
if(pai[n]==n)
return n;
else
return pai[n] = encontrar(pai[n]);
}
double kruskal(){
int a, b;
double res = 0;
dii v;
while(!adj.empty()){
v = *adj.begin();
adj.erase(adj.begin());
a = encontrar(v.second.first);
b = encontrar(v.second.second);
if(a != b){
unir(a,b);
res += v.first;
}
}
return res;
}
int main(){
long int c;
int n;
double x, y, dist;
dd v[MAX];
scanf("%ld", &c);
for(long int i = 0; i < c; i++){
scanf("%d", &n);
for(int j = 1; j <= n; j++){
pai[j] = j;
ranking[j] = 0;
scanf("%lf %lf", &x, &y);
v[j] = dd(x,y);
for(int k = j-1; k >= 1; k--){
dist = sqrt(pow(v[j].first - v[k].first,2) + pow(v[j].second - v[k].second,2));
adj.insert(dii(dist/100,ii(j,k)));
}
}
printf("%.4lf\n", kruskal());
}
return 0;
}
|
5c9527bed162facf723382786b6843d669330dc0
|
2ab096890572411dad2c21db0ba4f18784f9b93a
|
/Arduino/Env_Sensor.ino
|
ae7286e666d7ad4356fd40b670bfaa71e99e554c
|
[] |
no_license
|
YangBH-0/semina2020_2
|
f77b8299c0808f3a675dc12e8771e551e31173ac
|
9abce8f090258e52f1a701a0d91d435b52ba0231
|
refs/heads/master
| 2022-12-18T07:01:18.643110
| 2020-09-28T09:29:05
| 2020-09-28T09:29:05
| 290,708,107
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,020
|
ino
|
Env_Sensor.ino
|
#include <SoftwareSerial.h>
#include "DHT.h"
#define DHTPIN 2 // 디지털 2번핀 사용
#define DHTTYPE DHT11 // DHT 11 모델사용
DHT dht(DHTPIN, DHTTYPE);
int cds=0;
String arduino_num = "01";
SoftwareSerial BTSerial(4,5); // Rx, Tx
void setup() {
Serial.begin(9600); // 시리얼 모니터
BTSerial.begin(9600); // 블루투스 시리얼 개방
dht.begin();
}
void loop() {
int h = dht.readHumidity(); // 습도 측정
int t = dht.readTemperature(); // 섭씨 온도 측정
cds = analogRead(A0);
//블루투스 시리얼 출력
BTSerial.print(arduino_num);
BTSerial.print(":");
BTSerial.print(h);
BTSerial.print(" ");
BTSerial.print(t);
BTSerial.print(" ");
BTSerial.print(cds);
BTSerial.print("!");
// 시리얼 모니터 출력
Serial.print(arduino_num);
Serial.print(":");
Serial.print(h);
Serial.print(" ");
Serial.print(t);
Serial.print(" ");
Serial.print(cds);
Serial.println();
delay(5000);
}
|
58bbc8281e80a12921aa3d03ce0586f6a315c5fd
|
97cfb46f5088f24e459328d5581fe582889fbf74
|
/Cell.cpp
|
52d7d3622df32dcca2c9c75f4bbe2e7b7d8a77e5
|
[] |
no_license
|
rostislavts/OOP-project-FMI
|
e20c376becfb224634aad88817c49181ad2fd8a4
|
9d693eea6a8ab7d0d30b558d11fb3831406466cd
|
refs/heads/master
| 2022-11-16T13:32:34.419300
| 2020-07-16T10:38:56
| 2020-07-16T10:38:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 436
|
cpp
|
Cell.cpp
|
#include "Cell.h"
Cell::Cell() { // invalid numbers
setIndexOfRow(-1);
setIndexOfCol(-1);
}
Cell::Cell(int indexOfRow, int indexOfCol) {
setIndexOfRow(indexOfRow);
setIndexOfCol(indexOfCol);
}
void Cell::setIndexOfRow(int row) {
this->indexOfRow = row;
}
void Cell::setIndexOfCol(int col) {
this->indexOfCol = col;
}
int Cell::getLengthOfData() const {
return -1; // invalid
}
double Cell::getValue() const {
return 0;
}
|
8a5758aa58316fe32562708fa35ab7f01f7b880b
|
c32ee8ade268240a8064e9b8efdbebfbaa46ddfa
|
/Libraries/m2sdk/ue/sys/gui/C_UniObjectCreator_1_TPL_E3497490.h
|
75701bc32e8355e69350ad6f4ee877ed1e1973e8
|
[] |
no_license
|
hopk1nz/maf2mp
|
6f65bd4f8114fdeb42f9407a4d158ad97f8d1789
|
814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8
|
refs/heads/master
| 2021-03-12T23:56:24.336057
| 2015-08-22T13:53:10
| 2015-08-22T13:53:10
| 41,209,355
| 19
| 21
| null | 2015-08-31T05:28:13
| 2015-08-22T13:56:04
|
C++
|
UTF-8
|
C++
| false
| false
| 590
|
h
|
C_UniObjectCreator_1_TPL_E3497490.h
|
// auto-generated file (rttidump-exporter by h0pk1nz)
#pragma once
#include <ue/sys/gui/C_UniFunctor_1_TPL_978C1783.h>
namespace ue
{
namespace sys
{
namespace gui
{
/** ue::sys::gui::C_UniObjectCreator_1<ue::sys::gui::widgets::controllers::C_ComboBoxKey> (VTable=0x01E8A440) */
class C_UniObjectCreator_1_TPL_E3497490 : public C_UniFunctor_1_TPL_978C1783
{
public:
virtual void vfn_0001_60A5CF1F() = 0;
virtual void vfn_0002_60A5CF1F() = 0;
virtual void vfn_0003_60A5CF1F() = 0;
virtual void vfn_0004_60A5CF1F() = 0;
};
} // namespace gui
} // namespace sys
} // namespace ue
|
8d33d50955ee3fb84402d2ab2d149be28218e97c
|
ffe43a8c5c4e79252eb7c36ccfd392343b22e69f
|
/kdecoration/breezeexceptionlist.cpp
|
4e5bd6b26349ca1efb8eb0f4fbf58afe57908343
|
[] |
no_license
|
KDE/breeze
|
3bed9e37c8081c888f6017120ad3a9200d71aea3
|
750ca9475c51eed769ed25042d0e8080f254b804
|
refs/heads/master
| 2023-08-19T20:31:36.200871
| 2023-08-18T11:31:22
| 2023-08-18T11:31:22
| 42,735,405
| 223
| 133
| null | 2022-08-09T15:46:43
| 2015-09-18T17:01:14
|
C++
|
UTF-8
|
C++
| false
| false
| 3,447
|
cpp
|
breezeexceptionlist.cpp
|
//////////////////////////////////////////////////////////////////////////////
// breezeexceptionlist.cpp
// window decoration exceptions
// -------------------
//
// SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////
#include "breezeexceptionlist.h"
namespace Breeze
{
//______________________________________________________________
void ExceptionList::readConfig(KSharedConfig::Ptr config)
{
_exceptions.clear();
QString groupName;
for (int index = 0; config->hasGroup(groupName = exceptionGroupName(index)); ++index) {
// create exception
InternalSettings exception;
// reset group
readConfig(&exception, config.data(), groupName);
// create new configuration
InternalSettingsPtr configuration(new InternalSettings());
configuration.data()->load();
// apply changes from exception
configuration->setEnabled(exception.enabled());
configuration->setExceptionType(exception.exceptionType());
configuration->setExceptionPattern(exception.exceptionPattern());
configuration->setMask(exception.mask());
// propagate all features found in mask to the output configuration
if (exception.mask() & BorderSize) {
configuration->setBorderSize(exception.borderSize());
}
configuration->setHideTitleBar(exception.hideTitleBar());
// append to exceptions
_exceptions.append(configuration);
}
}
//______________________________________________________________
void ExceptionList::writeConfig(KSharedConfig::Ptr config)
{
// remove all existing exceptions
QString groupName;
for (int index = 0; config->hasGroup(groupName = exceptionGroupName(index)); ++index) {
config->deleteGroup(groupName);
}
// rewrite current exceptions
int index = 0;
for (const InternalSettingsPtr &exception : std::as_const(_exceptions)) {
writeConfig(exception.data(), config.data(), exceptionGroupName(index));
++index;
}
}
//_______________________________________________________________________
QString ExceptionList::exceptionGroupName(int index)
{
return QString("Windeco Exception %1").arg(index);
}
//______________________________________________________________
void ExceptionList::writeConfig(KCoreConfigSkeleton *skeleton, KConfig *config, const QString &groupName)
{
// list of items to be written
const QStringList keys = {"Enabled", "ExceptionPattern", "ExceptionType", "HideTitleBar", "Mask", "BorderSize"};
// write all items
for (auto key : keys) {
KConfigSkeletonItem *item(skeleton->findItem(key));
if (!item) {
continue;
}
if (!groupName.isEmpty()) {
item->setGroup(groupName);
}
KConfigGroup configGroup(config, item->group());
configGroup.writeEntry(item->key(), item->property());
}
}
//______________________________________________________________
void ExceptionList::readConfig(KCoreConfigSkeleton *skeleton, KConfig *config, const QString &groupName)
{
const auto items = skeleton->items();
for (KConfigSkeletonItem *item : items) {
if (!groupName.isEmpty()) {
item->setGroup(groupName);
}
item->readConfig(config);
}
}
}
|
9bd8b49e655bf4f58c34f75242552ea1b6781c04
|
b5a93fa4f4383bee43c7909f40773639d4302cfe
|
/ProjectImmunity/Editor/MapEditor.h
|
304c2dbe67ff4e11e297de1b55659f63bc4a6601
|
[] |
no_license
|
rupee990/ProjectImmunity
|
1150efc76382681550e188b9d04515ccc99c5050
|
6e58083956abfaa207b9e35573ef2f763776e6c1
|
refs/heads/master
| 2021-07-08T09:00:29.860946
| 2020-10-02T00:58:01
| 2020-10-02T00:58:01
| 185,951,048
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,579
|
h
|
MapEditor.h
|
#pragma once
#include <vector>
#include <string>
namespace ru
{
class Map;
class Room;
class ResourceManager;
}
class Editor;
#define ButtonWidth 100
#define ButtonHeight 100
enum EditorTabs
{
TILEMAP = 0,
OBJVIEWER,
GENERATION
};
enum ToolStates
{
SELECT,
ROOM,
BRUSH,
ERASE,
COLLIDER
};
namespace sf
{
class Texture;
class Sprite;
}
struct Room;
class MapEditor
{
public:
MapEditor(Editor* editorManager_);
~MapEditor();
void UpdateEditorUI(float dt);
void Update(float dt);
void Render();
void NewMap(); //Initialize Map map and default map values
void NewRoom(unsigned int sizex_, unsigned int sizey_, float posx_, float posy_, std::string TileMap = "DebugTileMap");
//Various PopUps
void OpenTilemapPopup();
void TilemapParametersPopup();
//Refresh used Assets
void RefreshAssets();
private:
ru::Map* map;
Editor* editor;
EditorTabs currentTab = TILEMAP;
ToolStates toolState = SELECT;
sf::Texture* tilemap;
std::string tileMapAssetId;
sf::Sprite* tilemapSprite;
ru::Room* selectedRoom;
sf::Sprite* selectedTile;
sf::Sprite* tilePreview;
//Room Selection
float roomPos[2] = { 0,0 };
//Variables for Texture Selector Popup
bool isTextureSelectorOpen;
const char* textureName;
int* texture_id;
std::vector<const char*> textures_items;
//Variables for New Map popup
bool isNewMapOpen;
std::vector<const char*> map_items;
int layer = 0;
};
|
09359bbc6bc826a4ee14161abed681056f3ec810
|
7c5d7fb6a64df1a118a64bdf6087ecf395a3a722
|
/data/russia-team-h/sources/502-h-1.cpp
|
5add010917e6ff5784a5c9860bc994a68446b082
|
[] |
no_license
|
alexhein189/code-plagiarism-detector
|
e66df71c46cc5043b6825ef76a940b658c0e5015
|
68d21639d4b37bb2c801befe6f7ce0007d7eccc5
|
refs/heads/master
| 2023-03-18T06:02:45.508614
| 2016-05-04T14:29:57
| 2016-05-04T14:54:19
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,977
|
cpp
|
502-h-1.cpp
|
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF=1000000000;
int getint() {
int x;
scanf("%d",&x);
return x;
}
const int MAXN=5005;
const long long LINF=1000000000LL*1000000000LL;
set<pair<long long,int> > s;
void dijkstra(int v, int n, vector<pair<int,long long> > * g, long long * d) {
for (int i=1;i<=n;i++)
d[i]=LINF;
d[v]=0;
s.insert(make_pair(d[v],v));
while (!s.empty()) {
v=s.begin()->second;
s.erase(s.begin());
for (size_t i=0;i<g[v].size();i++) {
int to=g[v][i].first;
long long c=g[v][i].second;
if (d[v]+c<d[to]) {
s.erase(make_pair(d[to],to));
d[to]=d[v]+c;
s.insert(make_pair(d[to],to));
}
}
}
}
int a[MAXN];
long long d[MAXN];
vector<pair<int,long long> > g[MAXN];
void add_edge(int x, int y, long long c) {
if (a[y]!=1)
g[x].push_back(make_pair(y,c));
if (a[x]!=1)
g[y].push_back(make_pair(x,c));
}
int main()
{
freopen("secure.in","r",stdin);
freopen("secure.out","w",stdout);
int n,m;
cin >> n >> m;
for (int i=1;i<=n;i++)
cin >> a[i];
while (m--) {
int x,y,c;
cin >> x >> y >> c;
add_edge(x,y,c);
}
long long glMi=LINF;
int x,y;
for (int i=1;i<=n;i++) {
if (a[i]!=1) continue;
dijkstra(i,n,g,d);
long long mi=LINF;
int xx,yy;
for (int j=1;j<=n;j++)
if (a[j]==2 && d[j]<mi) {
xx=i,yy=j,mi=d[j];
}
if (mi<glMi) {
glMi=mi;
x=xx,y=yy;
}
}
if (glMi==LINF) cout << -1;
else cout << x << ' ' << y << ' ' << glMi;
return 0;
}
|
555e592abb2d99f6a0a4b34b8399b655d18f8806
|
92c6aab59941637526d7280220ca12660b11e8e0
|
/GCPtr/GCPtr/main.cpp
|
62b14af52f0a39a9ee66ae00083392f5016a0edb
|
[] |
no_license
|
JodeZer/GarbageCollenction4CPP
|
aa569ce98a3483412adea96d7c112acb92b03a57
|
97e42c3daf6ab5d309512e4f6f58574521f19a39
|
refs/heads/master
| 2021-01-01T06:27:54.381109
| 2015-03-29T15:39:47
| 2015-03-29T15:39:47
| 33,021,057
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 323
|
cpp
|
main.cpp
|
#include <iostream>
#include "GCPtr.h"
#include "GCPInfo.h"
using namespace std;
void main(void)
{
list<int> l;
list<int>::iterator it;
it=l.begin();
/*int *p=new int(2);
int *p2=p;
GCPInfo<int> a(p,0);
GCPInfo<int> b(p2);
cout<<(int)(a==b);
p2=new int(2);
GCPInfo<int> c(p2);
cout<<(int)(a==c);*/
return;
}
|
92c99d00a72aae9c07f7cc9b38361ecec33b4909
|
046f161cf8966b81bec442315f7e26e25d99c1ac
|
/SUB2.CPP
|
ea0ab1541ab8a1cf47df77c9ad9674394150366d
|
[] |
no_license
|
Balaji4/LetUsCPlusPlus
|
759a9e7a73462b90539d7305cabe3d95d77cd7e9
|
4da78b2f20f0575c13e21d7a1d1257da46e75cb8
|
refs/heads/main
| 2023-01-21T03:06:04.713810
| 2020-11-26T21:15:43
| 2020-11-26T21:15:43
| 316,336,367
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 398
|
cpp
|
SUB2.CPP
|
79
89
78
99
67
87
66
77
55
76
67
85
92
86
97
88
76
66
57
76
80
75
64
76
73
82
91
88
90
74
83
72
95
88
99
66
78
98
56
74
71
92
85
71
74
79
80
90
83
69
95
88
87
86
84
90
93
91
80
90
80
98
65
75
69
95
88
87
86
84
90
93
91
80
90
90
74
83
72
95
88
99
66
78
98
56
74
71
92
85
71
74
79
80
90
83
69
98
78
88
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.