blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
listlengths
1
16
author_lines
listlengths
1
16
06c03e5bed349e3be870dd05fe48745f478230d7
b1115ba5b162f7dba9324f53d09694857ffee313
/physics/src/BasicDemo.h
2eac97efa0efbd731c0424efcad76055cc13f033
[]
no_license
eweitnauer/TangramRobot
cf0ec43f232252673c7a6a55ec5ef2c1f3c013c4
1c40e0b04dcb4fbf5876f06b4a28a0e2b7651be3
refs/heads/master
2016-09-06T00:49:38.596706
2010-08-26T09:14:10
2010-08-26T09:14:10
863,567
1
2
null
null
null
null
UTF-8
C++
false
false
2,183
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BASIC_DEMO_H #define BASIC_DEMO_H #include "GlutDemoApplication.h" #include "LinearMath/btAlignedObjectArray.h" class btBroadphaseInterface; class btCollisionShape; class btOverlappingPairCache; class btCollisionDispatcher; class btConstraintSolver; struct btCollisionAlgorithmCreateFunc; class btDefaultCollisionConfiguration; ///BasicDemo is good starting point for learning the code base and porting. class BasicDemo : public DemoApplication { //keep the collision shapes, for deletion/cleanup btAlignedObjectArray<btCollisionShape*> m_collisionShapes; btBroadphaseInterface* m_broadphase; btCollisionDispatcher* m_dispatcher; btConstraintSolver* m_solver; btDefaultCollisionConfiguration* m_collisionConfiguration; public: BasicDemo() { } virtual ~BasicDemo() { exitPhysics(); } void initPhysics(); void exitPhysics(); virtual void clientMoveAndDisplay(); virtual void displayCallback(); static DemoApplication* Create() { BasicDemo* demo = new BasicDemo; demo->myinit(); demo->initPhysics(); return demo; } virtual void swapBuffers() {} virtual void updateModifierKeys() {} }; #endif //BASIC_DEMO_H
[ [ [ 1, 74 ] ] ]
350ea1867bb5732e8e397b1823135122f46c502d
1e5a2230acf1c2edfe8b9d226100438f9374e98a
/src/gecko-sdk/include/nscore.h
1c904813ce8a5a78f4bcb90e61ef721b0781ceb4
[]
no_license
lifanxi/tabimswitch
258860fea291c935d3630abeb61436e20f5dcd09
f351fc4b04983e59d1ad2b91b85e396e1f4920ed
refs/heads/master
2020-05-20T10:53:41.990172
2008-10-15T11:15:41
2008-10-15T11:15:41
32,111,854
0
0
null
null
null
null
UTF-8
C++
false
false
15,079
h
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef nscore_h___ #define nscore_h___ /** * Make sure that we have the proper platform specific * c++ definitions needed by nscore.h */ #ifndef _XPCOM_CONFIG_H_ #include "xpcom-config.h" #endif /** * Incorporate the core NSPR data types which XPCOM uses. */ #include "prtypes.h" /* Core XPCOM declarations. */ /** * Macros defining the target platform... */ #ifdef _WIN32 #define NS_WIN32 1 #elif defined(__unix) #define NS_UNIX 1 #elif defined(XP_OS2) #define NS_OS2 1 #endif /*----------------------------------------------------------------------*/ /* Import/export defines */ /** * Using the visibility("hidden") attribute allows the compiler to use * PC-relative addressing to call this function. If a function does not * access any global data, and does not call any methods which are not either * file-local or hidden, then on ELF systems we avoid loading the address of * the PLT into a register at the start of the function, which reduces code * size and frees up a register for general use. * * As a general rule, this should be used for any non-exported symbol * (including virtual method implementations). NS_IMETHOD uses this by * default; if you need to have your NS_IMETHOD functions exported, you can * wrap your class as follows: * * #undef IMETHOD_VISIBILITY * #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT * * class Foo { * ... * }; * * #undef IMETHOD_VISIBILITY * #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN * * Don't forget to change the visibility back to hidden before the end * of a header! * * Other examples: * * NS_HIDDEN_(int) someMethod(); * SomeCtor() NS_HIDDEN; */ #ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE #define NS_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden"))) #else #define NS_VISIBILITY_HIDDEN #endif #if defined(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE) && defined(HAVE_VISIBILITY_PRAGMA) #define NS_VISIBILITY_DEFAULT __attribute__ ((visibility ("default"))) #else #define NS_VISIBILITY_DEFAULT #endif #define NS_HIDDEN_(type) NS_VISIBILITY_HIDDEN type #define NS_EXTERNAL_VIS_(type) NS_VISIBILITY_DEFAULT type #define NS_HIDDEN NS_VISIBILITY_HIDDEN #define NS_EXTERNAL_VIS NS_VISIBILITY_DEFAULT #undef IMETHOD_VISIBILITY #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN /** * Mark a function as using a potentially non-standard function calling * convention. This can be used on functions that are called very * frequently, to reduce the overhead of the function call. It is still worth * using the macro for C++ functions which take no parameters since it allows * passing |this| in a register. * * - Do not use this on any scriptable interface method since xptcall won't be * aware of the different calling convention. * - This must appear on the declaration, not the definition. * - Adding this to a public function _will_ break binary compatibility. * - This may be used on virtual functions but you must ensure it is applied * to all implementations - the compiler will _not_ warn but it will crash. * - This has no effect for inline functions or functions which take a * variable number of arguments. * * Examples: int NS_FASTCALL func1(char *foo); * NS_HIDDEN_(int) NS_FASTCALL func2(char *foo); */ #if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2) #define NS_FASTCALL __attribute__ ((regparm (3), stdcall)) #else #define NS_FASTCALL #endif /* * NS_DEFCALL undoes the effect of a global regparm/stdcall setting * so that xptcall works correctly. */ #if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2) #define NS_DEFCALL __attribute__ ((regparm (0), cdecl)) #else #define NS_DEFCALL #endif #ifdef NS_WIN32 #define NS_IMPORT __declspec(dllimport) #define NS_IMPORT_(type) type __declspec(dllimport) __stdcall #define NS_EXPORT __declspec(dllexport) #define NS_EXPORT_(type) type __declspec(dllexport) __stdcall #define NS_IMETHOD_(type) virtual type __stdcall #define NS_IMETHODIMP_(type) type __stdcall #define NS_METHOD_(type) type __stdcall #define NS_CALLBACK_(_type, _name) _type (__stdcall * _name) #define NS_STDCALL __stdcall /* These are needed to mark static members in exported classes, due to gcc bug XXX insert bug# here. */ #define NS_EXPORT_STATIC_MEMBER_(type) type #define NS_IMPORT_STATIC_MEMBER_(type) type #else #define NS_IMPORT NS_EXTERNAL_VIS #define NS_IMPORT_(type) NS_EXTERNAL_VIS_(type) #define NS_EXPORT NS_EXTERNAL_VIS #define NS_EXPORT_(type) NS_EXTERNAL_VIS_(type) #define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL #define NS_IMETHODIMP_(type) type #define NS_METHOD_(type) type #define NS_CALLBACK_(_type, _name) _type (* _name) #define NS_STDCALL #define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type) #define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type) #endif /** * Macro for creating typedefs for pointer-to-member types which are * declared with stdcall. It is important to use this for any type which is * declared as stdcall (i.e. NS_IMETHOD). For example, instead of writing: * * typedef nsresult (nsIFoo::*someType)(nsISupports* arg); * * you should write: * * typedef * NS_STDCALL_FUNCPROTO(nsresult, someType, nsIFoo, typeFunc, (nsISupports*)); * * where nsIFoo::typeFunc is any method declared as * NS_IMETHOD typeFunc(nsISupports*); * * XXX this can be simplified to always use the non-typeof implementation * when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed. */ #ifdef __GNUC__ #define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \ typeof(&class::func) name #else #define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \ ret (NS_STDCALL class::*name) args #endif /** * Generic API modifiers which return the standard XPCOM nsresult type */ #define NS_IMETHOD NS_IMETHOD_(nsresult) #define NS_IMETHODIMP NS_IMETHODIMP_(nsresult) #define NS_METHOD NS_METHOD_(nsresult) #define NS_CALLBACK(_name) NS_CALLBACK_(nsresult, _name) /** * Import/Export macros for XPCOM APIs */ #ifdef _IMPL_NS_COM #define NS_COM NS_EXPORT #elif _IMPL_NS_COM_OFF #define NS_COM #elif XPCOM_GLUE #define NS_COM #else #define NS_COM NS_IMPORT #endif #ifdef MOZILLA_INTERNAL_API # define NS_COM_GLUE NS_COM /* The frozen string API has different definitions of nsAC?String classes than the internal API. On systems that explicitly declare dllexport symbols this is not a problem, but on ELF systems internal symbols can accidentally "shine through"; we rename the internal classes to avoid symbol conflicts. */ # define nsAString nsAString_internal # define nsACString nsACString_internal #else # define NS_COM_GLUE #endif /** * NS_NO_VTABLE is emitted by xpidl in interface declarations whenever * xpidl can determine that the interface can't contain a constructor. * This results in some space savings and possible runtime savings - * see bug 49416. We undefine it first, as xpidl-generated headers * define it for IDL uses that don't include this file. */ #ifdef NS_NO_VTABLE #undef NS_NO_VTABLE #endif #if defined(_MSC_VER) && _MSC_VER >= 1100 #define NS_NO_VTABLE __declspec(novtable) #else #define NS_NO_VTABLE #endif /** * Generic XPCOM result data type */ typedef PRUint32 nsresult; /** * The preferred symbol for null. */ #define nsnull 0 #include "nsError.h" /* ------------------------------------------------------------------------ */ /* Casting macros for hiding C++ features from older compilers */ /* All our compiler support template specialization, but not all support the |template <>| notation. The compiler that don't understand this notation just omit it for specialization. Need to add an autoconf test for this. */ /* under Metrowerks (Mac), we don't have autoconf yet */ #ifdef __MWERKS__ #define HAVE_CPP_PARTIAL_SPECIALIZATION #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX #define HAVE_CPP_ACCESS_CHANGING_USING #define HAVE_CPP_AMBIGUITY_RESOLVING_USING #define HAVE_CPP_EXPLICIT #define HAVE_CPP_TYPENAME #define HAVE_CPP_BOOL #define HAVE_CPP_NAMESPACE_STD #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL #define HAVE_CPP_2BYTE_WCHAR_T #endif /* under VC++ (Windows), we don't have autoconf yet */ #if defined(_MSC_VER) && (_MSC_VER>=1100) /* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */ #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX #define HAVE_CPP_EXPLICIT #define HAVE_CPP_TYPENAME #define HAVE_CPP_ACCESS_CHANGING_USING #if (_MSC_VER==1100) /* VC++5.0 has an internal compiler error (sometimes) without this */ #undef HAVE_CPP_ACCESS_CHANGING_USING #endif #define HAVE_CPP_NAMESPACE_STD #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL #define HAVE_CPP_2BYTE_WCHAR_T #endif #ifndef __PRUNICHAR__ #define __PRUNICHAR__ /* For now, don't use wchar_t on Unix because it breaks the Netscape * commercial build. When this is fixed there will be no need for the * |NS_REINTERPRET_CAST| in nsLiteralString.h either. */ #if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32) typedef wchar_t PRUnichar; #else typedef PRUint16 PRUnichar; #endif #endif /* If the compiler doesn't support |explicit|, we'll just make it go away, trusting that the builds under compilers that do have it will keep us on the straight and narrow. */ #ifndef HAVE_CPP_EXPLICIT #define explicit #endif #ifndef HAVE_CPP_TYPENAME #define typename #endif #ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX #define NS_SPECIALIZE_TEMPLATE template <> #else #define NS_SPECIALIZE_TEMPLATE #endif /* unix and beos now determine this automatically */ #if ! defined XP_UNIX && ! defined XP_BEOS && !defined(XP_OS2) #ifndef HAVE_CPP_NEW_CASTS #define HAVE_CPP_NEW_CASTS 1 /* we'll be optimistic. */ #endif #endif #if defined(HAVE_CPP_NEW_CASTS) #define NS_STATIC_CAST(__type, __ptr) static_cast< __type >(__ptr) #define NS_CONST_CAST(__type, __ptr) const_cast< __type >(__ptr) #define NS_REINTERPRET_POINTER_CAST(__type, __ptr) reinterpret_cast< __type >(__ptr) #define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) reinterpret_cast< __type >(__obj) #define NS_REINTERPRET_CAST(__type, __expr) reinterpret_cast< __type >(__expr) #else #define NS_STATIC_CAST(__type, __ptr) ((__type)(__ptr)) #define NS_CONST_CAST(__type, __ptr) ((__type)(__ptr)) #define NS_REINTERPRET_POINTER_CAST(__type, __ptr) ((__type)((void*)(__ptr))) #define NS_REINTERPRET_NONPOINTER_CAST(__type, __obj) ((__type)(__obj)) /* Note: the following is only appropriate for pointers. */ #define NS_REINTERPRET_CAST(__type, __expr) NS_REINTERPRET_POINTER_CAST(__type, __expr) /* Why cast to a |void*| first? Well, when old-style casting from a pointer to a base to a pointer to a derived class, the cast will be ambiguous if the source pointer type appears multiple times in the destination, e.g., class Base {}; class Derived : public Base, public Base {}; void foo( Base* b ) { ((Derived*)b)->some_derived_member ... // Error: Ambiguous, expand from which |Base|? } an old-style cast (like |static_cast|) will change the pointer, but here, doesn't know how. The cast to |void*| prevents it from thinking it needs to expand the original pointer. The cost is, |NS_REINTERPRET_CAST| is no longer appropriate for non-pointer conversions. Also, mis-applying |NS_REINTERPRET_CAST| to cast |this| to something will still expand the pointer to the outer object in standards complying compilers. */ /* No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate the semantics. So if you want to dynamic_cast, then just use it "straight", no macro. */ #endif /* * Use these macros to do 64bit safe pointer conversions. */ #define NS_PTR_TO_INT32(x) ((PRInt32) (PRWord) (x)) #define NS_PTR_TO_UINT32(x) ((PRUint32) (PRWord) (x)) #define NS_INT32_TO_PTR(x) ((void *) (PRWord) (x)) /* * Use NS_STRINGIFY to form a string literal from the value of a macro. */ #define NS_STRINGIFY_HELPER(x_) #x_ #define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_) /* * These macros allow you to give a hint to the compiler about branch * probability so that it can better optimize. Use them like this: * * if (NS_LIKELY(v == 1)) { * ... expected code path ... * } * * if (NS_UNLIKELY(v == 0)) { * ... non-expected code path ... * } * */ #if defined(__GNUC__) && (__GNUC__ > 2) #define NS_LIKELY(x) (__builtin_expect((x), 1)) #define NS_UNLIKELY(x) (__builtin_expect((x), 0)) #else #define NS_LIKELY(x) (x) #define NS_UNLIKELY(x) (x) #endif #endif /* nscore_h___ */
[ "ftofficer.zhangc@237747d1-5336-0410-8d3f-2982d197fc3e" ]
[ [ [ 1, 455 ] ] ]
469c6efddd492056d121893caa68b6d9623f2668
3cd7d37bbc0d8767dcdc0d104c8c445107e38f36
/lines.cpp
69aa18794858741f1b9a7c9e3ae5cdcd6f8f1492
[]
no_license
farihi/gpsturbo
8978fa37d4c164cbdd85091ec3feeb9aa1ff2662
a56634b63a9022c48f1e529385b6926366da1fda
refs/heads/master
2021-01-10T12:09:32.768016
2010-06-30T23:35:18
2010-06-30T23:35:18
44,369,116
0
0
null
null
null
null
UTF-8
C++
false
false
34,017
cpp
/*********************************************************************************/ /* GPSTurbo */ /* */ /* Programmed by Kevin Pickell */ /* */ /* http://www.scale18.com/cgi-bin/page/gpsturbo.html */ /* */ /* GPSTurbo 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; version 2. */ /* */ /* GPSTurbo 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. */ /* */ /* http://www.gnu.org/licenses/gpl.txt */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with GPSTurbo; if not, write to the Free Software */ /* Foundation, Inc->, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* */ /*********************************************************************************/ #include "gpsturbo.h" class GPXLineEntry { friend class LinesPage; public: kGUIString m_type; kGUIString m_value1; kGUIString m_value2; void Load(kGUIXMLItem *xml); void Save(kGUIXMLItem *xml); }; class GPXLine { friend class LinesPage; public: GPXLine(kGUIString *name) {m_name.SetString(name);m_draw=true;m_numentries=0;m_entries.SetGrow(true);m_entries.Alloc(16);} ~GPXLine(); void SetName(kGUIString *name) {m_name.SetString(name);} const char *GetName(void) {return m_name.GetString();} void SetDraw(bool d) {m_draw=d;} bool GetDraw(void) {return m_draw;} unsigned int GetNumEntries(void) {return m_numentries;} void Load(kGUITableObj *table,kGUITickBoxObj *draw); bool Compare(kGUITableObj *table,kGUITickBoxObj *draw); void Save(kGUITableObj *table,kGUITickBoxObj *draw); void Load(kGUIXMLItem *xml); void Save(kGUIXMLItem *xml); bool LineRow(GPXRow *trow); GPXLineEntry *AddEntry(void) {GPXLineEntry *fe=new GPXLineEntry();m_entries.SetEntry(m_numentries++,fe);return fe;} GPXBounds *GetBoundsObj(void) {return &m_bounds;} private: kGUIString m_name; bool m_draw; unsigned int m_numentries; Array<GPXLineEntry *>m_entries; GPXBounds m_bounds; }; enum { LINECOL_TYPE, LINECOL_VALUE1, LINECOL_VALUE2, LINECOL_NUMCOLUMNS}; enum { LINEPRIM_WAYPOINT, LINEPRIM_POINT, LINEPRIM_PROJECT, LINEPRIM_HEADING, LINEPRIM_ADDHEADING, LINEPRIM_DISTANCE, LINEPRIM_RADIUS, LINEPRIM_COLOR, LINEPRIM_THICKNESS, LINEPRIM_LINE, LINEPRIM_ARC, LINEPRIM_CIRCLE, LINEPRIM_SETWAYPOINT, LINEPRIM_DEGREES, LINEPRIM_NUM}; enum { ARC_DISTANCE, ARC_DEGREES }; const char *liprimnames[LINEPRIM_NUM]={ "Waypoint","Point","Project","Heading","Add to Heading","Distance","Radius","Color","Thickness","Line","Arc","Circle","Set Waypoint","Degrees"}; const char *licolnames[LINECOL_NUMCOLUMNS]={ "Type","Value1","Value2"}; const char *licoldesc[LINECOL_NUMCOLUMNS]={ "Type","Value1","Value2"}; const int stcolwidths[LINECOL_NUMCOLUMNS]={150,250,250}; enum { USE_COMBO, USE_INPUT, USE_NONE }; class GPXLineRow : public kGUITableRowObj { public: GPXLineRow(); int GetNumObjects(void) {return LINECOL_NUMCOLUMNS;} kGUIObj **GetObjectList(void) {return m_objectlist;} kGUIObj *m_objectlist[LINECOL_NUMCOLUMNS]; CALLBACKGLUEPTR(GPXLineRow,TypeChangedEvent,kGUIEvent); void TypeChangedEvent(kGUIEvent *event) {if(event->GetEvent()==EVENT_AFTERUPDATE)TypeChanged();} void TypeChanged(void); int GetType(void) {return m_type.GetSelection();} const char *GetTypeString(void) {return m_type.GetSelectionString();} kGUIString *GetValue1(void) {return m_use1==USE_COMBO?m_combo1.GetSelectionStringObj():&m_input1;} kGUIString *GetValue2(void) {return m_use2==USE_COMBO?m_combo2.GetSelectionStringObj():&m_input2;} void SetType(int v) {m_type.SetSelection(v);TypeChanged();} void SetType(const char *v) {m_type.SetSelection(v);TypeChanged();} void SetValue1(const char *v) {if(m_use1==USE_COMBO)m_combo1.SetSelectionz(v);else m_input1.SetString(v);} void SetValue2(const char *v) {if(m_use2==USE_COMBO)m_combo2.SetSelectionz(v);else m_input2.SetString(v);} void SetPos(GPXCoord *c) {m_curpos.Set(c);} GPXCoord *GetPos(void) {return &m_curpos;} kGUIString *GetSettingsObj(void) {return &m_settings;} private: kGUIComboBoxObj m_type; int m_use1; kGUIComboBoxObj m_combo1; kGUIInputBoxObj m_input1; kGUITextObj m_text1; int m_use2; kGUIInputBoxObj m_input2; kGUIComboBoxObj m_combo2; kGUITextObj m_text2; GPXCoord m_curpos; /* current position at this point, used for double clicking on row */ kGUIString m_settings; }; LinesPage::LinesPage() { m_numlines=0; m_lines.Init(8,2); } LinesPage::~LinesPage() { } /* add gui items to their parent gui object */ void LinesPage::Init(kGUIContainerObj *obj) { int i,y,bw,bh; kGUIText *t; bw=obj->GetChildZoneW(); m_editlinecontrols.SetSize(bw,20); m_lineup.SetFontSize(BUTTONFONTSIZE); m_lineup.SetString(gpx->GetString(STRING_UP)); m_lineup.Contain(); m_lineup.SetEventHandler(this,CALLBACKNAME(ClickUp)); m_editlinecontrols.AddObject(&m_lineup); m_linedown.SetFontSize(BUTTONFONTSIZE); m_linedown.SetString(gpx->GetString(STRING_DOWN)); m_linedown.Contain(); m_linedown.SetEventHandler(this,CALLBACKNAME(ClickDown)); m_editlinecontrols.AddObject(&m_linedown); m_editlinelist.SetShowIterators(true); m_editlinelist.SetFontSize(BUTTONFONTSIZE); m_editlinelist.SetSize(300,20); m_editlinelist.SetNumEntries(1); /* list of Lines */ m_editlinelist.SetEntry(0,gpx->GetString(STRING_NEWLINE),0); m_editlinelist.SetEventHandler(this,CALLBACKNAME(LoadEvent)); m_editlinecontrols.AddObject(&m_editlinelist); m_saveline.SetFontSize(BUTTONFONTSIZE); m_saveline.SetString(gpx->GetString(STRING_SAVELINES)); m_saveline.Contain(); m_saveline.SetEventHandler(this,CALLBACKNAME(ClickSave)); m_editlinecontrols.AddObject(&m_saveline); m_undoline.SetFontSize(BUTTONFONTSIZE); m_undoline.SetString(gpx->GetString(STRING_UNDOCHANGES)); m_undoline.Contain(); m_undoline.SetEventHandler(this,CALLBACKNAME(ClickUndo)); m_editlinecontrols.AddObject(&m_undoline); m_deleteline.SetFontSize(BUTTONFONTSIZE); m_deleteline.SetString(gpx->GetString(STRING_DELETELINES)); m_deleteline.Contain(); m_deleteline.SetEventHandler(this,CALLBACKNAME(ClickDelete)); m_editlinecontrols.AddObject(&m_deleteline); m_renameline.SetFontSize(BUTTONFONTSIZE); m_renameline.SetString(gpx->GetString(STRING_RENAMELINES)); m_renameline.Contain(); m_renameline.SetEventHandler(this,CALLBACKNAME(ClickRename)); m_editlinecontrols.AddObject(&m_renameline); m_copyline.SetFontSize(BUTTONFONTSIZE); m_copyline.SetString(gpx->GetString(STRING_COPYLINES)); m_copyline.Contain(); m_copyline.SetEventHandler(this,CALLBACKNAME(ClickCopy)); m_editlinecontrols.AddObject(&m_copyline); m_deleteline.SetEnabled(false); m_renameline.SetEnabled(false); m_copyline.SetEnabled(false); m_editlinecontrols.NextLine(); m_drawlinecaption.SetPos(0,0); m_drawlinecaption.SetFontSize(SMALLCAPTIONFONTSIZE); m_drawlinecaption.SetFontID(SMALLCAPTIONFONT); m_drawlinecaption.SetString("Draw Lines on Map"); m_drawline.SetPos(0,15); m_drawline.SetEventHandler(this,CALLBACKNAME(ChangedEvent)); m_editlinecontrols.AddObjects(2,&m_drawlinecaption,&m_drawline); m_settingscaption.SetPos(0,0); m_settingscaption.SetFontSize(SMALLCAPTIONFONTSIZE); m_settingscaption.SetFontID(SMALLCAPTIONFONT); m_settingscaption.SetString("Settings after cursor line"); m_settings.SetLocked(true); m_settings.SetPos(0,15); m_settings.SetSize((m_editlinecontrols.GetChildZoneW()-m_editlinecontrols.GetCurrentX())-32,20); m_editlinecontrols.AddObjects(2,&m_settingscaption,&m_settings); obj->AddObject(&m_editlinecontrols); y=m_editlinecontrols.GetZoneH(); bh=(obj->GetChildZoneH()-y); m_linetable.SetPos(0,y); m_linetable.SetSize(bw,bh); m_linetable.SetNumCols(LINECOL_NUMCOLUMNS); for(i=0;i<LINECOL_NUMCOLUMNS;++i) { t=m_linetable.GetColHeaderTextPtr(i); t->SetFontID(1); /* bold */ m_linetable.SetColTitle(i,licolnames[i]); m_linetable.SetColHint(i,licoldesc[i]); m_linetable.SetColWidth(i,stcolwidths[i]); } m_linetable.SetAllowAddNewRow(true); m_linetable.SetEventHandler(this,CALLBACKNAME(TableEvent)); m_addmenu.SetNumEntries(2); m_addmenu.SetEntry(0,"Insert entry before row",0); m_addmenu.SetEntry(1,"Insert entry after row",1); m_addmenu.SetEventHandler(this,CALLBACKNAME(NewEntryMenuDone)); obj->AddObject(&m_editlinecontrols); obj->AddObject(&m_linetable); } void LinesPage::Resize(int changey) { m_linetable.SetZoneH(m_linetable.GetZoneH()+changey); } void LinesPage::TableEvent(kGUIEvent *event) { switch(event->GetEvent()) { case EVENT_AFTERUPDATE: Changed(); break; case EVENT_ADDROW: { GPXLineRow *fr=new GPXLineRow(); m_linetable.AddRow(fr); } break; case EVENT_ROW_RIGHTCLICK: m_addmenu.Activate(kGUI::GetMouseX(),kGUI::GetMouseY()); break; case EVENT_ROW_LEFTDOUBLECLICK: { GPXCoord c; GPXLineRow *row; row=static_cast<GPXLineRow *>(m_linetable.GetChild(event->m_value[0].ui)); c.Set(row->GetPos()); gpx->SetScrollCenter(&c); gpx->SetCurrentTab(TAB_MAIN); } break; } /* if a row has been changed, added or deleted or cursor moved */ switch(event->GetEvent()) { case EVENT_AFTERUPDATE: case EVENT_ADDROW: case EVENT_DELETEROW: case EVENT_MOVED: { GPXLineRow *row; /* when the user changes the cursor position, then we update the "settings" box */ /* to display the current values after the line is processed */ if(m_linetable.GetCursorRow()<m_linetable.GetNumChildren()) { row=static_cast<GPXLineRow *>(m_linetable.GetChild(m_linetable.GetCursorRow())); m_settings.SetString(row->GetSettingsObj()); } else m_settings.Clear(); } break; } } void LinesPage::Purge(void) { unsigned int i; m_linetable.DeleteChildren(); for(i=0;i<m_numlines;++i) delete m_lines.GetEntry(i); } void LinesPage::LoadPrefs(kGUIXMLItem *root) { unsigned int i; kGUIXMLItem *item; item=root->Locate("linestable"); if(item) m_linetable.LoadConfig(item); for(i=0;i<root->GetNumChildren();++i) { item=root->GetChild(i); if(!strcmp(item->GetName(),"line")) { GPXLine *s=new GPXLine(item->Locate("name")->GetValue()); m_lines.SetEntry(m_numlines++,s); s->Load(item); UpdateBounds(s,s->GetBoundsObj()); } } UpdateList(); } void LinesPage::SavePrefs(kGUIXMLItem *root) { unsigned int i; m_linetable.SaveConfig(root,"linestable"); for(i=0;i<m_numlines;++i) m_lines.GetEntry(i)->Save(root); } void LinesPage::NewEntryMenuDone(kGUIEvent *event) { if(event->GetEvent()==EVENT_SELECTED) { GPXLineRow *fr; switch(m_addmenu.GetSelection()) { case 0: /* insert before current row */ fr=new GPXLineRow(); m_linetable.AddRow(fr,-1); break; case 1: /* insert after before current row */ fr=new GPXLineRow(); m_linetable.AddRow(fr,1); break; } } } GPXLineRow::GPXLineRow() { int e; m_objectlist[LINECOL_TYPE]=&m_type; m_type.SetSize(300,20); m_type.SetNumEntries(LINEPRIM_NUM); for(e=0;e<LINEPRIM_NUM;++e) m_type.SetEntry(e,liprimnames[e],e); m_type.SetEventHandler(this,CALLBACKNAME(TypeChangedEvent)); m_combo1.SetSize(300,20); m_combo2.SetSize(300,20); /* place this in table for unused fields */ m_text1.SetBGColor(DrawColor(128,128,128)); m_text2.SetBGColor(DrawColor(128,128,128)); TypeChanged(); } void GPXLineRow::TypeChanged(void) { /* switch the two table columns between input boxes and comboboxes */ /* based on the type in the first column */ m_use1=USE_NONE; m_use2=USE_NONE; switch(m_type.GetSelection()) { case LINEPRIM_HEADING: case LINEPRIM_ADDHEADING: m_use1=USE_COMBO; m_use2=USE_INPUT; m_combo1.SetNumEntries(2); m_combo1.SetEntry(0,"Degrees",0); m_combo1.SetEntry(1,"Radians",1); m_combo1.SetHint("Heading type"); m_input2.SetHint("Heading angle in degrees"); break; case LINEPRIM_DISTANCE: m_use1=USE_COMBO; m_use2=USE_INPUT; GPX::InitDistCombo(&m_combo1); m_combo1.SetHint("Distance type"); m_input2.SetHint("Distance in units selected"); break; case LINEPRIM_RADIUS: m_use1=USE_COMBO; m_use2=USE_INPUT; GPX::InitDistCombo(&m_combo1); m_combo1.SetHint("Radius type"); m_input2.SetHint("Radius in units selected"); break; case LINEPRIM_DEGREES: m_use1=USE_INPUT; m_input1.SetLocked(false); m_input1.SetHint("Set arc distance in degrees"); break; case LINEPRIM_COLOR: m_use1=USE_COMBO; GPX::InitColorCombo(&m_combo1); m_combo1.SetHint("Color"); break; case LINEPRIM_WAYPOINT: case LINEPRIM_SETWAYPOINT: m_use1=USE_INPUT; m_input1.SetLocked(false); m_input1.SetHint("Waypoint Name"); break; case LINEPRIM_POINT: m_use1=USE_INPUT; m_use2=USE_INPUT; m_input1.SetLocked(false); m_input1.SetHint("Latitude"); m_input2.SetLocked(false); m_input2.SetHint("Longitude"); break; case LINEPRIM_THICKNESS: m_use1=USE_INPUT; m_input1.SetLocked(false); m_input1.SetHint("Thickness for drawing"); break; case LINEPRIM_ARC: m_use1=USE_COMBO; m_use2=USE_COMBO; m_combo1.SetNumEntries(2); m_combo1.SetEntry(0,"Clockwise",0); m_combo1.SetEntry(1,"Counterclockwise",1); m_combo1.SetHint("Direction"); m_combo2.SetNumEntries(2); m_combo2.SetEntry(0,"Distance",ARC_DISTANCE); m_combo2.SetEntry(1,"Degrees",ARC_DEGREES); m_combo2.SetHint("Arc distance type"); break; case LINEPRIM_LINE: case LINEPRIM_PROJECT: case LINEPRIM_CIRCLE: break; } switch(m_use1) { case USE_COMBO: m_objectlist[LINECOL_VALUE1]=&m_combo1; break; case USE_INPUT: m_objectlist[LINECOL_VALUE1]=&m_input1; break; case USE_NONE: m_objectlist[LINECOL_VALUE1]=&m_text1; m_input1.Clear(); break; } switch(m_use2) { case USE_COMBO: m_objectlist[LINECOL_VALUE2]=&m_combo2; break; case USE_INPUT: m_objectlist[LINECOL_VALUE2]=&m_input2; break; case USE_NONE: m_objectlist[LINECOL_VALUE2]=&m_text2; m_input2.Clear(); break; } //tell table code to re-position these cells CellChanged(); } /* load from prefs file */ void GPXLineEntry::Load(class kGUIXMLItem *wpr) { m_type.SetString(wpr->Locate("type")->GetValue()); m_value1.SetString(wpr->Locate("value1")->GetValue()); m_value2.SetString(wpr->Locate("value2")->GetValue()); } /* save to prefs file */ void GPXLineEntry::Save(class kGUIXMLItem *wpr) { wpr->AddParm("type",m_type.GetString()); wpr->AddParm("value1",m_value1.GetString()); wpr->AddParm("value2",m_value2.GetString()); } void LinesPage::Load(void) { int fnum; fnum=m_editlinelist.GetSelection(); if(!fnum) { m_drawline.SetSelected(false); m_linetable.DeleteChildren(); } else m_lines.GetEntry(fnum-1)->Load(&m_linetable,&m_drawline); Changed(); } /* update the save/undo button status based on if the filter has changed */ void LinesPage::Changed(void) { bool changed=false; UpdateBounds(0,&m_curbounds); if(!m_editlinelist.GetSelection()) { /* should be empty, so any rows means changed */ if(m_linetable.GetNumChildren(0)) changed=true; m_deleteline.SetEnabled(false); m_renameline.SetEnabled(false); m_copyline.SetEnabled(false); } else { int i=GetIndex(m_editlinelist.GetSelectionString()); changed=m_lines.GetEntry(i)->Compare(&m_linetable,&m_drawline); m_deleteline.SetEnabled(!changed); m_renameline.SetEnabled(!changed); m_copyline.SetEnabled(!changed); } m_saveline.SetEnabled(changed); /* enabled after editing */ m_undoline.SetEnabled(changed); /* enabled after editing */ m_editlinelist.SetLocked(changed); gpx->MapDirty(); { kGUIEvent e; /* trigger my own moved event so the current settings are updated */ e.SetEvent(EVENT_MOVED); TableEvent(&e); } } int LinesPage::GetIndex(const char *name) { unsigned int i; GPXLine *s; for(i=0;i<m_numlines;++i) { s=m_lines.GetEntry(i); if(!strcmp(s->GetName(),name)) return(i); } return(-1); } void LinesPage::ClickSave(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { int fnum; kGUIInputBoxReq *box; fnum=m_editlinelist.GetSelection(); if(!fnum) box=new kGUIInputBoxReq(this,CALLBACKNAME(ClickSave2),"Lines Name?"); else Save(m_editlinelist.GetSelectionStringObj()); } } void LinesPage::ClickSave2(kGUIString *result,int closebutton) { kGUIMsgBoxReq *box; if(result->GetLen() && closebutton==MSGBOX_OK) { if(GetIndex(result->GetString())>=0) box=new kGUIMsgBoxReq(MSGBOX_OK,false,"Error: name already used, try again with a different name!"); else Save(result); } } void LinesPage::Save(kGUIString *name) { int i; GPXLine *s; /* is this an existing line? */ i=GetIndex(name->GetString()); if(i>=0) { s=m_lines.GetEntry(i); s->Save(&m_linetable,&m_drawline); } else { /* new line */ s=new GPXLine(name); s->Save(&m_linetable,&m_drawline); m_lines.SetEntry(m_numlines,s); ++m_numlines; UpdateList(); m_editlinelist.SetSelection(m_numlines); } Load(); } void LinesPage::ClickDelete(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { kGUIMsgBoxReq *box; box=new kGUIMsgBoxReq(MSGBOX_YES|MSGBOX_NO,this,CALLBACKNAME(ClickDelete2),true,"Delete Lines '%s'?",m_editlinelist.GetSelectionString()); } } void LinesPage::ClickDelete2(int result) { int i; GPXLine *f; if(result==MSGBOX_YES) { i=GetIndex(m_editlinelist.GetSelectionString()); if(i>=0) { f=m_lines.GetEntry(i); delete f; m_lines.DeleteEntry(i); --m_numlines; m_editlinelist.SetSelection(0); UpdateList(); Load(); } } } void LinesPage::ClickRename(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { kGUIInputBoxReq *box; box=new kGUIInputBoxReq(this,CALLBACKNAME(ClickRename2),"New Line Name?"); } } void LinesPage::ClickRename2(kGUIString *result,int closebutton) { kGUIString newname; kGUIMsgBoxReq *box; if(result->GetLen() && closebutton==MSGBOX_OK) { newname.SetString(result); if(GetIndex(newname.GetString())>=0) box=new kGUIMsgBoxReq(MSGBOX_OK,false,"Error: name already used!"); else { int i; GPXLine *s; i=GetIndex(m_editlinelist.GetSelectionString()); if(i>=0) { s=m_lines.GetEntry(i); s->SetName(&newname); /* rename track name in select combo too! */ m_editlinelist.SetEntry(i+1,newname.GetString(),i+1); } } } } void LinesPage::ClickCopy(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { kGUIInputBoxReq *box; box=new kGUIInputBoxReq(this,CALLBACKNAME(ClickCopy2),"Copied Line Name?"); } } void LinesPage::ClickCopy2(kGUIString *result,int closebutton) { kGUIString copyname; kGUIMsgBoxReq *box; if(result->GetLen() && closebutton==MSGBOX_OK) { copyname.SetString(result->GetString()); if(GetIndex(copyname.GetString())>=0) box=new kGUIMsgBoxReq(MSGBOX_OK,false,"Error: name already used!"); else Save(&copyname); } } void LinesPage::ClickUndo(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { kGUIMsgBoxReq *box; box=new kGUIMsgBoxReq(MSGBOX_YES|MSGBOX_NO,this,CALLBACKNAME(ClickUndo2),false,"Undo Changes?"); } } void LinesPage::ClickUndo2(int result) { if(result==MSGBOX_YES) Load(); } void LinesPage::UpdateList(void) { unsigned int e; kGUIString editLines; editLines.SetString(m_editlinelist.GetSelectionString()); m_editlinelist.SetNumEntries(m_numlines+1); /* list of select Liness */ m_editlinelist.SetEntry(0,gpx->GetString(STRING_NEWLINE),0); for(e=0;e<m_numlines;++e) m_editlinelist.SetEntry(e+1,m_lines.GetEntry(e)->GetName(),e+1); m_editlinelist.SetSelection(editLines.GetString()); } GPXLine::~GPXLine() { unsigned int i; for(i=0;i<m_numentries;++i) delete m_entries.GetEntry(i); } void GPXLine::Load(kGUITableObj *table,kGUITickBoxObj *draw) { unsigned int e; GPXLineRow *row; GPXLineEntry *re; draw->SetSelected(GetDraw()); table->DeleteChildren(); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* line record */ row=new GPXLineRow(); row->SetType(re->m_type.GetString()); row->SetValue1(re->m_value1.GetString()); row->SetValue2(re->m_value2.GetString()); table->AddRow(row); } } /* true=changed, false=same */ bool GPXLine::Compare(kGUITableObj *table,kGUITickBoxObj *draw) { unsigned int e; GPXLineRow *row; GPXLineEntry *re; if(table->GetNumChildren(0)!=m_numentries) return(true); /* draw flag has changed */ if(draw->GetSelected()!=GetDraw()) return(true); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* line record */ row=static_cast<GPXLineRow *>(table->GetChild(e)); if(strcmp(re->m_type.GetString(),row->GetTypeString())) return(true); /* different */ if(strcmp(re->m_value1.GetString(),row->GetValue1()->GetString())) return(true); /* different */ if(strcmp(re->m_value2.GetString(),row->GetValue2()->GetString())) return(true); /* different */ } return(false); /* same! */ } void GPXLine::Save(kGUITableObj *table,kGUITickBoxObj *draw) { unsigned int e; unsigned int nr; kGUIObj *obj; GPXLineRow *row; GPXLineEntry *re; SetDraw(draw->GetSelected()); /* delete old entries if there are any? */ for(e=0;e<m_numentries;++e) delete m_entries.GetEntry(e); nr=table->GetNumChildren(0); /* number of valid entries */ m_numentries=nr; m_entries.Alloc(nr); for(e=0;e<nr;++e) { obj=table->GetChild(e); row=static_cast<GPXLineRow *>(obj); re=new GPXLineEntry(); re->m_type.SetString(row->GetTypeString()); re->m_value1.SetString(row->GetValue1()); re->m_value2.SetString(row->GetValue2()); m_entries.SetEntry(e,re); } } /* Load from preferences file */ void GPXLine::Load(kGUIXMLItem *xml) { int i,nc; GPXLineEntry *fe; kGUIXMLItem *flxml; flxml=xml->Locate("draw"); if(flxml) SetDraw(flxml->GetValueInt()?true:false); nc=xml->GetNumChildren(); for(i=0;i<nc;++i) { flxml=xml->GetChild(i); if(!strcmp(flxml->GetName(),"entry")) { fe=new GPXLineEntry(); fe->Load(flxml); m_entries.SetEntry(m_numentries++,fe); } } } /* save to preferences file */ void GPXLine::Save(kGUIXMLItem *xml) { unsigned int e; GPXLineEntry *re; kGUIXMLItem *fxml; kGUIXMLItem *flxml; /* if no entries in line then don't save it */ if(m_numentries) { fxml=xml->AddChild("line"); fxml->AddParm("name",m_name.GetString()); fxml->AddParm("draw",GetDraw()==true?"1":"0"); for(e=0;e<m_numentries;++e) { re=m_entries.GetEntry(e); /* line record */ flxml=fxml->AddChild("entry"); re->Save(flxml); } } } void LinesPage::ClickUp(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { unsigned int line; line=m_linetable.GetCursorRow(); if(line>0 && line<m_linetable.GetNumChildren(0)) { m_linetable.SwapRow(-1); m_linetable.MoveRow(-1); Changed(); } } } void LinesPage::ClickDown(kGUIEvent *event) { if(event->GetEvent()==EVENT_PRESSED) { int line; line=(int)m_linetable.GetCursorRow(); if(line<((int)m_linetable.GetNumChildren(0)-1)) { m_linetable.SwapRow(1); m_linetable.MoveRow(1); Changed(); } } } void LinesPage::AddPointToLine(const char *name) { GPXLineRow *lr=new GPXLineRow(); lr->SetType(LINEPRIM_WAYPOINT); lr->SetValue1(name); m_linetable.AddRow(lr); Changed(); } void LinesPage::AddPointToLine(double lat,double lon) { GPXLineRow *lr=new GPXLineRow(); GPXCoord c; kGUIString latstring,lonstring; lr->SetType(LINEPRIM_POINT); c.Set(lat,lon); c.Output(&latstring,&lonstring); lr->SetValue1(latstring.GetString()); lr->SetValue2(lonstring.GetString()); m_linetable.AddRow(lr); Changed(); } /* draw all line groups that are flagged to draw */ void LinesPage::DrawMap(kGUICorners *c) { unsigned int i; GPXLine *line; /* draw any lines tracks that are flagged to be drawn */ for(i=0;i<m_numlines;++i) { /* skip current track, it is drawn below using the table */ if(i!=((unsigned int)m_editlinelist.GetSelection()-1)) { line=m_lines.GetEntry(i); if(line->GetDraw()==true) Draw(c,line); } } /* draw current track being edited if it is to be drawn */ if(m_drawline.GetSelected()) Draw(c,0); } void LinesPage::ProcessInit(void) { m_pos1.Set(0.0f,0.0f); m_pos2.Set(0.0f,0.0f); m_col=DrawColor(0,0,0); m_heading=0.0f; m_degrees=45.0f; /* only used for arc distance */ m_disttype=0; m_distance=100.0f; m_radiustype=0; m_radius=100.0f; m_thickness=1; } /* calculate positions along line to generate a bounding box, also */ /* for a table calculate position at each table entry for double clicking */ /* on the row and going to that spot on the map */ void LinesPage::UpdateBounds(GPXLine *line,GPXBounds *bounds) { unsigned int i; int type; kGUIString *v1; kGUIString *v2; bounds->Init(); if(line) { GPXLineEntry *le; ProcessInit(); for(i=0;i<line->GetNumEntries();++i) { le=line->m_entries.GetEntry(i); type=GPX::GetIndex(le->m_type.GetString(),sizeof(liprimnames)/sizeof(char *),liprimnames); v1=&le->m_value1; v2=&le->m_value2; ProcessLine(0,bounds,type,v1,v2); } } else { GPXLineRow *row; kGUIString *s; ProcessInit(); for(i=0;i<m_linetable.GetNumChildren();++i) { row=static_cast<GPXLineRow *>(m_linetable.GetChild(i)); type=row->GetType(); v1=row->GetValue1(); v2=row->GetValue2(); ProcessLine(0,bounds,type,v1,v2); row->SetPos(&m_pos2); /* generate the current settings for this row */ s=row->GetSettingsObj(); s->Sprintf("lat=%f,lon=%f,heading=%f,distance=%f,radius=%f,degrees=%f,thickness=%d",m_pos2.GetLat(),m_pos2.GetLon(),m_heading,m_distance,m_radius,m_degrees,m_thickness); } } } /* if track is passed, then draw using it, else draw using current stuff in the table */ void LinesPage::Draw(kGUICorners *c,GPXLine *line) { unsigned int i; int type; kGUIString *v1; kGUIString *v2; kGUICorners b; GPXCoord pos; if(line) { GPXLineEntry *le; GPXBounds *bounds=line->GetBoundsObj(); /* first, project bounds for lines and see if it overlaps the draw area */ pos.Set(bounds->GetMinLat(),bounds->GetMinLon()); gpx->m_curmap->ToMap(&pos,&b.lx,&b.by); pos.Set(bounds->GetMaxLat(),bounds->GetMaxLon()); gpx->m_curmap->ToMap(&pos,&b.rx,&b.ty); /* return if track does not overlap draw area */ if(kGUI::Overlap(c,&b)==false) return; ProcessInit(); for(i=0;i<line->GetNumEntries();++i) { le=line->m_entries.GetEntry(i); type=GPX::GetIndex(le->m_type.GetString(),sizeof(liprimnames)/sizeof(char *),liprimnames); ProcessLine(c,0,type,&le->m_value1,&le->m_value2); } } else { GPXLineRow *row; /* first, project bounds for lines and see if it overlaps the draw area */ pos.Set(m_curbounds.GetMinLat(),m_curbounds.GetMinLon()); gpx->m_curmap->ToMap(&pos,&b.lx,&b.by); pos.Set(m_curbounds.GetMaxLat(),m_curbounds.GetMaxLon()); gpx->m_curmap->ToMap(&pos,&b.rx,&b.ty); // kGUI::DrawLine(b.lx-c->lx,b.ty-c->ty,b.rx-c->lx,b.ty-c->ty,DrawColor(255,255,0)); // kGUI::DrawLine(b.lx-c->lx,b.by-c->ty,b.rx-c->lx,b.by-c->ty,DrawColor(255,255,0)); // kGUI::DrawLine(b.lx-c->lx,b.ty-c->ty,b.lx-c->lx,b.by-c->ty,DrawColor(255,255,0)); // kGUI::DrawLine(b.rx-c->lx,b.ty-c->ty,b.rx-c->lx,b.by-c->ty,DrawColor(255,255,0)); /* return if track does not overlap draw area */ if(kGUI::Overlap(c,&b)==false) return; ProcessInit(); for(i=0;i<m_linetable.GetNumChildren();++i) { row=static_cast<GPXLineRow *>(m_linetable.GetChild(i)); type=row->GetType(); v1=row->GetValue1(); v2=row->GetValue2(); ProcessLine(c,0,type,v1,v2); } } } void LinesPage::ProcessLine(kGUICorners *c,GPXBounds *bounds,int type,kGUIString *v1,kGUIString *v2) { switch(type) { case LINEPRIM_WAYPOINT: { GPXRow *gpxrow; gpxrow=gpx->Locate(v1); if(gpxrow) { m_pos1.Set(&m_pos2); gpxrow->GetPos(&m_pos2); } } break; case LINEPRIM_POINT: m_pos1.Set(&m_pos2); m_pos2.Set(v1->GetString(),v2->GetString()); break; case LINEPRIM_PROJECT: m_pos1.Set(&m_pos2); GPX::Project(m_distance,m_disttype,0,m_heading,0,&m_pos1,&m_pos2); break; case LINEPRIM_HEADING: if(!strcmp("Degrees",v1->GetString())) m_heading=atof(v2->GetString()); else m_heading=atof(v2->GetString())*(PI/180.0f); /* radians */ break; case LINEPRIM_ADDHEADING: if(!strcmp("Degrees",v1->GetString())) m_heading+=atof(v2->GetString()); else m_heading+=atof(v2->GetString())*(PI/180.0f); /* radians */ break; case LINEPRIM_DISTANCE: m_disttype=GPX::GetDistIndex(v1->GetString()); m_distance=atof(v2->GetString()); break; case LINEPRIM_DEGREES: m_degrees=atof(v1->GetString()); break; case LINEPRIM_RADIUS: m_radiustype=GPX::GetDistIndex(v1->GetString()); m_radius=atof(v2->GetString()); break; case LINEPRIM_COLOR: m_col=GPX::GetTableColor(GPX::GetTableColorIndex(v1->GetString())); break; case LINEPRIM_THICKNESS: m_thickness=atoi(v1->GetString()); break; case LINEPRIM_LINE: if(bounds) { bounds->Add(&m_pos1); bounds->Add(&m_pos2); } if(c) { int x1,y1,x2,y2; gpx->m_curmap->ToMap(&m_pos1,&x1,&y1); gpx->m_curmap->ToMap(&m_pos2,&x2,&y2); x1-=c->lx; y1-=c->ty; x2-=c->lx; y2-=c->ty; if(m_thickness<=1) kGUI::DrawLine(x1,y1,x2,y2,m_col); else kGUI::DrawFatLine(x1,y1,x2,y2,m_col,m_thickness>>1); } break; case LINEPRIM_ARC: { int i,num; kGUIPoint2 points[360]; GPXCoord edgepos; double movelat,movelon; double sweep,step; int x1,y1; double off,dir; if(m_radius>0.0f) { if(!strcmp("Clockwise",v1->GetString())) { off=90.0f; dir=1.0f; } else { off=270.0f; dir=-1.0f; } /* make arc start at last position so we need to translate it over */ GPX::Project(m_radius,m_radiustype,0,m_heading-off,0,&m_pos2,&edgepos); movelat=edgepos.GetLat()-m_pos2.GetLat(); movelon=edgepos.GetLon()-m_pos2.GetLon(); /* use distance or degrees */ if(!strcmp("Distance",v2->GetString())) sweep=(GPX::GetMeters(m_distance,m_disttype)*(180.0f/PI))/GPX::GetMeters(m_radius,m_radiustype)*dir; else sweep=m_degrees*dir; /* stop at full circle */ if(sweep<-360.0f) sweep=-360.0f; else if(sweep>360.0f) sweep=360.0f; num=(int)abs((int)sweep); if(num) { step=sweep/num; for(i=0;i<num;++i) { GPX::Project(m_radius,m_radiustype,0,m_heading-off,0,&m_pos2,&edgepos); edgepos.SetLat(edgepos.GetLat()-movelat); edgepos.SetLon(edgepos.GetLon()-movelon); if(bounds) bounds->Add(&edgepos); if(c) { gpx->m_curmap->ToMap(&edgepos,&x1,&y1); points[i].x=x1-c->lx; points[i].y=y1-c->ty; } m_heading+=step; } /* set new current position to end of arc position */ m_pos1.Set(&m_pos2); m_pos2.Set(&edgepos); if(c) { if(m_thickness<=1) kGUI::DrawPolyLine(num,points,m_col); else kGUI::DrawFatPolyLine(3,num,points,m_col,(double)m_thickness); } } } } break; case LINEPRIM_CIRCLE: { int i; kGUIFPoint2 points[360+1]; GPXCoord edgepos; int x1,y1; for(i=0;i<=360;++i) { GPX::Project(m_radius,m_radiustype,0,(double)i,0,&m_pos2,&edgepos); if(bounds) bounds->Add(&edgepos); if(c) { gpx->m_curmap->ToMap(&edgepos,&x1,&y1); points[i].x=(float)(x1-c->lx); points[i].y=(float)(y1-c->ty); } } if(c) { if(m_thickness<=1) kGUI::DrawPolyLine(360+1,points,m_col); else kGUI::DrawFatPolyLine(0,360+1,points,m_col,(float)m_thickness); } } break; case LINEPRIM_SETWAYPOINT: { GPXRow *gpxrow; /* set the waypoints position to the current position */ gpxrow=gpx->Locate(v1); if(gpxrow) { if((gpxrow->GetLat()!=m_pos2.GetLat()) || (gpxrow->GetLon()!=m_pos2.GetLon())) { kGUIEvent e; gpxrow->SetCoord(m_pos2.GetLat(),m_pos2.GetLon()); /* map bsp needs to be rebuilt */ e.SetEvent(EVENT_AFTERUPDATE); gpxrow->LocChanged(&e); } } } break; } }
[ [ [ 1, 1343 ] ] ]
535a881ba7d5065ca9c926d34a64899232da7730
bf7d05c055c5686e4ded30f9705a28a396520d48
/Meta/MetaConnJoint.h
bb09425299fd3da6c08dfd82a2fa13735be35b8e
[]
no_license
ghemingway/mgalib
f32438d5abdbeb5739c298e401a0513f91c8d6d0
c8cf8507a7fe73efe1da19abcdb77b52e75e2de0
refs/heads/master
2020-12-24T15:40:33.538434
2011-02-04T16:38:09
2011-02-04T16:38:09
32,185,568
0
1
null
null
null
null
UTF-8
C++
false
false
1,334
h
#ifndef __META_CONNJOINT_H__ #define __META_CONNJOINT_H__ /*** Included Header Files ***/ #include "MetaBase.h" /*** Namespace Declaration ***/ namespace MGA { /*** Class Predefinitions ***/ class MetaPointerSpec; class MetaConnection; // --------------------------- MetaConnJoint --------------------------- // class MetaConnJoint { private: MetaConnJoint(); //!< Deny access to default constructor MetaConnJoint(const MetaConnJoint &); //!< Deny access to copy constructor MetaConnJoint& operator=(const MetaConnJoint &); //!< Deny access to equals operator CoreObject _coreObject; //!< Associated coreObject MetaProject *_metaProject; //!< Contained in this metaProject friend class MetaBase; MetaConnJoint(CoreObject &coreObject, MetaProject* const &metaProject); public: const Result_t GetParent(MetaConnection* &parent) const throw(); //!< const Result_t GetPointerSpecs(std::list<MetaPointerSpec*> &pointerSpecList) const throw(); //!< const Result_t GetPointerSpecByName(const std::string &name, MetaPointerSpec* &pointerSpec) const throw(); //!< const Result_t CreatePointerSpec(MetaPointerSpec* &pointerSpec) throw(); //!< }; /*** End of MGA Namespace ***/ } #endif // __META_CONNJOINT_H__
[ "graham.hemingway@8932de9b-a0df-7518-fb39-9aee4a96b462" ]
[ [ [ 1, 47 ] ] ]
2da7596ce6270e156a18b286b97aaaa15e61738e
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/array/array_expand_abstract.h
a75ba1f8b5f3b8b78452ac0a4b4aadf6467ca473
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
4,032
h
// Copyright (C) 2006 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #undef DLIB_ARRAY_EXPANd_ABSTRACT_ #ifdef DLIB_ARRAY_EXPANd_ABSTRACT_ #include "array_kernel_abstract.h" namespace dlib { template < typename array_base > class array_expand : public array_base { /*! REQUIREMENTS ON ARRAY_BASE must be an implementation of array/array_kernel_abstract.h POINTERS AND REFERENCES resize() may invalidate pointers and references to internal data. WHAT THIS EXTENSION DOES FOR ARRAY This extension gives an array the ability to expand its size() beyond its max_size() without clearing out all its elements. It also adds a std::vector style push/pop back set of functions. !*/ typedef typename array_base::type T; public: void resize ( unsigned long new_size ); /*! ensures - #size() == new_size - #max_size() == max(new_size,max_size()) - for all i < size(): - #(*this)[i] == (*this)[i] (i.e. all the original elements of *this are still present and at their same positions.) - for all valid i >= size(): - #(*this)[i] has an undefined value (i.e. any new elements of the array have an undefined value) throws - std::bad_alloc or any exception thrown by T's constructor. If an exception is thrown then it has no effect on *this. !*/ const T& back ( ) const; /*! requires - size() != 0 ensures - returns a const reference to (*this)[size()-1] !*/ T& back ( ); /*! requires - size() != 0 ensures - returns a non-const reference to (*this)[size()-1] !*/ void pop_back ( T& item ); /*! requires - size() != 0 ensures - #size() == size() - 1 - swaps (*this)[size()-1] into item - All elements with an index less than size()-1 are unmodified by this operation. !*/ void pop_back ( ); /*! requires - size() != 0 ensures - #size() == size() - 1 - All elements with an index less than size()-1 are unmodified by this operation. !*/ void push_back ( T& item ); /*! ensures - #size() == size()+1 - swaps item into (*this)[#size()-1] - #back() == item - #item has some undefined value (whatever happens to get swapped out of the array) throws - std::bad_alloc or any exception thrown by T's constructor. If an exception is thrown then it has no effect on *this. !*/ }; template < typename array_base > inline void swap ( array_expand<array_base>& a, array_expand<array_base>& b ) { a.swap(b); } /*! provides a global swap function !*/ } #endif // DLIB_ARRAY_EXPANd_ABSTRACT_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 126 ] ] ]
3e723db0581360c0c4fc6d752e1197d7ff004054
44d499cacf286b033ce08eeceec1002e5ce782c9
/hardware/lm3s/timer_lm3s.cpp
8764b863d49b415074fed1d164640ef6b3c8a3c2
[]
no_license
thumbos/tmos
ef134ecc57b44e029ded14f957d7a23c982a4fae
756c2bc513288bfe1be96331a9e388ed0d744c83
refs/heads/master
2021-03-12T22:56:14.235818
2010-12-04T16:25:26
2010-12-04T16:25:26
1,137,841
0
0
null
null
null
null
UTF-8
C++
false
false
20,491
cpp
/**************************************************************************//** * @ingroup lm3s_timer * @{ * @file timer_lm3s.cpp * @brief TIMER class methods * @version V3.00 * @date 23. March 2010 * @author Miroslav Kostadinov * * ******************************************************************************/ #include <tmos.h> #include "fam_cpp.h" /** * * Get TIMER peripheral value * * \return values that can be passed to the * SysCtlPeripheralPresent(), SysCtlPeripheralEnable(), * SysCtlPeripheralDisable(), and SysCtlPeripheralReset() APIs as the * ulPeripheral parameter. * */ unsigned long TIMER_Type::GetPeripheral(void) { if( this == TIMER0 ) return SYSCTL_PERIPH_TIMER0; if( this == TIMER1 ) return SYSCTL_PERIPH_TIMER1; if( this == TIMER2 ) return SYSCTL_PERIPH_TIMER2; if( this == TIMER3 ) return SYSCTL_PERIPH_TIMER3; return 0; } /** * * Reset TIMER peripheral * */ void TIMER_Type::Reset(void) { SysCtlPeripheralReset(this->GetPeripheral()); } //***************************************************************************** // //! Enables the timer(s). //! //! \param ulTimer specifies the timer(s) to enable; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. //! //! This will enable operation of the timer module. The timer must be //! configured before it is enabled. //! //! \return None. // //***************************************************************************** void TIMER_Type::Enable(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Enable the timer(s) module. this->CTL |= ulTimer & (TIMER_CTL_TAEN | TIMER_CTL_TBEN); } //***************************************************************************** // //! Disables the timer(s). //! //! \param ulTimer specifies the timer(s) to disable; must be one of //! \b TIMER_A, \b TIMER_B, or \b TIMER_BOTH. //! //! This will disable operation of the timer module. //! //! \return None. // //***************************************************************************** void TIMER_Type::Disable(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Disable the timer module. this->CTL &= ~(ulTimer & (TIMER_CTL_TAEN | TIMER_CTL_TBEN)); } //***************************************************************************** // //! Configures the timer(s). //! //! \param ulConfig is the configuration for the timer. //! //! This function configures the operating mode of the timer(s). The timer //! module is disabled before being configured, and is left in the disabled //! state. The configuration is specified in \e ulConfig as one of the //! following values: //! //! - \b TIMER_CFG_32_BIT_OS - 32-bit one shot timer //! - \b TIMER_CFG_32_BIT_PER - 32-bit periodic timer //! - \b TIMER_CFG_32_RTC - 32-bit real time clock timer //! - \b TIMER_CFG_16_BIT_PAIR - Two 16-bit timers //! //! When configured for a pair of 16-bit timers, each timer is separately //! configured. The first timer is configured by setting \e ulConfig to //! the result of a logical OR operation between one of the following values //! and \e ulConfig: //! //! - \b TIMER_CFG_A_ONE_SHOT - 16-bit one shot timer //! - \b TIMER_CFG_A_PERIODIC - 16-bit periodic timer //! - \b TIMER_CFG_A_CAP_COUNT - 16-bit edge count capture //! - \b TIMER_CFG_A_CAP_TIME - 16-bit edge time capture //! - \b TIMER_CFG_A_PWM - 16-bit PWM output //! //! Similarly, the second timer is configured by setting \e ulConfig to //! the result of a logical OR operation between one of the corresponding //! \b TIMER_CFG_B_* values and \e ulConfig. //! //! \return None. // //***************************************************************************** void TIMER_Type::Configure(unsigned long ulConfig) { ASSERT((ulConfig == TIMER_CFG_32_BIT_OS) || (ulConfig == TIMER_CFG_32_BIT_PER) || (ulConfig == TIMER_CFG_32_RTC) || ((ulConfig & 0xff000000) == TIMER_CFG_16_BIT_PAIR)); ASSERT(((ulConfig & 0xff000000) != TIMER_CFG_16_BIT_PAIR) || ((((ulConfig & 0x000000ff) == TIMER_CFG_A_ONE_SHOT) || ((ulConfig & 0x000000ff) == TIMER_CFG_A_PERIODIC) || ((ulConfig & 0x000000ff) == TIMER_CFG_A_CAP_COUNT) || ((ulConfig & 0x000000ff) == TIMER_CFG_A_CAP_TIME) || ((ulConfig & 0x000000ff) == TIMER_CFG_A_PWM)) && (((ulConfig & 0x0000ff00) == TIMER_CFG_B_ONE_SHOT) || ((ulConfig & 0x0000ff00) == TIMER_CFG_B_PERIODIC) || ((ulConfig & 0x0000ff00) == TIMER_CFG_B_CAP_COUNT) || ((ulConfig & 0x0000ff00) == TIMER_CFG_B_CAP_TIME) || ((ulConfig & 0x0000ff00) == TIMER_CFG_B_PWM)))); // Disable the timers. this->CTL &= ~(TIMER_CTL_TAEN | TIMER_CTL_TBEN); // Set the global timer configuration. this->CFG = ulConfig >> 24; // Set the configuration of the A and B timers. Note that the B timer // configuration is ignored by the hardware in 32-bit modes. this->TAMR = ulConfig & 255; this->TBMR = (ulConfig >> 8) & 255; } //***************************************************************************** // //! Controls the output level. //! //! \param ulTimer specifies the timer(s) to adjust; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. //! \param bInvert specifies the output level. //! //! This function sets the PWM output level for the specified timer. If the //! \e bInvert parameter is \b true, then the timer's output will be made //! active low; otherwise, it will be made active high. //! //! \return None. // //***************************************************************************** void TIMER_Type::ControlLevel(unsigned long ulTimer, int bInvert) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the output levels as requested. ulTimer &= TIMER_CTL_TAPWML | TIMER_CTL_TBPWML; this->CTL = (bInvert ?(this->CTL | ulTimer) : (this->CTL & ~(ulTimer))); } //***************************************************************************** // //! Enables or disables the trigger output. //! //! \param ulTimer specifies the timer to adjust; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. //! \param bEnable specifies the desired trigger state. //! //! This function controls the trigger output for the specified timer. If the //! \e bEnable parameter is \b true, then the timer's output trigger is //! enabled; otherwise it is disabled. //! //! \return None. // //***************************************************************************** void TIMER_Type::ControlTrigger(unsigned long ulTimer, int bEnable) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the trigger output as requested. ulTimer &= TIMER_CTL_TAOTE | TIMER_CTL_TBOTE; this->CTL = (bEnable ? (this->CTL | ulTimer) : (this->CTL & ~(ulTimer))); } //***************************************************************************** // //! Controls the event type. //! //! \param ulTimer specifies the timer(s) to be adjusted; must be one of //! \b TIMER_A, \b TIMER_B, or \b TIMER_BOTH. //! \param ulEvent specifies the type of event; must be one of //! \b TIMER_EVENT_POS_EDGE, \b TIMER_EVENT_NEG_EDGE, or //! \b TIMER_EVENT_BOTH_EDGES. //! //! This function sets the signal edge(s) that will trigger the timer when in //! capture mode. //! //! \return None. // //***************************************************************************** void TIMER_Type::ControlEvent(unsigned long ulTimer, unsigned long ulEvent) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the event type. ulEvent &= ulTimer & (TIMER_CTL_TAEVENT_M | TIMER_CTL_TBEVENT_M); this->CTL = ((this->CTL & ~(TIMER_CTL_TAEVENT_M | TIMER_CTL_TBEVENT_M)) | ulEvent); } //***************************************************************************** // //! Controls the stall handling. //! //! \param ulTimer specifies the timer(s) to be adjusted; must be one of //! \b TIMER_A, \b TIMER_B, or \b TIMER_BOTH. //! \param bStall specifies the response to a stall signal. //! //! This function controls the stall response for the specified timer. If the //! \e bStall parameter is \b true, then the timer will stop counting if the //! processor enters debug mode; otherwise the timer will keep running while in //! debug mode. //! //! \return None. // //***************************************************************************** void TIMER_Type::ControlStall(unsigned long ulTimer, int bStall) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the stall mode. ulTimer &= TIMER_CTL_TASTALL | TIMER_CTL_TBSTALL; this->CTL = (bStall ? (this->CTL | ulTimer) : (this->CTL & ~(ulTimer))); } //***************************************************************************** // //! Enable RTC counting. //! //! This function causes the timer to start counting when in RTC mode. If not //! configured for RTC mode, this will do nothing. //! //! \return None. // //***************************************************************************** void TIMER_Type::RTCEnable(void) { // Enable RTC counting. this->CTL |= TIMER_CTL_RTCEN; } //***************************************************************************** // //! Disable RTC counting. //! //! This function causes the timer to stop counting when in RTC mode. //! //! \return None. // //***************************************************************************** void TIMER_Type::RTCDisable(void) { // Disable RTC counting. this->CTL &= ~(TIMER_CTL_RTCEN); } //***************************************************************************** // //! Set the timer prescale value. //! //! \param ulTimer specifies the timer(s) to adjust; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. //! \param ulValue is the timer prescale value; must be between 0 and 255, //! inclusive. //! //! This function sets the value of the input clock prescaler. The prescaler //! is only operational when in 16-bit mode and is used to extend the range of //! the 16-bit timer modes. //! //! \return None. // //***************************************************************************** void TIMER_Type::PrescaleSet(unsigned long ulTimer, unsigned long ulValue) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); ASSERT(ulValue < 256); // Set the timer A prescaler if requested. if(ulTimer & TIMER_A) this->TAPR = ulValue; // Set the timer B prescaler if requested. if(ulTimer & TIMER_B) this->TBPR = ulValue; } //***************************************************************************** // //! Get the timer prescale value. //! //! \param ulTimer specifies the timer; must be one of \b TIMER_A or //! \b TIMER_B. //! //! This function gets the value of the input clock prescaler. The prescaler //! is only operational when in 16-bit mode and is used to extend the range of //! the 16-bit timer modes. //! //! \return The value of the timer prescaler. // //***************************************************************************** unsigned long TIMER_Type::PrescaleGet(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Return the appropriate prescale value. return((ulTimer == TIMER_A) ? this->TAPR : this->TBPR); } //***************************************************************************** // //! Sets the timer load value. //! //! \param ulTimer specifies the timer(s) to adjust; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. Only \b TIMER_A should be used when the //! timer is configured for 32-bit operation. //! \param ulValue is the load value. //! //! This function sets the timer load value; if the timer is running then the //! value will be immediately loaded into the timer. //! //! \return None. // //***************************************************************************** void TIMER_Type::LoadSet(unsigned long ulTimer, unsigned long ulValue) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the timer A load value if requested. if(ulTimer & TIMER_A) this->TAILR = ulValue; // Set the timer B load value if requested. if(ulTimer & TIMER_B) this->TBILR = ulValue; } //***************************************************************************** // //! Gets the timer load value. //! //! \param ulTimer specifies the timer; must be one of \b TIMER_A or //! \b TIMER_B. Only \b TIMER_A should be used when the timer is configured //! for 32-bit operation. //! //! This function gets the currently programmed interval load value for the //! specified timer. //! //! \return Returns the load value for the timer. // //***************************************************************************** unsigned long TIMER_Type::LoadGet(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B)); // Return the appropriate load value. return((ulTimer == TIMER_A) ? this->TAILR : this->TBILR); } //***************************************************************************** // //! Gets the current timer value. //! //! \param ulTimer specifies the timer; must be one of \b TIMER_A or //! \b TIMER_B. Only \b TIMER_A should be used when the timer is configured //! for 32-bit operation. //! //! This function reads the current value of the specified timer. //! //! \return Returns the current value of the timer. // //***************************************************************************** unsigned long TIMER_Type::ValueGet(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B)); // Return the appropriate timer value. return((ulTimer == TIMER_A) ? this->TAR : this->TBR); } //***************************************************************************** // //! Sets the timer match value. //! //! \param ulTimer specifies the timer(s) to adjust; must be one of \b TIMER_A, //! \b TIMER_B, or \b TIMER_BOTH. Only \b TIMER_A should be used when the //! timer is configured for 32-bit operation. //! \param ulValue is the match value. //! //! This function sets the match value for a timer. This is used in capture //! count mode to determine when to interrupt the processor and in PWM mode to //! determine the duty cycle of the output signal. //! //! \return None. // //***************************************************************************** void TIMER_Type::MatchSet(unsigned long ulTimer, unsigned long ulValue) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); // Set the timer A match value if requested. if(ulTimer & TIMER_A) this->TAMATCHR = ulValue; // Set the timer B match value if requested. if(ulTimer & TIMER_B) this->TBMATCHR = ulValue; } //***************************************************************************** // //! Gets the timer match value. //! //! \param ulTimer specifies the timer; must be one of \b TIMER_A or //! \b TIMER_B. Only \b TIMER_A should be used when the timer is configured //! for 32-bit operation. //! //! This function gets the match value for the specified timer. //! //! \return Returns the match value for the timer. // //***************************************************************************** unsigned long TIMER_Type::MatchGet(unsigned long ulTimer) { ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B)); // Return the appropriate match value. return((ulTimer == TIMER_A) ? this->TAMATCHR : this->TBMATCHR); } //***************************************************************************** // //! Enables individual timer interrupt sources. //! //! \param ulIntFlags is the bit mask of the interrupt sources to be enabled. //! //! Enables the indicated timer interrupt sources. Only the sources that are //! enabled can be reflected to the processor interrupt; disabled sources have //! no effect on the processor. //! //! The \e ulIntFlags parameter must be the logical OR of any combination of //! the following: //! //! - \b TIMER_CAPB_EVENT - Capture B event interrupt //! - \b TIMER_CAPB_MATCH - Capture B match interrupt //! - \b TIMER_TIMB_TIMEOUT - Timer B timeout interrupt //! - \b TIMER_RTC_MATCH - RTC interrupt mask //! - \b TIMER_CAPA_EVENT - Capture A event interrupt //! - \b TIMER_CAPA_MATCH - Capture A match interrupt //! - \b TIMER_TIMA_TIMEOUT - Timer A timeout interrupt //! //! \return None. // //***************************************************************************** void TIMER_Type::IntEnable(unsigned long ulIntFlags) { // Enable the specified interrupts. this->IMR |= ulIntFlags; } //***************************************************************************** // //! Disables individual timer interrupt sources. //! //! \param ulIntFlags is the bit mask of the interrupt sources to be disabled. //! //! Disables the indicated timer interrupt sources. Only the sources that are //! enabled can be reflected to the processor interrupt; disabled sources have //! no effect on the processor. //! //! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags //! parameter to TimerIntEnable(). //! //! \return None. // //***************************************************************************** void TIMER_Type::IntDisable(unsigned long ulIntFlags) { // Disable the specified interrupts. this->IMR &= ~(ulIntFlags); } //***************************************************************************** // //! Gets the current interrupt status. //! //! \param bMasked is false if the raw interrupt status is required and true if //! the masked interrupt status is required. //! //! This returns the interrupt status for the timer module. Either the raw //! interrupt status or the status of interrupts that are allowed to reflect to //! the processor can be returned. //! //! \return The current interrupt status, enumerated as a bit field of //! values described in TimerIntEnable(). // //***************************************************************************** unsigned long TIMER_Type::IntStatus(int bMasked) { // Return either the interrupt status or the raw interrupt status as // requested. return(bMasked ? this->MIS : this->RIS); } //***************************************************************************** // //! Clears timer interrupt sources. //! //! \param ulIntFlags is a bit mask of the interrupt sources to be cleared. //! //! The specified timer interrupt sources are cleared, so that they no longer //! assert. This must be done in the interrupt handler to keep it from being //! called again immediately upon exit. //! //! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags //! parameter to TimerIntEnable(). //! //! \note Since there is a write buffer in the Cortex-M3 processor, it may take //! several clock cycles before the interrupt source is actually cleared. //! Therefore, it is recommended that the interrupt source be cleared early in //! the interrupt handler (as opposed to the very last action) to avoid //! returning from the interrupt handler before the interrupt source is //! actually cleared. Failure to do so may result in the interrupt handler //! being immediately reentered (since NVIC still sees the interrupt source //! asserted). //! //! \return None. // //***************************************************************************** void TIMER_Type::IntClear(unsigned long ulIntFlags) { // Clear the requested interrupt sources. this->ICR = ulIntFlags; } /** @} ingroup lm3s_timer */
[ [ [ 1, 552 ] ] ]
d8a05f9a447bfbd24faaea9aa9a5780f0bb519d8
a84b013cd995870071589cefe0ab060ff3105f35
/webdriver/branches/chrome/chrome/src/cpp/include/v8/src/assembler-arm.h
da2cc29066595b74e0482b2cf6c14637ad1d58c4
[ "Apache-2.0" ]
permissive
vdt/selenium
137bcad58b7184690b8785859d77da0cd9f745a0
30e5e122b068aadf31bcd010d00a58afd8075217
refs/heads/master
2020-12-27T21:35:06.461381
2009-08-18T15:56:32
2009-08-18T15:56:32
13,650,409
1
0
null
null
null
null
UTF-8
C++
false
false
27,923
h
// Copyright (c) 1994-2006 Sun Microsystems Inc. // All Rights Reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // - Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // - Redistribution in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // - Neither the name of Sun Microsystems or the names of contributors may // be used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. // The original source code covered by the above license above has been modified // significantly by Google Inc. // Copyright 2006-2008 the V8 project authors. All rights reserved. // A light-weight ARM Assembler // Generates user mode instructions for the ARM architecture up to version 5 #ifndef V8_ASSEMBLER_ARM_H_ #define V8_ASSEMBLER_ARM_H_ #include "assembler.h" namespace v8 { namespace internal { // CPU Registers. // // 1) We would prefer to use an enum, but enum values are assignment- // compatible with int, which has caused code-generation bugs. // // 2) We would prefer to use a class instead of a struct but we don't like // the register initialization to depend on the particular initialization // order (which appears to be different on OS X, Linux, and Windows for the // installed versions of C++ we tried). Using a struct permits C-style // "initialization". Also, the Register objects cannot be const as this // forces initialization stubs in MSVC, making us dependent on initialization // order. // // 3) By not using an enum, we are possibly preventing the compiler from // doing certain constant folds, which may significantly reduce the // code generated for some assembly instructions (because they boil down // to a few constants). If this is a problem, we could change the code // such that we use an enum in optimized mode, and the struct in debug // mode. This way we get the compile-time error checking in debug mode // and best performance in optimized code. // // Core register struct Register { bool is_valid() const { return 0 <= code_ && code_ < 16; } bool is(Register reg) const { return code_ == reg.code_; } int code() const { ASSERT(is_valid()); return code_; } int bit() const { ASSERT(is_valid()); return 1 << code_; } // (unfortunately we can't make this private in a struct) int code_; }; extern Register no_reg; extern Register r0; extern Register r1; extern Register r2; extern Register r3; extern Register r4; extern Register r5; extern Register r6; extern Register r7; extern Register r8; extern Register r9; extern Register r10; extern Register fp; extern Register ip; extern Register sp; extern Register lr; extern Register pc; // Coprocessor register struct CRegister { bool is_valid() const { return 0 <= code_ && code_ < 16; } bool is(CRegister creg) const { return code_ == creg.code_; } int code() const { ASSERT(is_valid()); return code_; } int bit() const { ASSERT(is_valid()); return 1 << code_; } // (unfortunately we can't make this private in a struct) int code_; }; extern CRegister no_creg; extern CRegister cr0; extern CRegister cr1; extern CRegister cr2; extern CRegister cr3; extern CRegister cr4; extern CRegister cr5; extern CRegister cr6; extern CRegister cr7; extern CRegister cr8; extern CRegister cr9; extern CRegister cr10; extern CRegister cr11; extern CRegister cr12; extern CRegister cr13; extern CRegister cr14; extern CRegister cr15; // Coprocessor number enum Coprocessor { p0 = 0, p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5, p6 = 6, p7 = 7, p8 = 8, p9 = 9, p10 = 10, p11 = 11, p12 = 12, p13 = 13, p14 = 14, p15 = 15 }; // Condition field in instructions enum Condition { eq = 0 << 28, ne = 1 << 28, cs = 2 << 28, hs = 2 << 28, cc = 3 << 28, lo = 3 << 28, mi = 4 << 28, pl = 5 << 28, vs = 6 << 28, vc = 7 << 28, hi = 8 << 28, ls = 9 << 28, ge = 10 << 28, lt = 11 << 28, gt = 12 << 28, le = 13 << 28, al = 14 << 28 }; // Returns the equivalent of !cc. INLINE(Condition NegateCondition(Condition cc)); // Corresponds to transposing the operands of a comparison. inline Condition ReverseCondition(Condition cc) { switch (cc) { case lo: return hi; case hi: return lo; case hs: return ls; case ls: return hs; case lt: return gt; case gt: return lt; case ge: return le; case le: return ge; default: return cc; }; } // The pc store offset may be 8 or 12 depending on the processor implementation. int PcStoreOffset(); // ----------------------------------------------------------------------------- // Addressing modes and instruction variants // Shifter operand shift operation enum ShiftOp { LSL = 0 << 5, LSR = 1 << 5, ASR = 2 << 5, ROR = 3 << 5, RRX = -1 }; // Condition code updating mode enum SBit { SetCC = 1 << 20, // set condition code LeaveCC = 0 << 20 // leave condition code unchanged }; // Status register selection enum SRegister { CPSR = 0 << 22, SPSR = 1 << 22 }; // Status register fields enum SRegisterField { CPSR_c = CPSR | 1 << 16, CPSR_x = CPSR | 1 << 17, CPSR_s = CPSR | 1 << 18, CPSR_f = CPSR | 1 << 19, SPSR_c = SPSR | 1 << 16, SPSR_x = SPSR | 1 << 17, SPSR_s = SPSR | 1 << 18, SPSR_f = SPSR | 1 << 19 }; // Status register field mask (or'ed SRegisterField enum values) typedef uint32_t SRegisterFieldMask; // Memory operand addressing mode enum AddrMode { // bit encoding P U W Offset = (8|4|0) << 21, // offset (without writeback to base) PreIndex = (8|4|1) << 21, // pre-indexed addressing with writeback PostIndex = (0|4|0) << 21, // post-indexed addressing with writeback NegOffset = (8|0|0) << 21, // negative offset (without writeback to base) NegPreIndex = (8|0|1) << 21, // negative pre-indexed with writeback NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback }; // Load/store multiple addressing mode enum BlockAddrMode { // bit encoding P U W da = (0|0|0) << 21, // decrement after ia = (0|4|0) << 21, // increment after db = (8|0|0) << 21, // decrement before ib = (8|4|0) << 21, // increment before da_w = (0|0|1) << 21, // decrement after with writeback to base ia_w = (0|4|1) << 21, // increment after with writeback to base db_w = (8|0|1) << 21, // decrement before with writeback to base ib_w = (8|4|1) << 21 // increment before with writeback to base }; // Coprocessor load/store operand size enum LFlag { Long = 1 << 22, // long load/store coprocessor Short = 0 << 22 // short load/store coprocessor }; // ----------------------------------------------------------------------------- // Machine instruction Operands // Class Operand represents a shifter operand in data processing instructions class Operand BASE_EMBEDDED { public: // immediate INLINE(explicit Operand(int32_t immediate, RelocInfo::Mode rmode = RelocInfo::NONE)); INLINE(explicit Operand(const ExternalReference& f)); INLINE(explicit Operand(const char* s)); INLINE(explicit Operand(Object** opp)); INLINE(explicit Operand(Context** cpp)); explicit Operand(Handle<Object> handle); INLINE(explicit Operand(Smi* value)); // rm INLINE(explicit Operand(Register rm)); // rm <shift_op> shift_imm explicit Operand(Register rm, ShiftOp shift_op, int shift_imm); // rm <shift_op> rs explicit Operand(Register rm, ShiftOp shift_op, Register rs); // Return true if this is a register operand. INLINE(bool is_reg() const); Register rm() const { return rm_; } private: Register rm_; Register rs_; ShiftOp shift_op_; int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg int32_t imm32_; // valid if rm_ == no_reg RelocInfo::Mode rmode_; friend class Assembler; }; // Class MemOperand represents a memory operand in load and store instructions class MemOperand BASE_EMBEDDED { public: // [rn +/- offset] Offset/NegOffset // [rn +/- offset]! PreIndex/NegPreIndex // [rn], +/- offset PostIndex/NegPostIndex // offset is any signed 32-bit value; offset is first loaded to register ip if // it does not fit the addressing mode (12-bit unsigned and sign bit) explicit MemOperand(Register rn, int32_t offset = 0, AddrMode am = Offset); // [rn +/- rm] Offset/NegOffset // [rn +/- rm]! PreIndex/NegPreIndex // [rn], +/- rm PostIndex/NegPostIndex explicit MemOperand(Register rn, Register rm, AddrMode am = Offset); // [rn +/- rm <shift_op> shift_imm] Offset/NegOffset // [rn +/- rm <shift_op> shift_imm]! PreIndex/NegPreIndex // [rn], +/- rm <shift_op> shift_imm PostIndex/NegPostIndex explicit MemOperand(Register rn, Register rm, ShiftOp shift_op, int shift_imm, AddrMode am = Offset); private: Register rn_; // base Register rm_; // register offset int32_t offset_; // valid if rm_ == no_reg ShiftOp shift_op_; int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg AddrMode am_; // bits P, U, and W friend class Assembler; }; typedef int32_t Instr; class Assembler : public Malloced { public: // Create an assembler. Instructions and relocation information are emitted // into a buffer, with the instructions starting from the beginning and the // relocation information starting from the end of the buffer. See CodeDesc // for a detailed comment on the layout (globals.h). // // If the provided buffer is NULL, the assembler allocates and grows its own // buffer, and buffer_size determines the initial buffer size. The buffer is // owned by the assembler and deallocated upon destruction of the assembler. // // If the provided buffer is not NULL, the assembler uses the provided buffer // for code generation and assumes its size to be buffer_size. If the buffer // is too small, a fatal error occurs. No deallocation of the buffer is done // upon destruction of the assembler. Assembler(void* buffer, int buffer_size); ~Assembler(); // GetCode emits any pending (non-emitted) code and fills the descriptor // desc. GetCode() is idempotent; it returns the same result if no other // Assembler functions are invoked in between GetCode() calls. void GetCode(CodeDesc* desc); // Label operations & relative jumps (PPUM Appendix D) // // Takes a branch opcode (cc) and a label (L) and generates // either a backward branch or a forward branch and links it // to the label fixup chain. Usage: // // Label L; // unbound label // j(cc, &L); // forward branch to unbound label // bind(&L); // bind label to the current pc // j(cc, &L); // backward branch to bound label // bind(&L); // illegal: a label may be bound only once // // Note: The same Label can be used for forward and backward branches // but it may be bound only once. void bind(Label* L); // binds an unbound label L to the current code position // Returns the branch offset to the given label from the current code position // Links the label to the current position if it is still unbound // Manages the jump elimination optimization if the second parameter is true. int branch_offset(Label* L, bool jump_elimination_allowed); // Return the address in the constant pool of the code target address used by // the branch/call instruction at pc. INLINE(static Address target_address_address_at(Address pc)); // Read/Modify the code target address in the branch/call instruction at pc. INLINE(static Address target_address_at(Address pc)); INLINE(static void set_target_address_at(Address pc, Address target)); // Distance between the instruction referring to the address of the call // target (ldr pc, [target addr in const pool]) and the return address static const int kTargetAddrToReturnAddrDist = sizeof(Instr); // --------------------------------------------------------------------------- // Code generation // Insert the smallest number of nop instructions // possible to align the pc offset to a multiple // of m. m must be a power of 2 (>= 4). void Align(int m); // Branch instructions void b(int branch_offset, Condition cond = al); void bl(int branch_offset, Condition cond = al); void blx(int branch_offset); // v5 and above void blx(Register target, Condition cond = al); // v5 and above void bx(Register target, Condition cond = al); // v5 and above, plus v4t // Convenience branch instructions using labels void b(Label* L, Condition cond = al) { b(branch_offset(L, cond == al), cond); } void b(Condition cond, Label* L) { b(branch_offset(L, cond == al), cond); } void bl(Label* L, Condition cond = al) { bl(branch_offset(L, false), cond); } void bl(Condition cond, Label* L) { bl(branch_offset(L, false), cond); } void blx(Label* L) { blx(branch_offset(L, false)); } // v5 and above // Data-processing instructions void and_(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void eor(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void sub(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void sub(Register dst, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al) { sub(dst, src1, Operand(src2), s, cond); } void rsb(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void add(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void adc(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void sbc(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void rsc(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void tst(Register src1, const Operand& src2, Condition cond = al); void tst(Register src1, Register src2, Condition cond = al) { tst(src1, Operand(src2), cond); } void teq(Register src1, const Operand& src2, Condition cond = al); void cmp(Register src1, const Operand& src2, Condition cond = al); void cmp(Register src1, Register src2, Condition cond = al) { cmp(src1, Operand(src2), cond); } void cmn(Register src1, const Operand& src2, Condition cond = al); void orr(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void orr(Register dst, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al) { orr(dst, src1, Operand(src2), s, cond); } void mov(Register dst, const Operand& src, SBit s = LeaveCC, Condition cond = al); void mov(Register dst, Register src, SBit s = LeaveCC, Condition cond = al) { mov(dst, Operand(src), s, cond); } void bic(Register dst, Register src1, const Operand& src2, SBit s = LeaveCC, Condition cond = al); void mvn(Register dst, const Operand& src, SBit s = LeaveCC, Condition cond = al); // Multiply instructions void mla(Register dst, Register src1, Register src2, Register srcA, SBit s = LeaveCC, Condition cond = al); void mul(Register dst, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al); void smlal(Register dstL, Register dstH, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al); void smull(Register dstL, Register dstH, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al); void umlal(Register dstL, Register dstH, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al); void umull(Register dstL, Register dstH, Register src1, Register src2, SBit s = LeaveCC, Condition cond = al); // Miscellaneous arithmetic instructions void clz(Register dst, Register src, Condition cond = al); // v5 and above // Status register access instructions void mrs(Register dst, SRegister s, Condition cond = al); void msr(SRegisterFieldMask fields, const Operand& src, Condition cond = al); // Load/Store instructions void ldr(Register dst, const MemOperand& src, Condition cond = al); void str(Register src, const MemOperand& dst, Condition cond = al); void ldrb(Register dst, const MemOperand& src, Condition cond = al); void strb(Register src, const MemOperand& dst, Condition cond = al); void ldrh(Register dst, const MemOperand& src, Condition cond = al); void strh(Register src, const MemOperand& dst, Condition cond = al); void ldrsb(Register dst, const MemOperand& src, Condition cond = al); void ldrsh(Register dst, const MemOperand& src, Condition cond = al); // Load/Store multiple instructions void ldm(BlockAddrMode am, Register base, RegList dst, Condition cond = al); void stm(BlockAddrMode am, Register base, RegList src, Condition cond = al); // Semaphore instructions void swp(Register dst, Register src, Register base, Condition cond = al); void swpb(Register dst, Register src, Register base, Condition cond = al); // Exception-generating instructions and debugging support void stop(const char* msg); void bkpt(uint32_t imm16); // v5 and above void swi(uint32_t imm24, Condition cond = al); // Coprocessor instructions void cdp(Coprocessor coproc, int opcode_1, CRegister crd, CRegister crn, CRegister crm, int opcode_2, Condition cond = al); void cdp2(Coprocessor coproc, int opcode_1, CRegister crd, CRegister crn, CRegister crm, int opcode_2); // v5 and above void mcr(Coprocessor coproc, int opcode_1, Register rd, CRegister crn, CRegister crm, int opcode_2 = 0, Condition cond = al); void mcr2(Coprocessor coproc, int opcode_1, Register rd, CRegister crn, CRegister crm, int opcode_2 = 0); // v5 and above void mrc(Coprocessor coproc, int opcode_1, Register rd, CRegister crn, CRegister crm, int opcode_2 = 0, Condition cond = al); void mrc2(Coprocessor coproc, int opcode_1, Register rd, CRegister crn, CRegister crm, int opcode_2 = 0); // v5 and above void ldc(Coprocessor coproc, CRegister crd, const MemOperand& src, LFlag l = Short, Condition cond = al); void ldc(Coprocessor coproc, CRegister crd, Register base, int option, LFlag l = Short, Condition cond = al); void ldc2(Coprocessor coproc, CRegister crd, const MemOperand& src, LFlag l = Short); // v5 and above void ldc2(Coprocessor coproc, CRegister crd, Register base, int option, LFlag l = Short); // v5 and above void stc(Coprocessor coproc, CRegister crd, const MemOperand& dst, LFlag l = Short, Condition cond = al); void stc(Coprocessor coproc, CRegister crd, Register base, int option, LFlag l = Short, Condition cond = al); void stc2(Coprocessor coproc, CRegister crd, const MemOperand& dst, LFlag l = Short); // v5 and above void stc2(Coprocessor coproc, CRegister crd, Register base, int option, LFlag l = Short); // v5 and above // Pseudo instructions void nop() { mov(r0, Operand(r0)); } void push(Register src) { str(src, MemOperand(sp, 4, NegPreIndex), al); } void pop(Register dst) { ldr(dst, MemOperand(sp, 4, PostIndex), al); } void pop() { add(sp, sp, Operand(kPointerSize)); } // Load effective address of memory operand x into register dst void lea(Register dst, const MemOperand& x, SBit s = LeaveCC, Condition cond = al); // Jump unconditionally to given label. void jmp(Label* L) { b(L, al); } // Debugging // Record a comment relocation entry that can be used by a disassembler. // Use --debug_code to enable. void RecordComment(const char* msg); void RecordPosition(int pos); void RecordStatementPosition(int pos); void WriteRecordedPositions(); int pc_offset() const { return pc_ - buffer_; } int current_position() const { return current_position_; } int current_statement_position() const { return current_position_; } protected: int buffer_space() const { return reloc_info_writer.pos() - pc_; } // Read/patch instructions Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } void instr_at_put(byte* pc, Instr instr) { *reinterpret_cast<Instr*>(pc) = instr; } Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } void instr_at_put(int pos, Instr instr) { *reinterpret_cast<Instr*>(buffer_ + pos) = instr; } // Decode branch instruction at pos and return branch target pos int target_at(int pos); // Patch branch instruction at pos to branch to given branch target pos void target_at_put(int pos, int target_pos); // Check if is time to emit a constant pool for pending reloc info entries void CheckConstPool(bool force_emit, bool require_jump); // Block the emission of the constant pool before pc_offset void BlockConstPoolBefore(int pc_offset) { if (no_const_pool_before_ < pc_offset) no_const_pool_before_ = pc_offset; } private: // Code buffer: // The buffer into which code and relocation info are generated. byte* buffer_; int buffer_size_; // True if the assembler owns the buffer, false if buffer is external. bool own_buffer_; // Buffer size and constant pool distance are checked together at regular // intervals of kBufferCheckInterval emitted bytes static const int kBufferCheckInterval = 1*KB/2; int next_buffer_check_; // pc offset of next buffer check // Code generation static const int kInstrSize = sizeof(Instr); // signed size // The relocation writer's position is at least kGap bytes below the end of // the generated instructions. This is so that multi-instruction sequences do // not have to check for overflow. The same is true for writes of large // relocation info entries. static const int kGap = 32; byte* pc_; // the program counter; moves forward // Constant pool generation // Pools are emitted in the instruction stream, preferably after unconditional // jumps or after returns from functions (in dead code locations). // If a long code sequence does not contain unconditional jumps, it is // necessary to emit the constant pool before the pool gets too far from the // location it is accessed from. In this case, we emit a jump over the emitted // constant pool. // Constants in the pool may be addresses of functions that gets relocated; // if so, a relocation info entry is associated to the constant pool entry. // Repeated checking whether the constant pool should be emitted is rather // expensive. By default we only check again once a number of instructions // has been generated. That also means that the sizing of the buffers is not // an exact science, and that we rely on some slop to not overrun buffers. static const int kCheckConstIntervalInst = 32; static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize; // Pools are emitted after function return and in dead code at (more or less) // regular intervals of kDistBetweenPools bytes static const int kDistBetweenPools = 1*KB; // Constants in pools are accessed via pc relative addressing, which can // reach +/-4KB thereby defining a maximum distance between the instruction // and the accessed constant. We satisfy this constraint by limiting the // distance between pools. static const int kMaxDistBetweenPools = 4*KB - 2*kBufferCheckInterval; // Emission of the constant pool may be blocked in some code sequences int no_const_pool_before_; // block emission before this pc offset // Keep track of the last emitted pool to guarantee a maximal distance int last_const_pool_end_; // pc offset following the last constant pool // Relocation info generation // Each relocation is encoded as a variable size value static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; RelocInfoWriter reloc_info_writer; // Relocation info records are also used during code generation as temporary // containers for constants and code target addresses until they are emitted // to the constant pool. These pending relocation info records are temporarily // stored in a separate buffer until a constant pool is emitted. // If every instruction in a long sequence is accessing the pool, we need one // pending relocation entry per instruction. static const int kMaxNumPRInfo = kMaxDistBetweenPools/kInstrSize; RelocInfo prinfo_[kMaxNumPRInfo]; // the buffer of pending relocation info int num_prinfo_; // number of pending reloc info entries in the buffer // The bound position, before this we cannot do instruction elimination. int last_bound_pos_; // source position information int current_position_; int current_statement_position_; int written_position_; int written_statement_position_; // Code emission inline void CheckBuffer(); void GrowBuffer(); inline void emit(Instr x); // Instruction generation void addrmod1(Instr instr, Register rn, Register rd, const Operand& x); void addrmod2(Instr instr, Register rd, const MemOperand& x); void addrmod3(Instr instr, Register rd, const MemOperand& x); void addrmod4(Instr instr, Register rn, RegList rl); void addrmod5(Instr instr, CRegister crd, const MemOperand& x); // Labels void print(Label* L); void bind_to(Label* L, int pos); void link_to(Label* L, Label* appendix); void next(Label* L); // Record reloc info for current pc_ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); }; } } // namespace v8::internal #endif // V8_ASSEMBLER_ARM_H_
[ "noel.gordon@07704840-8298-11de-bf8c-fd130f914ac9" ]
[ [ [ 1, 782 ] ] ]
c471a7201402a456bb60fa18811f19c8baf69dbf
1df8e73545f4cce1cc3df5af42e6cc8a711d7f13
/util.cpp
5a719beb69b57f1f90cf2e368e013d6faa34d39c
[]
no_license
Mohamedss/qt-segy-viewer
6e5c84a846e63e5e61b1489ef675a36e799c3929
54a55718a91bae8b9eab2610c1d23eddc0abb95d
refs/heads/master
2021-01-19T09:44:00.639450
2010-12-21T00:36:15
2010-12-21T00:36:15
35,456,892
5
1
null
null
null
null
WINDOWS-1252
C++
false
false
8,624
cpp
#include "util.h" #include <mem.h> #define swapb(x,y) {byte tmp; tmp=(x); (x)=(y); (y)=tmp;} static int _swap=1; int setswap(int swap) { _swap=swap; return swap; } int swapi4(int x) { if(_swap) { byte* cbuf; byte tem; cbuf=(byte*)&x; /* assign address of input to char array */ tem=cbuf[0]; cbuf[0]=cbuf[3]; cbuf[3]=tem; tem=cbuf[2]; cbuf[2]=cbuf[1]; cbuf[1]=tem; } return x; } short swapi2(short x) { if(_swap) { byte* cbuf; byte tem; cbuf=(byte*)&x; /* assign address of input to char array */ tem=cbuf[0]; cbuf[0]=cbuf[1]; cbuf[1]=tem; } return x; } void ibm2ieee(float* input, int swap) { typedef unsigned char byte; typedef unsigned long ulng; byte *cbuf,expp,tem,sign; ulng *umantis,expll; long *mantis; int shift; cbuf=(byte*)&input[0]; /* assign address of input to char array */ umantis=(ulng*)&input[0]; /* two differnt points to the same spot */ mantis =(long*)&input[0]; /* signned & unsigned */ if(swap) { /* now byte reverce for PC use if swap true */ tem=cbuf[0]; cbuf[0]=cbuf[3]; cbuf[3]=tem; tem=cbuf[2]; cbuf[2]=cbuf[1]; cbuf[1]=tem; } /* start extraction information from number */ expp=*mantis>>24; /* get expo fro upper byte */ *mantis=(*mantis)<<8; /* shift off upper byte */ shift=1; /* set a counter to 1 */ while(*mantis>0 && shift<23) /* start of shifting data*/ { *mantis=*mantis<<1; shift++; } /* shift until a 1 in msb */ *mantis=*mantis<<1; /* need one more shift to get implied one bit */ sign=expp & 0x80; /* set sign to msb of exponent */ expp=expp & 0x7F; /* kill sign bit */ if(expp!=0) /* don't do anymore if zero exponent */ { expp=expp-64; /* compute what shift was (old exponent)*/ *umantis=*umantis>>9; /* MOST IMPORTANT an UNSIGNED shift back down */ expll=0x7F+(expp*4-shift); /* add in excess 172 */ /* now mantissa is correctly aligned, now create the other two pairs */ /* needed the extended sign word and the exponent word */ expll=expll<<23; /* shift exponent up */ /* combine them into a floating point IEEE format ! */ if(sign) *umantis=expll | *mantis | 0x80000000; else *umantis=expll | *mantis; /* set or don't set sign bit */ } } void toibm(long *addr, int ll) { unsigned long real; unsigned long lng; unsigned char *ch; unsigned int gain,sign,t; // ch= (long *)&lng; ch= (unsigned char*)&lng; while(ll--) { if(real = *addr) { gain = (real>>23); sign = (gain & 0x100)>>1; gain = (gain & 0xff) - 0x80 +2; real = ((real& 0x7FFFFFL)| 0x800000L); // real = (real& 0x7FFFFFL); // real = (real | 0x800000L); t = gain & 3; if(t) { real >>= 4-t; gain += 4-t; } gain = ((gain>>2) + 0x40) & 0x7f; gain |= sign; lng = real; ch[3] = ch[0]; t = ch[1]; ch[1] = ch[2]; ch[2] = t; ch[0] = gain; real = lng; } *addr++ = real; } } int tt[256]= { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 91, 46, 60, 40, 43, 33, 38, 32, 32, 32, 32, 32, 32, 32, 32, 32, 93, 36, 42, 41, 59, 94, 45, 47, 32, 32, 32, 32, 32, 32, 32, 32,124, 44, 37, 95, 62, 63, 32, 32, 32, 32, 32, 32,238,160, 161, 96, 58, 35, 64, 39, 61, 34, 230, 97, 98, 99,100,101,102,103, 104,105,164,165,228,163,229,168, 169,106,107,108,109,110,111,112, 113,114,170,171,172,173,174,175, 239,126,115,116,117,118,119,120, 121,122,224,225,226,227,166,162, 236,235,167,232,237,233,231,234, 158,128,129,150,132,133,148,131, 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,149,136,137,138,139,140, 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,141,142,143,159,144,145, 92, 32, 83, 84, 85, 86, 87, 88, 89, 90,146,147,134,130,156,155, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,135,152,157,153,151, 32 }; unsigned char ebasc(unsigned char ascii) { unsigned char ebcd; ebcd=tt[ascii]; return ebcd; } void ebasd(unsigned char* ascii, unsigned char* ebcd) { int n; for(n=0;ebcd[n];n++) { ascii[n]=ebasc(ebcd[n]); } ascii[n]=0; } char asebc(char ascii) { char ebcd; static char tt[256]= { 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x4F,0x7F,0x7B,0x5B,0x6C,0x50,0x7D, /* !"#$%&' */ 0x4D,0x5D,0x5C,0x4E,0x6B,0x60,0x4B,0x61, /* ()*+,-./ */ 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7, /* 01234567 */ 0xF8,0xF9,0x7A,0x5E,0x4C,0x7E,0x6E,0x6F, /* 89:;<=>? */ 0x7C,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7, /* @ABCDEFG */ 0xC8,0xC9,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6, /* HIJKLMNO */ 0xD7,0xD8,0xD9,0xE2,0xE3,0xE4,0xE5,0xE6, /* PQRSTUVW */ 0xE7,0xE8,0xE9,0x4A,0xE0,0x5A,0x5F,0x6D, /* XYZ[\]^_ */ 0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87, /* `abcdefg */ 0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96, /* hijklmno */ 0x97,0x98,0x99,0xA2,0xA3,0xA4,0xA5,0xA6, /* pqrstuvw */ 0xA7,0xA8,0xA9,0xC0,0x6A,0xD0,0xA1,0x40, /* xyz{|}~ */ 0xB9,0xBA,0xED,0xBF,0xBC,0xBD,0xEC,0xFA, /* */ 0xCB,0xCC,0xCD,0xCE,0xCF,0xDA,0xDB,0xDC, /* */ 0xDE,0xDF,0xEA,0xEB,0xBE,0xCA,0xBB,0xFE, /* */ 0xFB,0xFD,0x7d,0xEF,0xEE,0xFC,0xB8,0xDD, /* */ 0x77,0x78,0xAF,0x8D,0x8A,0x8B,0xAE,0xB2, /* */ 0x8F,0x90,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0xAA,0xAB,0xAC,0xAD,0x8C,0x8E,0x80,0xB6, /* ðñòóôõö÷ */ 0xB3,0xB5,0xB7,0xB1,0xB0,0xB4,0x76,0xA0, /* øùúûüýþÿ */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, /* */ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 /* */ }; ebcd=tt[ascii]; return ebcd; } void asebd( char* ebcd, char* ascii) { int n; for(n=0;ascii[n];n++) { ebcd[n]=asebc(ascii[n]); } ebcd[n]=0; } void si4(char* buf, int nbyte, int i) { union { byte h[4]; int x; } u; u.x=i; if(_swap) { swapb(u.h[0], u.h[3]); swapb(u.h[1], u.h[2]);} memcpy(buf+nbyte-1, &u.x, sizeof(int)); } void si2(char* buf,int nbyte, short i) { union { byte h[2]; short x; } u; u.x=i; if(_swap) swapb(u.h[0], u.h[1]); memcpy(buf+nbyte-1, &u.x, sizeof(short)); } void si1(char* buf, int nbyte, char i) { memcpy(buf+nbyte-1,&i,sizeof(char)); } int i4(char* buf, int nbyte) { int i; union { byte h[4]; long x; } u; memcpy(&i,buf+nbyte-1,sizeof(int)); u.x=i; if(_swap) swapb(u.h[0], u.h[3]); swapb(u.h[1], u.h[2]); return u.x; } short i2(char* buf, int nbyte) { short i; union { byte h[2]; int x; } u; memcpy(&i,buf+nbyte-1,sizeof(short)); u.x=i; if(_swap) swapb(u.h[0], u.h[1]); return u.x; } char i1(char* buf, int nbyte) { char i; memcpy(&i,buf+nbyte-1,sizeof(char)); return i; }
[ "[email protected]@ba798d5c-232d-d148-425a-647f199d9ac8" ]
[ [ [ 1, 315 ] ] ]
6a067f674f60c43682dcc0b138b2559b06608338
a405cf24ef417f6eca00c688ceb9008d80f84e1a
/trunk/NassiDiagramWindow.h
8b6c569f10b43a6d1d05ec626f1144c11e2adc3b
[]
no_license
BackupTheBerlios/nassiplugin-svn
186ac2b1ded4c0bf7994e6309150aa23bc70b644
abd9d809851d58d7206008b470680a23d0548ef6
refs/heads/master
2020-06-02T21:23:32.923994
2010-02-23T21:37:37
2010-02-23T21:37:37
40,800,406
0
0
null
null
null
null
UTF-8
C++
false
false
2,316
h
#ifndef _NASSI_DIAGRAM_H_INCLUDED #define _NASSI_DIAGRAM_H_INCLUDED // For compilers that support precompilation, includes <wx/wx.h> #include <wx/wxprec.h> #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include <wx/scrolwin.h> #include <wx/caret.h> #include <wx/dnd.h> #include "bricks.h" class NassiView; class HooverDrawlet; class NassiDiagramWindow: public wxScrolledWindow { friend class TextCtrl; public: //NassiDiagramWindow(){} NassiDiagramWindow(wxWindow *parent, NassiView *view); ~NassiDiagramWindow(); private: NassiDiagramWindow(const NassiDiagramWindow &p); NassiDiagramWindow &operator=(const NassiDiagramWindow &rhs); private: void OnDraw(wxDC& dc){} //virtual void OnMouseWheel(wxMouseEvent& event); void OnMouseLeftUp(wxMouseEvent &event); void OnMouseLeftDown(wxMouseEvent &event); void OnMouseRightDown(wxMouseEvent &event); void OnMouseRightUp(wxMouseEvent& event); void OnMouseMove(wxMouseEvent &event); void OnEnter(wxMouseEvent &event); void OnLeave(wxMouseEvent &event); void OnKeyDown(wxKeyEvent &event); void OnChar(wxKeyEvent &event); void RemoveDrawlet(wxDC &dc); void OnErase(wxEraseEvent &event); void OnPaint(wxPaintEvent &event); void PaintBackground(wxDC &dc); void Draw(wxDC &dc); bool HasFocus(){return this == this->FindFocus();} void OnKillFocus(wxFocusEvent &event); void OnSetFocus(wxFocusEvent &event); // wxPoint dndpt; // bool dndsource; // bool focus; // bool pasting; // bool drop; // bool dropcopy; // bool OnDrop(wxPoint pt, NassiBrick *brick, wxString strc = _T(""), wxString strs = _T("case :") ); // wxDragResult OnDragOver(wxPoint pt, wxDragResult def); // void OnDragLeave(void); // void OnDragEnter(void); private: NassiView *m_view; HooverDrawlet *m_hd; public: wxDragResult OnDrop(const wxPoint &pt, NassiBrick *brick, wxString strc, wxString strs, wxDragResult def); wxDragResult OnDragOver(const wxPoint &pt, wxDragResult def, bool HasNoBricks); void OnDragLeave(void); void OnDragEnter(void); protected: //DECLARE_DYNAMIC_CLASS(NassiDiagramWindow) DECLARE_EVENT_TABLE() }; #endif
[ "danselmi@1ca45b2e-1973-0410-a226-9012aad761af" ]
[ [ [ 1, 90 ] ] ]
72d5a37f1b9a65a71116ce58b67cbb8ecebeee98
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/MapLib/Symbian/include/MapComponentWrapper.h
53bf6b5f7017ba5cf487ce3610c19efac611e401
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,806
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef MAPCOMPONENTWRAPPER_H #define MAPCOMPONENTWRAPPER_H class MapMovingInterface; class MapDrawingInterface; class SymbianBitmapDrawingInterface; class CCoeControl; class MapRectInterface; /** * Wrapper class for a map component. */ class MapComponentWrapper { public: /** * Virtual destructor. */ virtual ~MapComponentWrapper() {} /** * Get the CCoeControl. */ virtual CCoeControl& getControl() const = 0; /** * Get the map rect interface. */ virtual const MapRectInterface& getMapRectInterface() const = 0; /** * Get the MapMovingInterface. */ virtual MapMovingInterface& getMapMovingInterface() const = 0; /** * Get the MapDrawingInterface. */ virtual MapDrawingInterface& getMapDrawingInterface() const = 0; /** * Get the BitmapDrawingInterface. */ virtual SymbianBitmapDrawingInterface& getBitmapDrawingInterface() const = 0; /** * Get the minimum scale when this map component should be shown. */ virtual int getMinScale() const = 0; }; /** * Creates the globe component. */ class GlobeCreator { public: /** * Create the globe component. */ static MapComponentWrapper* createGlobe( const CCoeControl& container ); /** * Create the globe component with additional parameters. * * @param container The parent control. * @param aPath The path to the resources. * @param aRect The rectangle. * @param aLocationString The location string e.g. * "I'm currently in". * @param aLanguageCode The two character language code. */ static MapComponentWrapper* createGlobe( const CCoeControl& container, const char* aPath, const TRect& aRect, const char* aLocationString, const char* aLanguageCode ); }; #endif
[ [ [ 1, 94 ] ] ]
754274ab3363f9dfdc562f97b4be7ff4f466a1da
bf3bc7ec0580d9da732fc16ce00baccda68f2f42
/common_wallpaper_ngpod.cpp
cdf359cd21157729b6cdb21ec3281d92e5d7c919
[]
no_license
rexzhang/ngpodwc
69ddbfd736e955bb9d223fb900dec7f026105261
02a7d7c9afc5cf6d34d7dd865969b5478bae4bb7
refs/heads/master
2020-07-26T23:25:56.308274
2008-07-24T13:08:57
2008-07-24T13:08:57
208,796,954
0
0
null
null
null
null
GB18030
C++
false
false
4,892
cpp
///////////////////////////////////////////////////////////////////////////// // Name: common_wallpaper_ngpod.cpp // Purpose: // Author: Rex Zhang // Modified by: // Created: 2006-03-04 // RCS-ID: // Copyright: (c) 2006 Rex Zhang // Licence: GNU General Public License (GPL) version 2 ///////////////////////////////////////////////////////////////////////////// #include <wx/wxprec.h> #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include "common_globals.h" #include "common_wallpaper_ngpod.h" //WallpaperNGPOD::WallpaperNGPOD(ngpodwcConfig programConfig):WallpaperBase(programConfig) WallpaperNGPOD::WallpaperNGPOD():WallpaperBase() { Init(); //ctor } WallpaperNGPOD::~WallpaperNGPOD() { //dtor } bool WallpaperNGPOD::Init() { //获取POD 图片描述信息以及图片文件名称 if(!podPictureInfo.GetInfo(configRunning.PodBasePath + wxT("\\") + configRunning.PodDatabaseName, configRunning.PodDate)) { wxString msgTitle("获取POD 图片描述信息以及图片文件名称错误!",*wxConvCurrent); wxString msgContext("获取POD 图片描述信息以及图片文件名称错误!\n请运行 ngpodcc.exe 进行初始化操作!",*wxConvCurrent); wxSafeShowMessage(msgTitle, msgContext); return false; } //PodImage.SetOption(wxIMAGE_OPTION_BMP_FORMAT,wxBMP_8BPP_GREY); //PodImage.SetOption(wxIMAGE_OPTION_BMP_FORMAT,wxBMP_24BPP); /* //Debug Info wxSafeShowMessage(pConfig->PodBasePath + wxT("\\") + pConfig->PodPicturePath + wxT("\\") + podPictureInfo.PhotoName, pConfig->ScreenPicturePath + wxT("\\") + pConfig->ScreenPictureName); */ //获取原始图片 wxString NGPODPictureName = configRunning.PodBasePath + wxT("\\") + configRunning.PodPicturePath + wxT("\\") + podPictureInfo.PhotoName; if (!Image.LoadFile(NGPODPictureName, wxBITMAP_TYPE_JPEG)) { //wxSafeShowMessage(wxT("Can't load JPG image"), podPictureInfo.PhotoName); wxLogError(_("ERROR! Can't read NGPOD 1.x Local Picture(%s)!"), NGPODPictureName.c_str()); return false; } if(!Image.Ok()) { wxSafeShowMessage(wxT("Image Loading Op Error"), wxT("Image Loading Op Error")); return false; } return true; } bool WallpaperNGPOD::SaveWallpaper() { //将处理完毕的图片输出至指定目录 /* wxString wallpaper = config.ScreenPicturePath + wxT("\\") + config.ScreenPictureName; if(!Image.SaveFile(wallpaper, wxBITMAP_TYPE_BMP)) { wxLogError(_("ERROR! Can't create(save) wallpaper file(%s)!"), wallpaper.c_str()); return false; } */ if(!WallpaperBase::SaveWallpaper()) { return false; } //保存变化后(当前背景图片)的日期信息至配置文件 configRunning.WriteConfig(); return true; } wxString WallpaperNGPOD::GetText() { wxString podInfoDisc(podPictureInfo.Disc); if(podInfoDisc.Contains(wxT("#"))) { podInfoDisc.Replace(wxT("#034"), wxT("\""), true); podInfoDisc.Replace(wxT("#039"), wxT("\'"), true); podInfoDisc.Replace(wxT("#133"), wxT("..."), true);//... podInfoDisc.Replace(wxT("#145"), wxT("\'"), true);//‘ podInfoDisc.Replace(wxT("#146"), wxT("\'"), true);//’ podInfoDisc.Replace(wxT("#147"), wxT("\""), true);//“ podInfoDisc.Replace(wxT("#148"), wxT("\""), true);//” podInfoDisc.Replace(wxT("#151"), wxT("\'"), true);//' } // podInfoDisc.Replace(wxT("<BR>"), wxT(""), true); podInfoDisc.Replace(wxT("<P>"), wxT(""), true); podInfoDisc.Replace(wxT("</P>"), wxT(""), true); podInfoDisc.Replace(wxT("<I>"), wxT(""), true); podInfoDisc.Replace(wxT("</I>"), wxT(""), true); podInfoDisc.Replace(wxT("\n"), wxT(""), true); podInfoDisc.Replace(wxT(".\n"), wxT("."), true); podInfoDisc.Replace(wxT(". "), wxT(". \n "), true); podInfoDisc.Replace(wxT(" \n \n"), wxT(" \n"), true); podInfoDisc.Replace(wxT(".\'\" "), wxT(".\'\" \n "), true); wxString podInfoString;// podInfoString.Printf(wxT(" Title : %s \n Date: %s \n When : %s \n Who : %s \n\n "), podPictureInfo.Title, podPictureInfo.PodDate, podPictureInfo.When, podPictureInfo.Who); podInfoString = podInfoString + podInfoDisc + wxT(" "); podInfoString.Replace(wxT("National Geographic Photo of the Day: "), wxT(""), true); podInfoString.Replace(wxT(" 00:00:00"), wxT(""), true); return podInfoString; }
[ [ [ 1, 138 ] ] ]
5dad5713aff1aaba87a6545c67d0cc34b792bda9
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ObjectDLL/ObjectShared/EventCounter.h
26ea4fe3b306f3f22a2c00f0072aa9d4af4847af
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
2,155
h
// ----------------------------------------------------------------------- // // // MODULE : EventCounter.h // // PURPOSE : EventCounter - Definition // // CREATED : 04.23.1999 // // (c) 2000-2002 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #ifndef __EVENT_COUNTER_H__ #define __EVENT_COUNTER_H__ #include "ltengineobjects.h" #include "ServerUtilities.h" #include "CommandMgr.h" #include "GameBase.h" #define EC_MAX_NUMBER_OF_EVENTS 10 LINKTO_MODULE( EventCounter ); struct EventData { EventData() { nValue = 0; hstrIncToValCmd = LTNULL; hstrDecToValCmd = LTNULL; } virtual ~EventData() { FREE_HSTRING(hstrIncToValCmd); FREE_HSTRING(hstrDecToValCmd); } inline void Save(ILTMessage_Write *pMsg) { SAVE_INT(nValue); SAVE_HSTRING(hstrIncToValCmd); SAVE_HSTRING(hstrDecToValCmd); } inline void Load(ILTMessage_Read *pMsg) { LOAD_INT(nValue); LOAD_HSTRING(hstrIncToValCmd); LOAD_HSTRING(hstrDecToValCmd); } // Data... int nValue; HSTRING hstrIncToValCmd; HSTRING hstrDecToValCmd; }; class EventCounter : public GameBase { public : EventCounter(); ~EventCounter(); uint32 EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData); bool OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg); protected : LTBOOL ReadProp(ObjectCreateStruct *pData); void Save(ILTMessage_Write *pMsg); void Load(ILTMessage_Read *pMsg); private : LTBOOL m_bLocked; int m_nCurVal; EventData m_EventData[EC_MAX_NUMBER_OF_EVENTS]; void Increment(); void Decrement(); }; class CEventCounterPlugin : public IObjectPlugin { public: virtual LTRESULT PreHook_PropChanged( const char *szObjName, const char *szPropName, const int nPropType, const GenericProp &gpPropValue, ILTPreInterface *pInterface, const char *szModifiers ); protected: CCommandMgrPlugin m_CommandMgrPlugin; }; #endif // __EVENT_COUNTER_H__
[ [ [ 1, 109 ] ] ]
838c8ba67b68726b7c3bcb6d443162ebae5a851b
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/WayFinder/symbian-r6/ItineraryView.h
126eb23165a10e1a9ef3622eabf3594940801a5a
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,557
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ITINERARYVIEW_H #define ITINERARYVIEW_H // INCLUDES #include "ViewBase.h" #include "WayFinderConstants.h" #include "Log.h" #include "memlog.h" #include "RouteEnums.h" #include "RouteInfo.h" #include "TurnPictures.h" // CONSTANTS // FORWARD DECLARATIONS class CWayFinderAppUi; class CItineraryContainer; class GuiDataStore; namespace isab{ class RouteList; } // CLASS DECLARATION /** * CItineraryView view class. * */ class CItineraryView : public CViewBase { public: // Constructors and destructor CItineraryView(class CWayFinderAppUi* aUi, isab::Log* aLog); /** * EPOC default constructor. */ void ConstructL(); ///Factory method. Creates a new object and calls its ConstructL method. ///The object is pushed onto the CleanupStack before ConstructL and is ///left there when this function returns. ///@param aUi pointer to the applications single CWayFinderAppUi object. ///@param aLog pointer to the memory log Log object. May be NULL. ///@return a new, completely constructed, CItineraryView object. /// Note that this object is still on the CleanupStack. static class CItineraryView* NewLC(CWayFinderAppUi* aUi, isab::Log* aLog); ///Factory method. Creates a new object and calls its ConstructL method. ///The object is pushed onto the CleanupStack before ConstructL and is ///popped before this function returns. ///@param aUi pointer to the applications single CWayFinderAppUi object. ///@param aLog pointer to the memory log Log object. May be NULL. ///@return a new, completely constructed, CItineraryView object. static class CItineraryView* NewL(CWayFinderAppUi* aUi, isab::Log* aLog); /** * Destructor. */ ~CItineraryView(); public: // New Functions GuiDataStore* GetGuiDataStore(); void ClearRoute(); void SetRouteList( const isab::RouteList* aRouteList ); TBool IsGpsAllowed(); TInt GetDistanceMode(); void UpdateCurrentTurn( TBool aNextTurn ); void SetCurrentTurn( TInt aTurn ); TInt GetCurrentTurn(TInt currentIndex); void SetSelection( TInt aCurrentTurn, TInt aPreviousTurn ); private: //void AddItemL( TPictures aTurn, TBool aRightTraffic, // TInt aDistance, TInt aExit, TDesC &aText ); public: // Functions from base classes /** * From AknView. * @return the ID of the view. */ TUid Id() const; /** * From AknView, takes care of command handling. * @param aCommand command to be handled */ void HandleCommandL(TInt aCommand); /** * From AknView, handles a change in the view. */ void HandleClientRectChange(); private: // Functions from base classes /** * From AknView, Called when the option softkey is pressed. * @param aResourceId the focused resource. * @param aMenuPane the current menu. */ void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ); /** * From AknView, Called when the view is activated. * @param aPrevViewId the id of the previous view. * @param aCustomMessageId id of a message sent to the view. * @param aCustomMessage a message sent to the view. */ void DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); /** * From AknView, Called when the view is activated. * @param aPrevViewId the id of the previous view. * @param aCustomMessageId id of a message sent to the view. * @param aCustomMessage a message sent to the view. */ void DoDeactivate(); private: // Data /// The controls container. CItineraryContainer* iContainer; isab::Log* iLog; CDesCArrayFlat* iRouteArray; TInt iExternalTurn; TInt iCurrentTurn; TPoint *iTurnPointArray; TInt *iTranslationArray; }; #endif // End of File
[ [ [ 1, 167 ] ] ]
54368fd7141803ef497ddc5edae5fcb7b183d5c7
e95784c83b6cec527f3292d2af4f2ee9b257a0b7
/GV/Drivers/ISpeedSensor.h
11862258a9ca715e175a022eceaa9555ea8b8a7d
[]
no_license
ehaskins/scoe-robotics-onboard-controller
5e6818cb469c512a4429aa6ccb96478b89c9ce6f
f44887f79cf89c9ff85963e515381199c9b2b2d7
refs/heads/master
2020-06-06T12:53:54.350781
2011-05-01T00:26:17
2011-05-01T00:26:17
32,115,864
0
0
null
null
null
null
UTF-8
C++
false
false
278
h
/* * ISpeedSensor.h * * Created on: Apr 12, 2011 * Author: Nick */ #ifndef ISPEEDSENSOR_H_ #define ISPEEDSENSOR_H_ #include "IDevice.h" class ISpeedSensor : public IDevice { public: virtual int getSpeed() = 0; }; #endif /* ISPEEDSENSOR_H_ */
[ [ [ 1, 19 ] ] ]
651bddce3492f5e29d43891d5128fab204725c5d
83c85d3cae31e27285ca07e192cc9bbad8081736
/pane_mem.cpp
0fc82c08187b9f48a3fc72dd744541b0a8f50d65
[]
no_license
yjfcool/poitool
0768d7299a453335cbd1ae1045440285b3295801
1068837ab32dbb9c6df18bbab1ea64bc70942cbf
refs/heads/master
2016-09-05T11:37:18.585724
2010-04-09T06:16:14
2010-04-09T06:16:14
42,576,080
0
0
null
null
null
null
GB18030
C++
false
false
5,259
cpp
// pane_mem.cpp: implementation of the pane_mem class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "pane_mem.h" #include "xmemory.h" pane_mem_cache::~pane_mem_cache() { //----------------------------------------------------------------销毁旧的pane unsigned int i = 0; for(i = 0; i < m_y_dem; i++) pod_allocator<idx_pane>::deallocate(m_p_mem[i], m_x_dem); pod_allocator<idx_pane*>::deallocate(m_p_mem, m_y_dem); delete m_geo_pane; } BOOL pane_mem_cache::build_pane_mem(POINT pt, int radius) { unsigned int lon_idx_b, lat_idx_b, pane_dem_x, pane_dem_y; if (!m_geo_pane->bnd_idx(pt, radius, lon_idx_b, lat_idx_b, pane_dem_x, pane_dem_y)) { return FALSE; } unsigned int i = 0, j = 0; if (m_p_mem == NULL) { m_p_mem = pod_allocator<idx_pane*>::allocate(pane_dem_y); for(i = 0; i < pane_dem_y; i++) { m_p_mem[i] = pod_allocator<idx_pane>::allocate(pane_dem_x); memset(m_p_mem[i], 0, sizeof(idx_pane) * pane_dem_x); for(j = 0; j < pane_dem_x; j++) { m_p_mem[i][j].x_idx = lon_idx_b + j; m_p_mem[i][j].y_idx = lat_idx_b + i; } } } else { //--------------------------------------------------------------------判断维数是否相同 if (pane_dem_x != m_x_dem || pane_dem_y != m_y_dem) { //----------------------------------------------------------------建立新的pane并重用旧的pane idx_pane** p_mem = pod_allocator<idx_pane*>::allocate(pane_dem_y); for(i = 0; i < pane_dem_y; i++) { p_mem[i] = pod_allocator<idx_pane>::allocate(pane_dem_x); memset(p_mem[i], 0, sizeof(idx_pane) * pane_dem_x); for(j = 0; j < pane_dem_x; j++) { //-------------------------------------------------------------------------新的id号 p_mem[i][j].x_idx = lon_idx_b + j; p_mem[i][j].y_idx = lat_idx_b + i; if ( lon_idx_b + j >= m_x_idx && lon_idx_b + j <= m_x_idx + m_x_dem - 1 && lat_idx_b + i >= m_y_idx && lat_idx_b + i <= m_y_idx + m_y_dem - 1) { //-------------------------------------------------------------------------新的id号对应的旧id号 unsigned int o_idx_x = lon_idx_b + j - m_x_idx; unsigned int o_idx_y = lat_idx_b + i - m_y_idx; p_mem[i][j].pane_mem.m_buf = m_p_mem[o_idx_y][o_idx_x].pane_mem.m_buf; p_mem[i][j].pane_mem.m_len = m_p_mem[o_idx_y][o_idx_x].pane_mem.m_len; m_p_mem[o_idx_y][o_idx_x].pane_mem.m_buf = NULL; m_p_mem[o_idx_y][o_idx_x].pane_mem.m_len = 0; } } } //----------------------------------------------------------------销毁旧的pane for(i = 0; i < m_y_dem; i++) pod_allocator<idx_pane>::deallocate(m_p_mem[i], m_x_dem); pod_allocator<idx_pane*>::deallocate(m_p_mem, m_y_dem); //----------------------------------------------------------------替代旧的pane m_p_mem = p_mem; } else { //--------------------------------------------------------------------维数是否相同但不相交 if (m_x_idx > lon_idx_b + pane_dem_x - 1|| m_x_idx + m_x_dem < lon_idx_b || m_y_idx > lat_idx_b + pane_dem_y - 1|| m_y_idx + m_y_dem < lat_idx_b) { for(i = 0; i < pane_dem_y; i++) { for(j = 0; j < pane_dem_x; j++) { m_p_mem[i][j].x_idx = lon_idx_b + j; m_p_mem[i][j].y_idx = lat_idx_b + i; m_p_mem[i][j].pane_mem.free(); } } } else { i = 0; j = 0; unsigned int k = 0, l = 0; for(i = 0; i < m_y_dem; i++) { for(j = 0; j < m_x_dem; j++) { //--------------------------------------------------------------------上移后y方向从下边开始遍历 k = (lon_idx_b > m_x_idx)?i : (m_x_dem - i - 1); //--------------------------------------------------------------------右移后x方向从左边开始遍历 l = (lat_idx_b > m_y_idx)?j : (m_y_dem - j - 1); unsigned int o_idx_x = m_p_mem[k][l].x_idx; unsigned int o_idx_y = m_p_mem[k][l].y_idx; m_p_mem[k][l].x_idx = lon_idx_b + j; m_p_mem[k][l].y_idx = lat_idx_b + i; if ( o_idx_x >= lon_idx_b && o_idx_x <= (lon_idx_b + pane_dem_x - 1) && o_idx_y >= lat_idx_b && o_idx_y <= (lat_idx_b + pane_dem_y - 1)) { //--------------------------------------------------------------------新的索引 unsigned int n_idx_x = o_idx_x - lon_idx_b; unsigned int n_idx_y = o_idx_y - lat_idx_b; m_p_mem[n_idx_y][n_idx_x].pane_mem.free(); unsigned char* p = m_p_mem[k][l].pane_mem.m_buf; unsigned int xx = m_p_mem[k][l].pane_mem.m_len; m_p_mem[n_idx_y][n_idx_x].pane_mem.m_buf = m_p_mem[k][l].pane_mem.m_buf; m_p_mem[n_idx_y][n_idx_x].pane_mem.m_len = m_p_mem[k][l].pane_mem.m_len; m_p_mem[k][l].pane_mem.m_buf = 0; m_p_mem[k][l].pane_mem.m_len = 0; } else { m_p_mem[k][l].pane_mem.free(); } } } } } } m_x_idx = lon_idx_b; m_y_idx = lat_idx_b; m_x_dem = pane_dem_x; m_y_dem = pane_dem_y; return TRUE; }
[ "dulton@370d939e-410d-02cf-1e1d-9a5f4ca5de21" ]
[ [ [ 1, 160 ] ] ]
ef4230516c57ec32e1f9fa0afa705e3088ead917
fcdddf0f27e52ece3f594c14fd47d1123f4ac863
/terralib/src/terralib/kernel/TeOverlay.cpp
7e8fa8f98f2fba095d3077474508a31561cffcb4
[]
no_license
radtek/terra-printer
32a2568b1e92cb5a0495c651d7048db6b2bbc8e5
959241e52562128d196ccb806b51fda17d7342ae
refs/heads/master
2020-06-11T01:49:15.043478
2011-12-12T13:31:19
2011-12-12T13:31:19
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
22,366
cpp
/************************************************************************************ TerraLib - a library for developing GIS applications. Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio. This code is part of the TerraLib library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. You should have received a copy of the GNU Lesser General Public License along with this library. The authors reassure the license terms regarding the warranties. They specifically disclaim any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The library provided hereunder is on an "as is" basis, and the authors have no obligation to provide maintenance, support, updates, enhancements, or modifications. In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct, indirect, special, incidental, or consequential damages arising out of the use of this library and its documentation. *************************************************************************************/ // TerraLib's include #include "TeOverlay.h" #include "TeOverlayUtils.h" #include "TeIntersector.h" #include "TeGeometryAlgorithms.h" #include "TeFragmentation.h" #include "TeRTree.h" //---------------- Overlay operations ----------------// // Operacao de uniao otimizada: consome memoria! bool TeOVERLAY::TeUnion(TePolygonSet& polsIn, TePolygonSet& polsOut, const bool& makeCopy, const bool fixOrientation) { // limpa a lista de saida polsOut.clear(); // verifica se e necessario realizar uma copia dos polígonos TePolygonSet polygonSetIn; if(makeCopy) { if(!TeOVERLAY::TeClonePolygonSet(polsIn, polygonSetIn)) return false; //polygonSetIn.copyElements(polsIn); } else { polygonSetIn = polsIn; } if(polygonSetIn.empty()) return false; if(polygonSetIn.size() == 1) { polsOut.copyElements(polygonSetIn); return true; } // verifica a orientacao de cada linha se necessario: aneis externos devem estar no sentido horario e os internos devem estar no sentido anti-horario if(fixOrientation) TeFixOrientation(polygonSetIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE); // cria uma arvore que indexara os segmentos de cada linha e // chama uma rotina que calcula os pontos de intersecao e ja indexa os segmentos TeINTERSECTOR2::TeSegmentRTree segmentTree(polygonSetIn.box()); TeINTERSECTOR2::TeVectorBoundaryIP report; TeINTERSECTOR2::TeIntersection(polygonSetIn, segmentTree, report); // fragmenta as linhas TeLineSet fragments; TeLineSet boundaryFragments; vector<pair<unsigned int, unsigned int> > fragmentsIds; vector<pair<unsigned int, unsigned int> > boundaryFragmentsIds; TeFragmentBoundary(polygonSetIn, report, boundaryFragments, boundaryFragmentsIds, fragments, fragmentsIds); report.clear(); short mask = TeUNKNOWNPOSITION; // os fragmentos de fronteira ja sao separados TeLineIndex boundaryFragmentsIndex; unsigned int i; if(boundaryFragments.size()) { mask = TeBOUNDARY; unsigned int boundaryFragmentsSize = boundaryFragments.size(); for(i = 0; i < boundaryFragmentsSize; ++i) boundaryFragmentsIndex.insert(TeLineIndex::value_type(boundaryFragments[i][0], pair<unsigned int, TeLine2D>(i, boundaryFragments[i]))); } // escolhe os fragmentos que estiverem localizados dentro de cada polígono short locationFragments = TeOUTSIDE; TeLineIndex fragmentsIndex; vector<TeLinearRing> rings; TeRtreeGetFragments(polygonSetIn, segmentTree, fragments, fragmentsIds, locationFragments, mask, fragmentsIndex, rings); // Tenta eliminar fragmentos de fronteira no mesmo sentido, deixando apenas um nesta direcao TeRemoveSameBoundaryFragments(boundaryFragmentsIndex); // Tenta eliminar fragmentos sobre fronteira opostos TeRemoveOpositeBoundaryFragments(boundaryFragmentsIndex); //--remover do boundaryfragments os fragmentos removidos do boundaryFragmentsIndex TeRtreeRemoveFragments(polygonSetIn, segmentTree, boundaryFragmentsIndex, boundaryFragmentsIds, TeINSIDE, mask, rings); segmentTree.clear(); // Faz um merge dos fragmentos de fronteira para o índice de fragmentos normal TeJoinFragments(fragmentsIndex, boundaryFragmentsIndex); // monta os poligonos a partir dos fragmentos bool returnValue = TeMergeFragments(fragmentsIndex, rings, true); vector<TeLinearRing> ringsOut; bool resultSplit = true; if(TeOVERLAY::TeSplitRings(rings, ringsOut) == false) { ringsOut.clear(); ringsOut = rings; resultSplit = false; } // separate holes from islands vector<TeLinearRing> holes; bool result = TeClassifyRings(ringsOut, polsOut, holes); // mount topology if((polsOut.size() == 0) && (holes.size() == 0)) { return false; // Na uniao deve haver a formacao de poligonos } bool mountResult = TeMountTopology(polsOut, holes); return (returnValue && result && mountResult && resultSplit); } // Operacao geral de conjunto: uniao, intersecao e diferenca bool TeOverlay(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const short& operation, const bool& makeCopy, const bool fixOrientation) { // limpa a saida vecPolsOut.clear(); resultVec.clear(); // verifica se a lista dos poligonos vermelhos esta vazia unsigned int numBluePols = bluePols.size(); unsigned int i; if(redPols.empty()) { // se os poligonos vermelhos nao foram informados, no caso da uniao tenta copiar os azuis para o vetor de saida if(operation == TeUNION) { for(i = 0; i < numBluePols; ++i) { TePolygonSet bluePolsInAux; if(!TeOVERLAY::TeClonePolygonSet(bluePols[i], bluePolsInAux)) return false; //bluePolsInAux.copyElements(bluePols[i]); // se nao existir tambem o poligono azul, entao retirn falso vecPolsOut.push_back(bluePolsInAux); resultVec.push_back (true); } if(vecPolsOut.empty()) return false; return true; } // TeDIFFERENCE ou TeINTERSECTION: resultado eh vazio, logo ja retorna true return true; } // Defines location to choose fragments short locationRedFragments = TeINSIDE; short locationBlueFragments = TeINSIDE; TeOVERLAY::TeChooseBoundaryLocation(operation, locationRedFragments, locationBlueFragments); // verifica se e necessario realizar uma copia dos poligonos TePolygonSet redPolsIn; vector<TePolygonSet> bluePolsIn; if(makeCopy) { if(!TeOVERLAY::TeClonePolygonSet(redPols, redPolsIn)) return false; //redPolsIn.copyElements(redPols); for(i = 0; i < numBluePols; ++i) { TePolygonSet bluePolsInAux; if(!TeOVERLAY::TeClonePolygonSet(bluePols[i], bluePolsInAux)) return false; //bluePolsInAux.copyElements(bluePols[i]); bluePolsIn.push_back(bluePolsInAux); } } else { redPolsIn = redPols; bluePolsIn = bluePols; } // verifica a orientacao de cada linha se necessario: aneis externos devem estar no sentido horario e os internos devem estar no sentido anti-horario if(fixOrientation) { if(operation == TeINTERSECTION || operation == TeUNION) { TeOVERLAY::TeFixOrientation(redPolsIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE); for(i = 0; i < numBluePols; ++i) TeOVERLAY::TeFixOrientation(bluePolsIn[i], TeCOUNTERCLOCKWISE, TeCLOCKWISE); } else { TeOVERLAY::TeFixOrientation(redPolsIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE); for(i = 0; i < numBluePols; ++i) TeOVERLAY::TeFixOrientation(bluePolsIn[i], TeCLOCKWISE, TeCOUNTERCLOCKWISE); } } // cria uma arvore que indexara os segmentos dos poligonos vermelhos TeINTERSECTOR2::TeSegmentRTree redSegmentTree(redPolsIn.box()); TeINTERSECTOR2::TeIndexPolygonSet(redPolsIn, redSegmentTree); bool resultValue = true; // para cada conjunto de poligonos azuis, faz a operacao dele com os vermelhos for(i = 0; i < numBluePols; ++i) { // verifica se tem poligonos no polygonset azul if(bluePolsIn[i].empty()) { if((operation == TeUNION) || (operation == TeDIFFERENCE)) { vecPolsOut.push_back(redPolsIn); resultVec.push_back(true); // mario - 2006-03 } else { TePolygonSet emptySet; vecPolsOut.push_back(emptySet); resultVec.push_back(true); // mario - 2006-03 } continue; } // Indexa os segmentos azuis TeINTERSECTOR2::TeSegmentRTree blueSegmentTree(bluePolsIn[i].box()); TeINTERSECTOR2::TeIndexPolygonSet(bluePolsIn[i], blueSegmentTree); // calcula os potos de intersecao dos vermelhos com os azuis TeINTERSECTOR2::TeVectorBoundaryIP report; TeINTERSECTOR2::TeIntersection(redPolsIn, redSegmentTree, bluePolsIn[i], report); // fragmenta as linhas vermelhas TeLineSet redFragments; TeLineSet redBoundaryFragments; vector<pair<unsigned int, unsigned int> > redFragmentsIds; vector<pair<unsigned int, unsigned int> > boundaryFragmentsIds; TeFragmentBoundary(redPolsIn, report, redBoundaryFragments, boundaryFragmentsIds, redFragments, redFragmentsIds); short mask = TeUNKNOWNPOSITION; // os fragmentos de fronteira ja sao separados TeOVERLAY::TeLineIndex boundaryFragmentsIndex; unsigned int boundaryId_ = 0; if(redBoundaryFragments.size()) { mask = TeBOUNDARY; unsigned int boundaryFragmentsSize = redBoundaryFragments.size(); for(unsigned int ti = 0; ti < boundaryFragmentsSize; ++ti) { boundaryFragmentsIndex.insert(TeOVERLAY::TeLineIndex::value_type(redBoundaryFragments[ti][0], pair<unsigned int, TeLine2D>(boundaryId_, redBoundaryFragments[ti]))); ++boundaryId_; } } // escolhe os fragmentos vermelhos que estiverem localizados dentro/fora (dependendo da oparacao) dos poligonos azuis vector<TeLinearRing> rings; TeOVERLAY::TeLineIndex fragmentsIndex; TeOVERLAY::TeRtreeGetFragments(bluePolsIn[i], blueSegmentTree, redFragments, locationRedFragments, mask, fragmentsIndex, rings); // inverte a ordem dos pontos de intersecao para fragmentar as linhas azuis TeINTERSECTOR2::TeVectorBoundaryIP::iterator it = report.begin(); TeINTERSECTOR2::TeVectorBoundaryIP::iterator it_end = report.end(); while(it != it_end) { swap(it->bluePolNum_, it->redPolNum_); swap(it->bluePartNum_, it->redPartNum_); swap(it->blueSegNum_, it->redSegNum_); if(it->coords_.size() == 2) //overlap { // Verificar se os pontos estao em ordem crescente if(it->coords_[0].x_ < it->coords_[1].x_) { } else if(it->coords_[0].x_ > it->coords_[1].x_) { swap(it->coords_[0], it->coords_[1]); } else if(it->coords_[0].y_ < it->coords_[1].y_) { } else { swap(it->coords_[0], it->coords_[1]); } } ++it; } // fragmenta as linhas azuis TeLineSet blueFragments; TeLineSet blueBoundaryFragments; vector<pair<unsigned int, unsigned int> > blueFragmentsIds; boundaryFragmentsIds.clear(); TeFragmentBoundary(bluePolsIn[i], report, blueBoundaryFragments, boundaryFragmentsIds, blueFragments, blueFragmentsIds); report.clear(); mask = TeUNKNOWNPOSITION; // os fragmentos de fronteira ja sao separados if(blueBoundaryFragments.size()) { mask = TeBOUNDARY; unsigned int boundaryFragmentsSize = blueBoundaryFragments.size(); for(unsigned int ti = 0; ti < boundaryFragmentsSize; ++ti) { boundaryFragmentsIndex.insert(TeOVERLAY::TeLineIndex::value_type(blueBoundaryFragments[ti][0], pair<unsigned int, TeLine2D>(boundaryId_, blueBoundaryFragments[ti]))); ++boundaryId_; } } // escolhe os fragmentos vermelhos que estiverem localizados fora dos poligonos azuis - fragmenta as linhas vermelhas TeRtreeGetFragments(redPolsIn, redSegmentTree, blueFragments, locationBlueFragments, mask, fragmentsIndex, rings); // libera a memoria usada pelos indice azul blueSegmentTree.clear(); // tenta eliminar fragmentos de fronteira no mesmo sentido, deixando apenas um nesta direcao TeRemoveSameBoundaryFragments(boundaryFragmentsIndex); // tenta eliminar fragmentos sobre fronteira opostos TeRemoveOpositeBoundaryFragments(boundaryFragmentsIndex); // faz um merge dos fragmentos de fronteira para o indice de fragmentos normal TeJoinFragments(fragmentsIndex, boundaryFragmentsIndex); // monta os poligonos a partir dos fragmentos bool returnValue = TeMergeFragments(fragmentsIndex, rings, true); // faz o split vector<TeLinearRing> ringsOut; bool resultSplit = true; if(TeOVERLAY::TeSplitRings(rings, ringsOut) == false) { ringsOut.clear(); ringsOut = rings; resultSplit = false; } // separate holes from islands vector<TeLinearRing> holes; TePolygonSet polsOut; bool result = TeOVERLAY::TeClassifyRings(ringsOut, polsOut, holes); returnValue = returnValue && result && resultSplit; // mount topology if((polsOut.size() == 0) && (holes.size() == 0)) { if(operation == TeUNION) { resultVec.push_back(false); // mario - 2006-03 resultValue = false; // uniao nao pode dar vazio } else { resultVec.push_back(returnValue); // mario - 2006-03 resultValue = (resultValue && returnValue); // Diferenca e intersecao podem retornar vazio } vecPolsOut.push_back(polsOut); // only to mark result } else { bool mountResult = TeOVERLAY::TeMountTopology(polsOut, holes); resultVec.push_back(returnValue && mountResult); // mario - 2006-03 resultValue = resultValue && returnValue && mountResult; vecPolsOut.push_back(polsOut); } } redSegmentTree.clear(); return resultValue; } bool TeOVERLAY::TeIntersection(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation) { return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeINTERSECTION, makeCopy, fixOrientation); } bool TeOVERLAY::TeUnion(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation) { return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeUNION, makeCopy, fixOrientation); } bool TeOVERLAY::TeDifference(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation) { return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeDIFFERENCE, makeCopy, fixOrientation); } // deprecated functions bool TeOVERLAY::TeOverlay(const TePolygonSet& redPols, const TePolygonSet& bluePols, TePolygonSet& polsOut, const short& operation) { vector<TePolygonSet> bluePolsVec; bluePolsVec.push_back(bluePols); vector<TePolygonSet> resultPols; TePolygonSet redPolsAux = redPols; vector<bool> resultVec; bool result = TeOverlay(redPolsAux, bluePolsVec, resultPols, resultVec, operation, true, true); if(resultPols.size() > 0) polsOut = resultPols[0]; return result; } bool TeOVERLAY::TeUnion(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut) { return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeUNION); } bool TeOVERLAY::TeIntersection(const TePolygonSet& redPols, const TePolygonSet& bluePols, TePolygonSet& polsOut) { return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeINTERSECTION); } bool TeOVERLAY::TeDifference(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut) { return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeDIFFERENCE); } TeMultiGeometry TeOverlay(const TeLineSet& redLinesIn, const TePolygonSet& bluePolsIn, TeINTERSECTOR2::TeSegmentRTree& blueTree, const short& operation) { // short location = TeUNKNOWNPOSITION; short locationRedFragments = TeUNKNOWNPOSITION; short locationBlueFragments = TeUNKNOWNPOSITION; TeMultiGeometry mGeom; TeLineSet redLines; TePolygonSet bluePols; // copia o conteudo das linhas de entrada redLines.copyElements(redLinesIn); // copia o conteudo dos poligonos de entrada bluePols.copyElements(bluePolsIn); // determina a localizacao dos fragmentos que serao utilizados TeOVERLAY::TeChooseBoundaryLocation(operation, locationRedFragments, locationBlueFragments); // gets intersection list TeINTERSECTOR2::TeVectorBoundaryIP report; TeINTERSECTOR2::TeIntersection(redLines, bluePols, blueTree, report); // fragment lines TeLineSet redFragments; TeLineSet redBoundaryFragments; TeFragmentBoundary(redLines, report, redBoundaryFragments, redFragments); // choose red fragments vector<TeLinearRing> rings; TeOVERLAY::TeLineIndex fragmentsIndex; short mask = 0; TeRtreeGetFragments(bluePols, blueTree, redFragments, locationRedFragments, mask, fragmentsIndex, rings); // report fragments from red lines TeOVERLAY::TeLineIndex::iterator it = fragmentsIndex.begin(); while(it != fragmentsIndex.end()) { mGeom.addGeometry(it->second.second); ++it; } unsigned int nrings = rings.size(); unsigned int i; for(i = 0; i < nrings; ++i) { mGeom.addGeometry(rings[i]); } // if the operaton is union, so push bluepols if(operation == TeUNION) { mGeom.setGeometry(bluePols); } return mGeom; } void TeOverlay(vector<TeLineSet>& redLinesIn, const TePolygonSet& bluePolsIn, vector<TeMultiGeometry>& outPutGeoms, const short& operation) { TeINTERSECTOR2::TeSegmentRTree blueTree(bluePolsIn.box()); unsigned int nLines = redLinesIn.size(); unsigned int i; for(i = 0; i < nLines; ++i) { TeMultiGeometry mg; mg = TeOverlay(redLinesIn[i], bluePolsIn, blueTree, operation); outPutGeoms.push_back(mg); } blueTree.clear(); return; } // overlay for lines/polygons TeMultiGeometry TeOVERLAY::TeOverlay(const TeLineSet& redLinesIn, const TePolygonSet& bluePolsIn, const short& operation) { vector<TeMultiGeometry> mgeoms; vector<TeLineSet> redLines; redLines.push_back(redLinesIn); TeMultiGeometry outputGeom; ::TeOverlay(redLines, bluePolsIn, mgeoms, operation); if(mgeoms.empty()) return outputGeom; outputGeom = mgeoms[0]; return outputGeom; } TeMultiGeometry TeOVERLAY::TeUnion(TeLineSet& redLines, TePolygonSet& bluePols) { return TeOVERLAY::TeOverlay(redLines, bluePols, TeUNION); } TeMultiGeometry TeOVERLAY::TeIntersection(TeLineSet& redLines, TePolygonSet& bluePols) { return TeOVERLAY::TeOverlay(redLines, bluePols, TeINTERSECTION); } TeMultiGeometry TeOVERLAY::TeDifference(TeLineSet& redLines, TePolygonSet& bluePols) { return TeOVERLAY::TeOverlay(redLines, bluePols, TeDIFFERENCE); } bool TeOVERLAY::TePairUnion(TePolygonSet& psetIn, TePolygonSet& psetOut) { psetOut.clear(); vector<TePolygonSet> outPutSet; unsigned int i; for(i = 0; i < psetIn.size(); ++i) { TePolygonSet pset; pset.add(psetIn[i]); outPutSet.push_back(pset); } unsigned int outsize = outPutSet.size(); bool resultUnion = true; while(outsize > 1) { // une dois a dois unsigned int auxsize = 0; unsigned int i; for(i = 0; i < outsize; i += 2) { TePolygonSet psRed = outPutSet[i]; if((i + 1) < outsize) { TePolygonSet psBlue = outPutSet[i+1]; TePolygonSet psUnidoAgregado; resultUnion = resultUnion && TeOVERLAY::TeUnion(psRed, psBlue, psUnidoAgregado); if(psUnidoAgregado.size() > 0) { outPutSet[auxsize] = psUnidoAgregado; ++auxsize; } } else { outPutSet[auxsize] = psRed; ++auxsize; } } outsize = auxsize; } for(unsigned int i = 0; i < outsize; ++i) for(unsigned int j = 0; j < outPutSet[i].size(); ++j) psetOut.add(outPutSet[i][j]); return resultUnion; } bool TeOVERLAY::TeValidPolygonHoles(TePolygon& polygon, TePolygonSet& psValid) { string objectId = polygon.objectId(); int geomId = polygon.geomId(); psValid.clear(); if(polygon.size() == 0) return false; if(polygon.size() == 1) { TePolygon paux; paux.copyElements(polygon); paux.geomId(geomId); paux.objectId(objectId); psValid.add(paux); return true; } TePolygon fixedPolygon; fixedPolygon.add(polygon[0]); //adiciona todos os buracos em um TePolygonSet TePolygonSet psHoles; unsigned int i; for(i = 1; i < polygon.size(); i++) { TePolygon hole; hole.add(polygon[i]); psHoles.add(hole); } //faz a uniao dos buracos TePolygonSet psOut; if(!TeOVERLAY::TeUnion(psHoles, psOut)) return false; psHoles = TePolygonSet(); psHoles.copyElements(psOut); psOut = TePolygonSet(); /* //faz a diferenca entre o poligono original e a uniao dos seus buracos // A principio não faz sentindo processar todos os buracos arrancando-os do poligono principal. Apenas adicionei os buracos ao poligono adicional como "buracos" TePolygonSet psTemp; psTemp.add(fixedPolygon); if(!TeOVERLAY::TeDifference(psTemp, psHoles, psOut)) return false; for(i = 0; i < psOut.size(); i++) { psOut[i].geomId(geomId); psOut[i].objectId(objectId); psValid.add(psOut[i]); } return true; */ fixedPolygon.geomId(geomId); fixedPolygon.objectId(objectId); psValid.add(fixedPolygon); for(i=0;i<psOut.size();i++) { psValid.add(psHoles[i]); psValid[i+1].geomId(geomId); psValid[i+1].objectId(objectId); } return !psValid.empty(); } bool TeOVERLAY::TeValidPolygonHoles(TePolygonSet& polygons, TePolygonSet& psValid) { psValid.clear(); unsigned int i, j; for(i = 0; i < polygons.size(); ++i) { // do valid for each polygon TePolygon pol = polygons[i]; TePolygonSet psAux; if(TeValidPolygonHoles(pol, psAux)) { for(j = 0; j < psAux.size(); ++j) { psValid.add(psAux[j]); } } else { return false; } } return true; }
[ "[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec" ]
[ [ [ 1, 778 ] ] ]
ccd954963fc15bd90f658b800821ba0934cc5db1
ee065463a247fda9a1927e978143186204fefa23
/Src/Depends/ClanLib/ClanLib2.0/Sources/Core/Zip/zip_writer.cpp
e97e24e926674d9ac6a26cb8ad07442bdeb40a8f
[]
no_license
ptrefall/hinsimviz
32e9a679170eda9e552d69db6578369a3065f863
9caaacd39bf04bbe13ee1288d8578ece7949518f
refs/heads/master
2021-01-22T09:03:52.503587
2010-09-26T17:29:20
2010-09-26T17:29:20
32,448,374
1
0
null
null
null
null
UTF-8
C++
false
false
11,249
cpp
/* ** ClanLib SDK ** Copyright (c) 1997-2010 The ClanLib Team ** ** This software is provided 'as-is', without any express or implied ** warranty. In no event will the authors be held liable for any damages ** arising from the use of this software. ** ** Permission is granted to anyone to use this software for any purpose, ** including commercial applications, and to alter it and redistribute it ** freely, subject to the following restrictions: ** ** 1. The origin of this software must not be misrepresented; you must not ** claim that you wrote the original software. If you use this software ** in a product, an acknowledgment in the product documentation would be ** appreciated but is not required. ** 2. Altered source versions must be plainly marked as such, and must not be ** misrepresented as being the original software. ** 3. This notice may not be removed or altered from any source distribution. ** ** Note: Some of the libraries ClanLib may link to may have additional ** requirements or restrictions. ** ** File Author(s): ** ** Magnus Norddahl */ #include "Core/precomp.h" #include "API/Core/Zip/zip_writer.h" #include "API/Core/Text/string_help.h" #include "zip_archive_impl.h" #include "zip_local_file_header.h" #include "zip_compression_method.h" #include "zip_file_header.h" #include "zip_end_of_central_directory_record.h" #include "zip_flags.h" #include <zlib.h> ///////////////////////////////////////////////////////////////////////////// // CL_ZipWriter_Impl class: class CL_ZipWriter_Impl { public: CL_ZipWriter_Impl(CL_IODevice &output, bool storeFilenamesAsUTF8) : output(output), storeFilenamesAsUTF8(storeFilenamesAsUTF8), file_begun(false), local_header_offset(0), uncompressed_length(0), compressed_length(0), compress(false) { } ~CL_ZipWriter_Impl() { if (file_begun && compress) { deflateEnd(&zs); } } struct FileEntry { CL_ZipLocalFileHeader local_header; cl_int64 local_header_offset; }; CL_IODevice output; bool storeFilenamesAsUTF8; bool file_begun; CL_ZipLocalFileHeader local_header; cl_int64 local_header_offset; cl_int64 uncompressed_length; cl_int64 compressed_length; cl_uint32 crc32; bool compress; z_stream zs; char zbuffer[16*1024]; std::vector<FileEntry> written_files; }; ///////////////////////////////////////////////////////////////////////////// // CL_ZipWriter Construction: CL_ZipWriter::CL_ZipWriter(CL_IODevice &output, bool storeFilenamesAsUTF8) : impl(new CL_ZipWriter_Impl(output, storeFilenamesAsUTF8)) { } ///////////////////////////////////////////////////////////////////////////// // CL_ZipWriter Operations: void CL_ZipWriter::begin_file(const CL_StringRef &filename, bool compress) { if (impl->file_begun) throw CL_Exception("CL_ZipWriter already writing a file"); impl->file_begun = true; impl->uncompressed_length = 0; impl->compressed_length = 0; impl->compress = compress; impl->crc32 = CL_ZIP_CRC_START_VALUE; impl->local_header_offset = impl->output.get_position(); impl->local_header = CL_ZipLocalFileHeader(); impl->local_header.version_needed_to_extract = 20; if (impl->storeFilenamesAsUTF8) impl->local_header.general_purpose_bit_flag = CL_ZIP_USE_UTF8; else impl->local_header.general_purpose_bit_flag = 0; impl->local_header.compression_method = compress ? zip_compress_deflate : zip_compress_store; CL_ZipArchive_Impl::calc_time_and_date( impl->local_header.last_mod_file_date, impl->local_header.last_mod_file_time); impl->local_header.crc32 = 0; impl->local_header.uncompressed_size = 0; impl->local_header.compressed_size = 0; impl->local_header.file_name_length = filename.length(); impl->local_header.filename = filename; if (!impl->storeFilenamesAsUTF8) // Add UTF-8 as extra field if we aren't storing normal UTF-8 filenames { // -Info-ZIP Unicode Path Extra Field (0x7075) CL_String8 filename_cp437 = CL_StringHelp::text_to_cp437(filename); CL_String8 filename_utf8 = CL_StringHelp::text_to_utf8(filename); CL_DataBuffer unicode_path(9 + filename_utf8.length()); cl_uint16 *extra_id = (cl_uint16 *) (unicode_path.get_data()); cl_uint16 *extra_len = (cl_uint16 *) (unicode_path.get_data() + 2); cl_uint8 *extra_version = (cl_uint8 *) (unicode_path.get_data() + 4); cl_uint32 *extra_crc32 = (cl_uint32 *) (unicode_path.get_data() + 5); *extra_id = 0x7075; *extra_len = 5 + filename_utf8.length(); *extra_version = 1; *extra_crc32 = CL_ZipArchive_Impl::calc_crc32(filename_cp437.data(), filename_cp437.size()); memcpy(unicode_path.get_data() + 9, filename_utf8.data(), filename_utf8.length()); impl->local_header.extra_field_length = unicode_path.get_size(); impl->local_header.extra_field = unicode_path; } impl->local_header.save(impl->output); if (compress) { memset(&impl->zs, 0, sizeof(z_stream)); int result = deflateInit2(&impl->zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); // Undocumented: if wbits is negative, zlib skips header check if (result != Z_OK) throw CL_Exception("Zlib deflateInit failed for zip index!"); } } void CL_ZipWriter::write_file_data(const void *data, cl_int64 size) { if (!impl->file_begun) throw CL_Exception("CL_ZipWriter::begin_file not called prior CL_ZipWriter::write_file_data"); impl->uncompressed_length += size; if (impl->compress) { impl->zs.next_in = (Bytef *) data; impl->zs.avail_in = size; while (impl->zs.avail_in > 0) { impl->zs.next_out = (Bytef *) impl->zbuffer; impl->zs.avail_out = 16*1024; int result = deflate(&impl->zs, Z_NO_FLUSH); if (result == Z_NEED_DICT) throw CL_Exception("Zlib deflate wants a dictionary!"); if (result == Z_DATA_ERROR) throw CL_Exception("Zip data stream is corrupted"); if (result == Z_STREAM_ERROR) throw CL_Exception("Zip stream structure was inconsistent!"); if (result == Z_MEM_ERROR) throw CL_Exception("Zlib did not have enough memory to compress file!"); if (result == Z_BUF_ERROR) throw CL_Exception("Not enough data in buffer when Z_FINISH was used"); if (result != Z_OK) throw CL_Exception("Zlib deflate failed while compressing zip file!"); cl_int64 zsize = 16*1024 - impl->zs.avail_out; if (zsize > 0) { impl->compressed_length += zsize; impl->output.write(impl->zbuffer, zsize); } } } else { impl->compressed_length += size; impl->output.write(data, size); } impl->crc32 = CL_ZipArchive_Impl::calc_crc32(data, size, impl->crc32, false); } void CL_ZipWriter::end_file() { if (!impl->file_begun) return; if (impl->compress) { impl->zs.next_in = 0; impl->zs.avail_in = 0; while (true) { impl->zs.next_out = (Bytef *) impl->zbuffer; impl->zs.avail_out = 16*1024; int result = deflate(&impl->zs, Z_FINISH); if (result == Z_NEED_DICT) throw CL_Exception("Zlib deflate wants a dictionary!"); if (result == Z_DATA_ERROR) throw CL_Exception("Zip data stream is corrupted"); if (result == Z_STREAM_ERROR) throw CL_Exception("Zip stream structure was inconsistent!"); if (result == Z_MEM_ERROR) throw CL_Exception("Zlib did not have enough memory to compress file!"); if (result == Z_BUF_ERROR) throw CL_Exception("Not enough data in buffer when Z_FINISH was used"); if (result != Z_OK && result != Z_STREAM_END) throw CL_Exception("Zlib deflate failed while compressing zip file!"); cl_int64 zsize = 16*1024 - impl->zs.avail_out; if (zsize == 0) break; impl->output.write(impl->zbuffer, zsize); impl->compressed_length += zsize; if (result == Z_STREAM_END) break; } deflateEnd(&impl->zs); impl->compress = false; } impl->local_header.uncompressed_size = impl->uncompressed_length; impl->local_header.compressed_size = impl->compressed_length; impl->local_header.crc32 = CL_ZipArchive_Impl::calc_crc32(0, 0, impl->crc32, true); cl_int64 current_offset = impl->output.get_position(); impl->output.seek(impl->local_header_offset); impl->local_header.save(impl->output); impl->output.seek(current_offset); CL_ZipWriter_Impl::FileEntry file_entry; file_entry.local_header = impl->local_header; file_entry.local_header_offset = impl->local_header_offset; impl->written_files.push_back(file_entry); impl->file_begun = false; } void CL_ZipWriter::write_toc() { if (impl->file_begun) throw CL_Exception("Cannot write zip TOC when already writing a file entry"); cl_int64 offset_start_central_dir = impl->output.get_position(); // write central directory entries. std::vector<CL_ZipWriter_Impl::FileEntry>::size_type index; for (index = 0; index < impl->written_files.size(); index++) { CL_ZipFileHeader file_header; file_header.version_made_by = 20; file_header.version_needed_to_extract = impl->written_files[index].local_header.version_needed_to_extract; file_header.general_purpose_bit_flag = impl->written_files[index].local_header.general_purpose_bit_flag; file_header.compression_method = impl->written_files[index].local_header.compression_method; file_header.last_mod_file_time = impl->written_files[index].local_header.last_mod_file_time; file_header.last_mod_file_date = impl->written_files[index].local_header.last_mod_file_date; file_header.crc32 = impl->written_files[index].local_header.crc32; file_header.uncompressed_size = impl->written_files[index].local_header.uncompressed_size; file_header.compressed_size = impl->written_files[index].local_header.compressed_size; file_header.file_name_length = impl->written_files[index].local_header.file_name_length; file_header.filename = impl->written_files[index].local_header.filename; file_header.extra_field = impl->written_files[index].local_header.extra_field; file_header.extra_field_length = impl->written_files[index].local_header.extra_field_length; file_header.file_comment_length = 0; file_header.disk_number_start = 0; file_header.internal_file_attributes = 0; file_header.external_file_attributes = 0; file_header.relative_offset_of_local_header = impl->written_files[index].local_header_offset; file_header.save(impl->output); } /* CL_ZipDigitalSignature digi_sign; digi_sign.size_of_data = 0; digi_sign.save(output); */ cl_int64 central_dir_size = impl->output.get_position() - offset_start_central_dir; CL_ZipEndOfCentralDirectoryRecord central_dir_end; central_dir_end.number_of_this_disk = 0; central_dir_end.number_of_disk_with_start_of_central_directory = 0; central_dir_end.number_of_entries_on_this_disk = impl->written_files.size(); central_dir_end.number_of_entries_in_central_directory = impl->written_files.size(); central_dir_end.size_of_central_directory = central_dir_size; central_dir_end.offset_to_start_of_central_directory = offset_start_central_dir; central_dir_end.file_comment_length = 0; central_dir_end.file_comment = ""; central_dir_end.save(impl->output); } ///////////////////////////////////////////////////////////////////////////// // CL_ZipWriter Implementation:
[ "[email protected]@28a56cb3-1e7c-bc60-7718-65c159e1d2df" ]
[ [ [ 1, 294 ] ] ]
36a2b4415fa7bbfe900774879c85a1a5c436749e
ee636be1d3c3ab19b23251beb1292d006db0a4df
/Hunters/src/itmAnimal.cpp
ca0373c844473b2f446943d3d8f140de83fe766f
[]
no_license
arturo182/OOP
6f5084f515fc34f9b0be95298538f0f4ce0bbb0e
978aa6f13c62850593ffcca0e314218e297180f9
refs/heads/master
2020-06-05T13:27:36.779823
2011-02-28T07:36:32
2011-02-28T07:36:32
1,420,589
0
0
null
null
null
null
UTF-8
C++
false
false
989
cpp
#include "itmAnimal.h" #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfoList> #include <QtXml/QDomDocument> itmAnimal::itmAnimal(): itmPawn() { } void itmAnimal::loadFromDir(QString d) { QDir dir(d); QFileInfoList list = dir.entryInfoList(QStringList() << "*", QDir::NoDotAndDotDot | QDir::Dirs); QFileInfo info = list.at(rand() % list.count()); QFile file(info.absoluteFilePath() + "/info.xml"); if(file.open(QIODevice::ReadOnly)) { QDomDocument doc; doc.setContent(&file); QDomElement root = doc.documentElement(); QDomElement name = root.elementsByTagName("name").at(0).toElement(); m_name = name.attribute("value"); m_nameSex = name.attribute("sex").toInt(); m_genetivus = name.attribute("genetivus"); QDomElement pixmap = root.elementsByTagName("pixmap").at(0).toElement(); setPixmap(QPixmap(d + info.fileName() + "/" + pixmap.attribute("file"))); } file.close(); }
[ [ [ 1, 35 ] ] ]
7a8b93873bf3816adb73b66398736ab57a3bdaee
610590a1925a6f9d185d4a562b5736438689318b
/JHLIB/JHLIB.cpp
e2ae8f6412b396cfc9c0308c1d654bd016f8a077
[]
no_license
ltsochev-dev/tabula-rasa-server-emulator
47a46ed296215c978044d2816d63bd9148943561
50c7b4ebce644d3b7ab7b9012b3fe5e975a0409b
refs/heads/master
2021-05-28T10:51:32.729642
2011-05-21T11:49:07
2011-05-21T11:49:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
820
cpp
// JHLIB.cpp : Defines the exported functions for the DLL application. // #include "stdafx.h" #include "JHLIB.h" //// This is an example of an exported variable //JHLIB_API int nJHLIB=0; // //// This is an example of an exported function. //JHLIB_API int fnJHLIB(void) //{ // return 42; //} // //// This is the constructor of a class that has been exported. //// see JHLIB.h for the class definition //CJHLIB::CJHLIB() //{ // return; //} // The keywords and parameter types must match the above extern // declaration. extern int __cdecl Add (int a, int b) { // This is part of the DLL, so we can call any function we want // in the C++. The parameters can have any names we want to give // them and they don't need to match the extern declaration. return a + b; }
[ "[email protected]@d6b412fb-78a4-b329-1f31-49661cb3b798" ]
[ [ [ 1, 35 ] ] ]
e0d1a13d157822a7b2fbb2f26933689319e9c7d2
515e917815568d213e75bfcbd3fb9f0e08cf2677
/common/configfile.cpp
ae49c2a11df049ed7b1317ef907fea529bcb6c10
[ "BSD-2-Clause" ]
permissive
dfk789/CodenameInfinite
bd183aec6b9e60e20dda6764d99f4e8d8a945add
aeb88b954b65f6beca3fb221fe49459b75e7c15f
refs/heads/master
2020-05-30T15:46:20.450963
2011-10-15T00:21:38
2011-10-15T00:21:38
5,652,791
2
0
null
null
null
null
UTF-8
C++
false
false
3,926
cpp
// ConfigFile.cpp #include "configfile.h" #include <string> #include <strutils.h> #include <common.h> ConfigFile::ConfigFile( tstring filename, tstring delimiter, tstring comment, tstring sentry ) : myDelimiter(delimiter), myComment(comment), mySentry(sentry) { // Construct a ConfigFile, getting keys and values from given file std::basic_ifstream<tchar> in( convertstring<tchar, char>(filename).c_str() ); fileValid = !!in; if (in) in >> (*this); } ConfigFile::ConfigFile() : myDelimiter( tstring(1,_T('=')) ), myComment( tstring(1,_T('#')) ) { // Construct a ConfigFile without a file; empty fileValid = false; } void ConfigFile::remove( const tstring& key ) { // Remove key and its value myContents.erase( myContents.find( key ) ); return; } bool ConfigFile::keyExists( const tstring& key ) const { // Indicate whether key is found mapci p = myContents.find( key ); return ( p != myContents.end() ); } /* static */ void ConfigFile::trim( tstring& s ) { // Remove leading and trailing whitespace static const tchar whitespace[] = _T(" \n\t\v\r\f"); s.erase( 0, s.find_first_not_of(whitespace) ); s.erase( s.find_last_not_of(whitespace) + 1U ); } std::basic_ostream<tchar>& operator<<( std::basic_ostream<tchar>& os, const ConfigFile& cf ) { // Save a ConfigFile to os for( ConfigFile::mapci p = cf.myContents.begin(); p != cf.myContents.end(); ++p ) { os << p->first.c_str() << " " << cf.myDelimiter.c_str() << " "; os << p->second.c_str() << std::endl; } return os; } std::basic_istream<tchar>& operator>>( std::basic_istream<tchar>& is, ConfigFile& cf ) { // Load a ConfigFile from is // Read in keys and values, keeping internal whitespace typedef tstring::size_type pos; const tstring& delim = cf.myDelimiter; // separator const tstring& comm = cf.myComment; // comment const tstring& sentry = cf.mySentry; // end of file sentry const pos skip = delim.length(); // length of separator tstring nextline = _T(""); // might need to read ahead to see where value ends while( is || nextline.length() > 0 ) { // Read an entire line at a time std::basic_string<tchar> sline; tstring line; if( nextline.length() > 0 ) { line = nextline; // we read ahead; use it now nextline = _T(""); } else { std::getline( is, sline ); line = sline.c_str(); } // Ignore comments line = line.substr( 0, line.find(comm) ); // Check for end of file sentry if( sentry != _T("") && line.find(sentry) != tstring::npos ) return is; // Parse the line if it contains a delimiter pos delimPos = line.find( delim ); if( delimPos < tstring::npos ) { // Extract the key tstring key = line.substr( 0, delimPos ); line.replace( 0, delimPos+skip, _T("") ); // See if value continues on the next line // Stop at blank line, next line with a key, end of stream, // or end of file sentry bool terminate = false; while( !terminate && is ) { std::basic_string<tchar> snextline; std::getline( is, snextline ); nextline = snextline.c_str(); terminate = true; tstring nlcopy = nextline; ConfigFile::trim(nlcopy); if( nlcopy == _T("") ) continue; nextline = nextline.substr( 0, nextline.find(comm) ); if( nextline.find(delim) != tstring::npos ) continue; if( sentry != _T("") && nextline.find(sentry) != tstring::npos ) continue; nlcopy = nextline; ConfigFile::trim(nlcopy); if( nlcopy != _T("") ) line += _T("\n"); line += nextline; terminate = false; } // Store key and value ConfigFile::trim(key); ConfigFile::trim(line); cf.myContents[key] = line; // overwrites if key is repeated } } return is; }
[ [ [ 1, 2 ], [ 4, 5 ], [ 9, 9 ], [ 12, 15 ], [ 17, 25 ], [ 27, 33 ], [ 35, 41 ], [ 43, 50 ], [ 52, 53 ], [ 55, 59 ], [ 61, 73 ], [ 75, 77 ], [ 82, 83 ], [ 86, 88 ], [ 91, 93 ], [ 95, 105 ], [ 107, 109 ], [ 111, 112 ], [ 115, 121 ], [ 123, 126 ], [ 128, 128 ], [ 130, 131 ], [ 133, 133 ], [ 135, 138 ], [ 140, 152 ] ], [ [ 3, 3 ], [ 6, 8 ], [ 10, 11 ], [ 16, 16 ], [ 26, 26 ], [ 34, 34 ], [ 42, 42 ], [ 51, 51 ], [ 54, 54 ], [ 60, 60 ], [ 74, 74 ], [ 78, 81 ], [ 84, 85 ], [ 89, 90 ], [ 94, 94 ], [ 106, 106 ], [ 110, 110 ], [ 113, 114 ], [ 122, 122 ], [ 127, 127 ], [ 129, 129 ], [ 132, 132 ], [ 134, 134 ], [ 139, 139 ] ] ]
0bec2e12a860bc47d9ad08dd2ccb3b197c85d74a
38926bfe477f933a307f51376dd3c356e7893ffc
/Source/SDKs/STLPORT/stlport/stl/debug/_list.h
7d1e790a0fdf71f23ecf6c69ddaa2f7c69560ee8
[ "LicenseRef-scancode-stlport-4.5" ]
permissive
richmondx/dead6
b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161
955f76f35d94ed5f991871407f3d3ad83f06a530
refs/heads/master
2021-12-05T14:32:01.782047
2008-01-01T13:13:39
2008-01-01T13:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,308
h
/* * * Copyright (c) 1994 * Hewlett-Packard Company * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Copyright (c) 1997 * Moscow Center for SPARC Technology * * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */ /* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */ #ifndef _STLP_INTERNAL_DBG_LIST_H #define _STLP_INTERNAL_DBG_LIST_H #ifndef _STLP_INTERNAL_ALGO_H # include <stl/_algo.h> #endif #include <stl/debug/_iterator.h> #ifndef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM # undef _DBG_list # define _DBG_list list #endif # define _STLP_DBG_LIST_BASE __WORKAROUND_DBG_RENAME(list) <_Tp, _Alloc> _STLP_BEGIN_NAMESPACE # ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS template <class _Tp, class _Alloc> inline _Tp* value_type(const _DBG_iter_base< _STLP_DBG_LIST_BASE >&) { return (_Tp*)0; } template <class _Tp, class _Alloc> inline bidirectional_iterator_tag iterator_category(const _DBG_iter_base< _STLP_DBG_LIST_BASE >&) { return bidirectional_iterator_tag(); } # endif template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) > class _DBG_list : private __construct_checker<_STLP_DBG_LIST_BASE >, public _STLP_DBG_LIST_BASE #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) , public __stlport_class<_DBG_list<_Tp, _Alloc> > #endif { typedef _STLP_DBG_LIST_BASE _Base; typedef _DBG_list<_Tp, _Alloc> _Self; typedef __construct_checker<_STLP_DBG_LIST_BASE > _ConstructCheck; public: __IMPORT_CONTAINER_TYPEDEFS(_Base) public: typedef _DBG_iter<_Base, _DbgTraits<_Nonconst_traits<value_type> > > iterator; typedef _DBG_iter<_Base, _DbgTraits<_Const_traits<value_type> > > const_iterator; _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; protected: __owned_list _M_iter_list; _Base* _Get_base() { return this; } void _Invalidate_iterator(const iterator& __it) { __invalidate_iterator(&_M_iter_list,__it); } void _Invalidate_iterators(const iterator& __first, const iterator& __last) { __invalidate_range(&_M_iter_list, __first, __last); } void _Invalidate_all() { _M_iter_list._Invalidate_all(); } typedef typename _Base::iterator _Base_iterator; public: explicit _DBG_list(const allocator_type& __a = allocator_type()) : _STLP_DBG_LIST_BASE(__a), _M_iter_list(_Get_base()) {} #if !defined(_STLP_DONT_SUP_DFLT_PARAM) explicit _DBG_list(size_type __n, const _Tp& __x = _Tp(), #else _DBG_list(size_type __n, const _Tp& __x, #endif /*!_STLP_DONT_SUP_DFLT_PARAM*/ const allocator_type& __a = allocator_type()) : _STLP_DBG_LIST_BASE(__n, __x, __a), _M_iter_list(_Get_base()) {} #if defined(_STLP_DONT_SUP_DFLT_PARAM) explicit _DBG_list(size_type __n) : _STLP_DBG_LIST_BASE(__n), _M_iter_list(_Get_base()) {} #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ _DBG_list(__move_source<_Self> src) : _STLP_DBG_LIST_BASE(__move_source<_Base>(src.get())), _M_iter_list(_Get_base()) {} #if defined (_STLP_MEMBER_TEMPLATES) // We don't need any dispatching tricks here, because insert does all of // that anyway. template <class _InputIterator> _DBG_list(_InputIterator __first, _InputIterator __last, const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _ConstructCheck(__first, __last), _STLP_DBG_LIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) { } # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) template <class _InputIterator> _DBG_list(_InputIterator __first, _InputIterator __last) : _ConstructCheck(__first, __last), _STLP_DBG_LIST_BASE(__first, __last), _M_iter_list(_Get_base()) { } # endif #else /* _STLP_MEMBER_TEMPLATES */ _DBG_list(const value_type* __first, const value_type* __last, const allocator_type& __a = allocator_type()) : _ConstructCheck(__first, __last), _STLP_DBG_LIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) { } _DBG_list(const_iterator __first, const_iterator __last, const allocator_type& __a = allocator_type()) : _ConstructCheck(__first, __last), _STLP_DBG_LIST_BASE(__first._M_iterator, __last._M_iterator, __a), _M_iter_list(_Get_base()) { } #endif /* _STLP_MEMBER_TEMPLATES */ _DBG_list(const _Self& __x) : _ConstructCheck(__x), _STLP_DBG_LIST_BASE(__x) , _M_iter_list(_Get_base()) {} _Self& operator= (const _Self& __x) { if (this != &__x) { //Should not invalidate end iterator _Invalidate_iterators(this->begin(), this->end()); _Base::operator=((const _Base&)__x); } return *this; } public: iterator begin() { return iterator(&_M_iter_list, _Base::begin()); } const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); } iterator end() { return iterator(&_M_iter_list, _Base::end()); } const_iterator end() const { return const_iterator(&_M_iter_list, _Base::end()); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } // those are here to enforce checking reference front() { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) return *begin(); } const_reference front() const { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) return *begin(); } reference back() { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) return *(--end()); } const_reference back() const { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) return *(--end()); } void swap(_Self& __x) { _M_iter_list._Swap_owners(__x._M_iter_list); _Base::swap(__x); } #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) iterator insert(iterator __pos, const _Tp& __x = _Tp()) { #else iterator insert(iterator __pos, const _Tp& __x) { #endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) return iterator(&_M_iter_list,_Base::insert(__pos._M_iterator, __x) ); } #if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } #endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ #if defined (_STLP_MEMBER_TEMPLATES) template <class _InputIterator> void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { # if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) typedef typename _AreSameUnCVTypes<_InputIterator, iterator>::_Ret _IsListIterator; typedef typename _AreSameUnCVTypes<_InputIterator, const_iterator>::_Ret _IsListConstIterator; typedef typename _Lor2<_IsListIterator, _IsListConstIterator>::_Ret _DoCheck; # endif _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos)) _STLP_DEBUG_CHECK(__check_range(__first, __last)) _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first, _DoCheck())) _Base::insert(__pos._M_iterator, __first, __last); } #else void insert(iterator __pos, const _Tp* __first, const _Tp* __last) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) _STLP_DEBUG_CHECK(__check_ptr_range(__first, __last)) _Base::insert(__pos._M_iterator, __first, __last); } void insert(iterator __pos, const_iterator __first, const_iterator __last) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos)) _STLP_DEBUG_CHECK(__check_range(__first, __last)) _STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first, _DoCheck())) _Base::insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); } #endif /* _STLP_MEMBER_TEMPLATES */ void insert(iterator __pos, size_type __n, const _Tp& __x) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) _Base::insert(__pos._M_iterator, __n, __x); } void pop_back() { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) _Invalidate_iterator(this->end()); _Base::pop_back(); } void pop_front() { _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER) _Invalidate_iterator(this->begin()); _Base::pop_front(); } iterator erase(iterator __pos) { _STLP_DEBUG_CHECK(_Dereferenceable(__pos)) _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) _Invalidate_iterator(__pos); return iterator(&_M_iter_list,_Base::erase(__pos._M_iterator)); } iterator erase(iterator __first, iterator __last) { _STLP_DEBUG_CHECK(__check_range(__first, __last, this->begin(), this->end())) _Invalidate_iterators(__first, __last); return iterator (&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator)); } #if !defined(_STLP_DONT_SUP_DFLT_PARAM) void resize(size_type __new_size, const _Tp& __x = _Tp()) { #else void resize(size_type __new_size, const _Tp& __x) { #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ typename _Base::iterator __i = _Base::begin(); size_type __len = 0; for ( ; __i != _Base::end() && __len < __new_size; ++__i, ++__len); if (__len == __new_size) erase(iterator(&_M_iter_list, __i), this->end()); else // __i == end() _Base::insert(_Base::end(), __new_size - __len, __x); } #if defined(_STLP_DONT_SUP_DFLT_PARAM) void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ void remove(const _Tp& __x) { _Base_iterator __first = _Base::begin(), __last = _Base::end(); while (__first != __last) { _Base_iterator __next = __first; ++__next; if (__x == *__first) { _Invalidate_iterator(iterator(&_M_iter_list, __first)); _Base::erase(__first); } __first = __next; } } void clear() { _Invalidate_iterators(this->begin(), this->end()); _Base::clear(); } public: void splice(iterator __pos, _Self& __x) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) _Base::splice(__pos._M_iterator, __x); #if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) // Std: 23.2.2.4:4 __x._Invalidate_all(); #else __x._M_iter_list._Set_owner(_M_iter_list); #endif } void splice(iterator __pos, _Self& __x, iterator __i) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos)) _STLP_DEBUG_CHECK(_Dereferenceable(__i)) _STLP_DEBUG_CHECK(__check_if_owner(&(__x._M_iter_list),__i)) _Base::splice(__pos._M_iterator, __x, __i._M_iterator); #if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) // Std: 23.2.2.4:7 __x._Invalidate_iterator(__i); #else __change_ite_owner(__i, &_M_iter_list); #endif } void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos)) _STLP_DEBUG_CHECK(__check_range(__first, __last, __x.begin(), __x.end())) _STLP_DEBUG_CHECK(this == &__x ? !__check_range(__pos, __first, __last) : true) #if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) // Std: 23.2.2.4:12 __x._Invalidate_iterators(__first, __last); #else __change_range_owner(__first, __last, &_M_iter_list); #endif _Base::splice(__pos._M_iterator, __x, __first._M_iterator, __last._M_iterator); } void merge(_Self& __x) { _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(this->begin()._M_iterator, this->end()._M_iterator)) _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator)) _Base::merge(__x); __x._M_iter_list._Set_owner(_M_iter_list); } void reverse() { _Base::reverse(); } void unique() { _Base_iterator __first = _Base::begin(), __last = _Base::end(); if (__first == __last) return; _Base_iterator __next = __first; while (++__next != __last) { if (*__first == *__next) { _Invalidate_iterator(iterator(&_M_iter_list, __next)); _Base::erase(__next); } else __first = __next; __next = __first; } } void sort() { _Base::sort(); } #ifdef _STLP_MEMBER_TEMPLATES template <class _Predicate> void remove_if(_Predicate __pred) { _Base_iterator __first = _Base::begin(), __last = _Base::end(); while (__first != __last) { _Base_iterator __next = __first; ++__next; if (__pred(*__first)) { _Invalidate_iterator(iterator(&_M_iter_list, __first)); _Base::erase(__first); } __first = __next; } } template <class _BinaryPredicate> void unique(_BinaryPredicate __binary_pred) { _Base_iterator __first = _Base::begin(), __last = _Base::end(); if (__first == __last) return; _Base_iterator __next = __first; while (++__next != __last) { if (__binary_pred(*__first, *__next)) { _Invalidate_iterator(iterator(&_M_iter_list, __next)); _Base::erase(__next); } else __first = __next; __next = __first; } } template <class _StrictWeakOrdering> void merge(_Self& __x, _StrictWeakOrdering __comp) { _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(_Base::begin(), _Base::end(), __comp)) _STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __comp)) _Base::merge(__x, __comp); __x._M_iter_list._Set_owner(_M_iter_list); } template <class _StrictWeakOrdering> void sort(_StrictWeakOrdering __comp) { _Base::sort(__comp); } #endif /* _STLP_MEMBER_TEMPLATES */ }; #define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc> #define _STLP_TEMPLATE_CONTAINER _DBG_list<_Tp,_Alloc> #define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_LIST_BASE #include <stl/debug/_relops_cont.h> #undef _STLP_TEMPLATE_CONTAINER_BASE #undef _STLP_TEMPLATE_CONTAINER #undef _STLP_TEMPLATE_HEADER #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION template <class _Tp, class _Alloc> struct __move_traits<_DBG_list<_Tp,_Alloc> > : __move_traits_aux<_STLP_DBG_LIST_BASE > {}; #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ _STLP_END_NAMESPACE #undef _STLP_DBG_LIST_BASE #undef _DBG_list #endif /* _STLP_INTERNAL_LIST_H */ // Local Variables: // mode:C++ // End:
[ [ [ 1, 441 ] ] ]
8b233ab9c85073e629696cfdee77dcb1952e9d13
5124e1a9d04312802e5f2bdb8bc83c9db09eb6aa
/Root/Support/KeyPathKeyGenerator.cpp
5f8f442e0bc26298dc56f94a25c44ee773cc65b0
[]
no_license
BrandonHaynes/indexeddb
302f9cab90752758e02a7a49af0b35eda87d0c4a
477ac611b11977c36a44506fa86430638f292426
refs/heads/master
2020-03-31T12:19:14.663625
2010-05-10T15:27:40
2010-05-10T15:27:40
32,110,882
0
0
null
null
null
null
UTF-8
C++
false
false
1,034
cpp
/**********************************************************\ Copyright Brandon Haynes http://code.google.com/p/indexeddb GNU Lesser General Public License \**********************************************************/ #include "KeyPathKeyGenerator.h" #include "../Implementation/Key.h" #include "Convert.h" namespace BrandonHaynes { namespace IndexedDB { using class Implementation::Key; using class Implementation::Data; namespace API { namespace Support { Key KeyPathKeyGenerator::generateKey(const Data& context) const // TODO Does the spec support a keypath that looks like path1.path2? { return Convert::toKey(host, generateKey(Convert::toVariant(host, context))); } const FB::variant KeyPathKeyGenerator::generateKey(FB::variant value) const { return value.is_of_type<FB::JSObject>() ? generateKey(value.cast<FB::JSObject>()) : FB::variant(); } const FB::variant KeyPathKeyGenerator::generateKey(FB::JSObject object) const { return object->GetProperty(keyPath); } } } } }
[ [ [ 1, 37 ] ] ]
cdbe4fe76693a8389f7a15b551bbb53701df0afa
5dc78c30093221b4d2ce0e522d96b0f676f0c59a
/src/modules/graphics/opengl/SpriteBatch.cpp
d45bf2ef4e84b37eccd748a4c6f38addc7e35ae8
[ "Zlib" ]
permissive
JackDanger/love
f03219b6cca452530bf590ca22825170c2b2eae1
596c98c88bde046f01d6898fda8b46013804aad6
refs/heads/master
2021-01-13T02:32:12.708770
2009-07-22T17:21:13
2009-07-22T17:21:13
142,595
1
0
null
null
null
null
UTF-8
C++
false
false
2,716
cpp
/** * Copyright (c) 2006-2009 LOVE Development Team * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. **/ #include "SpriteBatch.h" // STD #include <iostream> // LOVE #include "VertexBuffer.h" #include "Image.h" namespace love { namespace graphics { namespace opengl { SpriteBatch::SpriteBatch(Image * image, int size, int usage) : size(size), next(0) { // Four vertices in one sprite. buffer = new VertexBuffer(image, size*6, TYPE_TRIANGLES, usage); } SpriteBatch::~SpriteBatch() { buffer->release(); } void SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy) { // Only do this if there's a free slot. if(next < size) { // Get a pointer to the correct insertion position. vertex * v = buffer->vertices + next*6; // Fill vertices with ones (for white colors). memset(v, 0xff, sizeof(vertex)*6); // Half-sizes. float w2 = buffer->image->getWidth()/2.0f; float h2 = buffer->image->getHeight()/2.0f; // MASSIVE TODO: just copy vertices from image. v[0].x = -w2; v[0].y = -h2; v[1].x = -w2; v[1].y = h2; v[2].x = w2; v[2].y = h2; v[3].x = w2; v[3].y = -h2; v[0].s = 0; v[0].t = 0; v[1].s = 0; v[1].t = 1; v[2].s = 1; v[2].t = 1; v[3].s = 1; v[3].t = 0; // Transform. Matrix t; t.translate(x, y); t.scale(sx, sy); t.rotate(a); t.transform(v, v, 4); v[5] = v[3]; v[4] = v[2]; v[3] = v[0]; // Send the buffer to the GPU. buffer->update(next*6, 6); // Increment counter. next++; } } void SpriteBatch::clear() { // Reset the position of the next index. next = 0; // Also reset the buffer. buffer->clear(); } void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const { // Let the buffer handle this. buffer->draw(x, y, angle, sx, sy, ox, oy); } } // opengl } // graphics } // love
[ "prerude@3494dbca-881a-0410-bd34-8ecbaf855390" ]
[ [ [ 1, 111 ] ] ]
c25c075cafbfc2ebc3f2fc9eea381a40c1f1e980
260c7664bea7daf8b9b9e18c43fd19908826777c
/src/glfMultiples/glfMultiples/GlfLikelihoods.h
1ddc00668a9eea2efb1589bb4475474b3f0e257e
[]
no_license
statgen/statgen
17f6cf6881428c68d0d11186e5b7f7d9c26b706e
2745cb85be29b9dceb14ffd00a60f891e19157cf
refs/heads/master
2020-05-30T14:52:49.616252
2011-03-24T00:02:18
2011-03-24T00:02:18
1,440,786
3
0
null
null
null
null
UTF-8
C++
false
false
6,106
h
#ifndef __GLFLIKELIHOODS_H__ #define __GLFLIKELIHOODS_H__ #include "glfHandler.h" #include "MathGold.h" #include "Pedigree.h" #include <math.h> // Chromosome types #define CT_AUTOSOME 0 #define CT_CHRX 1 #define CT_CHRY 2 #define CT_MITO 3 class GenotypeLikelihood : public ScalarMinimizer { public: int n; int position; glfHandler * glf; void SetAlleles(int al1, int al2) { chromosomeType = CT_AUTOSOME; allele1 = al1; allele2 = al2; geno11 = glfHandler::GenotypeIndex(allele1, allele1); geno12 = glfHandler::GenotypeIndex(allele1, allele2); geno22 = glfHandler::GenotypeIndex(allele2, allele2); } virtual double f(double freq) { return -Evaluate(freq); } double Evaluate(double freq) { double prior11 = freq * freq; double prior12 = freq * (1.0 - freq) * 2.0; double prior22 = (1.0 - freq) * (1.0 - freq); double prior1 = freq; double prior2 = 1.0 - freq; double likelihood = 0.0; switch (chromosomeType) { case CT_MITO : prior11 = prior1; prior12 = 0.0; prior22 = prior2; case CT_AUTOSOME : for (int i = 0; i < n; i++) likelihood += log(prior11 * glf[i].GetLikelihoods(position)[geno11] + prior12 * glf[i].GetLikelihoods(position)[geno12] + prior22 * glf[i].GetLikelihoods(position)[geno22] + 1e-30); break; case CT_CHRY : for (int i = 0; i < n; i++) if (sex[i] == SEX_MALE) likelihood += log(prior1 * glf[i].GetLikelihoods(position)[geno11] + prior2 * glf[i].GetLikelihoods(position)[geno22] + 1e-30); break; case CT_CHRX : for (int i = 0; i < n; i++) if (sex[i] == SEX_MALE) likelihood += log(prior1 * glf[i].GetLikelihoods(position)[geno11] + prior2 * glf[i].GetLikelihoods(position)[geno22] + 1e-30); else likelihood += log(prior11 * glf[i].GetLikelihoods(position)[geno11] + prior12 * glf[i].GetLikelihoods(position)[geno12] + prior22 * glf[i].GetLikelihoods(position)[geno22] + 1e-30); } return likelihood; } void GetPriors(double * priors, double freq) { for (int i = 0; i < 10; i++) priors[i] = 0.0; priors[geno11] = freq * freq; priors[geno12] = freq * (1.0 - freq) * 2.0; priors[geno22] = (1.0 - freq) * (1.0 - freq); } double OptimizeFrequency() { a = 0.00001; fa = f(a); b = 0.4; fb = f(b); c = 0.99999; fc = f(c); Brent(0.0001); return min; } protected: int chromosomeType; int allele1, allele2; int geno11, geno12, geno22; char * sex; }; class FilterLikelihood : public ScalarMinimizer { public: int n; int position; glfHandler * glf; void SetReferenceAllele(int ref) { chromosomeType = CT_AUTOSOME; reference = ref; for (int a1 = 1; a1 <= 4; a1++) for (int a2 = a1; a2 <= 4; a2++) { int index = glfHandler::GenotypeIndex(a1, a2); if (a1 == a2) group[index] = a1 == ref ? 0 : 2; else group[index] = (a1 == ref || a2 == ref) ? 1 : 2; } } virtual double f(double freq) { return -Evaluate(freq); } double Evaluate(double freq) { double prior11 = freq * freq; double prior12 = freq * (1.0 - freq) * 2.0; double prior22 = (1.0 - freq) * (1.0 - freq); double prior1 = freq; double prior2 = 1.0 - freq; double likelihood = 0.0; double lk[3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) lk[j] = 0.0; for (int j = 0; j < 10; j++) lk[group[j]] = max(lk[group[j]], glf[i].GetLikelihoods(position)[j]); switch (chromosomeType) { case CT_MITO : prior11 = prior1; prior12 = 0.0; prior22 = prior2; case CT_AUTOSOME : likelihood += log(prior11 * lk[0] + prior12 * lk[1] + prior22 * lk[2] + 1e-30); break; case CT_CHRY : if (sex[i] == SEX_MALE) likelihood += log(prior1 * lk[0] + prior2 * lk[2] + 1e-30); break; case CT_CHRX : if (sex[i] == SEX_MALE) likelihood += log(prior1 * lk[0] + prior2 * lk[2] + 1e-30); else likelihood += log(prior11 * lk[0] + prior12 * lk[1] + prior22 * lk[2] + 1e-30); } } return likelihood; } double OptimizeFrequency() { a = 0.00001; fa = f(a); b = 0.4; fb = f(b); c = 1.0 - 0.5 / n; fc = f(c); Brent(0.0001); return min; } protected: int chromosomeType; int reference; int group[10]; char * sex; }; #endif
[ [ [ 1, 208 ] ] ]
71a12f157187332a70611cd54ecad77a1e264a9f
23b2ab84309de65b42333c87e0de088503e2cb36
/src/gui/addclasswizard.cpp
4aca83dc3a6e0c483a5a7665dba7ecbd8cbc622b
[]
no_license
fyrestone/simple-pms
74a771d83979690eac231a82f1c457d7b6c55f41
1917d5c4e14bf7829707bacb9cc2452b49d6cc2b
refs/heads/master
2021-01-10T20:36:39.403902
2011-04-16T15:38:12
2011-04-16T15:38:12
32,192,134
0
0
null
null
null
null
UTF-8
C++
false
false
803
cpp
#include "addclasswizard.h" #include "ui_addclasswizard.h" #include "selectgradewizardpage.h" #include "inputclassinfowizardpage.h" AddClassWizard::AddClassWizard(QWidget *parent) : QWizard(parent), ui(new Ui::AddClassWizard) { ui->setupUi(this); setFixedSize(width(), height()); setButtonText(QWizard::BackButton, tr("上一步")); setButtonText(QWizard::NextButton, tr("下一步")); setButtonText(QWizard::CommitButton, tr("提交")); setButtonText(QWizard::FinishButton, tr("完成")); setButtonText(QWizard::CancelButton, tr("取消")); setButtonText(QWizard::HelpButton, tr("帮助")); addPage(new SelectGradeWizardPage); addPage(new InputClassInfoWizardPage); } AddClassWizard::~AddClassWizard() { delete ui; }
[ "[email protected]@95127988-2b6b-df20-625d-5ecc0e46e2bb" ]
[ [ [ 1, 28 ] ] ]
3e5d7ae6f34bd0ebffaae1ebb38218da84d1a24d
6f62b87010214a4a77d66c1df0d758ba65cd428c
/allocator.h
319a15bf098992600cbcbe72156b495a6fc55323
[]
no_license
cutepig/alligator
94eaa20ae1416fc1dc18e36e7ae3ba4e359410ac
8816de6f2c3eefdcd881bda7f30373b7026c7055
refs/heads/master
2021-01-01T18:37:23.331664
2011-09-16T09:40:12
2011-09-16T09:40:12
2,398,229
0
0
null
null
null
null
UTF-8
C++
false
false
14,587
h
/* allocator.h - cutepig stl allocators Copyright (C) 2011 Christian Holmberg 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. */ #ifndef ALLOCATOR_H_INCLUDED #define ALLOCATOR_H_INCLUDED #define __REPORT_ALLOCS__ #include <utility> // pair #include <algorithm> // max #include <new> // bad_alloc #include <stdlib.h> // malloc/free #ifdef __REPORT_ALLOCS__ #include <iostream> #include <cmath> #endif namespace cutepig { // helper to get either 32 or 64 depending on the platform // determined by length of void* pointer template<int __ptr_size> struct __int_32_64 {}; template<> struct __int_32_64<4> { typedef __uint32_t type; }; template<> struct __int_32_64<8> { typedef __uint64_t type; }; struct int_32_64 { typedef typename __int_32_64<sizeof(int*)>::type type; }; //============================================= // for copy/paste reference purposes only. unusable // allocator class template <class T> class __base_allocator; // specialize for void: template <> class __base_allocator<void> { public: typedef void* pointer; typedef const void* const_pointer; // reference-to-void members are impossible. typedef void value_type; template <class U> struct rebind { typedef __base_allocator<U> other; }; }; template <class T> class __base_allocator { public: typedef size_t size_type; typedef std::ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template <class U> struct rebind { typedef __base_allocator<U> other; }; __base_allocator() throw() {} __base_allocator(const __base_allocator&) throw() {} template <class U> __base_allocator(const __base_allocator<U>&) throw() {} ~__base_allocator() throw() {}; pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pointer allocate(size_type, typename __base_allocator<void>::const_pointer hint = 0) { return 0; }; void deallocate(pointer p, size_type n) {} size_type max_size() const throw() { return 0x8000000; } void construct(pointer p, const T& val) { new(p) T(val); } void destroy(pointer p) { p->~T(); } // to copy ctor or compare with private data, do this template<typename U> friend class __base_allocator; }; //=================================================== // so lets implement some allocator // allocator class template <class T> class malloc_allocator; // specialize for void: template <> class malloc_allocator<void> { public: typedef void* pointer; typedef const void* const_pointer; // reference-to-void members are impossible. typedef void value_type; template <class U> struct rebind { typedef malloc_allocator<U> other; }; }; template<typename T> class malloc_allocator { public: typedef size_t size_type; typedef std::ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template <class U> struct rebind { typedef malloc_allocator<U> other; }; malloc_allocator() throw() {} malloc_allocator(const malloc_allocator &/*other*/) throw() {} template<typename U> malloc_allocator(const malloc_allocator<U>&) throw() {} ~malloc_allocator() throw() {} // nothing to see here pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } size_type max_size() const throw() { return 0x8000000; } void construct(pointer p, const T& val) { new(p) T(val); } void destroy(pointer p) { p->~T(); } // to copy ctor or compare with private data, do this template<typename U> friend class __base_allocator; //======================================= // the "special" kind // allocation function, just use malloc here pointer allocate(size_type n, typename malloc_allocator<void>::const_pointer hint=0) { pointer p = static_cast<pointer>( malloc(n * sizeof(T)) ); if(!p) throw std::bad_alloc(); #ifdef __REPORT_ALLOCS__ std::cout << "malloc_allocator::allocate: " << n << " * " << sizeof(T) << ", hint: 0x" << std::hex << hint << " returning: 0x" << static_cast<malloc_allocator<void>::const_pointer>(p) << std::endl; #endif return p; } // deallocation, use free() void deallocate(pointer p, size_type n) { #ifdef __REPORT_ALLOCS__ std::cout << "malloc_allocator::deallocate: " << std::hex << static_cast<malloc_allocator<void>::const_pointer>(p) << ", size " << std::dec << n << " * " << sizeof(T) << std::endl; #endif if(p) free(p); } }; // then ofc these template<typename T1, typename T2> bool operator==(const malloc_allocator<T1> &a, const malloc_allocator<T2> &b) throw() { return true; } template<typename T1, typename T2> bool operator!=(const malloc_allocator<T1> &a, const malloc_allocator<T2> &b) throw() { return false; } //=================================================== // another more advanced allocator, suitable for lists and maps // that has the allocation policy of one at a time // (for platforms that actually do that for these containers!) // this is basically a bitmap allocator, just renamed to block_allocator // because it uses list of blocks where each block has N slots // block-size policy, 32-bit and smaller objects have block-size of 32 // larger objects have 8 (optimize further? utilize 64-bits on 64-bit archs?) template <typename T, int number_of_slots=(sizeof(T) > 4 ? 8 : 32)> class block_allocator; // specialize for void: template <int number_of_slots> class block_allocator<void,number_of_slots> { public: typedef void* pointer; typedef const void* const_pointer; // reference-to-void members are impossible. typedef void value_type; template <class U> struct rebind { typedef block_allocator<U> other; }; }; template <class T, int _number_of_slots> class block_allocator { public: typedef size_t size_type; typedef std::ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template <class U> struct rebind { typedef block_allocator<U> other; }; //=========================== /* This allocator keeps a shared list of blocks to allocate from. Each block has number of slots to allocate from. Amount of slots is static, while each block is dynamically allocated/free'd as necessary. */ // invidual block struct block_block { typedef int_32_64::type bitmask_t; block_block *prev; block_block *next; bitmask_t slots; T ptr[_number_of_slots]; static const bitmask_t fullmask = (1<<_number_of_slots) - 1; // very simple constructor block_block() { prev = next = 0; slots = 0; } // returns true if this block has slots available bool hasroom() { return (slots & fullmask) != fullmask; } // returns true if block is all empty bool isempty() { return (slots == 0); } // allocate a slot (excepts that the block has been checked with hasroom) pointer allocate() { // unoptimized scan of non-free elements for(int i = 0; i < _number_of_slots; i++) { if( !(slots & (1<<i)) ) { // mark allocated slots |= (1<<i); #ifdef __REPORT_ALLOCS__ std::cout << "block_block::allocate found slot " << i << " @ " << (void*)(&ptr[i]) << std::endl << std::flush; #endif return &ptr[i]; } } #ifdef __REPORT_ALLOCS__ std::cout << "block_block::allocate couldnt find slot " << std::endl; #endif return 0; } // deallocate a slot void deallocate(pointer p) { bitmask_t bit = (1 << (bitmask_t)(p - ptr)); #ifdef __REPORT_ALLOCS__ std::cout << "block_block::deallocate freeing slot " << int(log2(float(bit))) << " @ " << (void*)(&ptr[bit]) << std::endl << std::flush; #endif slots &= ~bit; } // tell me if given pointer is inside this block bool inblock(pointer p) { return (p >= ptr && p < &(ptr[_number_of_slots])); } }; // container of blocks (refcounted so that you can share this) struct block_list { int_32_64::type refcount; // keep same size as pointers for padding block_block block; // we always keep this one block here block_block *head; block_block *tail; block_list() : refcount(1), block(), head(&block), tail(&block) {} // internal system allocation functions void *_alloc( size_t s ) { return malloc(s); } void _free( void *p ) { free( p ); } /* so, algorithm goes like this: if 'head' has slots available, call r = head->allocate(); if 'head' has no slots available and 'head' != 'tail' move 'head' to 'tail' (alt. approach is to 'float' 'head' towards 'tail') else allocate new 'head' return head->allocate() (this surely will have slots avail) */ pointer allocate() { // blocks with free space are always in the beginning if(head->hasroom()) { pointer r = head->allocate(); // if this block doesnt have anymore space, move it to tail // (alt. float up) if(!head->hasroom() && head != tail) { tail->next = head; head->prev = tail; tail = head; head = head->next; // tail and head are now updated head->prev = tail->next = 0; } return r; } else { // allocate new head with space block_block *block = new(_alloc(sizeof(*block))) block_block(); #ifdef __REPORT_ALLOCS__ std::cout << "block_list::allocate allocated new block @ " << (void*)block << std::endl << std::flush; #endif block->next = head; head->prev = block; head = block; return head->allocate(); } return 0; } /* algo to deallocate goes like this: find the block that contains p b->deallocate() if 'b' is empty and 'b' is not 'block', remove it from the list and 'delete' otherwise move to 'head' (alt. approach is to 'float' 'b' towards 'head') */ void deallocate(pointer p) { bool wasfull; block_block *iter; for(iter = head; iter != 0; iter = iter->next) { if(iter->inblock(p)) break; } // exceptionally throw from here (other functions just return 0) if(!iter) throw std::bad_alloc(); wasfull = !iter->hasroom(); iter->deallocate(p); // if we just emptied this block, we can deallocate it if(iter->isempty() && iter != &block) { // detach (TODO: function) if(iter->prev) iter->prev->next = iter->next; if(iter->next) iter->next->prev = iter->prev; if(iter == head) head = iter->next; if(iter == tail) tail = iter->prev; _free( iter ); } else if(wasfull && iter != head) { // move block back to head (alt. float downwards) if(iter->prev) iter->prev->next = iter->next; if(iter->next) iter->next->prev = iter->prev; iter->next = head; iter->prev = 0; head->prev = iter; head = iter; } } }; //=========================== block_allocator() throw() { blocks = &blocks_static; } block_allocator(const block_allocator &other) throw() { blocks = other.blocks; blocks->refcount++; } template <class U, int __number_of_slots> block_allocator(const block_allocator<U, __number_of_slots> &other) throw() { /* we can only use the blocks from the other allocator if its the same templation type, any wa */ blocks = &blocks_static; } ~block_allocator() throw() { blocks->refcount--; /* if(blocks->refcount <= 0) { blocks->~block_list(); _free( blocks ); } */ }; pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } size_type max_size() const throw() { return 0x1; } void construct(pointer p, const T& val) { new(p) T(val); } void destroy(pointer p) { p->~T(); } pointer allocate(size_type, typename block_allocator<void, _number_of_slots>::const_pointer hint = 0) { pointer r = blocks->allocate(); if(!r) throw std::bad_alloc(); return r; } void deallocate(pointer p, size_type n) { if(p) blocks->deallocate(p); } private: friend class block_block; friend class block_list; // to copy ctor or compare with private data, do this template<typename U, int __number_of_slots> friend class block_allocator; block_list *blocks; // static instantiation of blocks of same type // TODO: find a way to instantiate blocks of same size static block_list blocks_static; static const int number_of_slots = _number_of_slots; }; // static instantiation of blocks of same type template<typename T, int _number_of_slots> typename block_allocator<T, _number_of_slots>::block_list block_allocator<T, _number_of_slots>::blocks_static; // then ofc these template<typename T1, typename T2> bool operator==(const block_allocator<T1> &a, const block_allocator<T2> &b) throw() { return a.blocks == b.blocks; } template<typename T1, typename T2> bool operator!=(const block_allocator<T1> &a, const block_allocator<T2> &b) throw() { return a.blocks != b.blocks; } } #endif // ALLOCATOR_H_INCLUDED
[ [ [ 1, 489 ] ] ]
cca3c70faa79dd51d741278293c15bc841a1e7ca
4a99fa98abd0285bc3b5671f237b932114123340
/physics/LinearMath/btVector3.h
25522e27d1ed26c8b54abd685f1b9224222018d9
[]
no_license
automenta/crittergod1.5
937cd925a4ba57b3e8cfa4899a81ba24fe3e4138
4786fe9d621c0e61cdd43ca3a363bfce6510e3c0
refs/heads/master
2020-12-24T16:58:32.854270
2010-04-12T03:25:39
2010-04-12T03:25:39
520,917
1
0
null
null
null
null
UTF-8
C++
false
false
20,232
h
/* Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SIMD__VECTOR3_H #define SIMD__VECTOR3_H #include "btScalar.h" #include "btMinMax.h" /**@brief btVector3 can be used to represent 3D points and vectors. * It has an un-used w component to suit 16-byte alignment when btVector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user * Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers */ ATTRIBUTE_ALIGNED16(class) btVector3 { public: #if defined (__SPU__) && defined (__CELLOS_LV2__) btScalar m_floats[4]; public: SIMD_FORCE_INLINE const vec_float4& get128() const { return *((const vec_float4*)&m_floats[0]); } public: #else //__CELLOS_LV2__ __SPU__ #ifdef BT_USE_SSE // WIN32 union { __m128 mVec128; btScalar m_floats[4]; }; SIMD_FORCE_INLINE __m128 get128() const { return mVec128; } SIMD_FORCE_INLINE void set128(__m128 v128) { mVec128 = v128; } #else btScalar m_floats[4]; #endif #endif //__CELLOS_LV2__ __SPU__ public: /**@brief No initialization constructor */ SIMD_FORCE_INLINE btVector3() {} /**@brief Constructor from scalars * @param x X value * @param y Y value * @param z Z value */ SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z) { m_floats[0] = x; m_floats[1] = y; m_floats[2] = z; m_floats[3] = btScalar(0.); } /**@brief Add a vector to this one * @param The vector to add to this one */ SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v) { m_floats[0] += v.m_floats[0]; m_floats[1] += v.m_floats[1];m_floats[2] += v.m_floats[2]; return *this; } /**@brief Subtract a vector from this one * @param The vector to subtract */ SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) { m_floats[0] -= v.m_floats[0]; m_floats[1] -= v.m_floats[1];m_floats[2] -= v.m_floats[2]; return *this; } /**@brief Scale the vector * @param s Scale factor */ SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s) { m_floats[0] *= s; m_floats[1] *= s;m_floats[2] *= s; return *this; } /**@brief Inversely scale the vector * @param s Scale factor to divide by */ SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) { btFullAssert(s != btScalar(0.0)); return *this *= btScalar(1.0) / s; } /**@brief Return the dot product * @param v The other vector in the dot product */ SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const { return m_floats[0] * v.m_floats[0] + m_floats[1] * v.m_floats[1] +m_floats[2] * v.m_floats[2]; } /**@brief Return the length of the vector squared */ SIMD_FORCE_INLINE btScalar length2() const { return dot(*this); } /**@brief Return the length of the vector */ SIMD_FORCE_INLINE btScalar length() const { return btSqrt(length2()); } /**@brief Return the distance squared between the ends of this and another vector * This is symantically treating the vector like a point */ SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const; /**@brief Return the distance between the ends of this and another vector * This is symantically treating the vector like a point */ SIMD_FORCE_INLINE btScalar distance(const btVector3& v) const; /**@brief Normalize this vector * x^2 + y^2 + z^2 = 1 */ SIMD_FORCE_INLINE btVector3& normalize() { return *this /= length(); } /**@brief Return a normalized version of this vector */ SIMD_FORCE_INLINE btVector3 normalized() const; /**@brief Rotate this vector * @param wAxis The axis to rotate about * @param angle The angle to rotate by */ SIMD_FORCE_INLINE btVector3 rotate( const btVector3& wAxis, const btScalar angle ); /**@brief Return the angle between this and another vector * @param v The other vector */ SIMD_FORCE_INLINE btScalar angle(const btVector3& v) const { btScalar s = btSqrt(length2() * v.length2()); btFullAssert(s != btScalar(0.0)); return btAcos(dot(v) / s); } /**@brief Return a vector will the absolute values of each element */ SIMD_FORCE_INLINE btVector3 absolute() const { return btVector3( btFabs(m_floats[0]), btFabs(m_floats[1]), btFabs(m_floats[2])); } /**@brief Return the cross product between this and another vector * @param v The other vector */ SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const { return btVector3( m_floats[1] * v.m_floats[2] -m_floats[2] * v.m_floats[1], m_floats[2] * v.m_floats[0] - m_floats[0] * v.m_floats[2], m_floats[0] * v.m_floats[1] - m_floats[1] * v.m_floats[0]); } SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVector3& v2) const { return m_floats[0] * (v1.m_floats[1] * v2.m_floats[2] - v1.m_floats[2] * v2.m_floats[1]) + m_floats[1] * (v1.m_floats[2] * v2.m_floats[0] - v1.m_floats[0] * v2.m_floats[2]) + m_floats[2] * (v1.m_floats[0] * v2.m_floats[1] - v1.m_floats[1] * v2.m_floats[0]); } /**@brief Return the axis with the smallest value * Note return values are 0,1,2 for x, y, or z */ SIMD_FORCE_INLINE int minAxis() const { return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2); } /**@brief Return the axis with the largest value * Note return values are 0,1,2 for x, y, or z */ SIMD_FORCE_INLINE int maxAxis() const { return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0); } SIMD_FORCE_INLINE int furthestAxis() const { return absolute().minAxis(); } SIMD_FORCE_INLINE int closestAxis() const { return absolute().maxAxis(); } SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const btVector3& v1, btScalar rt) { btScalar s = btScalar(1.0) - rt; m_floats[0] = s * v0.m_floats[0] + rt * v1.m_floats[0]; m_floats[1] = s * v0.m_floats[1] + rt * v1.m_floats[1]; m_floats[2] = s * v0.m_floats[2] + rt * v1.m_floats[2]; //don't do the unused w component // m_co[3] = s * v0[3] + rt * v1[3]; } SIMD_FORCE_INLINE void setInterpolate3x(btVector3* v0, btVector3* v1, btScalar rt) { btScalar s = btScalar(1.0) - rt; m_floats[0] = s * v0->m_floats[0] + rt * v1->m_floats[0]; m_floats[1] = s * v0->m_floats[1] + rt * v1->m_floats[1]; m_floats[2] = s * v0->m_floats[2] + rt * v1->m_floats[2]; //don't do the unused w component // m_co[3] = s * v0[3] + rt * v1[3]; } /**@brief Return the linear interpolation between this and another vector * @param v The other vector * @param t The ration of this to v (t = 0 => return this, t=1 => return other) */ SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar& t) const { return btVector3(m_floats[0] + (v.m_floats[0] - m_floats[0]) * t, m_floats[1] + (v.m_floats[1] - m_floats[1]) * t, m_floats[2] + (v.m_floats[2] -m_floats[2]) * t); } /**@brief Elementwise multiply this vector by the other * @param v The other vector */ SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v) { m_floats[0] *= v.m_floats[0]; m_floats[1] *= v.m_floats[1];m_floats[2] *= v.m_floats[2]; return *this; } /**@brief Return the x value */ SIMD_FORCE_INLINE const btScalar& getX() const { return m_floats[0]; } /**@brief Return the y value */ SIMD_FORCE_INLINE const btScalar& getY() const { return m_floats[1]; } /**@brief Return the z value */ SIMD_FORCE_INLINE const btScalar& getZ() const { return m_floats[2]; } /**@brief Set the x value */ SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;}; /**@brief Set the y value */ SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;}; /**@brief Set the z value */ SIMD_FORCE_INLINE void setZ(btScalar z) {m_floats[2] = z;}; /**@brief Set the w value */ SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;}; /**@brief Return the x value */ SIMD_FORCE_INLINE const btScalar& x() const { return m_floats[0]; } /**@brief Return the y value */ SIMD_FORCE_INLINE const btScalar& y() const { return m_floats[1]; } /**@brief Return the z value */ SIMD_FORCE_INLINE const btScalar& z() const { return m_floats[2]; } /**@brief Return the w value */ SIMD_FORCE_INLINE const btScalar& w() const { return m_floats[3]; } //SIMD_FORCE_INLINE btScalar& operator[](int i) { return (&m_floats[0])[i]; } //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return (&m_floats[0])[i]; } ///operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons. SIMD_FORCE_INLINE operator btScalar *() { return &m_floats[0]; } SIMD_FORCE_INLINE operator const btScalar *() const { return &m_floats[0]; } SIMD_FORCE_INLINE bool operator==(const btVector3& other) const { return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0])); } SIMD_FORCE_INLINE bool operator!=(const btVector3& other) const { return !(*this == other); } /**@brief Set each element to the max of the current values and the values of another btVector3 * @param other The other btVector3 to compare with */ SIMD_FORCE_INLINE void setMax(const btVector3& other) { btSetMax(m_floats[0], other.m_floats[0]); btSetMax(m_floats[1], other.m_floats[1]); btSetMax(m_floats[2], other.m_floats[2]); btSetMax(m_floats[3], other.w()); } /**@brief Set each element to the min of the current values and the values of another btVector3 * @param other The other btVector3 to compare with */ SIMD_FORCE_INLINE void setMin(const btVector3& other) { btSetMin(m_floats[0], other.m_floats[0]); btSetMin(m_floats[1], other.m_floats[1]); btSetMin(m_floats[2], other.m_floats[2]); btSetMin(m_floats[3], other.w()); } SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z) { m_floats[0]=x; m_floats[1]=y; m_floats[2]=z; m_floats[3] = btScalar(0.); } void getSkewSymmetricMatrix(btVector3* v0,btVector3* v1,btVector3* v2) const { v0->setValue(0. ,-z() ,y()); v1->setValue(z() ,0. ,-x()); v2->setValue(-y() ,x() ,0.); } void setZero() { setValue(btScalar(0.),btScalar(0.),btScalar(0.)); } SIMD_FORCE_INLINE bool isZero() const { return m_floats[0] == btScalar(0) && m_floats[1] == btScalar(0) && m_floats[2] == btScalar(0); } SIMD_FORCE_INLINE bool fuzzyZero() const { return length2() < SIMD_EPSILON; } SIMD_FORCE_INLINE void serialize(struct btVector3Data& dataOut) const; SIMD_FORCE_INLINE void deSerialize(const struct btVector3Data& dataIn); }; /**@brief Return the sum of two vectors (Point symantics)*/ SIMD_FORCE_INLINE btVector3 operator+(const btVector3& v1, const btVector3& v2) { return btVector3(v1.m_floats[0] + v2.m_floats[0], v1.m_floats[1] + v2.m_floats[1], v1.m_floats[2] + v2.m_floats[2]); } /**@brief Return the elementwise product of two vectors */ SIMD_FORCE_INLINE btVector3 operator*(const btVector3& v1, const btVector3& v2) { return btVector3(v1.m_floats[0] * v2.m_floats[0], v1.m_floats[1] * v2.m_floats[1], v1.m_floats[2] * v2.m_floats[2]); } /**@brief Return the difference between two vectors */ SIMD_FORCE_INLINE btVector3 operator-(const btVector3& v1, const btVector3& v2) { return btVector3(v1.m_floats[0] - v2.m_floats[0], v1.m_floats[1] - v2.m_floats[1], v1.m_floats[2] - v2.m_floats[2]); } /**@brief Return the negative of the vector */ SIMD_FORCE_INLINE btVector3 operator-(const btVector3& v) { return btVector3(-v.m_floats[0], -v.m_floats[1], -v.m_floats[2]); } /**@brief Return the vector scaled by s */ SIMD_FORCE_INLINE btVector3 operator*(const btVector3& v, const btScalar& s) { return btVector3(v.m_floats[0] * s, v.m_floats[1] * s, v.m_floats[2] * s); } /**@brief Return the vector scaled by s */ SIMD_FORCE_INLINE btVector3 operator*(const btScalar& s, const btVector3& v) { return v * s; } /**@brief Return the vector inversely scaled by s */ SIMD_FORCE_INLINE btVector3 operator/(const btVector3& v, const btScalar& s) { btFullAssert(s != btScalar(0.0)); return v * (btScalar(1.0) / s); } /**@brief Return the vector inversely scaled by s */ SIMD_FORCE_INLINE btVector3 operator/(const btVector3& v1, const btVector3& v2) { return btVector3(v1.m_floats[0] / v2.m_floats[0],v1.m_floats[1] / v2.m_floats[1],v1.m_floats[2] / v2.m_floats[2]); } /**@brief Return the dot product between two vectors */ SIMD_FORCE_INLINE btScalar btDot(const btVector3& v1, const btVector3& v2) { return v1.dot(v2); } /**@brief Return the distance squared between two vectors */ SIMD_FORCE_INLINE btScalar btDistance2(const btVector3& v1, const btVector3& v2) { return v1.distance2(v2); } /**@brief Return the distance between two vectors */ SIMD_FORCE_INLINE btScalar btDistance(const btVector3& v1, const btVector3& v2) { return v1.distance(v2); } /**@brief Return the angle between two vectors */ SIMD_FORCE_INLINE btScalar btAngle(const btVector3& v1, const btVector3& v2) { return v1.angle(v2); } /**@brief Return the cross product of two vectors */ SIMD_FORCE_INLINE btVector3 btCross(const btVector3& v1, const btVector3& v2) { return v1.cross(v2); } SIMD_FORCE_INLINE btScalar btTriple(const btVector3& v1, const btVector3& v2, const btVector3& v3) { return v1.triple(v2, v3); } /**@brief Return the linear interpolation between two vectors * @param v1 One vector * @param v2 The other vector * @param t The ration of this to v (t = 0 => return v1, t=1 => return v2) */ SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v1, const btVector3& v2, const btScalar& t) { return v1.lerp(v2, t); } SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const { return (v - *this).length2(); } SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const { return (v - *this).length(); } SIMD_FORCE_INLINE btVector3 btVector3::normalized() const { return *this / length(); } SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar angle ) { // wAxis must be a unit lenght vector btVector3 o = wAxis * wAxis.dot( *this ); btVector3 x = *this - o; btVector3 y; y = wAxis.cross( *this ); return ( o + x * btCos( angle ) + y * btSin( angle ) ); } class btVector4 : public btVector3 { public: SIMD_FORCE_INLINE btVector4() {} SIMD_FORCE_INLINE btVector4(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) : btVector3(x,y,z) { m_floats[3] = w; } SIMD_FORCE_INLINE btVector4 absolute4() const { return btVector4( btFabs(m_floats[0]), btFabs(m_floats[1]), btFabs(m_floats[2]), btFabs(m_floats[3])); } btScalar getW() const { return m_floats[3];} SIMD_FORCE_INLINE int maxAxis4() const { int maxIndex = -1; btScalar maxVal = btScalar(-BT_LARGE_FLOAT); if (m_floats[0] > maxVal) { maxIndex = 0; maxVal = m_floats[0]; } if (m_floats[1] > maxVal) { maxIndex = 1; maxVal = m_floats[1]; } if (m_floats[2] > maxVal) { maxIndex = 2; maxVal =m_floats[2]; } if (m_floats[3] > maxVal) { maxIndex = 3; maxVal = m_floats[3]; } return maxIndex; } SIMD_FORCE_INLINE int minAxis4() const { int minIndex = -1; btScalar minVal = btScalar(BT_LARGE_FLOAT); if (m_floats[0] < minVal) { minIndex = 0; minVal = m_floats[0]; } if (m_floats[1] < minVal) { minIndex = 1; minVal = m_floats[1]; } if (m_floats[2] < minVal) { minIndex = 2; minVal =m_floats[2]; } if (m_floats[3] < minVal) { minIndex = 3; minVal = m_floats[3]; } return minIndex; } SIMD_FORCE_INLINE int closestAxis4() const { return absolute4().maxAxis4(); } /**@brief Set x,y,z and zero w * @param x Value of x * @param y Value of y * @param z Value of z */ /* void getValue(btScalar *m) const { m[0] = m_floats[0]; m[1] = m_floats[1]; m[2] =m_floats[2]; } */ /**@brief Set the values * @param x Value of x * @param y Value of y * @param z Value of z * @param w Value of w */ SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z,const btScalar& w) { m_floats[0]=x; m_floats[1]=y; m_floats[2]=z; m_floats[3]=w; } }; ///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization SIMD_FORCE_INLINE void btSwapScalarEndian(const btScalar& sourceVal, btScalar& destVal) { #ifdef BT_USE_DOUBLE_PRECISION unsigned char* dest = (unsigned char*) &destVal; unsigned char* src = (unsigned char*) &sourceVal; dest[0] = src[7]; dest[1] = src[6]; dest[2] = src[5]; dest[3] = src[4]; dest[4] = src[3]; dest[5] = src[2]; dest[6] = src[1]; dest[7] = src[0]; #else unsigned char* dest = (unsigned char*) &destVal; unsigned char* src = (unsigned char*) &sourceVal; dest[0] = src[3]; dest[1] = src[2]; dest[2] = src[1]; dest[3] = src[0]; #endif //BT_USE_DOUBLE_PRECISION } ///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization SIMD_FORCE_INLINE void btSwapVector3Endian(const btVector3& sourceVec, btVector3& destVec) { for (int i=0;i<4;i++) { btSwapScalarEndian(sourceVec[i],destVec[i]); } } ///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization SIMD_FORCE_INLINE void btUnSwapVector3Endian(btVector3& vector) { btVector3 swappedVec; for (int i=0;i<4;i++) { btSwapScalarEndian(vector[i],swappedVec[i]); } vector = swappedVec; } SIMD_FORCE_INLINE void btPlaneSpace1 (const btVector3& n, btVector3& p, btVector3& q) { if (btFabs(n.z()) > SIMDSQRT12) { // choose p in y-z plane btScalar a = n[1]*n[1] + n[2]*n[2]; btScalar k = btRecipSqrt (a); p.setValue(0,-n[2]*k,n[1]*k); // set q = n x p q.setValue(a*k,-n[0]*p[2],n[0]*p[1]); } else { // choose p in x-y plane btScalar a = n.x()*n.x() + n.y()*n.y(); btScalar k = btRecipSqrt (a); p.setValue(-n.y()*k,n.x()*k,0); // set q = n x p q.setValue(-n.z()*p.y(),n.z()*p.x(),a*k); } } struct btVector3Data { btScalar m_floats[4]; }; SIMD_FORCE_INLINE void btVector3::serialize(struct btVector3Data& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = m_floats[i]; } SIMD_FORCE_INLINE void btVector3::deSerialize(const struct btVector3Data& dataIn) { for (int i=0;i<4;i++) m_floats[i] = dataIn.m_floats[i]; } #endif //SIMD__VECTOR3_H
[ [ [ 1, 702 ] ] ]
f0f9869477503644343cf8efa65a47e9d3922069
677f7dc99f7c3f2c6aed68f41c50fd31f90c1a1f
/SolidSBCCliSvc/SolidSBCCliConfigSocket.cpp
24f04a44b28f8892739276c8e383208a95d3c2c0
[]
no_license
M0WA/SolidSBC
0d743c71ec7c6f8cfe78bd201d0eb59c2a8fc419
3e9682e90a22650e12338785c368ed69a9cac18b
refs/heads/master
2020-04-19T14:40:36.625222
2011-12-02T01:50:05
2011-12-02T01:50:05
168,250,374
0
0
null
null
null
null
UTF-8
C++
false
false
3,971
cpp
// ServerConfigSocket.cpp : implementation file // #include "stdafx.h" #include "SolidSBCCliConfigSocket.h" CSolidSBCCliConfigSocket::CSolidSBCCliConfigSocket() : CSolidSBCSocketClient() , m_pszClientUUID(NULL) { } CSolidSBCCliConfigSocket::~CSolidSBCCliConfigSocket() { Close(); } bool CSolidSBCCliConfigSocket::OnConnect(bool bSuccess) { #ifdef _DEBUG { CString strMsg; strMsg.Format(_T("CSolidSBCCliConfigSocket::OnConnect(bool bSuccess = %d)"), bSuccess); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_DEBUG); } #endif if (bSuccess && SendConfigRequest()){ GetNextPacket(); } else { { CString strMsg; strMsg.Format(_T("Could not connect to config server.")); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_ERROR); } g_cClientService.ConnectionClosed(); } return bSuccess; } bool CSolidSBCCliConfigSocket::OnRead() { if ( ReceiveConfigResponse() ){ GetNextPacket(); return true;} else if ( m_vecTestConfigs.size() ){ { CString strMsg; strMsg.Format(_T("Fetched %d configs from config server."), m_vecTestConfigs.size()); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_INFO); } Close(); g_cClientService.StartResultConnection(); g_cClientService.StartTests(); return false;} else { { CString strMsg; strMsg.Format(_T("Could not fetch config from server.")); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_ERROR); } return false; } } bool CSolidSBCCliConfigSocket::SendConfigRequest(void) { { CString strMsg; strMsg.Format( _T("Requesting configs for this client.") ); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_INFO); } DWORD nNameSize = 1024; TCHAR szComputerName[1024] = {0}; GetComputerName(szComputerName,&nNameSize); USES_CONVERSION; CSolidSBCPacketConfigRequest configRequest(A2T(m_pszClientUUID),szComputerName); int nPacketSize = 0; PBYTE pPacketBytes = configRequest.GetPacketBytes(nPacketSize); u_long iMode = 0; ioctlsocket(m_hSocket, FIONBIO, &iMode); int nSent = send(m_hSocket,(char*)pPacketBytes,nPacketSize,0); DWORD dwError = GetLastError(); iMode = 1; ioctlsocket(m_hSocket, FIONBIO, &iMode); #ifdef _DEBUG { CString strMsg; strMsg.Format( _T("CSolidSBCCliConfigSocket::SendConfigRequest(): Sent config request. %d of %d byte(-s)\r\n %s"), nSent, nPacketSize, configRequest.GetXml()); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_DEBUG); } #endif if ( (nSent == -1) || ( nSent != nPacketSize )) { { CString strMsg; strMsg.Format( _T("Error while sending config request (%d)."), dwError); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_ERROR); } nSent = 0; } delete [] pPacketBytes; return nSent ? true : false; } bool CSolidSBCCliConfigSocket::ReceiveConfigResponse(void) { PBYTE pPacket = CSolidSBCPacket::ReceivePacket(m_hSocket); if(!pPacket) { #ifdef _DEBUG { CString strMsg; strMsg.Format(_T("CSolidSBCCliConfigSocket::ReceiveConfigResponse(): Error while receiving ConfigResponse packet")); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_DEBUG); } #endif return false; } /* if( ((PSSBC_PACKET_HEADER)pPacket)->nType != SSBC_PACKET_TYPE_CONFIG_RESPONSE) { return false; } */ CSolidSBCPacketConfigResponse response(pPacket); delete [] pPacket; CString strConfig = response.GetXml(); m_vecTestConfigs.push_back(strConfig); #ifdef _DEBUG { CString strMsg; strMsg.Format(_T("CSolidSBCCliConfigSocket::ReceiveConfigResponse(): Fetched config successfully from server:\r\n%s"),strConfig); CSolidSBCCliServiceWnd::LogServiceMessage(strMsg,SSBC_CLISVC_LOGMSG_TYPE_DEBUG); } #endif return true; }
[ "admin@bd7e3521-35e9-406e-9279-390287f868d3" ]
[ [ [ 1, 153 ] ] ]
af754fa67be7bd7ea48f1b778ca96d93842802d5
804e416433c8025d08829a08b5e79fe9443b9889
/src/network/socket.cpp
5179fff239ca6d566ee9db2c299492a6cff17235
[ "BSD-2-Clause" ]
permissive
cstrahan/argss
e77de08db335d809a482463c761fb8d614e11ba4
cc595bd9a1e4a2c079ea181ff26bdd58d9e65ace
refs/heads/master
2020-05-20T05:30:48.876372
2010-10-03T23:21:59
2010-10-03T23:21:59
1,682,890
1
0
null
null
null
null
UTF-8
C++
false
false
4,017
cpp
///////////////////////////////////////////////////////////////////////////// // ARGSS - Copyright (c) 2009 - 2010, Alejandro Marzini (vgvgf) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // Headers /////////////////////////////////////////////////////////// #include "socket.h" #include "argss/classes/aerror.h" Socket::Socket() { #ifdef WIN32 m_Socket = socket(AF_INET, SOCK_STREAM, AF_INET); #else m_Socket = socket(AF_INET, SOCK_STREAM, 0); #endif } void Socket::Connect(const std::string& host, unsigned short port) { struct sockaddr_in hostAddr; hostAddr.sin_family = AF_INET; #ifdef WIN32 hostAddr.sin_addr.s_addr = inet_addr(host.c_str()); #else (void)inet_pton(AF_INET, host.c_str(), &(hostAddr.sin_addr)); #endif hostAddr.sin_port = htons(port); if (connect(m_Socket, (struct sockaddr*)&hostAddr, sizeof(hostAddr))) { rb_raise(ARGSS::AError::id, "Could not connect to the host, make sure the host address is valid and the port is correct."); } } void Socket::Listen(unsigned short port, int maxclients) { struct sockaddr_in machineAddr; machineAddr.sin_family = AF_INET; machineAddr.sin_addr.s_addr = INADDR_ANY; machineAddr.sin_port = htons(port); if (bind(m_Socket, (struct sockaddr*)&machineAddr, sizeof(machineAddr))) { rb_raise(ARGSS::AError::id, "Could not bind the socket, port specified might be used."); return; } if (listen(m_Socket, maxclients)) { rb_raise(ARGSS::AError::id, "Could not set the socket to listening mode, make sure the arguments are right."); } } Buffer Socket::Receive() { Buffer buffer(0); unsigned short msglen = 0; if (recv(m_Socket, (char*)&msglen, 2, 0) <= 0) { rb_raise(ARGSS::AError::id, "Could not receive the message length."); } else { buffer = Buffer(msglen); char* pBufferData = buffer.GetData(); if (recv(m_Socket, pBufferData, msglen, 0) <= 0) { rb_raise(ARGSS::AError::id, "Could not receive the message."); } } return buffer; } void Socket::Send(Buffer buffer) { unsigned short bufferSize = (unsigned short)buffer.GetSize(); char* pFinalBuffer = new char[2 + bufferSize]; memcpy(pFinalBuffer, &bufferSize, 2); memcpy(pFinalBuffer + 2, buffer.GetData(), bufferSize); if (send(m_Socket, pFinalBuffer, 2 + bufferSize, 0) <= 0) { rb_raise(ARGSS::AError::id, "Could not send the message."); } delete[] pFinalBuffer; } void Socket::Shutdown() { if (m_Socket) { #ifdef WIN32 shutdown(m_Socket, SD_BOTH); #else shutdown(m_Socket, 0); #endif } } Socket::~Socket() { if (m_Socket) { Shutdown(); closesocket(m_Socket); } }
[ "vgvgf@a70b67f4-0116-4799-9eb2-a6e6dfe7dbda", "konom@a70b67f4-0116-4799-9eb2-a6e6dfe7dbda", "npepinpe@a70b67f4-0116-4799-9eb2-a6e6dfe7dbda" ]
[ [ [ 1, 25 ], [ 27, 29 ], [ 31, 31 ], [ 61, 61 ], [ 90, 90 ] ], [ [ 26, 26 ], [ 30, 30 ], [ 32, 43 ], [ 45, 45 ], [ 49, 60 ], [ 62, 89 ], [ 91, 117 ] ], [ [ 44, 44 ], [ 46, 48 ] ] ]
61e84cb308be345a63deaee5353d2e22dffc61a2
ef25bd96604141839b178a2db2c008c7da20c535
/src/src/Engine/Resources/MeshLoader.h
09613eed5e2aec745c186c749d0073078906bdbb
[]
no_license
OtterOrder/crock-rising
fddd471971477c397e783dc6dd1a81efb5dc852c
543dc542bb313e1f5e34866bd58985775acf375a
refs/heads/master
2020-12-24T14:57:06.743092
2009-07-15T17:15:24
2009-07-15T17:15:24
32,115,272
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,996
h
#pragma once //****************************************************************** #include <string> #include <vector> #include "TinyXml/tinyxml.h" #include "Core/Types/Vector.h" #include "Resource.h" using namespace std; //****************************************************************** #define NbFaceVertices 3 #define NbWeightsMax 4 struct Vertex { Vector4f m_Position; Vector3f m_Normal; Vector2f m_TexCoord; }; struct SkinnedVertex { Vector4f m_Position; Vector3f m_Normal; Vector2f m_TexCoord; Vector4f m_Bones; Vector4f m_Weights; }; struct NormalMappedVertex { Vector4f m_Position; Vector3f m_Normal; Vector2f m_TexCoord; Vector3f m_Tangent; Vector3f m_Binormal; }; struct SkinNormalMappedVertex { Vector4f m_Position; Vector3f m_Normal; Vector2f m_TexCoord; Vector3f m_Tangent; Vector3f m_Binormal; Vector4f m_Bones; Vector4f m_Weights; }; struct VertexBuffer { static enum VertexType { None, Default, Skinned, NormalMapped, SkinNormalMapped }; VertexType m_VertexType; u32 m_NbVertices; u32 m_Size; void* m_Datas; VertexBuffer (); ~VertexBuffer(); }; struct FaceVertex { int m_Position; int m_Normal; int m_TexCoord; int m_Tangent; int m_Binormal; bool operator == (const FaceVertex &faceVertex) { return ( m_Position == faceVertex.m_Position && m_Normal == faceVertex.m_Normal && m_TexCoord == faceVertex.m_TexCoord ); } bool operator != (const FaceVertex &faceVertex) { return ! (*this == faceVertex); } }; struct VertexSkinning { float m_Joint[NbWeightsMax]; float m_Weight[NbWeightsMax]; }; //****************************************************************** class MeshLoader { int m_iNbVertices, m_iNbFaces, m_iNbSkinnedVertices; // Vertex float **m_Positions, **m_Normals, **m_TexCoords; int m_iNbPositions, m_iNbNormals, m_iNbTexCoords; // Skinning int m_iNbWeights; float** m_Weights; VertexSkinning* m_SkinnedVertices; // Normal Mapping int m_iNbTangents; float** m_Tangents; int m_iNbBinormals; float** m_Binormals; // Faces FaceVertex *m_Faces; std::vector<D3DVERTEXELEMENT9> DxElements; // Vecteur d'éléments du vertex //Physic D3DXVECTOR3 m_ReglagePivot; //Vecteur qui permet de réajuster le pivot dans la physique. public: MeshLoader(void); virtual ~MeshLoader(void); ResourceResult Load (const char *sMeshPath, VertexBuffer& _VertexBuffer, int *&IndexBuffer, int &iNbIndex, IDirect3DVertexDeclaration9* &vertdecl); ResourceResult FillArrays (TiXmlNode* rootNode, VertexBuffer& _VertexBuffer, int *&IndexBuffer); // Remplit les tableaux de données ResourceResult ExtractArrayDatas (TiXmlNode* sourceNode, float** &Array, int &iNbElements, int &iNbMaxElements); // Extrait les données d'une balise ResourceResult ConvertTextToArray (const char* ArrayText, float** Array, int iCount, int iStride); // Remplit un double tableau de float à l'aide d'un texte ResourceResult ConvertTextToArray (const char* ArrayText, float* Array, int iCount); // Remplit un tableau de float à l'aide d'un texte ResourceResult ConvertTextToArray (const char* ArrayText, int* Array, int iCount); // Remplit un tableau de int à l'aide d'un texte ResourceResult FillVBArray (TiXmlNode* TrianglesNode, VertexBuffer& _VertexBuffer, int *&IndexBuffer); // Remplit le tableau de vertex void FillVertex (int VertexIndex, int FaceIndex, VertexBuffer& _VertexBuffer, int *&IndexBuffer); ResourceResult FillSkinArray (TiXmlNode* VertexWeightsNode); // Remplit le tableau de skinning ResourceResult FillFacesArray (TiXmlNode* TrianglesNode); // Remplit le tableau de faces D3DXVECTOR3 GetReglagePivot (){ return m_ReglagePivot; } };
[ "germain.mazac@7c6770cc-a6a4-11dd-91bf-632da8b6e10b", "mathieu.chabanon@7c6770cc-a6a4-11dd-91bf-632da8b6e10b", "berenger.mantoue@7c6770cc-a6a4-11dd-91bf-632da8b6e10b" ]
[ [ [ 1, 1 ], [ 45, 58 ], [ 66, 67 ], [ 107, 108 ], [ 111, 113 ] ], [ [ 2, 6 ], [ 8, 44 ], [ 59, 65 ], [ 68, 106 ], [ 109, 110 ], [ 114, 133 ], [ 137, 155 ], [ 158, 158 ] ], [ [ 7, 7 ], [ 134, 136 ], [ 156, 157 ] ] ]
f31b4aa58e199e8361fa5c5ffb3703276260b01c
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.5/cbear.berlios.de/windows/com/itypeinfo.hpp
80956acc7f6088f40f615d16970f844831b9629e
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
1,849
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) 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. */ #ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_ITYPEINFO_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_ITYPEINFO_HPP_INCLUDED #include <cbear.berlios.de/windows/com/object.hpp> #include <cbear.berlios.de/windows/com/exception.hpp> namespace cbear_berlios_de { namespace windows { namespace com { typedef object< ::ITypeInfo> itypeinfo; template<class T> class library_info; template<class T> class scoped_type_info { public: scoped_type_info() { Value = library_info<T>::type::typelib().gettypeinfoofguid<T>(); } static const itypeinfo &typeinfo() { return Value; } private: static itypeinfo Value; }; template<class T> itypeinfo scoped_type_info<T>::Value; } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 61 ] ] ]
56dc1e9f16af5691e79e8888045850ff2c77a621
ad80c85f09a98b1bfc47191c0e99f3d4559b10d4
/code/src/odetests/odetests.cc
72f50d17c5fdb9847c94402e0546cc8811167626
[]
no_license
DSPNerd/m-nebula
76a4578f5504f6902e054ddd365b42672024de6d
52a32902773c10cf1c6bc3dabefd2fd1587d83b3
refs/heads/master
2021-12-07T18:23:07.272880
2009-07-07T09:47:09
2009-07-07T09:47:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,552
cc
//-------------------------------------------------------------------- // odetests.cc - Test suite for OdePhysics module. // // (C) 2003 Vadim Macagon //-------------------------------------------------------------------- #include "kernel/nkernelserver.h" //#include "lua/nluaserver.h" #include "script/ntclserver.h" #include "kernel/nfileserver2.h" int main( int argc, char **argv ) { int retval = 0; //char* scriptServer = "nluaserver"; char* scriptServer = "ntclserver"; char* fileServer = "nfileserver2"; nKernelServer* ks = new nKernelServer(); if ( ks ) { // create a fileserver2 if ( ks->New( fileServer, "/sys/servers/file2" ) ) { // create script server //nScriptServer* ss = (nLuaServer*)ks->New( scriptServer, "/sys/servers/script" ); nScriptServer* ss = (nTclServer*)ks->New( scriptServer, "/sys/servers/script" ); if ( ss ) { const char* res = 0; //ss->RunScript( "../../data/odetests/start.lua", res ); ss->RunScript( "../../data/odetests/start.tcl", res ); if ( res ) printf( "%s\n", res ); ss->Release(); } else { retval = 10; printf( "Could not create script server object!\n" ); } } else { retval = 10; printf( "Could not create file server 2 object!\n" ); } delete ks; } else { retval = 10; printf( "Could not create nKernelServer object!\n" ); } getchar(); return retval; }
[ "plushe@411252de-2431-11de-b186-ef1da62b6547" ]
[ [ [ 1, 57 ] ] ]
466c77008865b1ce85eded0b6875b2659c716a22
cefb9faad36535ad8afa35bc60a317a144973232
/DataMiningExperiment/DataMiningExperiment/DMAlgorithm.h
0322c80521d8a5c0ee6cc1376c96a6c170412268
[]
no_license
anic/dmexperiment
29c609519e2df41f50eac65f9f96d61fe639c8ad
dd082a67dc852482a5e491e4c8bd998a714572e2
refs/heads/master
2021-01-16T18:20:44.795360
2009-01-05T15:42:18
2009-01-05T15:42:18
32,202,105
0
0
null
null
null
null
GB18030
C++
false
false
636
h
#pragma once #include <vector> #include "common.h" #include "TrDB.h" #include "FPTreeEx.h" typedef std::vector<Rule> Result; class DMAlgorithm { protected: Result m_result; public: /*! * \brief * 执行算法 * * \param trdb * 原始的数据库 * * \param nSupport * 用户定义的支持度 * * \returns * 算法是否执行成功,是则返回true;否则false * */ virtual bool execute(const TrDB& trdb,int nSupport) = 0; /*! * \brief * 获得算法返回的结果 * * \returns * 算法结果 */ Result& getResult(){return m_result;} };
[ "yaoancheng@ea3ec36c-c97b-11dd-a412-a1792178251d", "qw04ster@ea3ec36c-c97b-11dd-a412-a1792178251d" ]
[ [ [ 1, 4 ], [ 6, 40 ] ], [ [ 5, 5 ] ] ]
2fa4c9142bca482e8a2005c5b3f8197747f273c3
6581dacb25182f7f5d7afb39975dc622914defc7
/easyMule/easyMule/src/WorkLayer/SHAHashSet.cpp
c534976f634712f86ac8cf0d0695182e6f4ff0f4
[]
no_license
dice2019/alexlabonline
caeccad28bf803afb9f30b9e3cc663bb2909cc4f
4c433839965ed0cff99dad82f0ba1757366be671
refs/heads/master
2021-01-16T19:37:24.002905
2011-09-21T15:20:16
2011-09-21T15:20:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
37,990
cpp
/* * $Id: SHAHashSet.cpp 4483 2008-01-02 09:19:06Z soarchin $ * * this file is part of eMule * Copyright (C)2002-2006 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net ) * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "StdAfx.h" #include "shahashset.h" #include "opcodes.h" #include "otherfunctions.h" //#include "emule.h" #include "safefile.h" #include "knownfile.h" #include "preferences.h" #include "sha.h" #include "updownclient.h" #include "DownloadQueue.h" #include "partfile.h" #include "GlobalVariable.h" #include "resource.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // for this version the limits are set very high, they might be lowered later // to make a hash trustworthy, at least 10 unique Ips (255.255.128.0) must have send it // and if we have received more than one hash for the file, one hash has to be send by more than 95% of all unique IPs #define MINUNIQUEIPS_TOTRUST 10 // how many unique IPs most have send us a hash to make it trustworthy #define MINPERCENTAGE_TOTRUST 92 // how many percentage of clients most have sent the same hash to make it trustworthy CList<CAICHRequestedData> CAICHHashSet::m_liRequestedData; CMutex CAICHHashSet::m_mutKnown2File; ///////////////////////////////////////////////////////////////////////////////////////// ///CAICHHash CString CAICHHash::GetString() const{ return EncodeBase32(m_abyBuffer, HASHSIZE); } void CAICHHash::Read(CFileDataIO* file) { file->Read(m_abyBuffer,HASHSIZE); } void CAICHHash::Write(CFileDataIO* file) const{ file->Write(m_abyBuffer,HASHSIZE); } ///////////////////////////////////////////////////////////////////////////////////////// ///CAICHHashTree CAICHHashTree::CAICHHashTree(uint64 nDataSize, bool bLeftBranch, uint64 nBaseSize){ m_nDataSize = nDataSize; m_nBaseSize = nBaseSize; m_bIsLeftBranch = bLeftBranch; m_pLeftTree = NULL; m_pRightTree = NULL; m_bHashValid = false; } CAICHHashTree::~CAICHHashTree(){ delete m_pLeftTree; delete m_pRightTree; } // recursive CAICHHashTree* CAICHHashTree::FindHash(uint64 nStartPos, uint64 nSize, uint8* nLevel){ (*nLevel)++; if (*nLevel > 22){ // sanity ASSERT( false ); return false; } if (nStartPos + nSize > m_nDataSize){ // sanity ASSERT ( false ); return NULL; } if (nSize > m_nDataSize){ // sanity ASSERT ( false ); return NULL; } if (nStartPos == 0 && nSize == m_nDataSize){ // this is the searched hash return this; } else if (m_nDataSize <= m_nBaseSize){ // sanity // this is already the last level, cant go deeper ASSERT( false ); return NULL; } else{ uint64 nBlocks = m_nDataSize / m_nBaseSize + ((m_nDataSize % m_nBaseSize != 0 )? 1:0); uint64 nLeft = ( ((m_bIsLeftBranch) ? nBlocks+1:nBlocks) / 2)* m_nBaseSize; uint64 nRight = m_nDataSize - nLeft; if (nStartPos < nLeft){ if (nStartPos + nSize > nLeft){ // sanity ASSERT ( false ); return NULL; } if (m_pLeftTree == NULL) m_pLeftTree = new CAICHHashTree(nLeft, true, (nLeft <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pLeftTree->m_nDataSize == nLeft ); } return m_pLeftTree->FindHash(nStartPos, nSize, nLevel); } else{ nStartPos -= nLeft; if (nStartPos + nSize > nRight){ // sanity ASSERT ( false ); return NULL; } if (m_pRightTree == NULL) m_pRightTree = new CAICHHashTree(nRight, false, (nRight <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pRightTree->m_nDataSize == nRight ); } return m_pRightTree->FindHash(nStartPos, nSize, nLevel); } } } // recursive // calculates missing hash fromt he existing ones // overwrites existing hashs // fails if no hash is found for any branch bool CAICHHashTree::ReCalculateHash(CAICHHashAlgo* hashalg, bool bDontReplace){ ASSERT ( !( (m_pLeftTree != NULL) ^ (m_pRightTree != NULL)) ); if (m_pLeftTree && m_pRightTree){ if ( !m_pLeftTree->ReCalculateHash(hashalg, bDontReplace) || !m_pRightTree->ReCalculateHash(hashalg, bDontReplace) ) return false; if (bDontReplace && m_bHashValid) return true; if (m_pRightTree->m_bHashValid && m_pLeftTree->m_bHashValid){ hashalg->Reset(); hashalg->Add(m_pLeftTree->m_Hash.GetRawHash(), HASHSIZE); hashalg->Add(m_pRightTree->m_Hash.GetRawHash(), HASHSIZE); hashalg->Finish(m_Hash); m_bHashValid = true; return true; } else return m_bHashValid; } else return true; } bool CAICHHashTree::VerifyHashTree(CAICHHashAlgo* hashalg, bool bDeleteBadTrees){ if (!m_bHashValid){ ASSERT ( false ); if (bDeleteBadTrees){ delete m_pLeftTree; m_pLeftTree = NULL; delete m_pRightTree; m_pRightTree = NULL; } // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_HIGH,*/ false, _T("VerifyHashTree - No masterhash available")); return false; } // calculated missing hashs without overwriting anything if (m_pLeftTree && !m_pLeftTree->m_bHashValid) m_pLeftTree->ReCalculateHash(hashalg, true); if (m_pRightTree && !m_pRightTree->m_bHashValid) m_pRightTree->ReCalculateHash(hashalg, true); if ((m_pRightTree && m_pRightTree->m_bHashValid) ^ (m_pLeftTree && m_pLeftTree->m_bHashValid)){ // one branch can never be verified if (bDeleteBadTrees){ delete m_pLeftTree; m_pLeftTree = NULL; delete m_pRightTree; m_pRightTree = NULL; } // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_HIGH,*/ false, _T("VerifyHashSet failed - Hashtree incomplete")); return false; } if ((m_pRightTree && m_pRightTree->m_bHashValid) && (m_pLeftTree && m_pLeftTree->m_bHashValid)){ // check verify the hashs of both child nodes against my hash CAICHHash CmpHash; hashalg->Reset(); hashalg->Add(m_pLeftTree->m_Hash.GetRawHash(), HASHSIZE); hashalg->Add(m_pRightTree->m_Hash.GetRawHash(), HASHSIZE); hashalg->Finish(CmpHash); if (m_Hash != CmpHash){ if (bDeleteBadTrees){ delete m_pLeftTree; m_pLeftTree = NULL; delete m_pRightTree; m_pRightTree = NULL; } return false; } return m_pLeftTree->VerifyHashTree(hashalg, bDeleteBadTrees) && m_pRightTree->VerifyHashTree(hashalg, bDeleteBadTrees); } else // last hash in branch - nothing below to verify return true; } void CAICHHashTree::SetBlockHash(uint64 nSize, uint64 nStartPos, CAICHHashAlgo* pHashAlg){ ASSERT ( nSize <= EMBLOCKSIZE ); CAICHHashTree* pToInsert = FindHash(nStartPos, nSize); if (pToInsert == NULL){ // sanity ASSERT ( false ); // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Critical Error: Failed to Insert SHA-HashBlock, FindHash() failed!")); return; } //sanity if (pToInsert->m_nBaseSize != EMBLOCKSIZE || pToInsert->m_nDataSize != nSize){ ASSERT ( false ); // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Critical Error: Logical error on values in SetBlockHashFromData")); return; } pHashAlg->Finish(pToInsert->m_Hash); pToInsert->m_bHashValid = true; //DEBUG_ONLY(CGlobalVariable::QueueDebugLogLine(/*DLP_VERYLOW,*/ false, _T("Set ShaHash for block %u - %u (%u Bytes) to %s"), nStartPos, nStartPos + nSize, nSize, pToInsert->m_Hash.GetString()) ); } bool CAICHHashTree::CreatePartRecoveryData(uint64 nStartPos, uint64 nSize, CFileDataIO* fileDataOut, uint32 wHashIdent, bool b32BitIdent){ if (nStartPos + nSize > m_nDataSize){ // sanity ASSERT ( false ); return false; } if (nSize > m_nDataSize){ // sanity ASSERT ( false ); return false; } if (nStartPos == 0 && nSize == m_nDataSize){ // this is the searched part, now write all blocks of this part // hashident for this level will be adjsuted by WriteLowestLevelHash return WriteLowestLevelHashs(fileDataOut, wHashIdent, false, b32BitIdent); } else if (m_nDataSize <= m_nBaseSize){ // sanity // this is already the last level, cant go deeper ASSERT( false ); return false; } else{ wHashIdent <<= 1; wHashIdent |= (m_bIsLeftBranch) ? 1: 0; uint64 nBlocks = m_nDataSize / m_nBaseSize + ((m_nDataSize % m_nBaseSize != 0 )? 1:0); uint64 nLeft = ( ((m_bIsLeftBranch) ? nBlocks+1:nBlocks) / 2)* m_nBaseSize; uint64 nRight = m_nDataSize - nLeft; if (m_pLeftTree == NULL || m_pRightTree == NULL){ ASSERT( false ); return false; } if (nStartPos < nLeft){ if (nStartPos + nSize > nLeft || !m_pRightTree->m_bHashValid){ // sanity ASSERT ( false ); return false; } m_pRightTree->WriteHash(fileDataOut, wHashIdent, b32BitIdent); return m_pLeftTree->CreatePartRecoveryData(nStartPos, nSize, fileDataOut, wHashIdent, b32BitIdent); } else{ nStartPos -= nLeft; if (nStartPos + nSize > nRight || !m_pLeftTree->m_bHashValid){ // sanity ASSERT ( false ); return false; } m_pLeftTree->WriteHash(fileDataOut, wHashIdent, b32BitIdent); return m_pRightTree->CreatePartRecoveryData(nStartPos, nSize, fileDataOut, wHashIdent, b32BitIdent); } } } void CAICHHashTree::WriteHash(CFileDataIO* fileDataOut, uint32 wHashIdent, bool b32BitIdent) const{ ASSERT( m_bHashValid ); wHashIdent <<= 1; wHashIdent |= (m_bIsLeftBranch) ? 1: 0; if (!b32BitIdent){ ASSERT( wHashIdent <= 0xFFFF ); fileDataOut->WriteUInt16((uint16)wHashIdent); } else fileDataOut->WriteUInt32(wHashIdent); m_Hash.Write(fileDataOut); } // write lowest level hashs into file, ordered from left to right optional without identifier bool CAICHHashTree::WriteLowestLevelHashs(CFileDataIO* fileDataOut, uint32 wHashIdent, bool bNoIdent, bool b32BitIdent) const{ wHashIdent <<= 1; wHashIdent |= (m_bIsLeftBranch) ? 1: 0; if (m_pLeftTree == NULL && m_pRightTree == NULL){ if (m_nDataSize <= m_nBaseSize && m_bHashValid ){ if (!bNoIdent && !b32BitIdent){ ASSERT( wHashIdent <= 0xFFFF ); fileDataOut->WriteUInt16((uint16)wHashIdent); } else if (!bNoIdent && b32BitIdent) fileDataOut->WriteUInt32(wHashIdent); m_Hash.Write(fileDataOut); //theApp.AddDebugLogLine(false,_T("%s"),m_Hash.GetString(), wHashIdent, this); return true; } else{ ASSERT( false ); return false; } } else if (m_pLeftTree == NULL || m_pRightTree == NULL){ ASSERT( false ); return false; } else{ return m_pLeftTree->WriteLowestLevelHashs(fileDataOut, wHashIdent, bNoIdent, b32BitIdent) && m_pRightTree->WriteLowestLevelHashs(fileDataOut, wHashIdent, bNoIdent, b32BitIdent); } } // recover all low level hashs from given data. hashs are assumed to be ordered in left to right - no identifier used bool CAICHHashTree::LoadLowestLevelHashs(CFileDataIO* fileInput){ if (m_nDataSize <= m_nBaseSize){ // sanity // lowest level, read hash m_Hash.Read(fileInput); //theApp.AddDebugLogLine(false,m_Hash.GetString()); m_bHashValid = true; return true; } else{ uint64 nBlocks = m_nDataSize / m_nBaseSize + ((m_nDataSize % m_nBaseSize != 0 )? 1:0); uint64 nLeft = ( ((m_bIsLeftBranch) ? nBlocks+1:nBlocks) / 2)* m_nBaseSize; uint64 nRight = m_nDataSize - nLeft; if (m_pLeftTree == NULL) m_pLeftTree = new CAICHHashTree(nLeft, true, (nLeft <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pLeftTree->m_nDataSize == nLeft ); } if (m_pRightTree == NULL) m_pRightTree = new CAICHHashTree(nRight, false, (nRight <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pRightTree->m_nDataSize == nRight ); } return m_pLeftTree->LoadLowestLevelHashs(fileInput) && m_pRightTree->LoadLowestLevelHashs(fileInput); } } // write the hash, specified by wHashIdent, with Data from fileInput. bool CAICHHashTree::SetHash(CFileDataIO* fileInput, uint32 wHashIdent, sint8 nLevel, bool bAllowOverwrite){ if (nLevel == (-1)){ // first call, check how many level we need to go uint8 i; for (i = 0; i != 32 && (wHashIdent & 0x80000000) == 0; i++){ wHashIdent <<= 1; } if (i > 31){ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_HIGH,*/ false, _T("CAICHHashTree::SetHash - found invalid HashIdent (0)")); return false; } else{ nLevel = 31 - i; } } if (nLevel == 0){ // this is the searched hash if (m_bHashValid && !bAllowOverwrite){ // not allowed to overwrite this hash, however move the filepointer by reading a hash CAICHHash(file); return true; } m_Hash.Read(fileInput); m_bHashValid = true; return true; } else if (m_nDataSize <= m_nBaseSize){ // sanity // this is already the last level, cant go deeper ASSERT( false ); return false; } else{ // adjust ident to point the path to the next node wHashIdent <<= 1; nLevel--; uint64 nBlocks = m_nDataSize / m_nBaseSize + ((m_nDataSize % m_nBaseSize != 0 )? 1:0); uint64 nLeft = ( ((m_bIsLeftBranch) ? nBlocks+1:nBlocks) / 2)* m_nBaseSize; uint64 nRight = m_nDataSize - nLeft; if ((wHashIdent & 0x80000000) > 0){ if (m_pLeftTree == NULL) m_pLeftTree = new CAICHHashTree(nLeft, true, (nLeft <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pLeftTree->m_nDataSize == nLeft ); } return m_pLeftTree->SetHash(fileInput, wHashIdent, nLevel); } else{ if (m_pRightTree == NULL) m_pRightTree = new CAICHHashTree(nRight, false, (nRight <= PARTSIZE) ? EMBLOCKSIZE : PARTSIZE); else{ ASSERT( m_pRightTree->m_nDataSize == nRight ); } return m_pRightTree->SetHash(fileInput, wHashIdent, nLevel); } } } ///////////////////////////////////////////////////////////////////////////////////////// ///CAICHUntrustedHash bool CAICHUntrustedHash::AddSigningIP(uint32 dwIP){ dwIP &= 0x00F0FFFF; // we use only the 20 most significant bytes for unique IPs for (int i=0; i < m_adwIpsSigning.GetCount(); i++){ if (m_adwIpsSigning[i] == dwIP) return false; } m_adwIpsSigning.Add(dwIP); return true; } ///////////////////////////////////////////////////////////////////////////////////////// ///CAICHHashSet CAICHHashSet::CAICHHashSet(CKnownFile* pOwner) : m_pHashTree(0, true, PARTSIZE) { m_eStatus = AICH_EMPTY; m_pOwner = pOwner; } CAICHHashSet::~CAICHHashSet(void) { FreeHashSet(); } bool CAICHHashSet::CreatePartRecoveryData(uint64 nPartStartPos, CFileDataIO* fileDataOut, bool bDbgDontLoad){ ASSERT( m_pOwner ); if (m_pOwner->IsPartFile() || m_eStatus != AICH_HASHSETCOMPLETE){ ASSERT( false ); return false; } if (m_pHashTree.m_nDataSize <= EMBLOCKSIZE){ ASSERT( false ); return false; } if (!bDbgDontLoad){ if (!LoadHashSet()){ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Created RecoveryData error: failed to load hashset (file: %s)"), m_pOwner->GetFileName() ); SetStatus(AICH_ERROR); return false; } } bool bResult; uint8 nLevel = 0; uint32 nPartSize = (uint32)min(PARTSIZE, (uint64)m_pOwner->GetFileSize()-nPartStartPos); m_pHashTree.FindHash(nPartStartPos, nPartSize,&nLevel); uint16 nHashsToWrite = (uint16)((nLevel-1) + nPartSize/EMBLOCKSIZE + ((nPartSize % EMBLOCKSIZE != 0 )? 1:0)); const bool bUse32BitIdentifier = m_pOwner->IsLargeFile(); if (bUse32BitIdentifier) fileDataOut->WriteUInt16(0); // no 16bit hashs to write fileDataOut->WriteUInt16(nHashsToWrite); uint32 nCheckFilePos = (UINT)fileDataOut->GetPosition(); if (m_pHashTree.CreatePartRecoveryData(nPartStartPos, nPartSize, fileDataOut, 0, bUse32BitIdentifier)){ if (nHashsToWrite*(HASHSIZE+(bUse32BitIdentifier? 4:2)) != fileDataOut->GetPosition() - nCheckFilePos){ ASSERT( false ); // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Created RecoveryData has wrong length (file: %s)"), m_pOwner->GetFileName() ); bResult = false; SetStatus(AICH_ERROR); } else bResult = true; } else{ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to create RecoveryData for %s"), m_pOwner->GetFileName() ); bResult = false; SetStatus(AICH_ERROR); } if (!bUse32BitIdentifier) fileDataOut->WriteUInt16(0); // no 32bit hashs to write if (!bDbgDontLoad){ FreeHashSet(); } return bResult; } bool CAICHHashSet::ReadRecoveryData(uint64 nPartStartPos, CSafeMemFile* fileDataIn){ if (/*TODO !m_pOwner->IsPartFile() ||*/ !(m_eStatus == AICH_VERIFIED || m_eStatus == AICH_TRUSTED) ){ ASSERT( false ); return false; } /* V2 AICH Hash Packet: <count1 uint16> 16bit-hashs-to-read (<identifier uint16><hash HASHSIZE>)[count1] AICH hashs <count2 uint16> 32bit-hashs-to-read (<identifier uint32><hash HASHSIZE>)[count2] AICH hashs */ // at this time we check the recoverydata for the correct ammounts of hashs only // all hash are then taken into the tree, depending on there hashidentifier (except the masterhash) uint8 nLevel = 0; uint32 nPartSize = (uint32)min(PARTSIZE, (uint64)m_pOwner->GetFileSize()-nPartStartPos); m_pHashTree.FindHash(nPartStartPos, nPartSize,&nLevel); uint16 nHashsToRead = (uint16)((nLevel-1) + nPartSize/EMBLOCKSIZE + ((nPartSize % EMBLOCKSIZE != 0 )? 1:0)); // read hashs with 16 bit identifier uint16 nHashsAvailable = fileDataIn->ReadUInt16(); if (fileDataIn->GetLength()-fileDataIn->GetPosition() < nHashsToRead*(HASHSIZE+2) || (nHashsToRead != nHashsAvailable && nHashsAvailable != 0)){ // this check is redunant, CSafememfile would catch such an error too // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Received datasize/amounts of hashs was invalid (1)"), m_pOwner->GetFileName() ); return false; } // Comment UI //DEBUG_ONLY( CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("read RecoveryData for %s - Received packet with %u 16bit hash identifiers)"), m_pOwner->GetFileName(), nHashsAvailable ) ); for (uint32 i = 0; i != nHashsAvailable; i++){ uint16 wHashIdent = fileDataIn->ReadUInt16(); if (wHashIdent == 1 /*never allow masterhash to be overwritten*/ || !m_pHashTree.SetHash(fileDataIn, wHashIdent,(-1), false)) { // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Error when trying to read hash into tree (1)"), m_pOwner->GetFileName() ); VerifyHashTree(true); // remove invalid hashs which we have already written return false; } } // read hashs with 32bit identifier if (nHashsAvailable == 0 && fileDataIn->GetLength() - fileDataIn->GetPosition() >= 2){ nHashsAvailable = fileDataIn->ReadUInt16(); if (fileDataIn->GetLength()-fileDataIn->GetPosition() < nHashsToRead*(HASHSIZE+4) || (nHashsToRead != nHashsAvailable && nHashsAvailable != 0)){ // this check is redunant, CSafememfile would catch such an error too // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Received datasize/amounts of hashs was invalid (2)"), m_pOwner->GetFileName() ); return false; } // Comment UI //DEBUG_ONLY( CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("read RecoveryData for %s - Received packet with %u 32bit hash identifiers)"), m_pOwner->GetFileName(), nHashsAvailable ) ); for (uint32 i = 0; i != nHashsToRead; i++){ uint32 wHashIdent = fileDataIn->ReadUInt32(); if (wHashIdent == 1 /*never allow masterhash to be overwritten*/ || wHashIdent > 0x400000 || !m_pHashTree.SetHash(fileDataIn, wHashIdent,(-1), false)) { // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Error when trying to read hash into tree (2)"), m_pOwner->GetFileName() ); VerifyHashTree(true); // remove invalid hashs which we have already written return false; } } } if (nHashsAvailable == 0){ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Packet didn't contained any hashs"), m_pOwner->GetFileName() ); return false; } if (VerifyHashTree(true)){ // some final check if all hashs we wanted are there for (uint32 nPartPos = 0; nPartPos < nPartSize; nPartPos += EMBLOCKSIZE){ CAICHHashTree* phtToCheck = m_pHashTree.FindHash(nPartStartPos+nPartPos, min(EMBLOCKSIZE, nPartSize-nPartPos)); if (phtToCheck == NULL || !phtToCheck->m_bHashValid){ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Error while verifying presence of all lowest level hashs"), m_pOwner->GetFileName() ); return false; } } // all done return true; } else{ // Comment UI //CGlobalVariable::QueueDebugLogLine(/*DLP_VERYHIGH,*/ false, _T("Failed to read RecoveryData for %s - Verifying received hashtree failed"), m_pOwner->GetFileName() ); return false; } } // this function is only allowed to be called right after successfully calculating the hashset (!) // will delete the hashset, after saving to free the memory bool CAICHHashSet::SaveHashSet(){ if (m_eStatus != AICH_HASHSETCOMPLETE){ ASSERT( false ); return false; } if ( !m_pHashTree.m_bHashValid || m_pHashTree.m_nDataSize != m_pOwner->GetFileSize()){ ASSERT( false ); return false; } CSingleLock lockKnown2Met(&m_mutKnown2File, false); if (!lockKnown2Met.Lock(5000)){ return false; } CString fullpath = thePrefs.GetMuleDirectory(EMULE_CONFIGDIR); fullpath.Append(KNOWN2_MET_FILENAME); CSafeFile file; CFileException fexp; if (!file.Open(fullpath,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){ if (fexp.m_cause != CFileException::fileNotFound){ CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); TCHAR szError[MAX_CFEXP_ERRORMSG]; if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){ strError += _T(" - "); strError += szError; } // Comment UI CGlobalVariable::QueueLogLine(true, _T("%s"), strError); } return false; } try { //setvbuf(file.m_pStream, NULL, _IOFBF, 16384); uint8 header = file.ReadUInt8(); if (header != KNOWN2_MET_VERSION){ AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName()); } // first we check if the hashset we want to write is already stored CAICHHash CurrentHash; uint32 nExistingSize = (UINT)file.GetLength(); uint32 nHashCount; while (file.GetPosition() < nExistingSize){ CurrentHash.Read(&file); if (m_pHashTree.m_Hash == CurrentHash){ // this hashset if already available, no need to save it again return true; } nHashCount = file.ReadUInt32(); if (file.GetPosition() + nHashCount*HASHSIZE > nExistingSize){ AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName()); } // skip the rest of this hashset file.Seek(nHashCount*HASHSIZE, CFile::current); } // write hashset m_pHashTree.m_Hash.Write(&file); nHashCount = (uint32)((PARTSIZE/EMBLOCKSIZE + ((PARTSIZE % EMBLOCKSIZE != 0)? 1 : 0)) * (m_pHashTree.m_nDataSize/PARTSIZE)); if (m_pHashTree.m_nDataSize % PARTSIZE != 0) nHashCount += (uint32)((m_pHashTree.m_nDataSize % PARTSIZE)/EMBLOCKSIZE + (((m_pHashTree.m_nDataSize % PARTSIZE) % EMBLOCKSIZE != 0)? 1 : 0)); file.WriteUInt32(nHashCount); if (!m_pHashTree.WriteLowestLevelHashs(&file, 0, true, true)){ // thats bad... really file.SetLength(nExistingSize); // Comment UI //CGlobalVariable::QueueDebugLogLine(true, _T("Failed to save HashSet: WriteLowestLevelHashs() failed!")); return false; } if (file.GetLength() != nExistingSize + (nHashCount+1)*HASHSIZE + 4){ // thats even worse file.SetLength(nExistingSize); // Comment UI //CGlobalVariable::QueueDebugLogLine(true, _T("Failed to save HashSet: Calculated and real size of hashset differ!")); return false; } // Comment UI //CGlobalVariable::QueueDebugLogLine(false, _T("Sucessfully saved eMuleAC Hashset, %u Hashs + 1 Masterhash written"), nHashCount); file.Flush(); file.Close(); } catch(CFileException* error){ // Comment UI if (error->m_cause == CFileException::endOfFile) CGlobalVariable::QueueLogLine(true, GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME); else{ TCHAR buffer[MAX_CFEXP_ERRORMSG]; error->GetErrorMessage(buffer, ARRSIZE(buffer)); CGlobalVariable::QueueLogLine(true,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer); } error->Delete(); return false; } FreeHashSet(); return true; } bool CAICHHashSet::LoadHashSet(){ if (m_eStatus != AICH_HASHSETCOMPLETE){ ASSERT( false ); return false; } if ( !m_pHashTree.m_bHashValid || m_pHashTree.m_nDataSize != m_pOwner->GetFileSize() || m_pHashTree.m_nDataSize == 0){ ASSERT( false ); return false; } CString fullpath = thePrefs.GetMuleDirectory(EMULE_CONFIGDIR); fullpath.Append(KNOWN2_MET_FILENAME); CSafeFile file; CFileException fexp; if (!file.Open(fullpath,CFile::modeCreate|CFile::modeRead|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){ if (fexp.m_cause != CFileException::fileNotFound){ CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); TCHAR szError[MAX_CFEXP_ERRORMSG]; if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){ strError += _T(" - "); strError += szError; } CGlobalVariable::QueueLogLine(true, _T("%s"), strError); } return false; } try { //setvbuf(file.m_pStream, NULL, _IOFBF, 16384); uint8 header = file.ReadUInt8(); if (header != KNOWN2_MET_VERSION){ AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName()); } CAICHHash CurrentHash; uint32 nExistingSize = (UINT)file.GetLength(); uint32 nHashCount; while (file.GetPosition() < nExistingSize){ CurrentHash.Read(&file); if (m_pHashTree.m_Hash == CurrentHash){ // found Hashset uint32 nExpectedCount = (uint32)((PARTSIZE/EMBLOCKSIZE + ((PARTSIZE % EMBLOCKSIZE != 0)? 1 : 0)) * (m_pHashTree.m_nDataSize/PARTSIZE)); if (m_pHashTree.m_nDataSize % PARTSIZE != 0) nExpectedCount += (uint32)((m_pHashTree.m_nDataSize % PARTSIZE)/EMBLOCKSIZE + (((m_pHashTree.m_nDataSize % PARTSIZE) % EMBLOCKSIZE != 0)? 1 : 0)); nHashCount = file.ReadUInt32(); if (nHashCount != nExpectedCount){ CGlobalVariable::QueueDebugLogLine(true, _T("Failed to load HashSet: Available Hashs and expected hashcount differ!")); return false; } //uint32 dbgPos = file.GetPosition(); if (!m_pHashTree.LoadLowestLevelHashs(&file)){ CGlobalVariable::QueueDebugLogLine(true, _T("Failed to load HashSet: LoadLowestLevelHashs failed!")); return false; } //uint32 dbgHashRead = (file.GetPosition()-dbgPos)/HASHSIZE; if (!ReCalculateHash(false)){ CGlobalVariable::QueueDebugLogLine(true, _T("Failed to load HashSet: Calculating loaded hashs failed!")); return false; } if (CurrentHash != m_pHashTree.m_Hash){ CGlobalVariable::QueueDebugLogLine(true, _T("Failed to load HashSet: Calculated Masterhash differs from given Masterhash - hashset corrupt!")); return false; } return true; } nHashCount = file.ReadUInt32(); if (file.GetPosition() + nHashCount*HASHSIZE > nExistingSize){ AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName()); } // skip the rest of this hashset file.Seek(nHashCount*HASHSIZE, CFile::current); } CGlobalVariable::QueueDebugLogLine(true, _T("Failed to load HashSet: HashSet not found!")); } catch(CFileException* error){ if (error->m_cause == CFileException::endOfFile) CGlobalVariable::QueueLogLine(true, GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME); else{ TCHAR buffer[MAX_CFEXP_ERRORMSG]; error->GetErrorMessage(buffer, ARRSIZE(buffer)); CGlobalVariable::QueueLogLine(true,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer); } error->Delete(); } return false; } // delete the hashset except the masterhash (we dont keep aich hashsets in memory to save ressources) void CAICHHashSet::FreeHashSet(){ delete m_pHashTree.m_pLeftTree; m_pHashTree.m_pLeftTree = NULL; delete m_pHashTree.m_pRightTree; m_pHashTree.m_pRightTree = NULL; } void CAICHHashSet::SetMasterHash(const CAICHHash& Hash, EAICHStatus eNewStatus){ m_pHashTree.m_Hash = Hash; m_pHashTree.m_bHashValid = true; SetStatus(eNewStatus); } CAICHHashAlgo* CAICHHashSet::GetNewHashAlgo(){ return new CSHA(); } bool CAICHHashSet::ReCalculateHash(bool bDontReplace){ CAICHHashAlgo* hashalg = GetNewHashAlgo(); bool bResult = m_pHashTree.ReCalculateHash(hashalg, bDontReplace); delete hashalg; return bResult; } bool CAICHHashSet::VerifyHashTree(bool bDeleteBadTrees){ CAICHHashAlgo* hashalg = GetNewHashAlgo(); bool bResult = m_pHashTree.VerifyHashTree(hashalg, bDeleteBadTrees); delete hashalg; return bResult; } void CAICHHashSet::SetFileSize(EMFileSize nSize){ m_pHashTree.m_nDataSize = nSize; m_pHashTree.m_nBaseSize = (nSize <= (uint64)PARTSIZE) ? EMBLOCKSIZE : PARTSIZE; } void CAICHHashSet::UntrustedHashReceived(const CAICHHash& Hash, uint32 dwFromIP){ switch(GetStatus()){ case AICH_EMPTY: case AICH_UNTRUSTED: case AICH_TRUSTED: break; default: return; } bool bFound = false; bool bAdded = false; for (int i = 0; i < m_aUntrustedHashs.GetCount(); i++){ if (m_aUntrustedHashs[i].m_Hash == Hash){ bAdded = m_aUntrustedHashs[i].AddSigningIP(dwFromIP); bFound = true; break; } } if (!bFound){ bAdded = true; CAICHUntrustedHash uhToAdd; uhToAdd.m_Hash = Hash; uhToAdd.AddSigningIP(dwFromIP); m_aUntrustedHashs.Add(uhToAdd); } uint32 nSigningIPsTotal = 0; // unique clients who send us a hash int nMostTrustedPos = (-1); // the hash which most clients send us uint32 nMostTrustedIPs = 0; for (uint32 i = 0; i < (uint32)m_aUntrustedHashs.GetCount(); i++){ nSigningIPsTotal += m_aUntrustedHashs[i].m_adwIpsSigning.GetCount(); if ((uint32)m_aUntrustedHashs[i].m_adwIpsSigning.GetCount() > nMostTrustedIPs){ nMostTrustedIPs = m_aUntrustedHashs[i].m_adwIpsSigning.GetCount(); nMostTrustedPos = i; } } if (nMostTrustedPos == (-1) || nSigningIPsTotal == 0){ ASSERT( false ); return; } // the check if we trust any hash if ( thePrefs.IsTrustingEveryHash() || (nMostTrustedIPs >= MINUNIQUEIPS_TOTRUST && (100 * nMostTrustedIPs)/nSigningIPsTotal >= MINPERCENTAGE_TOTRUST)){ //trusted //CGlobalVariable::QueueDebugLogLine(false, _T("AICH Hash received: %s (%sadded), We have now %u hash from %u unique IPs. We trust the Hash %s from %u clients (%u%%). Added IP:%s, file: %s") //, Hash.GetString(), bAdded? _T(""):_T("not "), m_aUntrustedHashs.GetCount(), nSigningIPsTotal, m_aUntrustedHashs[nMostTrustedPos].m_Hash.GetString() //, nMostTrustedIPs, (100 * nMostTrustedIPs)/nSigningIPsTotal, ipstr(dwFromIP & 0x00F0FFFF), m_pOwner->GetFileName()); SetStatus(AICH_TRUSTED); if (!HasValidMasterHash() || GetMasterHash() != m_aUntrustedHashs[nMostTrustedPos].m_Hash){ SetMasterHash(m_aUntrustedHashs[nMostTrustedPos].m_Hash, AICH_TRUSTED); FreeHashSet(); } } else{ // untrusted //CGlobalVariable::QueueDebugLogLine(false, _T("AICH Hash received: %s (%sadded), We have now %u hash from %u unique IPs. Best Hash (%s) is from %u clients (%u%%) - but we dont trust it yet. Added IP:%s, file: %s") // , Hash.GetString(), bAdded? _T(""):_T("not "), m_aUntrustedHashs.GetCount(), nSigningIPsTotal, m_aUntrustedHashs[nMostTrustedPos].m_Hash.GetString() // , nMostTrustedIPs, (100 * nMostTrustedIPs)/nSigningIPsTotal, ipstr(dwFromIP & 0x00F0FFFF), m_pOwner->GetFileName()); SetStatus(AICH_UNTRUSTED); if (!HasValidMasterHash() || GetMasterHash() != m_aUntrustedHashs[nMostTrustedPos].m_Hash){ SetMasterHash(m_aUntrustedHashs[nMostTrustedPos].m_Hash, AICH_UNTRUSTED); FreeHashSet(); } } } void CAICHHashSet::ClientAICHRequestFailed(CUpDownClient* pClient){ pClient->SetReqFileAICHHash(NULL); CAICHRequestedData data = GetAICHReqDetails(pClient); RemoveClientAICHRequest(pClient); if (data.m_pClient != pClient) return; if(CGlobalVariable::downloadqueue->IsPartFile(data.m_pPartFile)){ // Comment UI //CGlobalVariable::QueueDebugLogLine(false, _T("AICH Request failed, Trying to ask another client (file %s, Part: %u, Client%s)"), data.m_pPartFile->GetFileName(), data.m_nPart, pClient->DbgGetClientInfo()); data.m_pPartFile->RequestAICHRecovery(data.m_nPart); } } void CAICHHashSet::RemoveClientAICHRequest(const CUpDownClient* pClient){ for (POSITION pos = m_liRequestedData.GetHeadPosition();pos != 0; m_liRequestedData.GetNext(pos)) { if (m_liRequestedData.GetAt(pos).m_pClient == pClient){ m_liRequestedData.RemoveAt(pos); return; } } ASSERT( false ); } bool CAICHHashSet::IsClientRequestPending(const CPartFile* pForFile, uint16 nPart){ for (POSITION pos = m_liRequestedData.GetHeadPosition();pos != 0; m_liRequestedData.GetNext(pos)) { if (m_liRequestedData.GetAt(pos).m_pPartFile == pForFile && m_liRequestedData.GetAt(pos).m_nPart == nPart){ return true; } } return false; } CAICHRequestedData CAICHHashSet::GetAICHReqDetails(const CUpDownClient* pClient){ for (POSITION pos = m_liRequestedData.GetHeadPosition();pos != 0; m_liRequestedData.GetNext(pos)) { if (m_liRequestedData.GetAt(pos).m_pClient == pClient){ return m_liRequestedData.GetAt(pos); } } ASSERT( false ); CAICHRequestedData empty; return empty; } bool CAICHHashSet::IsPartDataAvailable(uint64 nPartStartPos){ if (!(m_eStatus == AICH_VERIFIED || m_eStatus == AICH_TRUSTED || m_eStatus == AICH_HASHSETCOMPLETE) ){ ASSERT( false ); return false; } uint32 nPartSize = (uint32)(min(PARTSIZE, (uint64)m_pOwner->GetFileSize()-nPartStartPos)); for (uint64 nPartPos = 0; nPartPos < nPartSize; nPartPos += EMBLOCKSIZE){ CAICHHashTree* phtToCheck = m_pHashTree.FindHash(nPartStartPos+nPartPos, min(EMBLOCKSIZE, nPartSize-nPartPos)); if (phtToCheck == NULL || !phtToCheck->m_bHashValid){ return false; } } return true; } void CAICHHashSet::DbgTest(){ #ifdef _DEBUG //define TESTSIZE 4294567295 uint8 maxLevel = 0; uint32 cHash = 1; uint8 curLevel = 0; //uint32 cParts = 0; maxLevel = 0; /* CAICHHashTree* pTest = new CAICHHashTree(TESTSIZE, true, 9728000); for (uint64 i = 0; i+9728000 < TESTSIZE; i += 9728000){ CAICHHashTree* pTest2 = new CAICHHashTree(9728000, true, EMBLOCKSIZE); pTest->ReplaceHashTree(i, 9728000, &pTest2); cParts++; } CAICHHashTree* pTest2 = new CAICHHashTree(TESTSIZE-i, true, EMBLOCKSIZE); pTest->ReplaceHashTree(i, (TESTSIZE-i), &pTest2); cParts++; */ #define TESTSIZE m_pHashTree.m_nDataSize if (m_pHashTree.m_nDataSize <= EMBLOCKSIZE) return; CAICHHashSet TestHashSet(m_pOwner); TestHashSet.SetFileSize(m_pOwner->GetFileSize()); TestHashSet.SetMasterHash(GetMasterHash(), AICH_VERIFIED); CSafeMemFile file; uint64 i; for (i = 0; i+9728000 < TESTSIZE; i += 9728000){ VERIFY( CreatePartRecoveryData(i, &file) ); /*uint32 nRandomCorruption = (rand() * rand()) % (file.GetLength()-4); file.Seek(nRandomCorruption, CFile::begin); file.Write(&nRandomCorruption, 4);*/ file.SeekToBegin(); VERIFY( TestHashSet.ReadRecoveryData(i, &file) ); file.SeekToBegin(); TestHashSet.FreeHashSet(); uint32 j; for (j = 0; j+EMBLOCKSIZE < 9728000; j += EMBLOCKSIZE){ VERIFY( m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel) ); //TRACE(_T("%u - %s\r\n"), cHash, m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel)->m_Hash.GetString()); maxLevel = max(curLevel, maxLevel); curLevel = 0; cHash++; } VERIFY( m_pHashTree.FindHash(i+j, 9728000-j, &curLevel) ); //TRACE(_T("%u - %s\r\n"), cHash, m_pHashTree.FindHash(i+j, 9728000-j, &curLevel)->m_Hash.GetString()); maxLevel = max(curLevel, maxLevel); curLevel = 0; cHash++; } VERIFY( CreatePartRecoveryData(i, &file) ); file.SeekToBegin(); VERIFY( TestHashSet.ReadRecoveryData(i, &file) ); file.SeekToBegin(); TestHashSet.FreeHashSet(); uint64 j; for (j = 0; j+EMBLOCKSIZE < TESTSIZE-i; j += EMBLOCKSIZE){ VERIFY( m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel) ); //TRACE(_T("%u - %s\r\n"), cHash,m_pHashTree.FindHash(i+j, EMBLOCKSIZE, &curLevel)->m_Hash.GetString()); maxLevel = max(curLevel, maxLevel); curLevel = 0; cHash++; } //VERIFY( m_pHashTree.FindHash(i+j, (TESTSIZE-i)-j, &curLevel) ); TRACE(_T("%u - %s\r\n"), cHash,m_pHashTree.FindHash(i+j, (TESTSIZE-i)-j, &curLevel)->m_Hash.GetString()); maxLevel = max(curLevel, maxLevel); #endif }
[ "damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838" ]
[ [ [ 1, 1027 ] ] ]
2a2652b0db5798af0c6bc5dc42bb63a7f363803a
a62d03eea64b3d456d95fa7c1df38f8b545319e0
/ElementNode.cpp
55fdc87bc80deb0c6b50ecbc20dd71c289baf162
[]
no_license
radtek/evtx-cpp
32dc4e30301739b069f7de19f04e807b9cdcc826
c7f08457ec19b7e617685ba9e36a59e52a25384d
refs/heads/master
2020-06-28T19:19:24.216152
2010-12-13T21:13:23
2010-12-13T21:13:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,860
cpp
#include "ElementNode.h" #include <sstream> namespace Bxml { ElementNode::ElementNode(char* data, size_t length, Context context, bool hasAttributes) : Node(data, length, context) { name = NULL; // TODO: use length to prevent data overrun DependencyId = DEP_NO_DEPENDENCY; size++; // pass ElementNode start token if (context == TemplateDefinition) { uint16* DependencyIdPtr = reinterpret_cast<uint16*>(data+size); DependencyId = *DependencyIdPtr; size += sizeof uint16; } uint32* LengthPtr = reinterpret_cast<uint32*>(data+size); Length = *LengthPtr; size += sizeof uint32; name = new Name(data+size, length-size); size += name->getSize(); if (hasAttributes) { attributeList = new AttributeList(data+size, length-size); size += attributeList->getSize(); } else { attributeList = NULL; } Node* node; do { node = Node::createNode(data+size, length-size, context); size += appendChild(node); } while (!node->isLast()); } ElementNode::~ElementNode(void) { if (name != NULL) { delete name; } } std::wstring* ElementNode::toXml() { if (Xml == NULL) { std::wstringstream xmlStream; if (DependencyId != DEP_NO_DEPENDENCY /* && NULL optional substitution exists */) { // TODO: do not emit anything } else { xmlStream << L'<'; std::wstring* nameXml = name->toXml(); xmlStream << (*nameXml); if (attributeList != NULL) { std::wstring* attrListXml = attributeList->toXml(); xmlStream << (*attrListXml); } for (Node* node = getFirstChild(); nextChildExists(); node = getNextChild()) { std::wstring* nodeXml = node->toXml(); xmlStream << (*nodeXml); } } Xml = new std::wstring(xmlStream.str()); } return Xml; } std::wstring* ElementNode::getName() { return name->toXml(); } }
[ "?????????????@SPARXXX-MOBILE" ]
[ [ [ 1, 80 ] ] ]
bf5e60bb4bcfe61fa8c19a219565422562ab1ef3
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.cpp
5c3a95610e78203c8a134caeaaf14f3fb16dad1c
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
18,894
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ BEGIN_JUCE_NAMESPACE //============================================================================== AudioSampleBuffer::AudioSampleBuffer (const int numChannels_, const int numSamples) noexcept : numChannels (numChannels_), size (numSamples) { jassert (numSamples >= 0); jassert (numChannels_ > 0); allocateData(); } AudioSampleBuffer::AudioSampleBuffer (const AudioSampleBuffer& other) noexcept : numChannels (other.numChannels), size (other.size) { allocateData(); const size_t numBytes = size * sizeof (float); for (int i = 0; i < numChannels; ++i) memcpy (channels[i], other.channels[i], numBytes); } void AudioSampleBuffer::allocateData() { const size_t channelListSize = (numChannels + 1) * sizeof (float*); allocatedBytes = (int) (numChannels * size * sizeof (float) + channelListSize + 32); allocatedData.malloc (allocatedBytes); channels = reinterpret_cast <float**> (allocatedData.getData()); float* chan = (float*) (allocatedData + channelListSize); for (int i = 0; i < numChannels; ++i) { channels[i] = chan; chan += size; } channels [numChannels] = 0; } AudioSampleBuffer::AudioSampleBuffer (float** dataToReferTo, const int numChannels_, const int numSamples) noexcept : numChannels (numChannels_), size (numSamples), allocatedBytes (0) { jassert (numChannels_ > 0); allocateChannels (dataToReferTo, 0); } AudioSampleBuffer::AudioSampleBuffer (float** dataToReferTo, const int numChannels_, const int startSample, const int numSamples) noexcept : numChannels (numChannels_), size (numSamples), allocatedBytes (0) { jassert (numChannels_ > 0); allocateChannels (dataToReferTo, startSample); } void AudioSampleBuffer::setDataToReferTo (float** dataToReferTo, const int newNumChannels, const int newNumSamples) noexcept { jassert (newNumChannels > 0); allocatedBytes = 0; allocatedData.free(); numChannels = newNumChannels; size = newNumSamples; allocateChannels (dataToReferTo, 0); } void AudioSampleBuffer::allocateChannels (float** const dataToReferTo, int offset) { // (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools) if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) { channels = static_cast <float**> (preallocatedChannelSpace); } else { allocatedData.malloc (numChannels + 1, sizeof (float*)); channels = reinterpret_cast <float**> (allocatedData.getData()); } for (int i = 0; i < numChannels; ++i) { // you have to pass in the same number of valid pointers as numChannels jassert (dataToReferTo[i] != nullptr); channels[i] = dataToReferTo[i] + offset; } channels [numChannels] = 0; } AudioSampleBuffer& AudioSampleBuffer::operator= (const AudioSampleBuffer& other) noexcept { if (this != &other) { setSize (other.getNumChannels(), other.getNumSamples(), false, false, false); const size_t numBytes = size * sizeof (float); for (int i = 0; i < numChannels; ++i) memcpy (channels[i], other.channels[i], numBytes); } return *this; } AudioSampleBuffer::~AudioSampleBuffer() noexcept { } void AudioSampleBuffer::setSize (const int newNumChannels, const int newNumSamples, const bool keepExistingContent, const bool clearExtraSpace, const bool avoidReallocating) noexcept { jassert (newNumChannels > 0); jassert (newNumSamples >= 0); if (newNumSamples != size || newNumChannels != numChannels) { const size_t channelListSize = (newNumChannels + 1) * sizeof (float*); const size_t newTotalBytes = (newNumChannels * newNumSamples * sizeof (float)) + channelListSize + 32; if (keepExistingContent) { HeapBlock <char, true> newData; newData.allocate (newTotalBytes, clearExtraSpace); const size_t numBytesToCopy = sizeof (float) * jmin (newNumSamples, size); float** const newChannels = reinterpret_cast <float**> (newData.getData()); float* newChan = reinterpret_cast <float*> (newData + channelListSize); for (int j = 0; j < newNumChannels; ++j) { newChannels[j] = newChan; newChan += newNumSamples; } const int numChansToCopy = jmin (numChannels, newNumChannels); for (int i = 0; i < numChansToCopy; ++i) memcpy (newChannels[i], channels[i], numBytesToCopy); allocatedData.swapWith (newData); allocatedBytes = (int) newTotalBytes; channels = newChannels; } else { if (avoidReallocating && allocatedBytes >= newTotalBytes) { if (clearExtraSpace) allocatedData.clear (newTotalBytes); } else { allocatedBytes = newTotalBytes; allocatedData.allocate (newTotalBytes, clearExtraSpace); channels = reinterpret_cast <float**> (allocatedData.getData()); } float* chan = reinterpret_cast <float*> (allocatedData + channelListSize); for (int i = 0; i < newNumChannels; ++i) { channels[i] = chan; chan += newNumSamples; } } channels [newNumChannels] = 0; size = newNumSamples; numChannels = newNumChannels; } } void AudioSampleBuffer::clear() noexcept { for (int i = 0; i < numChannels; ++i) zeromem (channels[i], size * sizeof (float)); } void AudioSampleBuffer::clear (const int startSample, const int numSamples) noexcept { jassert (startSample >= 0 && startSample + numSamples <= size); for (int i = 0; i < numChannels; ++i) zeromem (channels [i] + startSample, numSamples * sizeof (float)); } void AudioSampleBuffer::clear (const int channel, const int startSample, const int numSamples) noexcept { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); zeromem (channels [channel] + startSample, numSamples * sizeof (float)); } void AudioSampleBuffer::applyGain (const int channel, const int startSample, int numSamples, const float gain) noexcept { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); if (gain != 1.0f) { float* d = channels [channel] + startSample; if (gain == 0.0f) { zeromem (d, sizeof (float) * numSamples); } else { while (--numSamples >= 0) *d++ *= gain; } } } void AudioSampleBuffer::applyGainRamp (const int channel, const int startSample, int numSamples, float startGain, float endGain) noexcept { if (startGain == endGain) { applyGain (channel, startSample, numSamples, startGain); } else { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); const float increment = (endGain - startGain) / numSamples; float* d = channels [channel] + startSample; while (--numSamples >= 0) { *d++ *= startGain; startGain += increment; } } } void AudioSampleBuffer::applyGain (const int startSample, const int numSamples, const float gain) noexcept { for (int i = 0; i < numChannels; ++i) applyGain (i, startSample, numSamples, gain); } void AudioSampleBuffer::addFrom (const int destChannel, const int destStartSample, const AudioSampleBuffer& source, const int sourceChannel, const int sourceStartSample, int numSamples, const float gain) noexcept { jassert (&source != this || sourceChannel != destChannel); jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (isPositiveAndBelow (sourceChannel, source.numChannels)); jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size); if (gain != 0.0f && numSamples > 0) { float* d = channels [destChannel] + destStartSample; const float* s = source.channels [sourceChannel] + sourceStartSample; if (gain != 1.0f) { while (--numSamples >= 0) *d++ += gain * *s++; } else { while (--numSamples >= 0) *d++ += *s++; } } } void AudioSampleBuffer::addFrom (const int destChannel, const int destStartSample, const float* source, int numSamples, const float gain) noexcept { jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (source != nullptr); if (gain != 0.0f && numSamples > 0) { float* d = channels [destChannel] + destStartSample; if (gain != 1.0f) { while (--numSamples >= 0) *d++ += gain * *source++; } else { while (--numSamples >= 0) *d++ += *source++; } } } void AudioSampleBuffer::addFromWithRamp (const int destChannel, const int destStartSample, const float* source, int numSamples, float startGain, const float endGain) noexcept { jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (source != nullptr); if (startGain == endGain) { addFrom (destChannel, destStartSample, source, numSamples, startGain); } else { if (numSamples > 0 && (startGain != 0.0f || endGain != 0.0f)) { const float increment = (endGain - startGain) / numSamples; float* d = channels [destChannel] + destStartSample; while (--numSamples >= 0) { *d++ += startGain * *source++; startGain += increment; } } } } void AudioSampleBuffer::copyFrom (const int destChannel, const int destStartSample, const AudioSampleBuffer& source, const int sourceChannel, const int sourceStartSample, int numSamples) noexcept { jassert (&source != this || sourceChannel != destChannel); jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (isPositiveAndBelow (sourceChannel, source.numChannels)); jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size); if (numSamples > 0) { memcpy (channels [destChannel] + destStartSample, source.channels [sourceChannel] + sourceStartSample, sizeof (float) * numSamples); } } void AudioSampleBuffer::copyFrom (const int destChannel, const int destStartSample, const float* source, int numSamples) noexcept { jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (source != nullptr); if (numSamples > 0) { memcpy (channels [destChannel] + destStartSample, source, sizeof (float) * numSamples); } } void AudioSampleBuffer::copyFrom (const int destChannel, const int destStartSample, const float* source, int numSamples, const float gain) noexcept { jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (source != nullptr); if (numSamples > 0) { float* d = channels [destChannel] + destStartSample; if (gain != 1.0f) { if (gain == 0) { zeromem (d, sizeof (float) * numSamples); } else { while (--numSamples >= 0) *d++ = gain * *source++; } } else { memcpy (d, source, sizeof (float) * numSamples); } } } void AudioSampleBuffer::copyFromWithRamp (const int destChannel, const int destStartSample, const float* source, int numSamples, float startGain, float endGain) noexcept { jassert (isPositiveAndBelow (destChannel, numChannels)); jassert (destStartSample >= 0 && destStartSample + numSamples <= size); jassert (source != nullptr); if (startGain == endGain) { copyFrom (destChannel, destStartSample, source, numSamples, startGain); } else { if (numSamples > 0 && (startGain != 0.0f || endGain != 0.0f)) { const float increment = (endGain - startGain) / numSamples; float* d = channels [destChannel] + destStartSample; while (--numSamples >= 0) { *d++ = startGain * *source++; startGain += increment; } } } } void AudioSampleBuffer::findMinMax (const int channel, const int startSample, int numSamples, float& minVal, float& maxVal) const noexcept { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); findMinAndMax (channels [channel] + startSample, numSamples, minVal, maxVal); } float AudioSampleBuffer::getMagnitude (const int channel, const int startSample, const int numSamples) const noexcept { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); float mn, mx; findMinMax (channel, startSample, numSamples, mn, mx); return jmax (mn, -mn, mx, -mx); } float AudioSampleBuffer::getMagnitude (const int startSample, const int numSamples) const noexcept { float mag = 0.0f; for (int i = 0; i < numChannels; ++i) mag = jmax (mag, getMagnitude (i, startSample, numSamples)); return mag; } float AudioSampleBuffer::getRMSLevel (const int channel, const int startSample, const int numSamples) const noexcept { jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && startSample + numSamples <= size); if (numSamples <= 0 || channel < 0 || channel >= numChannels) return 0.0f; const float* const data = channels [channel] + startSample; double sum = 0.0; for (int i = 0; i < numSamples; ++i) { const float sample = data [i]; sum += sample * sample; } return (float) std::sqrt (sum / numSamples); } END_JUCE_NAMESPACE
[ "ow3nskip" ]
[ [ [ 1, 556 ] ] ]
123579e0cbd99665f728aaae61157253b565faa1
640a36607eb5b185eceb733643dda918221a40a4
/Sever/lib/IOCPFramework/DoubleList.h
79480818c574aaf398b95035a35885867bccd50f
[]
no_license
degravata/simple-flash-mmorpg
13cc97665e89dc8a0c6218a9a6ebc5c44217fc7d
71138defc786ce757eae8d6fc6bd53d16bf44e63
refs/heads/master
2016-09-12T10:38:44.046533
2011-01-25T07:51:25
2011-01-25T07:51:25
56,880,982
0
0
null
null
null
null
UTF-8
C++
false
false
14,021
h
#pragma once //#ifndef __DOUBLE_LIST_H_ //#define __DOUBLE_LIST_H_ #include <list> namespace SevenSmile{ namespace Net{ namespace IOCPFramework{ template<class T, int COUNT> class CDoubleList { public: typedef typename std::list<T*> LIST; typedef typename std::list<T*>::iterator ITERATOR; public: CDoubleList(); virtual ~CDoubleList(); private: CRITICAL_SECTION m_critical_section; //protected: public: LIST m_0_list; LIST m_1_list; private: inline void Base_InitSize(LIST &list,int count); inline void Base_RemoveAll(LIST &list); inline void Init(); inline void RemoveAll(); public: int GetCount(); int GetBlankCount(); T* GetBlank(); T* RemoveAt(ITERATOR pos); T* RemoveAt(T* lp_t); void GetHeadPosition(ITERATOR&pos); T* GetNext(ITERATOR&pos); T* GetHead(); T* RemoveHead(); T* GetOwnCycleNext(); void PutToBlank(); //////////////////////////////////////////////////////////// T* GetFromBlank(); T* PutToBlank(T*lp_t); T* GetFromUse(); T* PutToUse(T*lp_t); }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------- 功能:构造函数 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> CDoubleList<T,COUNT>::CDoubleList() { ::InitializeCriticalSection(&m_critical_section); Init(); } /*--------------------------------------------------------------------------------- 功能:析构函数 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> CDoubleList<T,COUNT>::~CDoubleList() { RemoveAll(); ::DeleteCriticalSection(&m_critical_section); } /*--------------------------------------------------------------------------------- 功能:初始化一个列表,并申请所需的内存 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::Base_InitSize(LIST &list,int count) { T *lp_t = NULL; for( int i = 0; i < count; i++ ) { lp_t = new T; list.push_back( lp_t ); } } /*--------------------------------------------------------------------------------- 功能:删除一个列表中所有元素,并释放内存 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::Base_RemoveAll(LIST &list) { for( ITERATOR i = list.begin(); i != list.end(); i++ ) { delete *i; } list.clear(); } /*--------------------------------------------------------------------------------- 功能:初始化 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::Init() { EnterCriticalSection( &m_critical_section ); Base_RemoveAll( m_0_list ); Base_RemoveAll( m_1_list ); Base_InitSize( m_0_list, COUNT ); LeaveCriticalSection( &m_critical_section ); } /*--------------------------------------------------------------------------------- 功能:清空所有内存 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::RemoveAll() { EnterCriticalSection( &m_critical_section ); Base_RemoveAll( m_0_list ); Base_RemoveAll( m_1_list ); LeaveCriticalSection( &m_critical_section ); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------- 功能:得到使用表的结点数量 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> int CDoubleList<T,COUNT>::GetCount() { int count = 0; EnterCriticalSection( &m_critical_section ); count = m_1_list.size(); LeaveCriticalSection( &m_critical_section ); return count; } /*--------------------------------------------------------------------------------- 功能:得到空表的结点数量 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> int CDoubleList<T,COUNT>::GetBlankCount() { int count = 0; EnterCriticalSection( &m_critical_section ); count = m_0_list.size(); LeaveCriticalSection( &m_critical_section ); return count; } /*--------------------------------------------------------------------------------- 功能:从空表,或者向系统申请一个结点 说明:如果空表已经无结点,且系统已无可用内存,此函数才会失败。 返回:成功,返回申请的结点;失败,NULL ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetBlank() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_0_list.begin(); if( pos == m_0_list.end() ) { lp_t = new T; } else { lp_t = *pos; m_0_list.pop_front(); } //因为有可能内存不足而申请内存失败 if( lp_t != NULL ) { m_1_list.push_back( lp_t ); } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:根据叠代器,删除使用表中的一个结点 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::RemoveAt(ITERATOR pos) { T* lp_t = NULL; EnterCriticalSection( &m_critical_section ); lp_t = *pos; m_1_list.erase( pos ); m_0_list.push_back( lp_t ); LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:根据结点指针,删除使用表中的一个结点 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::RemoveAt(T* lp_t) { EnterCriticalSection( &m_critical_section ); m_1_list.remove( lp_t ); m_0_list.push_back( lp_t ); LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:得到使用表头结点的叠代器 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::GetHeadPosition(ITERATOR&pos) { EnterCriticalSection( &m_critical_section ); pos = m_1_list.begin(); if( pos == m_1_list.end() ) { pos = NULL; } LeaveCriticalSection( &m_critical_section ); } /*--------------------------------------------------------------------------------- 功能:根据叠代器,得到结点。并使叠代器向表尾方向移动一个结点 说明:如果返回NULL,说明已经到了表尾 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetNext(ITERATOR&pos) { T* lp_t = NULL; EnterCriticalSection( &m_critical_section ); lp_t = *pos; pos++; if( pos == m_1_list.end() ) { pos = NULL; } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:得到使用表的表头结点,但不移走 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetHead() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_1_list.begin(); if( pos != m_1_list.end() ) { lp_t = *pos; } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:移走使用表的表头结点到空表中。 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::RemoveHead() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_1_list.begin(); if( pos != m_1_list.end() ) { lp_t = *pos; m_1_list.pop_front(); m_0_list.push_back( lp_t ); } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:从空表、使用表中取出一个结点,放到使用表的表头 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetOwnCycleNext() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_0_list.begin(); if( pos != m_0_list.end() ) { lp_t = *pos; m_0_list.pop_front(); } else { pos = m_1_list.begin(); if( pos != m_1_list.end() ) { lp_t = *pos; m_1_list.pop_front(); } } if( lp_t != NULL ) { m_1_list.push_back( lp_t ); } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:将使用表中的所有结点都移到空表中 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> void CDoubleList<T,COUNT>::PutToBlank() { ITERATOR pos; EnterCriticalSection( &m_critical_section ); for( pos = m_1_list.begin(); pos != m_1_list.end(); pos++ ) { m_0_list.push_back( *pos ); } m_1_list.clear(); LeaveCriticalSection( &m_critical_section ); } /*--------------------------------------------------------------------------------- 功能:从空表取得一个结点,但并不放到使用表中。此结点暂时悬空 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetFromBlank() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_0_list.begin(); if( pos == m_0_list.end() ) { lp_t = new T; } else { lp_t = *pos; m_0_list.pop_front(); } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:将一个结点放到空表中。 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::PutToBlank(T* lp_t) { EnterCriticalSection( &m_critical_section ); m_0_list.push_back( lp_t ); LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:从使用表取得一个结点,但并不放到空表中。此结点暂时悬空 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::GetFromUse() { T* lp_t = NULL; ITERATOR pos; EnterCriticalSection( &m_critical_section ); pos = m_1_list.begin(); if( pos != m_1_list.end() ) { lp_t = *pos; m_1_list.pop_front(); } LeaveCriticalSection( &m_critical_section ); return lp_t; } /*--------------------------------------------------------------------------------- 功能:将一个结点放到使用表中。 说明: 返回: ---------------------------------------------------------------------------------*/ template<class T,int COUNT> T* CDoubleList<T,COUNT>::PutToUse(T* lp_t) { EnterCriticalSection( &m_critical_section ); m_1_list.push_back( lp_t ); LeaveCriticalSection( &m_critical_section ); return lp_t; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } } //#endif //__DOUBLE_LIST_H_
[ "fangtong8752@60e69123-55e6-9807-5f38-cd17b4386222" ]
[ [ [ 1, 531 ] ] ]
07204aa7ce7c2de2a38829b608853ca7d9ee2768
5f4c6947873b41c025638a7c2da1e3d3403c58a4
/src/HumanSeeker.cpp
a561f9e3d55ba097b32bab0301b33eac2df5017f
[]
no_license
xflash/sdl-start-app
7888b6fc33f11cf7dca7e90d54fc5e63ade23f7c
e9c66ce691f9fe242f868cbad4f8f6854c945945
refs/heads/master
2020-04-06T05:41:32.224719
2009-02-23T17:09:51
2009-02-23T17:09:51
32,315,969
0
0
null
null
null
null
UTF-8
C++
false
false
1,592
cpp
#include "HumanSeeker.h" #include "Character.h" #include "systemstub.h" #include "Game.h" #include "tinyXML/TinyXML.h" HumanSeeker::HumanSeeker(Game* game, TiXmlElement* element): _stub(game->getStub()) { _sightRadius=atoi(element->Attribute("sightradius")); _fightRadius=atoi(element->Attribute("fightradius"));; _target= game->getCharacters()->find(element->Attribute("target"))->second; } void HumanSeeker::update(Character* character) { //throw new SystemException("TODO HumanSeeker::update()"); /* int r=((double)rand()/(RAND_MAX+1))*4; switch(r) { case 0: character->moveLeft(); break; case 1: character->moveRight(); break; //case 2: character->moveLeft(); break; //case 3: character->moveLeft(); break; default: break; } */ _dist = getDistance(&getCenter(character->getBBox()), &getCenter(_target->getBBox())); if(_dist<=_sightRadius) { // } if(_dist<=_fightRadius) { // } } void HumanSeeker::dbgDraw(Character* character) { //throw new SystemException("TODO HumanSeeker::dbgDraw()"); if(_dist<=_sightRadius) _stub->drawCircle(&getCenter(character->getBBox()), _sightRadius, 0x0000ff1f, true); else _stub->drawCircle(&getCenter(character->getBBox()), _sightRadius, 0x0000ffff); if(_dist<=_fightRadius) _stub->drawCircle(&getCenter(character->getBBox()), _fightRadius, 0xff00001f, true); else _stub->drawCircle(&getCenter(character->getBBox()), _fightRadius, 0xff0000ff); //_stub->drawString(&character->_loc, "Distance %d", _dist); }
[ "rcoqueugniot@64776c6c-f855-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 53 ] ] ]
6cfe3a75564cb38b7f0ec426206bd3a810ca6736
ad8657ad14520fa5740fd98be37061dc2962c5c7
/IBAList.h
28a0404a2cba089cb35022dc2cf035628671ab31
[]
no_license
tjkolev/ibaplayer
9bc86a837a7e1f87ac1e989f32727ccc1594f998
3a90f60502aea9f28406b7d6aac5cb5b09a21048
refs/heads/master
2020-05-17T17:20:19.198590
2009-07-11T04:12:14
2009-07-11T04:12:14
183,848,558
0
0
null
null
null
null
UTF-8
C++
false
false
1,951
h
/*************************************************************************** * Copyright (C) 2009 by TJ Kolev * * [email protected] * * * * 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef IBALIST_H_INCLUDED #define IBALIST_H_INCLUDED #include <string> #include <vector> using namespace std; class ListItem { public: ListItem(char* path); ListItem(int id, string& name); ListItem(int id, char* name); int Id; string Name; string Path; }; //typedef vector<ListItem> CascadeList_t; class CascadeList_t : public vector<ListItem> { public: int CurrentIndex; ListItem& AtItem(); private: static ListItem EMPTY; }; #endif // IBALIST_H_INCLUDED
[ [ [ 1, 55 ] ] ]
21d2ab245bdbdd40f974af69ad0cdc7eae37064d
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/regex/src/icu.cpp
1fe3765a8a545176b5425da3499d493a4c1b2caf
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
20,867
cpp
/* * * Copyright (c) 2004 * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ /* * LOCATION: see http://www.boost.org for most recent version. * FILE icu.cpp * VERSION see <boost/version.hpp> * DESCRIPTION: Unicode regular expressions on top of the ICU Library. */ #define BOOST_REGEX_SOURCE #include <boost/regex/config.hpp> #ifdef BOOST_HAS_ICU #define BOOST_REGEX_ICU_INSTANTIATE #include <boost/regex/icu.hpp> namespace boost{ namespace re_detail{ icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const { // TODO make thread safe!!!! : typedef u32_to_u16_iterator<const char_type*, ::UChar> itt; itt i(p1), j(p2); #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS std::vector< ::UChar> t(i, j); #else std::vector< ::UChar> t; while(i != j) t.push_back(*i++); #endif ::uint8_t result[100]; ::int32_t len; if(t.size()) len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result)); else len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), result, sizeof(result)); if(std::size_t(len) > sizeof(result)) { scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]); if(t.size()) len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1); else len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), presult.get(), len+1); if((0 == presult[len-1]) && (len > 1)) --len; #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS return string_type(presult.get(), presult.get()+len); #else string_type sresult; ::uint8_t const* ia = presult.get(); ::uint8_t const* ib = presult.get()+len; while(ia != ib) sresult.push_back(*ia++); return sresult; #endif } if((0 == result[len-1]) && (len > 1)) --len; #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS return string_type(result, result+len); #else string_type sresult; ::uint8_t const* ia = result; ::uint8_t const* ib = result+len; while(ia != ib) sresult.push_back(*ia++); return sresult; #endif } } icu_regex_traits::size_type icu_regex_traits::length(const char_type* p) { size_type result = 0; while(*p) { ++p; ++result; } return result; } // // define our bitmasks: // const icu_regex_traits::char_class_type icu_regex_traits::mask_blank = icu_regex_traits::char_class_type(1) << offset_blank; const icu_regex_traits::char_class_type icu_regex_traits::mask_space = icu_regex_traits::char_class_type(1) << offset_space; const icu_regex_traits::char_class_type icu_regex_traits::mask_xdigit = icu_regex_traits::char_class_type(1) << offset_xdigit; const icu_regex_traits::char_class_type icu_regex_traits::mask_underscore = icu_regex_traits::char_class_type(1) << offset_underscore; const icu_regex_traits::char_class_type icu_regex_traits::mask_unicode = icu_regex_traits::char_class_type(1) << offset_unicode; const icu_regex_traits::char_class_type icu_regex_traits::mask_any = icu_regex_traits::char_class_type(1) << offset_any; const icu_regex_traits::char_class_type icu_regex_traits::mask_ascii = icu_regex_traits::char_class_type(1) << offset_ascii; icu_regex_traits::char_class_type icu_regex_traits::lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2) { static const ::UChar32 prop_name_table[] = { /* any */ 'a', 'n', 'y', /* ascii */ 'a', 's', 'c', 'i', 'i', /* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', /* c* */ 'c', '*', /* cc */ 'c', 'c', /* cf */ 'c', 'f', /* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* cn */ 'c', 'n', /* co */ 'c', 'o', /* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l', /* cs */ 'c', 's', /* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l', /* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r', /* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k', /* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* format */ 'f', 'o', 'r', 'm', 'a', 't', /* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* l* */ 'l', '*', /* letter */ 'l', 'e', 't', 't', 'e', 'r', /* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', /* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', /* ll */ 'l', 'l', /* lm */ 'l', 'm', /* lo */ 'l', 'o', /* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', /* lt */ 'l', 't', /* lu */ 'l', 'u', /* m* */ 'm', '*', /* mark */ 'm', 'a', 'r', 'k', /* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l', /* mc */ 'm', 'c', /* me */ 'm', 'e', /* mn */ 'm', 'n', /* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', /* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', /* n* */ 'n', '*', /* nd */ 'n', 'd', /* nl */ 'n', 'l', /* no */ 'n', 'o', /* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k', /* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', /* number */ 'n', 'u', 'm', 'b', 'e', 'r', /* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* other */ 'o', 't', 'h', 'e', 'r', /* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', /* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', /* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', /* p* */ 'p', '*', /* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', /* pc */ 'p', 'c', /* pd */ 'p', 'd', /* pe */ 'p', 'e', /* pf */ 'p', 'f', /* pi */ 'p', 'i', /* po */ 'p', 'o', /* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e', /* ps */ 'p', 's', /* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', /* s* */ 's', '*', /* sc */ 's', 'c', /* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', /* sk */ 's', 'k', /* sm */ 's', 'm', /* so */ 's', 'o', /* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', /* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k', /* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e', /* symbol */ 's', 'y', 'm', 'b', 'o', 'l', /* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', /* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', /* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', /* z* */ 'z', '*', /* zl */ 'z', 'l', /* zp */ 'z', 'p', /* zs */ 'z', 's', }; static const re_detail::character_pointer_range< ::UChar32> range_data[] = { { prop_name_table+0, prop_name_table+3, }, // any { prop_name_table+3, prop_name_table+8, }, // ascii { prop_name_table+8, prop_name_table+16, }, // assigned { prop_name_table+16, prop_name_table+18, }, // c* { prop_name_table+18, prop_name_table+20, }, // cc { prop_name_table+20, prop_name_table+22, }, // cf { prop_name_table+22, prop_name_table+38, }, // closepunctuation { prop_name_table+38, prop_name_table+40, }, // cn { prop_name_table+40, prop_name_table+42, }, // co { prop_name_table+42, prop_name_table+62, }, // connectorpunctuation { prop_name_table+62, prop_name_table+69, }, // control { prop_name_table+69, prop_name_table+71, }, // cs { prop_name_table+71, prop_name_table+85, }, // currencysymbol { prop_name_table+85, prop_name_table+100, }, // dashpunctuation { prop_name_table+100, prop_name_table+118, }, // decimaldigitnumber { prop_name_table+118, prop_name_table+131, }, // enclosingmark { prop_name_table+131, prop_name_table+147, }, // finalpunctuation { prop_name_table+147, prop_name_table+153, }, // format { prop_name_table+153, prop_name_table+171, }, // initialpunctuation { prop_name_table+171, prop_name_table+173, }, // l* { prop_name_table+173, prop_name_table+179, }, // letter { prop_name_table+179, prop_name_table+191, }, // letternumber { prop_name_table+191, prop_name_table+204, }, // lineseparator { prop_name_table+204, prop_name_table+206, }, // ll { prop_name_table+206, prop_name_table+208, }, // lm { prop_name_table+208, prop_name_table+210, }, // lo { prop_name_table+210, prop_name_table+225, }, // lowercaseletter { prop_name_table+225, prop_name_table+227, }, // lt { prop_name_table+227, prop_name_table+229, }, // lu { prop_name_table+229, prop_name_table+231, }, // m* { prop_name_table+231, prop_name_table+235, }, // mark { prop_name_table+235, prop_name_table+245, }, // mathsymbol { prop_name_table+245, prop_name_table+247, }, // mc { prop_name_table+247, prop_name_table+249, }, // me { prop_name_table+249, prop_name_table+251, }, // mn { prop_name_table+251, prop_name_table+265, }, // modifierletter { prop_name_table+265, prop_name_table+279, }, // modifiersymbol { prop_name_table+279, prop_name_table+281, }, // n* { prop_name_table+281, prop_name_table+283, }, // nd { prop_name_table+283, prop_name_table+285, }, // nl { prop_name_table+285, prop_name_table+287, }, // no { prop_name_table+287, prop_name_table+301, }, // nonspacingmark { prop_name_table+301, prop_name_table+312, }, // notassigned { prop_name_table+312, prop_name_table+318, }, // number { prop_name_table+318, prop_name_table+333, }, // openpunctuation { prop_name_table+333, prop_name_table+338, }, // other { prop_name_table+338, prop_name_table+349, }, // otherletter { prop_name_table+349, prop_name_table+360, }, // othernumber { prop_name_table+360, prop_name_table+376, }, // otherpunctuation { prop_name_table+376, prop_name_table+387, }, // othersymbol { prop_name_table+387, prop_name_table+389, }, // p* { prop_name_table+389, prop_name_table+407, }, // paragraphseparator { prop_name_table+407, prop_name_table+409, }, // pc { prop_name_table+409, prop_name_table+411, }, // pd { prop_name_table+411, prop_name_table+413, }, // pe { prop_name_table+413, prop_name_table+415, }, // pf { prop_name_table+415, prop_name_table+417, }, // pi { prop_name_table+417, prop_name_table+419, }, // po { prop_name_table+419, prop_name_table+429, }, // privateuse { prop_name_table+429, prop_name_table+431, }, // ps { prop_name_table+431, prop_name_table+442, }, // punctuation { prop_name_table+442, prop_name_table+444, }, // s* { prop_name_table+444, prop_name_table+446, }, // sc { prop_name_table+446, prop_name_table+455, }, // separator { prop_name_table+455, prop_name_table+457, }, // sk { prop_name_table+457, prop_name_table+459, }, // sm { prop_name_table+459, prop_name_table+461, }, // so { prop_name_table+461, prop_name_table+475, }, // spaceseparator { prop_name_table+475, prop_name_table+495, }, // spacingcombiningmark { prop_name_table+495, prop_name_table+504, }, // surrogate { prop_name_table+504, prop_name_table+510, }, // symbol { prop_name_table+510, prop_name_table+519, }, // titlecase { prop_name_table+519, prop_name_table+534, }, // titlecaseletter { prop_name_table+534, prop_name_table+549, }, // uppercaseletter { prop_name_table+549, prop_name_table+551, }, // z* { prop_name_table+551, prop_name_table+553, }, // zl { prop_name_table+553, prop_name_table+555, }, // zp { prop_name_table+555, prop_name_table+557, }, // zs }; static const icu_regex_traits::char_class_type icu_class_map[] = { icu_regex_traits::mask_any, // any icu_regex_traits::mask_ascii, // ascii (0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned U_GC_C_MASK, // c* U_GC_CC_MASK, // cc U_GC_CF_MASK, // cf U_GC_PE_MASK, // closepunctuation U_GC_CN_MASK, // cn U_GC_CO_MASK, // co U_GC_PC_MASK, // connectorpunctuation U_GC_CC_MASK, // control U_GC_CS_MASK, // cs U_GC_SC_MASK, // currencysymbol U_GC_PD_MASK, // dashpunctuation U_GC_ND_MASK, // decimaldigitnumber U_GC_ME_MASK, // enclosingmark U_GC_PF_MASK, // finalpunctuation U_GC_CF_MASK, // format U_GC_PI_MASK, // initialpunctuation U_GC_L_MASK, // l* U_GC_L_MASK, // letter U_GC_NL_MASK, // letternumber U_GC_ZL_MASK, // lineseparator U_GC_LL_MASK, // ll U_GC_LM_MASK, // lm U_GC_LO_MASK, // lo U_GC_LL_MASK, // lowercaseletter U_GC_LT_MASK, // lt U_GC_LU_MASK, // lu U_GC_M_MASK, // m* U_GC_M_MASK, // mark U_GC_SM_MASK, // mathsymbol U_GC_MC_MASK, // mc U_GC_ME_MASK, // me U_GC_MN_MASK, // mn U_GC_LM_MASK, // modifierletter U_GC_SK_MASK, // modifiersymbol U_GC_N_MASK, // n* U_GC_ND_MASK, // nd U_GC_NL_MASK, // nl U_GC_NO_MASK, // no U_GC_MN_MASK, // nonspacingmark U_GC_CN_MASK, // notassigned U_GC_N_MASK, // number U_GC_PS_MASK, // openpunctuation U_GC_C_MASK, // other U_GC_LO_MASK, // otherletter U_GC_NO_MASK, // othernumber U_GC_PO_MASK, // otherpunctuation U_GC_SO_MASK, // othersymbol U_GC_P_MASK, // p* U_GC_ZP_MASK, // paragraphseparator U_GC_PC_MASK, // pc U_GC_PD_MASK, // pd U_GC_PE_MASK, // pe U_GC_PF_MASK, // pf U_GC_PI_MASK, // pi U_GC_PO_MASK, // po U_GC_CO_MASK, // privateuse U_GC_PS_MASK, // ps U_GC_P_MASK, // punctuation U_GC_S_MASK, // s* U_GC_SC_MASK, // sc U_GC_Z_MASK, // separator U_GC_SK_MASK, // sk U_GC_SM_MASK, // sm U_GC_SO_MASK, // so U_GC_ZS_MASK, // spaceseparator U_GC_MC_MASK, // spacingcombiningmark U_GC_CS_MASK, // surrogate U_GC_S_MASK, // symbol U_GC_LT_MASK, // titlecase U_GC_LT_MASK, // titlecaseletter U_GC_LU_MASK, // uppercaseletter U_GC_Z_MASK, // z* U_GC_ZL_MASK, // zl U_GC_ZP_MASK, // zp U_GC_ZS_MASK, // zs }; static const re_detail::character_pointer_range< ::UChar32>* ranges_begin = range_data; static const re_detail::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data)/sizeof(range_data[0])); re_detail::character_pointer_range< ::UChar32> t = { p1, p2, }; const re_detail::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t); if((p != ranges_end) && (t == *p)) return icu_class_map[p - ranges_begin]; return 0; } icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_type* p1, const char_type* p2) const { static const char_class_type masks[] = { 0, U_GC_L_MASK | U_GC_ND_MASK, U_GC_L_MASK, mask_blank, U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK, U_GC_ND_MASK, U_GC_ND_MASK, (0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK), U_GC_LL_MASK, U_GC_LL_MASK, ~(U_GC_C_MASK), U_GC_P_MASK, char_class_type(U_GC_Z_MASK) | mask_space, char_class_type(U_GC_Z_MASK) | mask_space, U_GC_LU_MASK, mask_unicode, U_GC_LU_MASK, char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, char_class_type(U_GC_ND_MASK) | mask_xdigit, }; int id = ::boost::re_detail::get_default_class_id(p1, p2); if(id >= 0) return masks[id+1]; char_class_type result = lookup_icu_mask(p1, p2); if(result != 0) return result; if(id < 0) { string_type s(p1, p2); string_type::size_type i = 0; while(i < s.size()) { s[i] = static_cast<char>((::u_tolower)(s[i])); if(::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_')) s.erase(s.begin()+i, s.begin()+i+1); else { s[i] = static_cast<char>((::u_tolower)(s[i])); ++i; } } if(s.size()) id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); if(id >= 0) return masks[id+1]; if(s.size()) result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); if(result != 0) return result; } BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); return masks[id+1]; } icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const { string_type result; if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2) { #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS std::string s(p1, p2); #else std::string s; const char_type* p3 = p1; while(p3 != p2) s.append(1, *p3++); #endif // Try Unicode name: UErrorCode err = U_ZERO_ERROR; UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err); if(U_SUCCESS(err)) { result.push_back(c); return result; } // Try Unicode-extended name: err = U_ZERO_ERROR; c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err); if(U_SUCCESS(err)) { result.push_back(c); return result; } // try POSIX name: s = ::boost::re_detail::lookup_default_collate_name(s); #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS result.assign(s.begin(), s.end()); #else result.clear(); std::string::const_iterator si, sj; si = s.begin(); sj = s.end(); while(si != sj) result.push_back(*si++); #endif } if(result.empty() && (p2-p1 == 1)) result.push_back(*p1); return result; } bool icu_regex_traits::isctype(char_type c, char_class_type f) const { // check for standard catagories first: char_class_type m = char_class_type(1u << u_charType(c)); if((m & f) != 0) return true; // now check for special cases: if(((f & mask_blank) != 0) && u_isblank(c)) return true; if(((f & mask_space) != 0) && u_isspace(c)) return true; if(((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0)) return true; if(((f & mask_unicode) != 0) && (c >= 0x100)) return true; if(((f & mask_underscore) != 0) && (c == '_')) return true; if(((f & mask_any) != 0) && (c <= 0x10FFFF)) return true; if(((f & mask_ascii) != 0) && (c <= 0x7F)) return true; return false; } } #endif // BOOST_HAS_ICU
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 495 ] ] ]
2bebcf4132cf416949dc76783988364ed1cff9c9
12732dc8a5dd518f35c8af3f2a805806f5e91e28
/trunk/CodeLite/cpp_comment_creator.cpp
8014255ad65ea8ca32845e66413dcc6977e516e9
[]
no_license
BackupTheBerlios/codelite-svn
5acd9ac51fdd0663742f69084fc91a213b24ae5c
c9efd7873960706a8ce23cde31a701520bad8861
refs/heads/master
2020-05-20T13:22:34.635394
2007-08-02T21:35:35
2007-08-02T21:35:35
40,669,327
0
0
null
null
null
null
UTF-8
C++
false
false
1,440
cpp
#include "cpp_comment_creator.h" #include <wx/datetime.h> #include <vector> #include "language.h" CppCommentCreator::CppCommentCreator(TagEntryPtr tag) : m_tag(tag) { } CppCommentCreator::~CppCommentCreator() { } wxString CppCommentCreator::CreateComment() { if(m_tag->GetKind() == wxT("class")) return ClassComment(); else if(m_tag->GetKind() == wxT("function")) return FunctionComment(); else if(m_tag->GetKind() == wxT("prototype")) return FunctionComment(); return wxEmptyString; } wxString CppCommentCreator::ClassComment() { wxDateTime now = wxDateTime::Now(); wxString comment; comment << wxT("/**\n"); comment << wxT(" * \\class ") << m_tag->GetName() << wxT("\n"); comment << wxT(" * \\brief \n"); comment << wxT(" * \\author ") << wxGetUserName() << wxT("\n"); comment << wxT(" * \\date ") << now.FormatDate() << wxT("\n"); comment << wxT(" */\n"); return comment; } wxString CppCommentCreator::FunctionComment() { wxDateTime now = wxDateTime::Now(); wxString comment; //parse the function signature std::vector<TagEntryPtr> tags; LanguageST::Get()->GetLocalVariables(m_tag->GetSignature(), tags); comment << wxT("/**\n"); comment << wxT(" * \\brief \n"); for(size_t i=0; i<tags.size(); i++) comment << wxT(" * \\param ") << tags.at(i)->GetName() << wxT("\n"); comment << wxT(" * \\return \n"); comment << wxT(" */\n"); return comment; }
[ "eranif@b1f272c1-3a1e-0410-8d64-bdc0ffbdec4b" ]
[ [ [ 1, 54 ] ] ]
1c6051447bd6e3ed601ef8c4114a4dc025d80063
99d3989754840d95b316a36759097646916a15ea
/tags/2011_09_07_to_baoxin_gpd_0.1/ferrylibs/src/ferry/feature_tracking/CleanedPOFM.h
78481bae321c08049e525b084aa54c7ab3d6723c
[]
no_license
svn2github/ferryzhouprojects
5d75b3421a9cb8065a2de424c6c45d194aeee09c
482ef1e6070c75f7b2c230617afe8a8df6936f30
refs/heads/master
2021-01-02T09:20:01.983370
2011-10-20T11:39:38
2011-10-20T11:39:38
11,786,263
1
0
null
null
null
null
UTF-8
C++
false
false
742
h
#pragma once #include "PointsOutFeatureMatcher.h" #include "MatchCleaner.h" namespace ferry { namespace feature_tracking { class CleanedPOFM : public PointsOutFeatureMatcher { public: CleanedPOFM(PointsOutFeatureMatcher* ppofm, MatchCleaner* pmc) { this->ppofm = ppofm; this->pmc = pmc; } ~CleanedPOFM(void); public: void compute(IplImage* im1, IplImage* im2, const vector<CvPoint>& corners1, const vector<CvPoint>& corners2, vector<CvPoint>& x1s, vector<CvPoint>& x2s) { vector<CvPoint> init_x1s, init_x2s; ppofm->compute(im1, im2, corners1, corners2, init_x1s, init_x2s); pmc->clean(init_x1s, init_x2s, x1s, x2s); } private: PointsOutFeatureMatcher* ppofm; MatchCleaner* pmc; }; } }
[ "ferryzhou@b6adba56-547e-11de-b413-c5e99dc0a8e2" ]
[ [ [ 1, 32 ] ] ]
5f230ba5dedec2ec8c8bc02b2a1feac38ba57000
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/contrib/nmax/ui/envelopecurvectrl/nmaxenvelopecurve/nmaxenvelopecurveidl.h
2b8c49f9406ce990b41bc9f0b0d0250fdc260e87
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
9,479
h
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 6.00.0361 */ /* at Fri Mar 23 10:17:13 2007 */ /* Compiler settings for .\nmaxenvelopecurve.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef __nmaxenvelopecurveidl_h__ #define __nmaxenvelopecurveidl_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef ___Dnmaxenvelopecurve_FWD_DEFINED__ #define ___Dnmaxenvelopecurve_FWD_DEFINED__ typedef interface _Dnmaxenvelopecurve _Dnmaxenvelopecurve; #endif /* ___Dnmaxenvelopecurve_FWD_DEFINED__ */ #ifndef ___DnmaxenvelopecurveEvents_FWD_DEFINED__ #define ___DnmaxenvelopecurveEvents_FWD_DEFINED__ typedef interface _DnmaxenvelopecurveEvents _DnmaxenvelopecurveEvents; #endif /* ___DnmaxenvelopecurveEvents_FWD_DEFINED__ */ #ifndef __nmaxenvelopecurve_FWD_DEFINED__ #define __nmaxenvelopecurve_FWD_DEFINED__ #ifdef __cplusplus typedef class nmaxenvelopecurve nmaxenvelopecurve; #else typedef struct nmaxenvelopecurve nmaxenvelopecurve; #endif /* __cplusplus */ #endif /* __nmaxenvelopecurve_FWD_DEFINED__ */ #ifdef __cplusplus extern "C"{ #endif void * __RPC_USER MIDL_user_allocate(size_t); void __RPC_USER MIDL_user_free( void * ); #ifndef __nmaxenvelopecurveLib_LIBRARY_DEFINED__ #define __nmaxenvelopecurveLib_LIBRARY_DEFINED__ /* library nmaxenvelopecurveLib */ /* [control][helpstring][helpfile][version][uuid] */ EXTERN_C const IID LIBID_nmaxenvelopecurveLib; #ifndef ___Dnmaxenvelopecurve_DISPINTERFACE_DEFINED__ #define ___Dnmaxenvelopecurve_DISPINTERFACE_DEFINED__ /* dispinterface _Dnmaxenvelopecurve */ /* [helpstring][uuid] */ EXTERN_C const IID DIID__Dnmaxenvelopecurve; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("949C1889-5D48-44FF-B422-CBE798F64039") _Dnmaxenvelopecurve : public IDispatch { }; #else /* C style interface */ typedef struct _DnmaxenvelopecurveVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( _Dnmaxenvelopecurve * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( _Dnmaxenvelopecurve * This); ULONG ( STDMETHODCALLTYPE *Release )( _Dnmaxenvelopecurve * This); HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( _Dnmaxenvelopecurve * This, /* [out] */ UINT *pctinfo); HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( _Dnmaxenvelopecurve * This, /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo **ppTInfo); HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( _Dnmaxenvelopecurve * This, /* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID *rgDispId); /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( _Dnmaxenvelopecurve * This, /* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS *pDispParams, /* [out] */ VARIANT *pVarResult, /* [out] */ EXCEPINFO *pExcepInfo, /* [out] */ UINT *puArgErr); END_INTERFACE } _DnmaxenvelopecurveVtbl; interface _Dnmaxenvelopecurve { CONST_VTBL struct _DnmaxenvelopecurveVtbl *lpVtbl; }; #ifdef COBJMACROS #define _Dnmaxenvelopecurve_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define _Dnmaxenvelopecurve_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define _Dnmaxenvelopecurve_Release(This) \ (This)->lpVtbl -> Release(This) #define _Dnmaxenvelopecurve_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) #define _Dnmaxenvelopecurve_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) #define _Dnmaxenvelopecurve_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) #define _Dnmaxenvelopecurve_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* ___Dnmaxenvelopecurve_DISPINTERFACE_DEFINED__ */ #ifndef ___DnmaxenvelopecurveEvents_DISPINTERFACE_DEFINED__ #define ___DnmaxenvelopecurveEvents_DISPINTERFACE_DEFINED__ /* dispinterface _DnmaxenvelopecurveEvents */ /* [helpstring][uuid] */ EXTERN_C const IID DIID__DnmaxenvelopecurveEvents; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("BC8E451C-50C9-4F41-9F4D-7113C3212D05") _DnmaxenvelopecurveEvents : public IDispatch { }; #else /* C style interface */ typedef struct _DnmaxenvelopecurveEventsVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( _DnmaxenvelopecurveEvents * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( _DnmaxenvelopecurveEvents * This); ULONG ( STDMETHODCALLTYPE *Release )( _DnmaxenvelopecurveEvents * This); HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( _DnmaxenvelopecurveEvents * This, /* [out] */ UINT *pctinfo); HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( _DnmaxenvelopecurveEvents * This, /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo **ppTInfo); HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( _DnmaxenvelopecurveEvents * This, /* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID *rgDispId); /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( _DnmaxenvelopecurveEvents * This, /* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS *pDispParams, /* [out] */ VARIANT *pVarResult, /* [out] */ EXCEPINFO *pExcepInfo, /* [out] */ UINT *puArgErr); END_INTERFACE } _DnmaxenvelopecurveEventsVtbl; interface _DnmaxenvelopecurveEvents { CONST_VTBL struct _DnmaxenvelopecurveEventsVtbl *lpVtbl; }; #ifdef COBJMACROS #define _DnmaxenvelopecurveEvents_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define _DnmaxenvelopecurveEvents_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define _DnmaxenvelopecurveEvents_Release(This) \ (This)->lpVtbl -> Release(This) #define _DnmaxenvelopecurveEvents_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) #define _DnmaxenvelopecurveEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) #define _DnmaxenvelopecurveEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) #define _DnmaxenvelopecurveEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* ___DnmaxenvelopecurveEvents_DISPINTERFACE_DEFINED__ */ EXTERN_C const CLSID CLSID_nmaxenvelopecurve; #ifdef __cplusplus class DECLSPEC_UUID("EDA6DBCD-A8BB-4709-AB92-40181C0C58CE") nmaxenvelopecurve; #endif #endif /* __nmaxenvelopecurveLib_LIBRARY_DEFINED__ */ /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 316 ] ] ]
93992eacc0c555062f1763bcbd48b86d3ec58dcc
dd5c8920aa0ea96607f2498701c81bb1af2b3c96
/stlplus/source/cli_parser.hpp
2b2d7f8c6da542cb105046eff1e2df429a87418f
[]
no_license
BackupTheBerlios/multicrew-svn
913279401e9cf886476a3c912ecd3d2b8d28344c
5087f07a100f82c37d2b85134ccc9125342c58d1
refs/heads/master
2021-01-23T13:36:03.990862
2005-06-10T16:52:32
2005-06-10T16:52:32
40,747,367
0
0
null
null
null
null
UTF-8
C++
false
false
12,066
hpp
#ifndef CLI_PARSER_HPP #define CLI_PARSER_HPP /*------------------------------------------------------------------------------ Author: Andy Rushton Copyright: (c) Andy Rushton, 2004 License: BSD License, see ../docs/license.html A subsystem for managing command-line parsing, including using INI files to control the default options. ------------------------------------------------------------------------------*/ #include "os_fixes.hpp" #include <string> #include <stdexcept> #include "error_handler.hpp" #include "ini_manager.hpp" //////////////////////////////////////////////////////////////////////////////// // declarations // enum to define the basic behaviour of an argument // - a switch is an option with no value but which can be switched on or off e.g. -help and -nohelp // - a value is an option followed by a value e.g. -output results.txt // (a default value can be removed by using the option as a negated switch e.g. -nooutput) // - command-line values (i.e. any strings not preceded by '-') are treated internally as an option with no name and must be values enum cli_kind_t {cli_switch_kind, cli_value_kind}; // the mode controls the behaviour if an option appears more than once in either the command-line or the ini files // - a single mode option overrides all previous values so will only be found once in the parsed result // - a multiple mode option can be repeated to define multiple values, but overrides values from ini files // - a cumulative mode option is a multiple mode option which keeps ini file values as well enum cli_mode_t {cli_single_mode, cli_multiple_mode, cli_cumulative_mode}; // There are two structures used for defining command-line parameters // (1) a C struct which is used in a C array - this is used for declaring command-line parameters in a static declaration // (2) a C++ class which is used in an STL vector - this is used for building command-line parameters within code // The C struct for definitions struct cli_definition_t { // the name of the option, e.g. "help" const char* m_name; // the kind of the option, e.g. cli_switch_kind cli_kind_t m_kind; // the mode e.g. cli_single_mode cli_mode_t m_mode; // the mnemonic for the message giving usage information for this option const char* m_message; // built-in default value - null if not present const char* m_default; }; // The C array of the C struct. The array must be terminated by END_CLI_DEFINITIONS. typedef cli_definition_t cli_definitions_t []; #define END_CLI_DEFINITIONS {0,cli_switch_kind,cli_single_mode,"",0} // The C++ class for definitions class cli_definition { public: // the name of the option, e.g. "help" std::string m_name; // the kind of the option, e.g. switch_kind cli_kind_t m_kind; // the mode e.g. xingle_mode cli_mode_t m_mode; // the mnemonic for the message giving usag std::string m_message; // built-in default value - empty string if not present std::string m_default; // constructor that allows a definition to be created in one line cli_definition(const std::string& name, cli_kind_t kind, cli_mode_t mode, const std::string& message, const std::string& default_value = std::string()) : m_name(name), m_kind(kind), m_mode(mode), m_message(message), m_default(default_value) {} }; // The C++ vector of the C++ class typedef std::vector<cli_definition> cli_definitions; ////////////////////////////////////////////////////////////////////////////// // exceptions that can be thrown by the CLI parser // they are all derivatives of std::logic_error because all errors are predictable by code inspection // a correct program will never throw an exception // thrown if a command-line argument is accessed with the wrong mode - i.e. attempt to get the value of a switch class cli_mode_error : public std::invalid_argument { public: cli_mode_error(const std::string& arg) : std::invalid_argument(arg) {} ~cli_mode_error(void) throw() {} }; // similar to std::out_of_range thrown for using an index out of range class cli_index_error : public std::out_of_range { public: cli_index_error(const std::string& arg) : std::out_of_range(arg) {} ~cli_index_error(void) throw() {} }; // similar to std::invalid_argument - thrown for passing an illegal argument to a method class cli_argument_error : public std::invalid_argument { public: cli_argument_error(const std::string& arg) : std::invalid_argument(arg) {} ~cli_argument_error(void) throw() {} }; //////////////////////////////////////////////////////////////////////////////// class cli_parser { public: // Type definitions map the global type names onto convenient scoped names typedef cli_kind_t kind_t; typedef cli_mode_t mode_t; typedef cli_definition_t definition_t; typedef cli_definitions_t definitions_t; typedef cli_definition definition; typedef cli_definitions definitions; //////////////////////////////////////////////////////////////////////////////// // Methods // various constructors // you have a choice of either creating an uninitialised CLI parser and then // calling separate functions to set it up or of calling one of the // composite constructors. However, you must set up the error handler in the // constructor. // set up the parser with its error handler // defer everything else cli_parser(error_handler& errors) throw(); // constructors using the C definitions_t structure // set up the parser with the error handler and define all the command-line options // defer default values and parameter parsing cli_parser(cli_definitions_t, error_handler& errors) throw(cli_mode_error); // set up the parser with the error handler and define all the command-line options and their default from the ini files // defer parameter parsing cli_parser(cli_definitions_t, const ini_manager& defaults, const std::string& ini_section, error_handler& errors) throw(cli_mode_error); // set up the parser with the error handler and define all the command-line options // no ini files used for default values, so only built-in defaults supported // then parse the command line cli_parser(char* argv[], cli_definitions_t, error_handler& errors) throw(cli_mode_error,error_handler_id_error,error_handler_format_error); // set up the parser with the error handler and define all the command-line options and their default from the ini files // then parse the command line cli_parser(char* argv[], cli_definitions_t, const ini_manager& defaults, const std::string& ini_section, error_handler& errors) throw(cli_mode_error,error_handler_id_error,error_handler_format_error); // constructors using the C++ definitions structure // set up the parser with the error handler and define all the command-line options from a C array of structs // defer default values and parameter parsing cli_parser(cli_definitions, error_handler& errors) throw(cli_mode_error); // set up the parser with the error handler and define all the command-line options and their default from the ini files // defer parameter parsing cli_parser(cli_definitions, const ini_manager& defaults, const std::string& ini_section, error_handler& errors) throw(cli_mode_error); // set up the parser with the error handler and define all the command-line options // no ini files used for default values, so only built-in defaults supported // then parse the command line cli_parser(char* argv[], cli_definitions, error_handler& errors) throw(cli_mode_error,error_handler_id_error,error_handler_format_error); // set up the parser with the error handler and define all the command-line options and their default from the ini files // then parse the command line cli_parser(char* argv[], cli_definitions, const ini_manager& defaults, const std::string& ini_section, error_handler& errors) throw(cli_mode_error,error_handler_id_error,error_handler_format_error); ~cli_parser(void) throw(); // the separate functions for initialising the parser in steps. These are // declared in the order of use. Firts, add definitions of command-line // arguments. Then optionally load default values from ini files, then // finally parse the command line. // add a set of C definitions. The definitions will be given ID codes from 0 to the number of elements - 1 in the array void add_definitions(cli_definitions_t) throw(cli_mode_error); // add a single C definition, returning the ID code for it unsigned add_definition(const definition_t&) throw(cli_mode_error,cli_argument_error); // add a set of C++ definitions. The definitions will be given ID codes from 0 to the number of elements - 1 in the array void add_definitions(cli_definitions) throw(cli_mode_error); // add a single C++ definition, returning the ID code for it unsigned add_definition(const definition&) throw(cli_mode_error); // All definitions have an optional built-in default value which is stored // in the definition types above. However, these can optionally be // overridden by a value from an ini file. If you want this functionality, // call this function. If you don't want ini file handling, simply don't // call it. The values will be searched for only in the named section of the // ini file (sections are labelled by e.g. [vassemble]), so in this case you // would specify the section name as "vassemble" (exclude the brackets). void set_defaults(const ini_manager& defaults, const std::string& ini_section) throw(); // the final stage of initialisation is to read the command-line and extract // the values from it. If parse errors are found, this will report the // errors using the error handler and return false. bool parse(char* argv[]) throw(cli_argument_error,error_handler_id_error,error_handler_format_error); // test for whether the CLI parser is still valid (no errors have happened) after the initialisation phase bool valid(void) throw(); // iteration functions avoiding the use of iterators. Just loop through the // arguments from 0 to size()-1 and use the index of the loop to interrogate // the command-line for the value at that position. // the number of values to read, indexed 0 to size()-1 unsigned size(void) const throw(); // the argument name std::string name(unsigned i) const throw(cli_index_error); // the argument ID, that is, the offset into the original definitions unsigned id(unsigned i) const throw(cli_index_error); // the kind (switch or value) and short-cut tests for the different kinds cli_kind_t kind(unsigned i) const throw(cli_index_error); bool switch_kind(unsigned i) const throw(cli_index_error); bool value_kind(unsigned i) const throw(cli_index_error); // the mode (single, multiple, cumulative) and short-cut tests for the different modes // - you rarely need to know this since it mainly controls the parsing cli_mode_t mode(unsigned i) const throw(cli_index_error); bool single_mode(unsigned i) const throw(cli_index_error); bool multiple_mode(unsigned i) const throw(cli_index_error); bool cumulative_mode(unsigned i) const throw(cli_index_error); // get the switch's value, but only if the value is of switch kind bool switch_value(unsigned i) const throw(cli_mode_error,cli_index_error); // get the option's value, but only if it is of value kind std::string string_value(unsigned i) const throw(cli_mode_error,cli_index_error); // print the usage report - typically in response to the -help switch being on void usage(void) const throw(std::runtime_error); private: friend class cli_parser_data; smart_ptr<cli_parser_data> m_data; }; #endif
[ "schimmi@cb9ff89a-abed-0310-8fc6-a4cabe7d48c9" ]
[ [ [ 1, 272 ] ] ]
9ddc464200870e48c408ae5a84107c234e1e8183
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/Library/CPPDrawManager.old.cpp
10c3e114d34b8da0a64dab950ad3dddb2de49857
[]
no_license
code4bones/crawlpaper
edbae18a8b099814a1eed5453607a2d66142b496
f218be1947a9791b2438b438362bc66c0a505f99
refs/heads/master
2021-01-10T13:11:23.176481
2011-04-14T11:04:17
2011-04-14T11:04:17
44,686,513
0
1
null
null
null
null
WINDOWS-1251
C++
false
false
41,875
cpp
#include "window.h" #include "CPPDrawManager.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif //LPI #define TRACE ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CPPDrawManager::CPPDrawManager() { } CPPDrawManager::~CPPDrawManager() { } CSize CPPDrawManager::GetSizeOfIcon(HICON hIcon) const { CSize sz (0, 0); if (hIcon != NULL) { ICONINFO ii; // Gets icon dimension ::ZeroMemory(&ii, sizeof(ICONINFO)); if (::GetIconInfo(hIcon, &ii)) { sz.cx = (DWORD)(ii.xHotspot * 2); sz.cy = (DWORD)(ii.yHotspot * 2); //release icon mask bitmaps if(ii.hbmMask) ::DeleteObject(ii.hbmMask); if(ii.hbmColor) ::DeleteObject(ii.hbmColor); } //if } //if return sz; } //End GetSizeOfIcon CSize CPPDrawManager::GetSizeOfBitmap(HBITMAP hBitmap) const { CSize sz (0, 0); if (hBitmap != NULL) { BITMAP csBitmapSize; // Get bitmap size int nRetValue = ::GetObject(hBitmap, sizeof(csBitmapSize), &csBitmapSize); if (nRetValue) { sz.cx = (DWORD)csBitmapSize.bmWidth; sz.cy = (DWORD)csBitmapSize.bmHeight; } //if } //if return sz; } //End GetSizeOfBitmap void CPPDrawManager::AlphaBitBlt(HDC hDestDC, int nDestX, int nDestY, DWORD dwWidth, DWORD dwHeight, HDC hSrcDC, int nSrcX, int nSrcY, int percent /* = 100 */) { ASSERT ((NULL != hDestDC) || (NULL != hSrcDC)); if (percent >= 100) { ::BitBlt(hDestDC, nDestX, nDestY, dwWidth, dwHeight, hSrcDC, nSrcX, nSrcY, SRCCOPY); return; } //if HDC hTempDC = ::CreateCompatibleDC(hDestDC); if (NULL == hTempDC) return; //Creates Source DIB LPBITMAPINFO lpbiSrc; // Fill in the BITMAPINFOHEADER lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiSrc->bmiHeader.biWidth = dwWidth; lpbiSrc->bmiHeader.biHeight = dwHeight; lpbiSrc->bmiHeader.biPlanes = 1; lpbiSrc->bmiHeader.biBitCount = 32; lpbiSrc->bmiHeader.biCompression = BI_RGB; lpbiSrc->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiSrc->bmiHeader.biXPelsPerMeter = 0; lpbiSrc->bmiHeader.biYPelsPerMeter = 0; lpbiSrc->bmiHeader.biClrUsed = 0; lpbiSrc->bmiHeader.biClrImportant = 0; COLORREF* pSrcBits = NULL; HBITMAP hSrcDib = CreateDIBSection ( hSrcDC, lpbiSrc, DIB_RGB_COLORS, (void **)&pSrcBits, NULL, NULL); if ((NULL != hSrcDib) && (NULL != pSrcBits)) { HBITMAP hOldTempBmp = (HBITMAP)::SelectObject (hTempDC, hSrcDib); ::BitBlt (hTempDC, 0, 0, dwWidth, dwHeight, hSrcDC, nSrcX, nSrcY, SRCCOPY); ::SelectObject (hTempDC, hOldTempBmp); //Creates Destination DIB LPBITMAPINFO lpbiDest; // Fill in the BITMAPINFOHEADER lpbiDest = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiDest->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiDest->bmiHeader.biWidth = dwWidth; lpbiDest->bmiHeader.biHeight = dwHeight; lpbiDest->bmiHeader.biPlanes = 1; lpbiDest->bmiHeader.biBitCount = 32; lpbiDest->bmiHeader.biCompression = BI_RGB; lpbiDest->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiDest->bmiHeader.biXPelsPerMeter = 0; lpbiDest->bmiHeader.biYPelsPerMeter = 0; lpbiDest->bmiHeader.biClrUsed = 0; lpbiDest->bmiHeader.biClrImportant = 0; COLORREF* pDestBits = NULL; HBITMAP hDestDib = CreateDIBSection ( hDestDC, lpbiDest, DIB_RGB_COLORS, (void **)&pDestBits, NULL, NULL); if ((NULL != hDestDib) && (NULL != pDestBits)) { ::SelectObject (hTempDC, hDestDib); ::BitBlt (hTempDC, 0, 0, dwWidth, dwHeight, hDestDC, nDestX, nDestY, SRCCOPY); ::SelectObject (hTempDC, hOldTempBmp); double src_darken = (double)percent / 100.0; double dest_darken = 1.0 - src_darken; for (DWORD pixel = 0; pixel < dwWidth * dwHeight; pixel++, pSrcBits++, pDestBits++) { *pDestBits = PixelAlpha(*pSrcBits, src_darken, *pDestBits, dest_darken); } //for ::SelectObject (hTempDC, hDestDib); ::BitBlt (hDestDC, nDestX, nDestY, dwWidth, dwHeight, hTempDC, 0, 0, SRCCOPY); ::SelectObject (hTempDC, hOldTempBmp); delete lpbiDest; ::DeleteObject(hDestDib); } //if delete lpbiSrc; ::DeleteObject(hSrcDib); ::DeleteObject(hOldTempBmp); } //if ::DeleteDC(hTempDC); } //End AlphaBitBlt HBITMAP CPPDrawManager::CreateImageEffect(HBITMAP hBitmap, DWORD dwWidth, DWORD dwHeight, DWORD dwEffect, BOOL bUseMask /* = TRUE */, COLORREF crMask /* = RGB(255, 0, 255) */, COLORREF crMono /* = RGB(255, 255, 255) */) { HBITMAP hOldSrcBmp = NULL; HBITMAP hOldResBmp = NULL; HDC hMainDC = NULL; HDC hSrcDC = NULL; HDC hResDC = NULL; hMainDC = GetDC(NULL); hSrcDC = ::CreateCompatibleDC(hMainDC); hResDC = ::CreateCompatibleDC(hMainDC); hOldSrcBmp = (HBITMAP)::SelectObject(hSrcDC, hBitmap); LPBITMAPINFO lpbi; // Fill in the BITMAPINFOHEADER lpbi = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbi->bmiHeader.biWidth = dwWidth; lpbi->bmiHeader.biHeight = dwHeight; lpbi->bmiHeader.biPlanes = 1; lpbi->bmiHeader.biBitCount = 32; lpbi->bmiHeader.biCompression = BI_RGB; lpbi->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbi->bmiHeader.biXPelsPerMeter = 0; lpbi->bmiHeader.biYPelsPerMeter = 0; lpbi->bmiHeader.biClrUsed = 0; lpbi->bmiHeader.biClrImportant = 0; COLORREF* pBits = NULL; HBITMAP hDibBmp = CreateDIBSection ( hSrcDC, lpbi, DIB_RGB_COLORS, (void **)&pBits, NULL, NULL); if (hDibBmp == NULL || pBits == NULL) { delete lpbi; ASSERT (FALSE); return NULL; } //if hOldResBmp = (HBITMAP)::SelectObject (hResDC, hDibBmp); ::BitBlt (hResDC, 0, 0, dwWidth, dwHeight, hSrcDC, 0, 0, SRCCOPY); for (DWORD pixel = 0; pixel < dwWidth * dwHeight; pixel++, *pBits++) { COLORREF color = (COLORREF)*pBits; if (bUseMask && (color == crMask)) { //This is transparent area color = RGB(0, 0, 0); } else { if (dwEffect & IMAGE_EFFECT_GRAYEN) color = GrayColor(color); if (dwEffect & IMAGE_EFFECT_DARKEN) color = DarkenColor(color, 0.75); if (dwEffect & IMAGE_EFFECT_LIGHTEN) color = LightenColor(color, 0.25); if (dwEffect & IMAGE_EFFECT_MONOCHROME) color = crMono; } //if if (dwEffect & IMAGE_EFFECT_INVERT) color = InvertColor(color); *pBits = color; } //for ::SelectObject(hSrcDC, hOldSrcBmp); ::SelectObject(hResDC, hOldResBmp); ::DeleteDC(hSrcDC); ::DeleteDC(hResDC); ::ReleaseDC(NULL, hMainDC); delete lpbi; return hDibBmp; } //End CreateImageEffect COLORREF CPPDrawManager::GrayColor(COLORREF clrColor) { BYTE nGrayColor = (BYTE)((GetRValue(clrColor) * 0.299) + (GetGValue(clrColor) * 0.587) + (GetBValue(clrColor) * 0.114)); //color to grey mapping <H. Muelner> <jurgene> //BYTE nGrayColor = (BYTE)((GetBValue(clrColor)*117 + GetGValue(clrColor)*601 + GetRValue(clrColor)*306) >> 10) return RGB(nGrayColor, nGrayColor, nGrayColor); } //End GrayColor COLORREF CPPDrawManager::InvertColor(COLORREF clrColor) { return RGB(255 - GetRValue(clrColor), 255 - GetGValue(clrColor), 255 - GetBValue(clrColor)); } //End InvertColor COLORREF CPPDrawManager::DarkenColor(COLORREF clrColor, double darken) { if (darken >= 0.0 && darken < 1.0) { BYTE color_r, color_g, color_b; color_r = (BYTE)(GetRValue(clrColor) * darken); color_g = (BYTE)(GetGValue(clrColor) * darken); color_b = (BYTE)(GetBValue(clrColor) * darken); clrColor = RGB(color_r, color_g, color_b); } //if return clrColor; } //End DarkenColor COLORREF CPPDrawManager::LightenColor(COLORREF clrColor, double lighten) { if (lighten > 0.0 && lighten <= 1.0) { BYTE color_r, color_g, color_b; lighten += 1.0; color_r = (BYTE)min((DWORD)GetRValue(clrColor) * lighten, 255); color_g = (BYTE)min((DWORD)GetGValue(clrColor) * lighten, 255); color_b = (BYTE)min((DWORD)GetBValue(clrColor) * lighten, 255); clrColor = RGB(color_r, color_g, color_b); /* lighten *= 255 color_r = (BYTE)max(0, min(255, (int)((color_r - 128) * 2.0 + 128 + lighten))); color_g = (BYTE)max(0, min(255, (int)((color_g - 128) * 2.0 + 128 + lighten))); color_b = (BYTE)max(0, min(255, (int)((color_b - 128) * 2.0 + 128 + lighten))); clrColor = RGB(color_r, color_g, color_b); */ } //if return clrColor; } //End LightenColor COLORREF CPPDrawManager::PixelAlpha(COLORREF clrSrc, double src_darken, COLORREF clrDest, double dest_darken) { return RGB (GetRValue (clrSrc) * src_darken + GetRValue (clrDest) * dest_darken, GetGValue (clrSrc) * src_darken + GetGValue (clrDest) * dest_darken, GetBValue (clrSrc) * src_darken + GetBValue (clrDest) * dest_darken); } //End PixelAlpha HICON CPPDrawManager::StretchIcon(HICON hIcon, DWORD dwWidth, DWORD dwHeight) { HICON hStretchedIcon = NULL; HDC hMainDC = NULL; HDC hSrcDC = NULL; HDC hDestDC = NULL; BITMAP bmp; HBITMAP hOldSrcBitmap = NULL; HBITMAP hOldDestBitmap = NULL; ICONINFO csOriginal, csStretched; if (!::GetIconInfo(hIcon, &csOriginal)) return FALSE; hMainDC = ::GetDC(NULL); hSrcDC = ::CreateCompatibleDC(hMainDC); hDestDC = ::CreateCompatibleDC(hMainDC); if ((NULL == hMainDC) || (NULL == hSrcDC) || (NULL == hDestDC)) return NULL; if (::GetObject(csOriginal.hbmColor, sizeof(BITMAP), &bmp)) { DWORD dwWidthOrg = csOriginal.xHotspot * 2; DWORD dwHeightOrg = csOriginal.yHotspot * 2; csStretched.hbmColor = ::CreateBitmap(dwWidth, dwHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL); if (NULL != csStretched.hbmColor) { hOldSrcBitmap = (HBITMAP)::SelectObject(hSrcDC, csOriginal.hbmColor); hOldDestBitmap = (HBITMAP)::SelectObject(hDestDC, csStretched.hbmColor); ::StretchBlt(hDestDC, 0, 0, dwWidth, dwHeight, hSrcDC, 0, 0, dwWidthOrg, dwHeightOrg, SRCCOPY); if (::GetObject(csOriginal.hbmMask, sizeof(BITMAP), &bmp)) { csStretched.hbmMask = ::CreateBitmap(dwWidth, dwHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL); if (NULL != csStretched.hbmMask) { ::SelectObject(hSrcDC, csOriginal.hbmMask); ::SelectObject(hDestDC, csStretched.hbmMask); ::StretchBlt(hDestDC, 0, 0, dwWidth, dwHeight, hSrcDC, 0, 0, dwWidthOrg, dwHeightOrg, SRCCOPY); } //if } //if ::SelectObject(hSrcDC, hOldSrcBitmap); ::SelectObject(hDestDC, hOldDestBitmap); csStretched.fIcon = TRUE; hStretchedIcon = ::CreateIconIndirect(&csStretched); } //if ::DeleteObject(csStretched.hbmColor); ::DeleteObject(csStretched.hbmMask); } //if ::DeleteObject(csOriginal.hbmColor); ::DeleteObject(csOriginal.hbmMask); ::DeleteDC(hSrcDC); ::DeleteDC(hDestDC); ::ReleaseDC(NULL, hMainDC); return hStretchedIcon; } //End StretchIcon void CPPDrawManager::FillGradient (HDC hDC, CRect rect, COLORREF colorStart, COLORREF colorFinish, BOOL bHorz/* = TRUE*/) { // this will make 2^6 = 64 fountain steps int nShift = 6; int nSteps = 1 << nShift; for (int i = 0; i < nSteps; i++) { // do a little alpha blending BYTE bR = (BYTE) ((GetRValue(colorStart) * (nSteps - i) + GetRValue(colorFinish) * i) >> nShift); BYTE bG = (BYTE) ((GetGValue(colorStart) * (nSteps - i) + GetGValue(colorFinish) * i) >> nShift); BYTE bB = (BYTE) ((GetBValue(colorStart) * (nSteps - i) + GetBValue(colorFinish) * i) >> nShift); HBRUSH hBrush = ::CreateSolidBrush(RGB(bR, bG, bB)); // then paint with the resulting color CRect r2 = rect; if (!bHorz) { r2.top = rect.top + ((i * rect.Height()) >> nShift); r2.bottom = rect.top + (((i + 1) * rect.Height()) >> nShift); if (r2.Height() > 0) ::FillRect(hDC, r2, hBrush); } else { r2.left = rect.left + ((i * rect.Width()) >> nShift); r2.right = rect.left + (((i + 1) * rect.Width()) >> nShift); if (r2.Width() > 0) ::FillRect(hDC, r2, hBrush); } //if if (NULL != hBrush) { ::DeleteObject(hBrush); hBrush = NULL; } //if } //for } //End FillGradient #ifdef USE_SHADE void CPPDrawManager::SetShade(CRect rect, UINT shadeID /* = 0 */, BYTE granularity /* = 8 */, BYTE coloring /* = 0 */, COLORREF hicr /* = 0 */, COLORREF midcr /* = 0 */, COLORREF locr /* = 0 */) { long sXSize,sYSize,bytes,j,i,k,h; BYTE *iDst ,*posDst; sYSize= rect.Height(); //rect.bottom-rect.top; sXSize= rect.Width(); //rect.right-rect.left ; // m_dh.Create(max(1,sXSize /*-2*m_FocusRectMargin-1*/ ),1,8); //create the horizontal focus bitmap // m_dv.Create(1,max(1,sYSize /*-2*m_FocusRectMargin*/),8); //create the vertical focus bitmap m_dNormal.Create(sXSize,sYSize,8); //create the default bitmap // COLORREF hicr = m_tool_info.crBegin; //GetSysColor(COLOR_BTNHIGHLIGHT); //get the button base colors // COLORREF midcr = m_tool_info.crMid; //GetSysColor(COLOR_BTNFACE); // COLORREF locr = m_tool_info.crEnd; //GetSysColor(COLOR_BTNSHADOW); long r,g,b; //build the shaded palette for(i=0;i<129;i++){ r=((128-i)*GetRValue(locr)+i*GetRValue(midcr))/128; g=((128-i)*GetGValue(locr)+i*GetGValue(midcr))/128; b=((128-i)*GetBValue(locr)+i*GetBValue(midcr))/128; m_dNormal.SetPaletteIndex((BYTE)i,(BYTE)r,(BYTE)g,(BYTE)b); // m_dh.SetPaletteIndex((BYTE)i,(BYTE)r,(BYTE)g,(BYTE)b); // m_dv.SetPaletteIndex((BYTE)i,(BYTE)r,(BYTE)g,(BYTE)b); } //for for(i=1;i<129;i++){ r=((128-i)*GetRValue(midcr)+i*GetRValue(hicr))/128; g=((128-i)*GetGValue(midcr)+i*GetGValue(hicr))/128; b=((128-i)*GetBValue(midcr)+i*GetBValue(hicr))/128; m_dNormal.SetPaletteIndex((BYTE)(i+127),(BYTE)r,(BYTE)g,(BYTE)b); // m_dh.SetPaletteIndex((BYTE)(i+127),(BYTE)r,(BYTE)g,(BYTE)b); // m_dv.SetPaletteIndex((BYTE)(i+127),(BYTE)r,(BYTE)g,(BYTE)b); } //for m_dNormal.BlendPalette(hicr,coloring); //color the palette /* iDst=m_dh.GetBits(); //build the horiz. dotted focus bitmap j=(long)m_dh.GetWidth(); for(i=0;i<j;i++){ // iDst[i]=64+127*(i%2); //soft iDst[i]=255*(i%2); //hard } iDst=m_dv.GetBits(); //build the vert. dotted focus bitmap j=(long)m_dv.GetHeight(); for(i=0;i<j;i++){ // *iDst=64+127*(i%2); //soft *iDst=255*(i%2); //hard iDst+=4; } */ bytes = m_dNormal.GetLineWidth(); iDst = m_dNormal.GetBits(); posDst =iDst; long a,x,y,d,xs,idxmax,idxmin; int grainx2=RAND_MAX/(max(1,2*granularity)); idxmax=255-granularity; idxmin=granularity; switch (shadeID) { //---------------------------------------------------- case EFFECT_METAL: m_dNormal.Clear(); // create the strokes k=40; //stroke granularity for(a=0;a<200;a++){ x=rand()/(RAND_MAX/sXSize); //stroke postion y=rand()/(RAND_MAX/sYSize); //stroke position xs=rand()/(RAND_MAX/min(sXSize,sYSize))/2; //stroke lenght d=rand()/(RAND_MAX/k); //stroke color for(i=0;i<xs;i++){ if (((x-i)>0)&&((y+i)<sYSize)) m_dNormal.SetPixelIndex(x-i,y+i,(BYTE)d); if (((x+i)<sXSize)&&((y-i)>0)) m_dNormal.SetPixelIndex(sXSize-x+i,y-i,(BYTE)d); } //for } //for //blend strokes with SHS_DIAGONAL posDst =iDst; a=(idxmax-idxmin-k)/2; for(i = 0; i < sYSize; i++) { for(j = 0; j < sXSize; j++) { d=posDst[j]+((a*i)/sYSize+(a*(sXSize-j))/sXSize); posDst[j]=(BYTE)d; posDst[j]+=rand()/grainx2; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_HARDBUMP: // //set horizontal bump for(i = 0; i < sYSize; i++) { k=(255*i/sYSize)-127; k=(k*(k*k)/128)/128; k=(k*(128-granularity*2))/128+128; for(j = 0; j < sXSize; j++) { posDst[j]=(BYTE)k; posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for //set vertical bump d=min(16,sXSize/6); //max edge=16 a=sYSize*sYSize/4; posDst =iDst; for(i = 0; i < sYSize; i++) { y=i-sYSize/2; for(j = 0; j < sXSize; j++) { x=j-sXSize/2; xs=sXSize/2-d+(y*y*d)/a; if (x>xs) posDst[j]=(BYTE)idxmin+(BYTE)(((sXSize-j)*128)/d); if ((x+xs)<0) posDst[j]=(BYTE)idxmax-(BYTE)((j*128)/d); posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_SOFTBUMP: // for(i = 0; i < sYSize; i++) { h=(255*i/sYSize)-127; for(j = 0; j < sXSize; j++) { k=(255*(sXSize-j)/sXSize)-127; k=(h*(h*h)/128)/128+(k*(k*k)/128)/128; k=k*(128-granularity)/128+128; if (k<idxmin) k=idxmin; if (k>idxmax) k=idxmax; posDst[j]=(BYTE)k; posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_VBUMP: // for(j = 0; j < sXSize; j++) { k=(255*(sXSize-j)/sXSize)-127; k=(k*(k*k)/128)/128; k=(k*(128-granularity))/128+128; for(i = 0; i < sYSize; i++) { posDst[j+i*bytes]=(BYTE)k; posDst[j+i*bytes]+=rand()/grainx2-granularity; } //for } //for break; //---------------------------------------------------- case EFFECT_HBUMP: // for(i = 0; i < sYSize; i++) { k=(255*i/sYSize)-127; k=(k*(k*k)/128)/128; k=(k*(128-granularity))/128+128; for(j = 0; j < sXSize; j++) { posDst[j]=(BYTE)k; posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_DIAGSHADE: // a=(idxmax-idxmin)/2; for(i = 0; i < sYSize; i++) { for(j = 0; j < sXSize; j++) { posDst[j]=(BYTE)(idxmin+a*i/sYSize+a*(sXSize-j)/sXSize); posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_HSHADE: // a=idxmax-idxmin; for(i = 0; i < sYSize; i++) { k=a*i/sYSize+idxmin; for(j = 0; j < sXSize; j++) { posDst[j]=(BYTE)k; posDst[j]+=rand()/grainx2-granularity; } //for posDst+=bytes; } //for break; //---------------------------------------------------- case EFFECT_VSHADE: //: a=idxmax-idxmin; for(j = 0; j < sXSize; j++) { k=a*(sXSize-j)/sXSize+idxmin; for(i = 0; i < sYSize; i++) { posDst[j+i*bytes]=(BYTE)k; posDst[j+i*bytes]+=rand()/grainx2-granularity; } //for } //for break; //---------------------------------------------------- case EFFECT_NOISE: for(i = 0; i < sYSize; i++) { for(j = 0; j < sXSize; j++) { posDst[j]=128+rand()/grainx2-granularity; } //for posDst+=bytes; } //for } //switch //---------------------------------------------------- } //End SetShade #endif void CPPDrawManager::FillEffect(HDC hDC, DWORD dwEffect, LPCRECT lpRect, COLORREF clrBegin, COLORREF clrMid /* = 0 */, COLORREF clrEnd /* = 0 */, BYTE granularity /* = 0 */, BYTE coloring /* = 0 */) { CRect rect = *lpRect; HBRUSH hBrush = NULL; switch (dwEffect) { default: hBrush = ::CreateSolidBrush(clrBegin); ::FillRect(hDC, lpRect, hBrush); break; /* case HS_HORIZONTAL: break; case HS_VERTICAL: break; case HS_FDIAGONAL: break; case HS_BDIAGONAL: break; case HS_CROSS: break; case HS_DIAGCROSS: break; */ case EFFECT_HGRADIENT: FillGradient(hDC, rect, clrBegin, clrEnd, TRUE); break; case EFFECT_VGRADIENT: FillGradient(hDC, rect, clrBegin, clrEnd, FALSE); break; case EFFECT_HCGRADIENT: FillGradient(hDC, CRect(rect.left, rect.top, rect.left + rect.Width() / 2, rect.bottom), clrBegin, clrEnd, TRUE); FillGradient(hDC, CRect(rect.left + rect.Width() / 2, rect.top, rect.right, rect.bottom), clrEnd, clrBegin, TRUE); break; case EFFECT_VCGRADIENT: FillGradient(hDC, CRect (rect.left, rect.top, rect.right, rect.top + rect.Height() / 2), clrBegin, clrEnd, FALSE); FillGradient(hDC, CRect (rect.left, rect.top + rect.Height() / 2, rect.right, rect.bottom), clrEnd, clrBegin, FALSE); break; case EFFECT_3HGRADIENT: FillGradient(hDC, CRect(rect.left, rect.top, rect.left + rect.Width()/2, rect.bottom), clrBegin, clrMid, TRUE); FillGradient(hDC, CRect(rect.left + rect.Width() / 2, rect.top, rect.right, rect.bottom), clrMid, clrEnd, TRUE); break; case EFFECT_3VGRADIENT: FillGradient(hDC, CRect (rect.left, rect.top, rect.right, rect.top + rect.Height() / 2), clrBegin, clrMid, FALSE); FillGradient(hDC, CRect (rect.left, rect.top + rect.Height() / 2, rect.right, rect.bottom), clrMid, clrEnd, FALSE); break; #ifdef USE_SHADE case EFFECT_NOISE: case EFFECT_DIAGSHADE: case EFFECT_HSHADE: case EFFECT_VSHADE: case EFFECT_HBUMP: case EFFECT_VBUMP: case EFFECT_SOFTBUMP: case EFFECT_HARDBUMP: case EFFECT_METAL: SetShade(CRect (0, 0, rect.Width(), rect.Height()), dwEffect, granularity, coloring, clrBegin, clrMid, clrEnd); m_dNormal.Draw(hDC, rect.left, rect.top); break; #endif } //switch if (NULL != hBrush) { ::DeleteObject(hBrush); hBrush = NULL; } //if } //End FillEffect void CPPDrawManager::MultipleCopy(HDC hDestDC, int nDestX, int nDestY, DWORD dwDestWidth, DWORD dwDestHeight, HDC hSrcDC, int nSrcX, int nSrcY, DWORD dwSrcWidth, DWORD dwSrcHeight) { // Horizontal copying int right, bottom; int nDestRight = (int)(nDestX + dwDestWidth); int nDestBottom = (int)(nDestY + dwDestHeight); for (int x = nDestX; x < nDestRight; x+= dwSrcWidth) { right = min (x + (int)dwSrcWidth, nDestRight); // Vertical copying for (int y = nDestY; y < nDestBottom; y+= dwSrcHeight) { bottom = min (y + (int)dwSrcHeight, nDestBottom); ::BitBlt(hDestDC, x, y, right - x, bottom - y, hSrcDC, nSrcX, nSrcY, SRCCOPY); } //for } //for } //End MultipleCopy void CPPDrawManager::DrawBitmap(HDC hDC, int x, int y, DWORD dwWidth, DWORD dwHeight, HBITMAP hSrcBitmap, BOOL bUseMask, COLORREF crMask, DWORD dwEffect /* = IMAGE_EFFECT_NONE */, BOOL bShadow /* = FALSE */, DWORD dwCxShadow /* = PPDRAWMANAGER_SHADOW_XOFFSET */, DWORD dwCyShadow /* = PPDRAWMANAGER_SHADOW_YOFFSET */, DWORD dwCxDepth /* = PPDRAWMANAGER_SHADOW_XDEPTH */, DWORD dwCyDepth /* = PPDRAWMANAGER_SHADOW_YDEPTH */, COLORREF clrShadow /* = PPDRAWMANAGER_SHADOW_COLOR */) { if (NULL == hSrcBitmap) return; CSize sz = GetSizeOfBitmap(hSrcBitmap); HDC hSrcDC = ::CreateCompatibleDC(hDC); HDC hDestDC = ::CreateCompatibleDC(hDC); HBITMAP hBitmapTemp = ::CreateCompatibleBitmap(hDC, dwWidth, dwHeight); HBITMAP hOldSrcBitmap = (HBITMAP)::SelectObject(hSrcDC, hSrcBitmap); HBITMAP hOldDestBitmap = (HBITMAP)::SelectObject(hDestDC, hBitmapTemp); //Scales a bitmap if need if (((DWORD)sz.cx != dwWidth) || ((DWORD)sz.cy != dwHeight)) ::StretchBlt(hDestDC, 0, 0, dwWidth, dwHeight, hSrcDC, 0, 0, sz.cx, sz.cy, SRCCOPY); else ::BitBlt(hDestDC, 0, 0, dwWidth, dwHeight, hSrcDC, 0, 0, SRCCOPY); ::SelectObject(hDestDC, hOldDestBitmap); HBITMAP hMaskBmp = CreateImageEffect(hBitmapTemp, dwWidth, dwHeight, IMAGE_EFFECT_MASK, bUseMask, crMask); HBITMAP hBitmap = CreateImageEffect(hBitmapTemp, dwWidth, dwHeight, dwEffect, bUseMask, crMask); if (bShadow) { if (dwEffect & IMAGE_EFFECT_SHADOW) { CPoint ptShadow = CPoint (x, y); ptShadow.x += dwCxShadow; ptShadow.y += dwCyShadow; HBITMAP hShadowBmp = CreateImageEffect(hBitmapTemp, dwWidth, dwHeight, IMAGE_EFFECT_MASK, bUseMask, crMask, InvertColor(clrShadow)); DrawShadow(hDC, ptShadow.x, ptShadow.y, dwWidth, dwHeight, hShadowBmp, dwEffect & IMAGE_EFFECT_GRADIENT_SHADOW, dwCxDepth, dwCyDepth); ::DeleteObject(hShadowBmp); } else { x += dwCxShadow; y += dwCyShadow; } //if } //if //Merge the image mask with backround ::SelectObject(hSrcDC, hMaskBmp); ::BitBlt(hDC, x, y, dwWidth, dwHeight, hSrcDC, 0, 0, SRCAND); //Draw the image ::SelectObject(hSrcDC, hBitmap); ::BitBlt(hDC, x, y, dwWidth, dwHeight, hSrcDC, 0, 0, SRCPAINT); ::SelectObject(hSrcDC, hOldSrcBitmap); ::DeleteDC(hDestDC); ::DeleteDC(hSrcDC); ::DeleteObject(hOldDestBitmap); ::DeleteObject(hOldSrcBitmap); ::DeleteObject(hBitmap); ::DeleteObject(hMaskBmp); ::DeleteObject(hBitmapTemp); } //End DrawBitmap void CPPDrawManager::DrawIcon(HDC hDC, int x, int y, DWORD dwWidth, DWORD dwHeight, HICON hSrcIcon, DWORD dwEffect /* = IMAGE_EFFECT_NONE */, BOOL bShadow /* = FALSE */, DWORD dwCxShadow /* = PPDRAWMANAGER_SHADOW_XOFFSET */, DWORD dwCyShadow /* = PPDRAWMANAGER_SHADOW_YOFFSET */, DWORD dwCxDepth /* = PPDRAWMANAGER_SHADOW_XDEPTH */, DWORD dwCyDepth /* = PPDRAWMANAGER_SHADOW_YDEPTH */, COLORREF clrShadow /* = PPDRAWMANAGER_SHADOW_COLOR */) { if (NULL == hSrcIcon) return; CSize sz = GetSizeOfIcon(hSrcIcon); HICON hIcon = NULL; if (((DWORD)sz.cx == dwWidth) && ((DWORD)sz.cy == dwHeight)) hIcon = ::CopyIcon(hSrcIcon); else hIcon = StretchIcon(hSrcIcon, dwWidth, dwHeight); ICONINFO csOriginal; if (!::GetIconInfo(hIcon, &csOriginal)) return; HDC hSrcDC = ::CreateCompatibleDC(hDC); HBITMAP hBitmap = CreateImageEffect(csOriginal.hbmColor, dwWidth, dwHeight, dwEffect, TRUE, RGB(0, 0, 0)); HBITMAP hOldSrcBitmap = (HBITMAP)::SelectObject(hSrcDC, hBitmap); if (bShadow) { if (dwEffect & IMAGE_EFFECT_SHADOW) { CPoint ptShadow = CPoint (x, y); ptShadow.x += dwCxShadow; ptShadow.y += dwCyShadow; HBITMAP hShadowBmp = CreateImageEffect(csOriginal.hbmMask, dwWidth, dwHeight, IMAGE_EFFECT_MASK, TRUE, RGB(255, 255, 255), InvertColor(clrShadow)); DrawShadow(hDC, ptShadow.x, ptShadow.y, dwWidth, dwHeight, hShadowBmp, dwEffect & IMAGE_EFFECT_GRADIENT_SHADOW, dwCxDepth, dwCyDepth); ::DeleteObject(hShadowBmp); } else { x += dwCxShadow; y += dwCyShadow; } //if } //if //------------------------------------------------------------------- // !!! ATTENTION !!! // I don't know why a icon uses text's color // Therefore I change a text's color to BLACK and after draw I restore // original color //------------------------------------------------------------------- COLORREF crOldColor = ::SetTextColor(hDC, RGB(0, 0, 0)); //Merge the image mask with background ::SelectObject(hSrcDC, csOriginal.hbmMask); ::BitBlt(hDC, x, y, dwWidth, dwHeight, hSrcDC, 0, 0, SRCAND); //Draw the image ::SelectObject(hSrcDC, hBitmap); ::BitBlt(hDC, x, y, dwWidth, dwHeight, hSrcDC, 0, 0, SRCPAINT); ::SetTextColor(hDC, crOldColor); ::SelectObject(hSrcDC, hOldSrcBitmap); ::DeleteDC(hSrcDC); ::DeleteObject(hOldSrcBitmap); ::DeleteObject(hBitmap); ::DestroyIcon(hIcon); ::DeleteObject(csOriginal.hbmColor); ::DeleteObject(csOriginal.hbmMask); } //End DrawIcon void CPPDrawManager::DrawShadow(HDC hDestDC, int nDestX, int nDestY, DWORD dwWidth, DWORD dwHeight, HBITMAP hMask, BOOL bGradient /* = FALSE */, DWORD dwDepthX /* = PPDRAWMANAGER_SHADOW_YOFFSET */, DWORD dwDepthY /* = PPDRAWMANAGER_SHADOW_XOFFSET */) { HDC hSrcDC = ::CreateCompatibleDC(hDestDC); if (NULL == hSrcDC) return; HDC hTempDC = ::CreateCompatibleDC(hDestDC); if (NULL == hTempDC) { ::DeleteDC(hSrcDC); return; } // if //Creates Source DIB LPBITMAPINFO lpbiSrc; // Fill in the BITMAPINFOHEADER lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiSrc->bmiHeader.biWidth = dwWidth; lpbiSrc->bmiHeader.biHeight = dwHeight; lpbiSrc->bmiHeader.biPlanes = 1; lpbiSrc->bmiHeader.biBitCount = 32; lpbiSrc->bmiHeader.biCompression = BI_RGB; lpbiSrc->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiSrc->bmiHeader.biXPelsPerMeter = 0; lpbiSrc->bmiHeader.biYPelsPerMeter = 0; lpbiSrc->bmiHeader.biClrUsed = 0; lpbiSrc->bmiHeader.biClrImportant = 0; COLORREF* pSrcBits = NULL; HBITMAP hSrcDib = CreateDIBSection ( hSrcDC, lpbiSrc, DIB_RGB_COLORS, (void **)&pSrcBits, NULL, NULL); if ((NULL != hSrcDib) && (NULL != pSrcBits)) { HBITMAP hOldSrcBmp = (HBITMAP)::SelectObject (hSrcDC, hSrcDib); HBITMAP hOldTempBmp = (HBITMAP)::SelectObject (hTempDC, hMask); if (bGradient) { if (!(dwDepthX & 0x1)) dwDepthX++; if (!(dwDepthY & 0x1)) dwDepthY++; ::BitBlt(hSrcDC, 0, 0, dwWidth, dwHeight, hTempDC, 0, 0, WHITENESS); ::StretchBlt (hSrcDC, dwDepthX / 2, dwDepthY / 2, dwWidth - dwDepthX, dwHeight - dwDepthY, hTempDC, 0, 0, dwWidth, dwHeight, SRCCOPY); } else { ::BitBlt(hSrcDC, 0, 0, dwWidth, dwHeight, hTempDC, 0, 0, SRCCOPY); } //if ::SelectObject (hTempDC, hOldTempBmp); ::SelectObject (hSrcDC, hOldSrcBmp); //Creates Destination DIB LPBITMAPINFO lpbiDest; // Fill in the BITMAPINFOHEADER lpbiDest = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiDest->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiDest->bmiHeader.biWidth = dwWidth; lpbiDest->bmiHeader.biHeight = dwHeight; lpbiDest->bmiHeader.biPlanes = 1; lpbiDest->bmiHeader.biBitCount = 32; lpbiDest->bmiHeader.biCompression = BI_RGB; lpbiDest->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiDest->bmiHeader.biXPelsPerMeter = 0; lpbiDest->bmiHeader.biYPelsPerMeter = 0; lpbiDest->bmiHeader.biClrUsed = 0; lpbiDest->bmiHeader.biClrImportant = 0; COLORREF* pDestBits = NULL; HBITMAP hDestDib = CreateDIBSection ( hDestDC, lpbiDest, DIB_RGB_COLORS, (void **)&pDestBits, NULL, NULL); if ((NULL != hDestDib) && (NULL != pDestBits)) { ::SelectObject (hTempDC, hDestDib); ::BitBlt (hTempDC, 0, 0, dwWidth, dwHeight, hDestDC, nDestX, nDestY, SRCCOPY); ::SelectObject (hTempDC, hOldTempBmp); if (bGradient) { double * depth = new double [dwWidth * dwHeight]; SmoothMaskImage(dwWidth, dwHeight, pSrcBits, dwDepthX, dwDepthY, depth); for(DWORD pixel = 0; pixel < dwWidth * dwHeight; pixel++, pDestBits++) *pDestBits = DarkenColor(*pDestBits, *(depth + pixel)); delete [] depth; } else { for(DWORD pixel = 0; pixel < dwWidth * dwHeight; pixel++, pSrcBits++, pDestBits++) *pDestBits = DarkenColor(*pDestBits, (double)GetRValue(*pSrcBits) / 255.0); } //if ::SelectObject (hTempDC, hDestDib); ::BitBlt (hDestDC, nDestX, nDestY, dwWidth, dwHeight, hTempDC, 0, 0, SRCCOPY); ::SelectObject (hTempDC, hOldTempBmp); delete lpbiDest; ::DeleteObject(hDestDib); } //if delete lpbiSrc; ::DeleteObject(hSrcDib); ::DeleteObject(hOldTempBmp); ::DeleteObject(hOldSrcBmp); } //if ::DeleteDC(hTempDC); ::DeleteDC(hSrcDC); } //End DrawIcon void CPPDrawManager::MaskToDepth(HDC hDC, DWORD dwWidth, DWORD dwHeight, HBITMAP hMask, double * pDepth, BOOL bGradient /* = FALSE */, DWORD dwDepthX /* = PPDRAWMANAGER_CXSHADOW */, DWORD dwDepthY /* = PPDRAWMANAGER_CYSHADOW */) { HDC hSrcDC = ::CreateCompatibleDC(hDC); if (NULL == hSrcDC) { ::DeleteDC(hSrcDC); hSrcDC = NULL; return; } //if HDC hTempDC = ::CreateCompatibleDC(hDC); if (NULL == hTempDC) { ::DeleteDC(hTempDC); hTempDC = NULL; return; } //if //Creates Source DIB LPBITMAPINFO lpbiSrc; // Fill in the BITMAPINFOHEADER lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiSrc->bmiHeader.biWidth = dwWidth; lpbiSrc->bmiHeader.biHeight = dwHeight; lpbiSrc->bmiHeader.biPlanes = 1; lpbiSrc->bmiHeader.biBitCount = 32; lpbiSrc->bmiHeader.biCompression = BI_RGB; lpbiSrc->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiSrc->bmiHeader.biXPelsPerMeter = 0; lpbiSrc->bmiHeader.biYPelsPerMeter = 0; lpbiSrc->bmiHeader.biClrUsed = 0; lpbiSrc->bmiHeader.biClrImportant = 0; COLORREF* pSrcBits = NULL; HBITMAP hSrcDib = CreateDIBSection ( hSrcDC, lpbiSrc, DIB_RGB_COLORS, (void **)&pSrcBits, NULL, NULL); if ((NULL != hSrcDib) && (NULL != pSrcBits)) { HBITMAP hOldSrcBmp = (HBITMAP)::SelectObject (hSrcDC, hSrcDib); HBITMAP hOldTempBmp = (HBITMAP)::SelectObject (hTempDC, hMask); if (bGradient) { if (!(dwDepthX & 0x1)) dwDepthX++; if (!(dwDepthY & 0x1)) dwDepthY++; ::BitBlt(hSrcDC, 0, 0, dwWidth, dwHeight, hTempDC, 0, 0, WHITENESS); ::StretchBlt (hSrcDC, dwDepthX / 2, dwDepthY / 2, dwWidth - dwDepthX, dwHeight - dwDepthY, hTempDC, 0, 0, dwWidth, dwHeight, SRCCOPY); } else { ::BitBlt(hSrcDC, 0, 0, dwWidth, dwHeight, hTempDC, 0, 0, SRCCOPY); } //if ::SelectObject (hTempDC, hOldTempBmp); ::SelectObject (hSrcDC, hOldSrcBmp); if (bGradient) { SmoothMaskImage(dwWidth, dwHeight, pSrcBits, dwDepthX, dwDepthY, pDepth); } else { for (DWORD pixel = 0; pixel < (dwHeight * dwWidth); pixel++, pSrcBits++, pDepth++) { *pDepth = GetRValue(*pSrcBits) / 255; } //for } //if delete lpbiSrc; ::DeleteObject(hSrcDib); ::DeleteObject(hOldTempBmp); ::DeleteObject(hOldSrcBmp); } //if ::DeleteDC(hTempDC); ::DeleteDC(hSrcDC); } //End MaskToDepth void CPPDrawManager::DarkenByDepth(HDC hDC, int x, int y, DWORD dwWidth, DWORD dwHeight, double * pDepth) { HDC hSrcDC = ::CreateCompatibleDC(hDC); if (NULL == hSrcDC) { ::DeleteDC(hSrcDC); hSrcDC = NULL; return; } //if //Creates Source DIB LPBITMAPINFO lpbiSrc; // Fill in the BITMAPINFOHEADER lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpbiSrc->bmiHeader.biWidth = dwWidth; lpbiSrc->bmiHeader.biHeight = dwHeight; lpbiSrc->bmiHeader.biPlanes = 1; lpbiSrc->bmiHeader.biBitCount = 32; lpbiSrc->bmiHeader.biCompression = BI_RGB; lpbiSrc->bmiHeader.biSizeImage = dwWidth * dwHeight; lpbiSrc->bmiHeader.biXPelsPerMeter = 0; lpbiSrc->bmiHeader.biYPelsPerMeter = 0; lpbiSrc->bmiHeader.biClrUsed = 0; lpbiSrc->bmiHeader.biClrImportant = 0; COLORREF* pSrcBits = NULL; HBITMAP hSrcDib = CreateDIBSection ( hSrcDC, lpbiSrc, DIB_RGB_COLORS, (void **)&pSrcBits, NULL, NULL); if ((NULL != hSrcDib) && (NULL != pSrcBits)) { HBITMAP hOldSrcBmp = (HBITMAP)::SelectObject (hSrcDC, hSrcDib); ::BitBlt(hSrcDC, 0, 0, dwWidth, dwHeight, hDC, x, y, SRCCOPY); ::SelectObject (hSrcDC, hOldSrcBmp); for (DWORD pixel = 0; pixel < (dwHeight * dwWidth); pixel++, pSrcBits++, pDepth++) { *pSrcBits = DarkenColor(*pSrcBits, *pDepth); } //for hOldSrcBmp = (HBITMAP)::SelectObject (hSrcDC, hSrcDib); ::BitBlt(hDC, x, y, dwWidth, dwHeight, hSrcDC, 0, 0, SRCCOPY); ::SelectObject (hSrcDC, hOldSrcBmp); delete lpbiSrc; ::DeleteObject(hSrcDib); ::DeleteObject(hOldSrcBmp); } //if ::DeleteDC(hSrcDC); } //DarkenByDepth void CPPDrawManager::SmoothMaskImage(const int ImageWidth, const int ImageHeight, const COLORREF* const pInitImg, const int KerWidth, const int KerHeight, double* const pResImg_R /*= NULL*/) { double* const pfBuff1 = new double[(ImageWidth + KerWidth - 1) * (ImageHeight + KerHeight - 1)]; double* const pfBuff2 = new double[(ImageWidth + KerWidth - 1) * (ImageHeight + KerHeight - 1)]; // expanding initial image with a padding procdure double* p = pfBuff1; const COLORREF * pInitImg_It = pInitImg; if(NULL != pResImg_R) { for(int _i = - KerHeight/2; _i < ImageHeight + KerHeight/2; _i++) { for(int _j = -KerWidth/2; _j < ImageWidth + KerWidth/2; _j++, p++) { if ((_i >= 0) && (_i < ImageHeight) && (_j >= 0) && (_j < ImageWidth)) { *p = GetRValue(*pInitImg_It++); // pInitImg_It++; } else *p = 255; } //for } //for //--- GetPartialSums(pfBuff1, (ImageHeight + KerHeight - 1), (ImageWidth + KerWidth - 1), KerHeight, KerWidth, pfBuff2, pResImg_R); for(int i = 0; i < ImageHeight*ImageWidth; i++) *(pResImg_R + i) /= KerHeight*KerWidth*255; } //if delete []pfBuff1; delete []pfBuff2; } //End SmoothMaskImage void CPPDrawManager::GetPartialSums(const double* const pM, unsigned int nMRows, unsigned int nMCols, unsigned int nPartRows, unsigned int nPartCols, double* const pBuff, double* const pRes) { const double* it1; const double* it2; const double* it3; double* pRowsPartSums; const unsigned int nRowsPartSumsMRows = nMRows; const unsigned int nRowsPartSumsMCols = nMCols - nPartCols + 1; const unsigned int nResMRows = nMRows - nPartRows + 1; const unsigned int nResMCols = nMCols - nPartCols + 1; unsigned int i,j; double s; // частичные суммы строк it1 = pM; pRowsPartSums = pBuff; for(i = 0; i < nMRows; i++) { //------------- it2 = it1; s = 0; for(j = 0;j < nPartCols;j++)s+=*it2++; //------------- it3 = it1; *pRowsPartSums++ = s; for(/*j = nPartCols*/; j < nMCols; j++) { s+=*it2 - *it3; *pRowsPartSums++ = s; it2++; it3++; } //for //-- it1 += nMCols; } //for // формирование резуьтата const double* it4; const double* it5; const double* it6; double* pResIt; it4 = pBuff; pResIt = pRes; for(j = 0; j < nRowsPartSumsMCols; j++) { pResIt = pRes + j; //------------- it5 = it4; s = 0; for(i = 0; i < nPartRows; i++) { s += *it5; it5 += nRowsPartSumsMCols; } //for //------------- it6 = it4; *pResIt = s; pResIt += nRowsPartSumsMCols; for(; i < nRowsPartSumsMRows; i++) { s += *it5 - *it6;//cout<<s<<endl; *pResIt = s; pResIt += nResMCols; it5 += nRowsPartSumsMCols; it6 += nRowsPartSumsMCols; } //for //-- it4 ++; } //for } //End GetPartialSums void CPPDrawManager::DrawRectangle(HDC hDC, LPRECT lpRect, COLORREF crLight, COLORREF crDark, int nStyle /* = PEN_SOLID */, int nSize /* = 1 */) { DrawRectangle(hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, crLight, crDark, nStyle, nSize); } void CPPDrawManager::DrawRectangle(HDC hDC, int left, int top, int right, int bottom, COLORREF crLight, COLORREF crDark, int nStyle /* = PEN_SOLID */, int nSize /* = 1 */) { if ((PEN_NULL == nStyle) || (nSize < 1)) return; int nSysPenStyle = PS_SOLID; int nDoubleLineOffset = nSize * 2; switch (nStyle) { case PEN_DASH: nSysPenStyle = PS_DASH; break; case PEN_DOT: nSysPenStyle = PS_DOT; break; case PEN_DASHDOT: nSysPenStyle = PS_DASHDOT; break; case PEN_DASHDOTDOT: nSysPenStyle = PS_DASHDOTDOT; break; case PEN_DOUBLE: case PEN_SOLID: default: nSysPenStyle = PS_SOLID; break; } //switch //Insideframe left += nSize / 2; top += nSize / 2; right -= nSize / 2; bottom -= nSize / 2; //Creates a light pen HPEN hPen = ::CreatePen(nSysPenStyle, nSize, crLight); HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen); //Draw light border ::MoveToEx(hDC, left, bottom, NULL); ::LineTo(hDC, left, top); ::LineTo(hDC, right, top); if (PEN_DOUBLE == nStyle) { ::MoveToEx(hDC, left + nDoubleLineOffset, bottom - nDoubleLineOffset, NULL); ::LineTo(hDC, left + nDoubleLineOffset, top + nDoubleLineOffset); ::LineTo(hDC, right - nDoubleLineOffset, top + nDoubleLineOffset); } //if //Creates a dark pen if needed if (crLight != crDark) { SelectObject(hDC, hOldPen); ::DeleteObject(hPen); hPen = ::CreatePen(nSysPenStyle, nSize, crDark); hOldPen = (HPEN)::SelectObject(hDC, hPen); } //if //Draw dark border ::MoveToEx(hDC, right, top, NULL); ::LineTo(hDC, right, bottom); ::LineTo(hDC, left, bottom); if (PEN_DOUBLE == nStyle) { ::MoveToEx(hDC, right - nDoubleLineOffset, top + nDoubleLineOffset, NULL); ::LineTo(hDC, right - nDoubleLineOffset, bottom - nDoubleLineOffset); ::LineTo(hDC, left + nDoubleLineOffset, bottom - nDoubleLineOffset); } //if SelectObject(hDC, hOldPen); ::DeleteObject(hPen); } //End DrawRectangle void CPPDrawManager::DrawLine(HDC hDC, int xStart, int yStart, int xEnd, int yEnd, COLORREF color, int nStyle /* = PEN_SOLID */, int nSize /* = 1 */) const { if ((PEN_NULL == nStyle) || (nSize < 1)) return; int nSysPenStyle; int nDoubleLineOffset = nSize * 2; switch (nStyle) { case PEN_DASH: nSysPenStyle = PS_DASH; break; case PEN_DOT: nSysPenStyle = PS_DOT; break; case PEN_DASHDOT: nSysPenStyle = PS_DASHDOT; break; case PEN_DASHDOTDOT: nSysPenStyle = PS_DASHDOTDOT; break; case PEN_DOUBLE: case PEN_SOLID: default: nSysPenStyle = PS_SOLID; break; } //switch HPEN hPen = ::CreatePen(nSysPenStyle, nSize, color); HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen); ::MoveToEx(hDC, xStart, yStart, NULL); ::LineTo(hDC, xEnd, yEnd); if (PEN_DOUBLE == nStyle) { if (xStart != xEnd) { yStart += nDoubleLineOffset; yEnd += nDoubleLineOffset; } //if if (yStart != yEnd) { xStart += nDoubleLineOffset; xEnd += nDoubleLineOffset; } //if ::MoveToEx(hDC, xStart, yStart, NULL); ::LineTo(hDC, xEnd, yEnd); } //if SelectObject(hDC, hOldPen); ::DeleteObject(hPen); } //End DrawLine
[ [ [ 1, 1349 ] ] ]
d4d1b14457952c747b766198112d7b25288248da
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/source/sound/soundcore2.cpp
be492549369ccec1c446db3db16e60b48d0cd0bd
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
7,933
cpp
#include"soundcore.h" #include"soundmessage1.h" #include"soundobjectpcmstatic.h" #include"soundobjectpcmstream.h" #include"soundobjectpcmrealtime.h" #include"soundobjectnull.h" #include"../auxiliary/debug/warning.h" namespace Maid { //! サウンドオブジェクトの登録 /*! @param pInfo [i ] 登録先 @param pObj [i ] 登録するもの */ void SoundCore::RegisterObject( const SPSOUNDOBJECTINFO& pInfo, const SPSOUNDOBJECT& pObj, const String& ShreadID ) { DATA dat; dat.pInfo = pInfo; dat.pObject = pObj; dat.ShreadID = ShreadID; m_ObjectList[pInfo->GetID()] = dat; } //! サウンドオブジェクトの破棄 /*! @param pInfo [i ] 登録先 */ void SoundCore::DeleteObject( const SPSOUNDOBJECTINFO& pInfo ) { OBJECTLIST::iterator ite = m_ObjectList.find(pInfo->GetID()); if( ite==m_ObjectList.end() ) { return ; } m_ObjectList.erase(ite); } //! サウンドオブジェクトの取得 /*! @param pInfo [i ] 登録先 */ SPSOUNDOBJECT SoundCore::GetObject( const SPSOUNDOBJECTINFO& pInfo ) { OBJECTLIST::iterator ite = m_ObjectList.find(pInfo->GetID()); if( ite==m_ObjectList.end() ) { return SPSOUNDOBJECT(new SoundObjectNULL); } return ite->second.pObject; } //! 共有できそうなサウンドオブジェクトの取得 /*! @param ShreadID [i ] 探すID @return あったらそれ。存在してなかったら空 */ Sound::SPBUFFER SoundCore::GetSharedBuffer( const String& ShreadID ) { for( OBJECTLIST::const_iterator ite=m_ObjectList.begin(); ite!=m_ObjectList.end(); ++ite ) { const DATA& dat = ite->second; if( dat.ShreadID==ShreadID ) { const SoundObjectPCMStatic* p = static_cast<const SoundObjectPCMStatic*>(dat.pObject.get()); return p->GetBuffer(); } } return Sound::SPBUFFER(); } //! サウンドを監視しているスレッド /*! */ unt SoundCore::ThreadFunction(volatile ThreadController::BRIGEDATA& brige) { Sound::SPDEVICE& pDevice = m_Param.pDevice; pDevice->Initialize(); PCMFORMAT fmt; fmt.Channels = 2; fmt.SamplesPerSecond = 44100; fmt.BitPerSamples = 16; pDevice->SetFormat(fmt); unt oldtime = m_Timer.Get(); while( true ) { if( brige.IsExit ) { // 終了命令がでてても、メッセージが残っている場合は処理を続ける ThreadMutexLocker Lock(m_MessageMutex); if( m_MessageQue.empty() ) { break; } } SOUNDMESSAGEQUE Mess; { // とりあえず溜まっているメッセージを拾う ThreadMutexLocker Lock(m_MessageMutex); Mess.swap(m_MessageQue); } // メッセージを順番に処理 for( int i=0; i<(int)Mess.size(); ++i ) { const SPSOUNDMESSAGE& pMess = Mess[i]; ExecuteMessage( *pMess ); } { // 定期的な更新 const unt newtime = m_Timer.Get(); for( OBJECTLIST::iterator ite=m_ObjectList.begin(); ite!=m_ObjectList.end(); ++ite ) { DATA& dat = ite->second; dat.pObject->Update(); dat.pInfo->m_IsPlay = dat.pObject->IsPlay(); dat.pInfo->m_Position = dat.pObject->GetPosition(); } } // メッセージを処理した分へらす { ThreadMutexLocker lock(m_MessageMutex); for( int i=0; i<(int)Mess.size(); ++i ) { const SPSOUNDMESSAGE& pMess = Mess[i]; pMess->pInfo->m_MessageCount -= 1; } } { const unt newtime = m_Timer.Get(); const unt sa = newtime-oldtime; oldtime = newtime; // あまりにも処理が早い場合は少しお休み if( sa<20 ) { ThreadController::Sleep( 20-sa ); } // if( sa<10 ) { ThreadController::Sleep( 1 ); } } } // ここにきたときに、オブジェクトが残っている場合はリークしている MAID_ASSERT( !m_ObjectList.empty(), "オブジェクトが残っています" ); m_Param.pDevice->Finalize(); return 0; } //! メッセージを処理する実態 /*! @param Mess [i ] 処理するメッセージ */ void SoundCore::ExecuteMessage( const SoundMessage::Base& Mess ) { Sound::SPDEVICE& pDevice = m_Param.pDevice; switch( Mess.Message ) { case SoundMessage::Base::CREATE_PCMSTATIC: { const SoundMessage::CreatePCMStatic& m = static_cast<const SoundMessage::CreatePCMStatic&>(Mess); Sound::SPBUFFER pSharedBuffer = GetSharedBuffer( m.ShreadID ); Sound::SPBUFFER pNewBuffer; if( pSharedBuffer.get()==NULL ) { pNewBuffer = pDevice->CreateBuffer( m.Param ); { Sound::IBuffer::LOCKDATA dat; pNewBuffer->Lock( 0, m.pData->GetSize(), dat ); memcpy( dat.pData1, m.pData->GetPointer(0), dat.Data1Length ); pNewBuffer->Unlock( dat ); } }else { pNewBuffer = pDevice->DuplicateBuffer( pSharedBuffer ); } boost::shared_ptr<SoundObjectPCMStatic> pObj( new SoundObjectPCMStatic ); pObj->Initialize( pNewBuffer ); RegisterObject( m.pInfo, pObj, m.ShreadID ); }break; case SoundMessage::Base::CREATE_PCMSTREAM: { const SoundMessage::CreatePCMStream& m = static_cast<const SoundMessage::CreatePCMStream&>(Mess); Sound::SPBUFFER pBuffer = pDevice->CreateBuffer( m.Param ); if( pBuffer.get()==NULL ) { break; } boost::shared_ptr<SoundObjectPCMStream> pObj( new SoundObjectPCMStream ); pObj->Initialize( pBuffer, m.pDecoder, m.pData ); RegisterObject( m.pInfo, pObj, MAIDTEXT("") ); }break; case SoundMessage::Base::CREATE_PCMREALTIME: { const SoundMessage::CreatePCMRealTime& m = static_cast<const SoundMessage::CreatePCMRealTime&>(Mess); Sound::SPBUFFER pBuffer = pDevice->CreateBuffer( m.Param ); if( pBuffer.get()==NULL ) { break; } boost::shared_ptr<SoundObjectPCMRealTime> pObj( new SoundObjectPCMRealTime ); pObj->Initialize( pBuffer, m.pData ); RegisterObject( m.pInfo, pObj, MAIDTEXT("") ); }break; case SoundMessage::Base::DELETEOBJECT: { const SoundMessage::DeleteObject& m = static_cast<const SoundMessage::DeleteObject&>(Mess); DeleteObject( m.pInfo ); }break; case SoundMessage::Base::PLAY: { const SoundMessage::Play& m = static_cast<const SoundMessage::Play&>(Mess); SPSOUNDOBJECT pObj = GetObject( m.pInfo ); m.pInfo->m_IsPlay = true; pObj->Play(); }break; case SoundMessage::Base::STOP: { const SoundMessage::Stop& m = static_cast<const SoundMessage::Stop&>(Mess); SPSOUNDOBJECT pObj = GetObject( m.pInfo ); m.pInfo->m_IsPlay = false; pObj->Stop(); }break; case SoundMessage::Base::SETPOSITION: { const SoundMessage::SetPosition& m = static_cast<const SoundMessage::SetPosition&>(Mess); SPSOUNDOBJECT pObj = GetObject( m.pInfo ); m.pInfo->m_Position = m.Position; pObj->SetPosition( m.Position ); }break; case SoundMessage::Base::SETVOLUME: { const SoundMessage::SetVolume& m = static_cast<const SoundMessage::SetVolume&>(Mess); SPSOUNDOBJECT pObj = GetObject( m.pInfo ); m.pInfo->m_Volume = m.Volume; pObj->SetVolume( m.Volume ); }break; case SoundMessage::Base::SETLOOPSTATE: { const SoundMessage::SetLoopState& m = static_cast<const SoundMessage::SetLoopState&>(Mess); SPSOUNDOBJECT pObj = GetObject( m.pInfo ); pObj->SetLoopState( m.IsLoop ); }break; case SoundMessage::Base::SETJUMPPOINT: { const SoundMessage::SetJumpPoint& m = static_cast<const SoundMessage::SetJumpPoint&>(Mess); }break; } } }
[ [ [ 1, 284 ] ] ]
fa48c10868c888e678ff53364e259e3c301365e1
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/nebula2/src/tools/nbundler.cc
c5010402f2f9800f9fec64a332e90d1fdfc72549
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
5,830
cc
//------------------------------------------------------------------------------ // nbundler.cc // // Nebula2 resource bundler // // (C) 2003 RadonLabs GmbH //------------------------------------------------------------------------------ #include "kernel/ntypes.h" #include "tools/ncmdlineargs.h" #include "kernel/nkernelserver.h" #include "kernel/nfileserver2.h" #include "kernel/nfile.h" #include "tools/nresourcecompiler.h" #include "kernel/nscriptserver.h" nNebulaUsePackage(nnebula); //------------------------------------------------------------------------------ /** Open text file with one Nebula2 object name per line, and read it into a string array. */ bool loadObjectList(nKernelServer* kernelServer, const nString& filename, nArray<nString>& array) { n_assert(filename.IsValid()); bool success = false; nFileServer2* fileServer = kernelServer->GetFileServer(); nFile* file = fileServer->NewFileObject(); if (file->Open(filename, "r")) { char line[1024]; while (file->GetS(line, sizeof(line))) { // strip newline char* nl = strpbrk(line, "\n\r"); if (nl) { *nl = 0; } array.Append(line); } file->Close(); success = true; } file->Release(); return success; } //------------------------------------------------------------------------------ int main(int argc, const char** argv) { nCmdLineArgs args(argc, argv); // get cmd line args bool helpArg = args.GetBoolArg("-help"); bool binaryArg = args.GetBoolArg("-binary"); bool waitArg = args.GetBoolArg("-waitforkey"); nString inArg = args.GetStringArg("-in"); nString outArg = args.GetStringArg("-out"); nString projDirArg = args.GetStringArg("-projdir"); nString scratchDirArg = args.GetStringArg("-scratchdir", "c:/temp"); nString scriptServerClassArg = args.GetStringArg("-scriptserver", "ntclserver"); // display help? if (helpArg) { n_printf("nbundler.cc [-help] [-in filename] [-out filename]\n" "(C) 2003 RadonLabs GmbH" "Nebula2 resource bundler.\n\n" "-help -- display this help\n" "-projdir -- project directory (ends with a slash!)\n" "-scratchdir -- scratch directory, default is c:/temp\n" "-in -- filename with list of input Nebula2 objects (1 filename per line)\n" "-out -- output base filename\n" "-scriptserver -- optional script server class (default is ntclserver)\n" "-binary -- save Nebula object hierarchy in binary .n2 format\n" "-waitforkey -- wait for key press when finished\n"); return 5; } // check arguments if (inArg.IsEmpty()) { n_printf("Error: -in argument expected!\n"); return 10; } if (outArg.IsEmpty()) { n_printf("Error: -out argument expected!\n"); return 10; } if (projDirArg.IsEmpty()) { n_printf("Error: -projdir argument expected!\n"); return 10; } // create and initialize Nebula environment nKernelServer kernelServer; kernelServer.AddPackage(nnebula); nScriptServer* scriptServer = (nScriptServer*)kernelServer.New(scriptServerClassArg.Get(), "/sys/servers/script"); kernelServer.New("nvariableserver", "/sys/servers/variable"); kernelServer.New("nanimationserver", "/sys/servers/anim"); kernelServer.New("nresourceserver", "/sys/servers/resource"); if (0 == scriptServer) { n_printf("Error: Could not create script server of class %s!\n", scriptServerClassArg); return 10; } // set proj: assign and run Nebula2 startup script if (!kernelServer.GetFileServer()->SetAssign("proj", projDirArg)) { return 10; } nString result; if (!scriptServer->RunScript("home:bin/startup.tcl", result)) { n_printf("Error: Could not execute 'home:bin/startup.tcl'!\n"); return 10; } // get list of objects nArray<nString> objectArray; if (!loadObjectList(&kernelServer, inArg, objectArray)) { n_printf("Error: could not open file %s\n", inArg); return 10; } // create and initialize resource compiler object int retval = 0; nResourceCompiler resComp; resComp.SetPath(nResourceCompiler::BaseFilename, outArg); resComp.SetPath(nResourceCompiler::ProjectDirectory, projDirArg); resComp.SetPath(nResourceCompiler::ScratchDirectory, scratchDirArg); resComp.SetBinaryFlag(binaryArg); if (resComp.Open(&kernelServer)) { if (!resComp.Compile(objectArray)) { n_printf("Error: resource compilation failed!\n"); retval = 10; } // show summary n_printf("\n" "Meshes: %.3f MB\n" "Animations: %.3f MB\n" "Textures: %.3f MB\n", float(resComp.GetMeshDataSize()) / 1000000.0f, float(resComp.GetAnimDataSize()) / 1000000.0f, float(resComp.GetTextureDataSize()) / 1000000.0f); resComp.Close(); } else { n_printf("Error: Could not initialize resource compiler object!\n"); return 10; } // wait for user input? if (waitArg) { printf("\nPress <Enter> to continue: "); fflush(stdout); getc(stdin); } // all ok return retval; }
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 175 ] ] ]
862771cb60d7376431016c95822bf28789338d89
38926bfe477f933a307f51376dd3c356e7893ffc
/Source/GameDLL/Menus/FlashMenuObjectOptions.cpp
d5716b073886e9543b8f3dc553202186f08d1b40
[]
no_license
richmondx/dead6
b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161
955f76f35d94ed5f991871407f3d3ad83f06a530
refs/heads/master
2021-12-05T14:32:01.782047
2008-01-01T13:13:39
2008-01-01T13:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,456
cpp
/************************************************************************* Crytek Source File. Copyright (C), Crytek Studios, 2001-2005. ------------------------------------------------------------------------- $Id$ $DateTime$ Description: Flash menu screen "Options" ------------------------------------------------------------------------- History: - 10:09:2006: Created by Jan Neugebauer *************************************************************************/ #include "StdAfx.h" #include "FlashMenuObject.h" #include "FlashMenuScreen.h" #include "IGameFramework.h" #include "IPlayerProfiles.h" #include "IUIDraw.h" #include "IMusicSystem.h" #include "ISound.h" #include "IActionMapManager.h" #include "Game.h" #include "Menus/OptionsManager.h" static const char* uiControlCodePrefix = "@cc_"; // "@cc_"; // AlexL 03/04/2007: enable this when keys/controls are fully localized static const size_t uiControlCodePrefixLen = strlen(uiControlCodePrefix); //----------------------------------------------------------------------------------------------------- void CFlashMenuObject::SaveActionToMap(const char* actionmap, const char* action, const char *uiKey) { if(!m_pPlayerProfileManager) return; IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser()); if(!pProfile) return; IActionMap* pMap = pProfile->GetActionMap(actionmap); if(pMap) { const char* key = uiKey; if (strstr(key, uiControlCodePrefix) == key) key+=uiControlCodePrefixLen; // else // assert(false); pMap->BindAction(action, key, 0); //START HACKS if(strcmp("hud_show_multiplayer_scoreboard", action) == 0) { pMap->BindAction("hud_hide_multiplayer_scoreboard", key, 0); } if(strcmp("landvehicle", actionmap) == 0) { IActionMap* pSeaMap = pProfile->GetActionMap("seavehicle"); if(pSeaMap) { pSeaMap->BindAction(action, key, 0); } } //END HACKS IPlayerProfileManager::EProfileOperationResult result; m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result); } } //----------------------------------------------------------------------------------------------------- void CFlashMenuObject::SetCVar(const char *command, const string& value) { string sCommand = command; //execute the console variable sCommand.append(" "); sCommand.append(value); gEnv->pConsole->ExecuteString(sCommand.c_str()); //save it to profile g_pGame->GetOptions()->SaveCVarToProfile(sCommand, value); } //----------------------------------------------------------------------------------------------------- void CFlashMenuObject::UpdateKeyMenu() { if(!m_pCurrentFlashMenuScreen) return; if(!m_pPlayerProfileManager) return; IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser()); if(!pProfile) return; IActionMapManager* pAM = gEnv->pGame->GetIGameFramework()->GetIActionMapManager(); IActionMapIteratorPtr iter = pAM->CreateActionMapIterator(); while (IActionMap* pMap = iter->Next()) { const char* actionMapName = pMap->GetName(); IActionMapBindInfoIteratorPtr pIter = pMap->CreateBindInfoIterator(); while (const SActionMapBindInfo* pInfo = pIter->Next()) { for (int i=0; i<pInfo->nKeys; ++i) { const char* sKey = pInfo->keys[i]; if (*sKey) { if(strcmp(sKey,"<unknown>") != 0) { if(strncmp(sKey, "xi_", 3) != 0) { CryFixedStringT<64> ui_key (uiControlCodePrefix, uiControlCodePrefixLen); ui_key+=sKey; SFlashVarValue args[3] = {actionMapName, pInfo->action, ui_key.c_str()}; m_pCurrentFlashMenuScreen->Invoke("Root.MainMenu.Options.setActionmapKey", args, 3); } } } } } } m_pCurrentFlashMenuScreen->Invoke("Root.MainMenu.Options.updateContent"); string sCrosshair; g_pGame->GetOptions()->GetProfileValue("Crosshair", sCrosshair); m_pCurrentFlashMenuScreen->Invoke("Root.MainMenu.Options.updateCrosshair", sCrosshair.c_str()); } //----------------------------------------------------------------------------------------------------- void CFlashMenuObject::UpdateCVar(const char *command) { string sCommand = command; //execute the console variable ICVar* state = gEnv->pConsole->GetCVar(sCommand); string sValue = state->GetString(); if(m_pCurrentFlashMenuScreen) { SFlashVarValue args[2] = {(const char *)sCommand, (const char *)sValue}; m_pCurrentFlashMenuScreen->Invoke("Root.MainMenu.Options.updateCVar", args, 2); } } //----------------------------------------------------------------------------------------------------- void CFlashMenuObject::RestoreDefaults() { IActionMapManager* pAmMgr = g_pGame->GetIGameFramework()->GetIActionMapManager(); if (pAmMgr == 0) return; XmlNodeRef root = GetISystem()->LoadXmlFile("libs/config/defaultProfile.xml"); pAmMgr->LoadFromXML(root); if(m_pCurrentFlashMenuScreen) { m_pCurrentFlashMenuScreen->Invoke("Root.MainMenu.Options.clearKeyChanges"); } UpdateKeyMenu(); IPlayerProfileManager::EProfileOperationResult result; m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result); } //-----------------------------------------------------------------------------------------------------
[ "[email protected]", "kkirst@c5e09591-5635-0410-80e3-0b71df3ecc31" ]
[ [ [ 1, 47 ], [ 49, 50 ], [ 52, 64 ], [ 67, 111 ], [ 122, 124 ], [ 127, 157 ], [ 163, 164 ], [ 168, 171 ] ], [ [ 48, 48 ], [ 51, 51 ], [ 65, 66 ], [ 112, 121 ], [ 125, 126 ], [ 158, 162 ], [ 165, 167 ] ] ]
db1fa0f456e745f38b6c935bf0a0333050d4a1bc
075c94a76df453abc5d831d76493dc1249bd6804
/readsdfg.h
cdac3e6f58838e1b77579d34d2ef7d427f296836
[]
no_license
gdrane/hw4_embedded_systems
7c2efca7261a7af16d1424386c08a46b15d216fb
0cd117b7dda7557781428d87289e7aaddd519d6a
refs/heads/master
2021-01-01T06:04:38.474062
2011-11-16T02:55:09
2011-11-16T02:55:09
2,746,787
0
0
null
null
null
null
UTF-8
C++
false
false
11,026
h
#ifndef READSDFG_H #define READSDFG_H // -- file includes -- #include <fstream> #include <string> #include <vector> #include "mbed.h" #include "Graph.h" #include "Node.h" #include "Edge.h" // -- defines -- #define INPUT_SIZE 20 #define MAX_BUFFER 10 // -- variables -- struct edge_info{ int edgeno,from,to; }; int edge_count = 0; // -- function headers -- void PrintSdfgFormatError(); Graph* ReadScheduleConfig(); // -- function implementations - void PrintSdfgFormatError(){ error("ERROR: BAD SDFG FORMAT\r\n"); } Graph* ReadScheduleConfig() { Graph* input_graph; // does the file exist? FILE *file = fopen("/local/sdfgconf.txt", "r"); if (!(file)){ error("ERROR: NO SDFG"); }else{ fclose(file); } ifstream sdfginput("/local/sdfgconf.txt"); // is the file empty? if(sdfginput.eof()) { PrintSdfgFormatError(); return NULL; } int noofnodes, noofedges; char str[INPUT_SIZE]; int input_size = INPUT_SIZE; sdfginput.getline(str, input_size); char *token = strtok(str, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } noofnodes = atoi(token); token = strtok(NULL, " "); if (token == NULL) { PrintSdfgFormatError(); return NULL; } noofedges = atoi(token); token = strtok(NULL, " "); if(token != NULL) { PrintSdfgFormatError(); return NULL; } input_graph = new Graph(noofnodes, noofedges); while(!sdfginput.eof()) { char node_type = '\0'; int tokeniter = 0; Node *newnode; sdfginput.getline(str, input_size); char *token = strtok(str, " "); do { if (token == NULL) { PrintSdfgFormatError(); return NULL; } if (node_type == '\0') { node_type = token[tokeniter]; // initialize variables used in switch int multconst,divconst,edgeno,buffer_size,dwnsample,upsample,constant = 0; int ICs[MAX_BUFFER]; switch(node_type) { case 'I' : newnode = new INode(); break; case 'O' : newnode = new ONode(); break; case 'A' : newnode = new ANode(); break; case 'S' : newnode = new SNode(); break; case 'D' : token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ++tokeniter; dwnsample = atoi(token); newnode = new DNode(dwnsample); break; case 'U' : token = strtok(NULL , " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ++tokeniter; upsample = atoi(token); newnode = new UNode(upsample); break; case 'M' : token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ++tokeniter; multconst = atoi(token); token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ++tokeniter; divconst = atoi(token); newnode = new MNode(multconst, divconst); break; case 'F' : newnode = new FNode(); break; case 'C' : token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ++tokeniter; constant = atoi(token); newnode = new CNode(constant); break; case 'E' : token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } edgeno = atoi(token); token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } buffer_size = atoi(token); // loop through initial conditions for(int i=0; i<buffer_size; i++){ token = strtok(NULL, " "); if(token == NULL) { PrintSdfgFormatError(); return NULL; } ICs[i] = atoi(token); } // do not create a new node, just enter the delay info in the graph input_graph->EnterDelay(edgeno, buffer_size, ICs); break; default: PrintSdfgFormatError(); return NULL; } // Adding the node to graph map input_graph->EnterNode(newnode); } // For the Edge information if(tokeniter > 0) { struct edge_info; int edgeno = atoi(token); switch(node_type) { case 'I' : // I oe1 [oe2 , oe3 ...] input_graph->EnterInEdge(newnode->get_node_no(), edgeno); break; case 'O' : if (tokeniter > 1) { PrintSdfgFormatError(); return NULL; } input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); break; case 'A' : // A ie1 ie2 oe1 [oe2 oe3...] if(tokeniter == 1 || tokeniter == 2) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); } else { input_graph->EnterInEdge(newnode->get_node_no(), edgeno); } break; case 'S' : // S ie1 ie2 oe1 [oe2 oe3 ...] if( tokeniter == 1 || tokeniter == 2) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); } else { input_graph->EnterInEdge(newnode->get_node_no(), edgeno); } break; case 'M' : // M c d ie oe1[oe2 oe3...] if( tokeniter == 3) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); } else if (tokeniter > 3){ input_graph->EnterInEdge(newnode->get_node_no(), edgeno); } break; case 'D' : // D n ie oe1[ oe2...] if (tokeniter == 2) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); // pad the buffer on this edge int n = ((DNode*)newnode)->getN(); input_graph->getEdge(edgeno)->addPadding(n); } else if (tokeniter > 2) { input_graph->EnterInEdge(newnode->get_node_no(), edgeno); } break; case 'U' : // U n ie oe1 [oe2 oe3...] if (tokeniter == 2) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); } else if(tokeniter > 2) { input_graph->EnterInEdge(newnode->get_node_no(), edgeno); // pad the buffer on this edge int n = ((UNode*)newnode)->getN(); input_graph->getEdge(edgeno)->addPadding(n); } break; case 'F' : // F ie oe1 oe2[oe3, oe3...] if (tokeniter == 1) { input_graph->EnterOutEdge(newnode->get_node_no(), edgeno); } else { input_graph->EnterInEdge(newnode->get_node_no(), edgeno); } break; case 'C' : // C k // no inputs, just outputs here input_graph->EnterOutEdge(newnode->get_node_no(),edgeno); break; default: break; } // TODO(gdrane): Have to add error handling for input underflow } // Incrementing no of tokens parsed ++tokeniter; } while((token = strtok(NULL, " ")) != NULL); } sdfginput.close(); return input_graph; } #endif
[ [ [ 1, 270 ] ] ]
133bc8e689a4f23c0a0ae8bb7314f0a8bc7324ea
f13f46fbe8535a7573d0f399449c230a35cd2014
/JelloMan/DeferredRenderer.cpp
45867bb4a5b05c9daf9cb358655b5a1b3ff78aa9
[]
no_license
fangsunjian/jello-man
354f1c86edc2af55045d8d2bcb58d9cf9b26c68a
148170a4834a77a9e1549ad3bb746cb03470df8f
refs/heads/master
2020-12-24T16:42:11.511756
2011-06-14T10:16:51
2011-06-14T10:16:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,223
cpp
#include "DeferredRenderer.h" #include "Vector4.h" #include "ContentManager.h" #include "vertex.h" #include <vector> #include "Light.h" #include "PointLight.h" #include "SpotLight.h" DeferredRenderer::DeferredRenderer(ID3D10Device* device): m_pDepthDSV(0), m_pDevice(device), m_pScreenMesh(new ModelMesh<VertexPosTex>(device, _T("screenMesh"))), m_pEffect(0), m_Width(0), m_Height(0), m_pPrevBackbuffer(0), m_pPrevDepthStencil(0) { ZeroMemory(&m_Viewport, sizeof(D3D10_VIEWPORT)); Vector4(0.f, 0.f, 0.f, 0.f).ToFloat4(m_ClearColor); for (int i = 0; i < MAXRENDERTARGETS; ++i) m_RenderTargets[i] = 0; for (int i = 0; i < MAXRENDERTARGETS + 1; ++i) m_pSRV[i] = 0; m_LightMode = LIGHT_MODE_LIT; } DeferredRenderer::~DeferredRenderer(void) { for (int i = 0; i < MAXRENDERTARGETS; ++i) SafeRelease(m_RenderTargets[i]); for (int i = 0; i < MAXRENDERTARGETS + 1; ++i) SafeRelease(m_pSRV[i]); SafeRelease(m_pDepthDSV); delete m_pScreenMesh; } void DeferredRenderer::Init(UINT width, UINT height) { OnResized(width, height); m_pEffect = ContentManager::GetSingleton()->LoadEffect<DeferredPostEffect>(_T("../Content/Effects/postdeferred.fx")); vector<VertexPosTex> vertices; vertices.push_back(VertexPosTex(-1.0f, 1.0f, 0.5f, 0.0f, 0.0f)); vertices.push_back(VertexPosTex( 1.0f, 1.0f, 0.5f, 1.0f, 0.0f)); vertices.push_back(VertexPosTex(-1.0f, -1.0f, 0.5f, 0.0f, 1.0f)); vertices.push_back(VertexPosTex( 1.0f, -1.0f, 0.5f, 1.0f, 1.0f)); vector<DWORD> indices; indices.push_back(0); indices.push_back(1); indices.push_back(2); indices.push_back(2); indices.push_back(1); indices.push_back(3); m_pScreenMesh->SetVertices(vertices); m_pScreenMesh->SetIndices(indices); } void DeferredRenderer::OnResize() { for (int i = 0; i < MAXRENDERTARGETS; ++i) SafeRelease(m_RenderTargets[i]); for (int i = 0; i < MAXRENDERTARGETS + 1; ++i) SafeRelease(m_pSRV[i]); SafeRelease(m_pDepthDSV); m_pPrevBackbuffer = 0; } void DeferredRenderer::OnResized(UINT width, UINT height) { ASSERT(m_pDepthDSV == 0 && m_RenderTargets[0] == 0 && m_pSRV[0] == 0, "OnResize() must be called first!"); m_Width = width; m_Height = height; m_Viewport.TopLeftX = 0; m_Viewport.TopLeftY = 0; m_Viewport.Width = m_Width; m_Viewport.Height = m_Height; m_Viewport.MinDepth = 0.f; m_Viewport.MaxDepth = 1.f; CreateColorMap(DeferredRenderMap_Color, DXGI_FORMAT_R8G8B8A8_UNORM); //R G B A CreateColorMap(DeferredRenderMap_Normal, DXGI_FORMAT_R16G16B16A16_FLOAT); //X Y Z Spec CreateColorMap(DeferredRenderMap_Position, DXGI_FORMAT_R16G16B16A16_FLOAT); //X Y Z gloss CreateDepthMap(); } UINT DeferredRenderer::GetBackbufferWidth() const { return m_Width; } UINT DeferredRenderer::GetBackbufferHeight() const { return m_Height; } ID3D10RenderTargetView* DeferredRenderer::GetBackbuffer() const { return m_pPrevBackbuffer; } ID3D10DepthStencilView* DeferredRenderer::GetDepthbuffer() const { return m_pDepthDSV; } void DeferredRenderer::SetClearColor(const Vector4& color) { color.ToFloat4(m_ClearColor); } void DeferredRenderer::CreateColorMap(DeferredRenderMap map, DXGI_FORMAT format) { ID3D10Texture2D* colorMap = 0; D3D10_TEXTURE2D_DESC texDesc; texDesc.Width = m_Width; texDesc.Height = m_Height; texDesc.Format = format; texDesc.ArraySize = 1; texDesc.MipLevels = 1; //1 texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D10_USAGE_DEFAULT; texDesc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = 0; //no mips HR(m_pDevice->CreateTexture2D(&texDesc, 0, &colorMap)); HR(m_pDevice->CreateRenderTargetView(colorMap, 0, &m_RenderTargets[map])); HR(m_pDevice->CreateShaderResourceView(colorMap, 0, &m_pSRV[map])); SafeRelease(colorMap); } void DeferredRenderer::CreateDepthMap() { ID3D10Texture2D* depthMap = 0; D3D10_TEXTURE2D_DESC texDesc; texDesc.Width = m_Width; texDesc.Height = m_Height; texDesc.Format = DXGI_FORMAT_R32_TYPELESS; texDesc.ArraySize = 1; texDesc.MipLevels = 1; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D10_USAGE_DEFAULT; texDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL | D3D10_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = 0; HR(m_pDevice->CreateTexture2D(&texDesc, 0, &depthMap)); //Create Depth Stencil View D3D10_DEPTH_STENCIL_VIEW_DESC dDesc; dDesc.Format = DXGI_FORMAT_D32_FLOAT; dDesc.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D; dDesc.Texture2D.MipSlice = 0; HR(m_pDevice->CreateDepthStencilView(depthMap, &dDesc, &m_pDepthDSV)); //Create Shader Resource View D3D10_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format = DXGI_FORMAT_R32_FLOAT; srvDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MipLevels = texDesc.MipLevels; srvDesc.Texture2D.MostDetailedMip = 0; HR(m_pDevice->CreateShaderResourceView(depthMap, &srvDesc, &m_pSRV[DeferredRenderMap_Depth])); SafeRelease(depthMap); } void DeferredRenderer::Begin() { m_pDevice->OMGetRenderTargets(1, &m_pPrevBackbuffer, &m_pPrevDepthStencil); m_pDevice->OMSetRenderTargets(MAXRENDERTARGETS, m_RenderTargets, m_pDepthDSV); m_pDevice->RSSetViewports(1, &m_Viewport); m_pDevice->ClearDepthStencilView(m_pDepthDSV, D3D10_CLEAR_DEPTH, 1.0f, 0); float c[4] = { 0, 0, 0, 1 }; for (int i = 0; i < MAXRENDERTARGETS; ++i) m_pDevice->ClearRenderTargetView(m_RenderTargets[i], c); } inline bool CullLight(Light* pLight, Graphics::Camera::CameraBase* pCam) { bool cull = false; Vector3 vec = pCam->GetPosition() - pLight->GetPosition(); float len = vec.Length(); cull |= len > 10000; vec /= len; cull |= len > pLight->GetAttenuationEnd() && vec.Dot(pCam->GetLook()) > 0; return cull; } void DeferredRenderer::End(const RenderContext* pRenderContext) { ASSERT(m_pPrevBackbuffer != 0, "Begin has not been called or backbuffer got lost"); ASSERT(m_pDepthDSV != 0, ""); m_pDevice->OMSetRenderTargets(1, &m_pPrevBackbuffer, NULL); //depth = 0, no depthbuffer needed in postprocessing m_pDevice->RSSetViewports(1, &m_Viewport); //Clear Backbuffer float c[4] = { 0, 0, 0, 1 }; m_pDevice->ClearRenderTargetView(m_pPrevBackbuffer, c); //Set vars needed for UNLIT && LIT m_pEffect->SetColorGlowMap(m_pSRV[DeferredRenderMap_Color]); m_pEffect->SetCameraPosition(pRenderContext->GetCamera()->GetPosition()); m_pScreenMesh->SetIA(m_pEffect); #pragma region LightMode LIT if(m_LightMode == LIGHT_MODE_LIT) { //Set vars needed for LIT m_pEffect->SetNormalSpecMap(m_pSRV[DeferredRenderMap_Normal]); m_pEffect->SetPosGlossMap(m_pSRV[DeferredRenderMap_Position]); //Loop Lights for_each(pRenderContext->GetLightController()->GetLights().cbegin(), pRenderContext->GetLightController()->GetLights().cend(), [&](Light* pLight) { //Check if on if (pLight->IsEnabled() == true && CullLight(pLight, pRenderContext->GetCamera()) == false) { //PointLight #pragma region if (pLight->GetType() == LightType_Point) { PointLight* pl = dynamic_cast<PointLight*>(pLight); m_pEffect->SetTechnique("tech_PointLightNoShadows"); m_pEffect->SetPointLight(pl->GetDesc()); } #pragma endregion //SpotLight #pragma region else if (pLight->GetType() == LightType_Spot) { SpotLight* sl = dynamic_cast<SpotLight*>(pLight); if (sl->HasShadowMap()) m_pEffect->SetTechnique("tech_SpotLightShadows"); else m_pEffect->SetTechnique("tech_SpotLightNoShadows"); m_pEffect->SetSpotLight(sl->GetDesc()); } #pragma endregion else ASSERT(false, "Lighttype not supported"); if (pLight->HasShadowMap() == true) { m_pEffect->SetShadowMap(pLight->GetShadowMap()->GetDepthMap()); m_pEffect->SetShadowWVP(pLight->GetShadowCamera()->GetViewProjection()); m_pEffect->SetShadowMapType(pLight->GetShadowMapType()); } D3D10_RECT scissorRect = pLight->CalcScissorRect(pRenderContext->GetCamera(), m_Viewport.Width, m_Viewport.Height); //Calc scissor rect // BX2D->SetColor(255,255,255,1.0f); // BX2D->DrawRect((float)scissorRect.left, (float)scissorRect.top, (float)(scissorRect.right - scissorRect.left), (float)(scissorRect.bottom - scissorRect.top), 1.0f); m_pDevice->RSSetScissorRects(1, &scissorRect); m_pEffect->GetCurrentTechnique()->GetPassByIndex(0)->Apply(0); m_pDevice->DrawIndexed(6, 0, 0); } }); m_pDevice->RSSetScissorRects(0, NULL); } #pragma endregion #pragma region LightMode UNLIT else { m_pEffect->SetTechnique("tech_UNLIT"); m_pScreenMesh->Draw(m_pEffect); } #pragma endregion ID3D10RenderTargetView* targets[MAXRENDERTARGETS] = { m_pPrevBackbuffer, 0, 0 }; m_pDevice->OMSetRenderTargets(MAXRENDERTARGETS, targets, m_pPrevDepthStencil); SafeRelease(m_pPrevBackbuffer); SafeRelease(m_pPrevDepthStencil); m_pPrevBackbuffer = 0; m_pPrevDepthStencil = 0; m_pEffect->SetColorGlowMap(0); m_pEffect->SetNormalSpecMap(0); m_pEffect->SetPosGlossMap(0); m_pEffect->SetShadowMap(0); m_pEffect->SetTechnique("tech_SpotLightShadows"); m_pEffect->GetCurrentTechnique()->GetPassByIndex(0)->Apply(0); //unbind rendertargets m_pEffect->SetTechnique("tech_SpotLightNoShadows"); m_pEffect->GetCurrentTechnique()->GetPassByIndex(0)->Apply(0); //unbind rendertargets m_pEffect->SetTechnique("tech_UNLIT"); m_pEffect->GetCurrentTechnique()->GetPassByIndex(0)->Apply(0); //unbind rendertargets } void DeferredRenderer::SetLightMode(LightMode lMode) { m_LightMode = lMode; } ID3D10ShaderResourceView* DeferredRenderer::GetColorGlowMap() const { return m_pSRV[DeferredRenderMap_Position]; } ID3D10ShaderResourceView* DeferredRenderer::GetNormalSpecMap() const { return m_pSRV[DeferredRenderMap_Normal]; } ID3D10ShaderResourceView* DeferredRenderer::GetPositionGlossMap() const { return m_pSRV[DeferredRenderMap_Position]; } ID3D10ShaderResourceView* DeferredRenderer::GetDepthMap() const { return m_pSRV[DeferredRenderMap_Depth]; }
[ "bastian.damman@0fb7bab5-1bf9-c5f3-09d9-7611b49293d6", "[email protected]" ]
[ [ [ 1, 25 ], [ 28, 191 ], [ 194, 219 ], [ 221, 223 ], [ 226, 274 ], [ 277, 285 ], [ 287, 288 ], [ 291, 292 ], [ 294, 312 ], [ 319, 335 ] ], [ [ 26, 27 ], [ 192, 193 ], [ 220, 220 ], [ 224, 225 ], [ 275, 276 ], [ 286, 286 ], [ 289, 290 ], [ 293, 293 ], [ 313, 318 ] ] ]
3f998ed3dca5b9e6993db946764fb20d57ceaee2
138a353006eb1376668037fcdfbafc05450aa413
/source/ogre/OgreNewt/boost/mpl/inserter.hpp
9e8d8a7f0aa9e57156d89b582cc81ea1cf538ca0
[]
no_license
sonicma7/choreopower
107ed0a5f2eb5fa9e47378702469b77554e44746
1480a8f9512531665695b46dcfdde3f689888053
refs/heads/master
2020-05-16T20:53:11.590126
2009-11-18T03:10:12
2009-11-18T03:10:12
32,246,184
0
0
null
null
null
null
UTF-8
C++
false
false
791
hpp
#ifndef BOOST_MPL_INSERTER_HPP_INCLUDED #define BOOST_MPL_INSERTER_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2003-2004 // Copyright David Abrahams 2003-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/inserter.hpp,v $ // $Date: 2006/04/17 23:48:05 $ // $Revision: 1.1 $ namespace boost { namespace mpl { template< typename Sequence , typename Operation > struct inserter { typedef Sequence state; typedef Operation operation; }; }} #endif // BOOST_MPL_INSERTER_HPP_INCLUDED
[ "Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e" ]
[ [ [ 1, 32 ] ] ]
251db43b12989ab492ecda7921861fb73232fb3c
b5ab57edece8c14a67cc98e745c7d51449defcff
/Captain's Log/MainGame/Source/Managers/CCamera.h
76fd69322e6fe8c768f3aed023de34dde1d52e10
[]
no_license
tabu34/tht-captainslog
c648c6515424a6fcdb628320bc28fc7e5f23baba
72d72a45e7ea44bdb8c1ffc5c960a0a3845557a2
refs/heads/master
2020-05-30T15:09:24.514919
2010-07-30T17:05:11
2010-07-30T17:05:11
32,187,254
0
0
null
null
null
null
UTF-8
C++
false
false
600
h
#ifndef CCamera_h__ #define CCamera_h__ #include <windows.h> #include "..\CGame.h" class CCamera { float m_fX; float m_fY; float m_VelX; float m_VelY; public: CCamera(); float GetX() { return m_fX; } float GetY() { return m_fY; } float VelX() const { return m_VelX; } float VelY() const { return m_VelY; } void SetX(float _x) { m_fX = _x; } void SetY(float _y) { m_fY = _y; } void VelX(float val) { m_VelX = val; } void VelY(float val) { m_VelY = val; } RECT GetCollisionRect(); void Input(); void Update(float fElapsedTime); }; #endif // CCamera_h__
[ "notserp007@34577012-8437-c882-6fb8-056151eb068d", "dpmakin@34577012-8437-c882-6fb8-056151eb068d" ]
[ [ [ 1, 9 ], [ 13, 13 ], [ 16, 17 ], [ 21, 22 ], [ 26, 27 ], [ 29, 30 ] ], [ [ 10, 12 ], [ 14, 15 ], [ 18, 20 ], [ 23, 25 ], [ 28, 28 ] ] ]
374759216b4228962f759d205b30710213e13540
9e79b20463b122df1d83a1e394f54689a949fb4e
/mojo.cpp
fdd3bd1a5d8bd0a1b4198ee9e7b4f1a3923b170a
[]
no_license
michaelvandam/mojoduino
4870c522b7be77a33cb19d1a6448dbee9ca9c148
57233cadde626b5b9a7accf941d78470ebe17000
refs/heads/master
2021-01-02T22:51:23.392713
2010-10-23T01:45:30
2010-10-23T01:45:30
32,952,233
0
0
null
null
null
null
UTF-8
C++
false
false
4,436
cpp
/* mojo.cpp - Library for MojoBus communication. Created by Henry Herman, October 18, 2009. Released under the BSD License. */ extern "C" { #include <stdlib.h> } #include <avr/eeprom.h> #include "WProgram.h" #include "HardwareSerial.h" #include "mojo.h" #include "mojodispatch.h" #include "mojomsg.h" #include "mojodefs.h" #include <inttypes.h> #include <string.h> /*********************************************** MOJO METHODS ***********************************************/ Mojo::Mojo() { init(); setSerial(Serial); loadBaudrate(); } Mojo::Mojo(HardwareSerial &S, char address) { init(); setSerial(S); setAddress(address); loadBaudrate(); } void Mojo::setSerial(HardwareSerial &S) { serial = &S; } void Mojo::init() { bufferLength = MAXMSGSIZE; reset(); } void Mojo::setAddress(char address) { addy=address; eeprom_write_byte((unsigned char *)ADDRADDR, (unsigned char)addy); } void Mojo::loadAddressEEPROM() { unsigned char c; c = eeprom_read_byte((unsigned char *)ADDRADDR); setAddress(c); } char Mojo::getAddress() { return addy; } void Mojo::reset() { #ifdef DEBUGMOJO serial->println("RESET"); #endif bufferIndex = 0; msgBuffer[bufferIndex] = '\0'; _messageState = _WAITING; } boolean Mojo::recieve() { char serialByte; #ifdef DEBUGMOJO serial->print("Buffer:"); serial->println(msgBuffer); #endif if (serial->available()>0) { msgBuffer[bufferIndex] = (char)serial->read(); serialByte = msgBuffer[bufferIndex]; msgBuffer[++bufferIndex]='\0'; } else { return false; } if (bufferIndex >= (MAXMSGSIZE -1)) { reset(); return true; } switch(_messageState) { #ifdef DEBUGMOJO serial->println("WAITING"); #endif case _WAITING: if (serialByte == STARTMSG) { _messageState = _STARTCHAR1; } else { reset(); } break; case _STARTCHAR1: #ifdef DEBUGMOJO serial->println("Start1"); #endif if (serialByte == STARTMSG) { _messageState = _STARTCHAR2; } else { reset(); } break; case _STARTCHAR2: #ifdef DEBUGMOJO serial->println("Start2"); #endif if (serialByte == addy || serialByte == BROADCASTADDY) { _messageState = _NEWMSG; } else { reset(); } break; case _NEWMSG: #ifdef DEBUGMOJO serial->println("NEW"); #endif if (serialByte == ENDMSG) _messageState = _COMPLETEMSG; break; case _COMPLETEMSG: #ifdef DEBUGMOJO serial->println("COMPLETE"); #endif break; default: reset(); break; } return true; } uint8_t Mojo::messageReady() { if (_messageState == _COMPLETEMSG) return 1; else return 0; } Message *Mojo::getMessage() { msgBuffer[strlen(msgBuffer)-1] = '\0'; msg.load(msgBuffer); reset(); return &msg; } void Mojo::readyForNext() { msg.reset(); } void Mojo::dispatch() { msgDispatch(&msg); } void Mojo::reply() { #ifdef DEBUGMOJO serial->println("Reply:"); #endif serial->print(msg.reply()); } void Mojo::run() { while(recieve()) continue; if (messageReady()) { getMessage(); dispatch(); reply(); readyForNext(); } } void Mojo::setBaudrate(char index){ baudIndex = index; loadBaudrate(); } void Mojo::loadBaudrate(){ serial->begin(getBaudrate()); } void Mojo::loadBaudrateEEPROM(){ baudIndex = eeprom_read_byte((unsigned char *)BAUDADDR); loadBaudrate(); } void Mojo::saveBaudrateEEPROM() { eeprom_write_byte((unsigned char *) BAUDADDR, baudIndex); } long Mojo::getBaudrate(){ if (baudIndex > BAUDRATELEN || baudIndex < 0) { //Default to 9600 baudIndex = 2; setBaudrate(baudIndex); } return baudRates[baudIndex]; } void Mojo::setDeviceType(char *s) { strcpy(deviceType, s); } void Mojo::setDeviceType_P(PGM_P s) { strcpy_P(deviceType, s); } char *Mojo::getDeviceType() { return deviceType; } Mojo mojo;
[ "henry.herman@2cfd8b6e-c46e-11de-b12b-e93134c88cf6" ]
[ [ [ 1, 229 ] ] ]
eabadf4523e207c9c1c81a19003ba263a8872014
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/util/Platforms/OS400/OS400PlatformUtils.hpp
fc658a1f83000624752fcaa015d25917d3ce5b66
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
1,695
hpp
#if (__OS400_TGTVRM__>=510) /* @01a */ #pragma datamodel(P128) /* @01a */ #endif /* @01a */ /* * Copyright 1999-2001,2004 The Apache Software Foundation. * * 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. */ /* * $Id: OS400PlatformUtils.hpp 191054 2005-06-17 02:56:35Z jberry $ */ #ifndef _OS400PLATFORMUTILS_H #define _OS400PLATFORMUTILS_H XERCES_CPP_NAMESPACE_BEGIN void send_message (char * text, char * messageid, char type); void convert_errno(char *,int); #define FILE_OPEN_PROBLEMS "XMLBED3" /* file open failure */ #define ICONV_CONVERT_PROBLEM "XMLBED4" /* failed to convert ICONV */ #define ICONV_CCSID_PROBLEM "XMLBED5" #define GENERAL_PANIC_MESSAGE "XMLBEED" /* iconv initialization problem */ XERCES_CPP_NAMESPACE_END #endif /* _OS400PLATFORMUTILS_H */ #if (__OS400_TGTVRM__>=510) /* @01a */ #pragma datamodel(pop) /* @01a */ #endif /* @01a */
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 45 ] ] ]
749c06cb17de924933ea27e213c9f770cf70d8c6
e806f8c3e255de9db42c39e09f27c1fc8727437a
/Contact.cpp
06f03df3829743b40af8c9cab3558aba0e553545
[]
no_license
gitpan/mojprogram
44f4844cb1fcf0fe3d35aa7e9ead6b56e20f12ef
aa031a46890908734cde1a600bd5c2539b29bd1f
refs/heads/master
2020-09-12T14:01:31.767804
2003-05-17T13:31:35
2014-10-26T18:24:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
803
cpp
#include <iostream.h> #include "Contact.h" Contact::Contact( string fn, string ln, string e, string phNum) { setFirstName(fn); setLastName(ln); setEmail(e); setPhoneNum(phNum); } Contact* Contact::create( string fn, string ln, string em, string phn) { return new Contact(fn,ln,em,phn); } void Contact::read(istream& is) { static const int MAXLEN=100; char buff[MAXLEN]; string s; is.getline(buff,MAXLEN); s=buff; setFirstName(s); is.getline(buff,MAXLEN); s=buff; setLastName(s); is.getline(buff,MAXLEN); s=buff; setEmail(s); is.getline(buff,MAXLEN); s=buff; setPhoneNum(s); } void Contact::write(ostream& os) const { os<<firstName<<'\n'; os<<lastName<<'\n'; os<<email<<'\n'; os<<phoneNum<<'\n'; }
[ [ [ 1, 43 ] ] ]
b022f4caf345747ace4d65bfdd848edc05f3a51f
58ef4939342d5253f6fcb372c56513055d589eb8
/ScheduleMessage/Client/source/Views/src/MainScreenContainer.cpp
2ebf1715e6fb05b0f0445b98a02e3c92da3d69ac
[]
no_license
flaithbheartaigh/lemonplayer
2d77869e4cf787acb0aef51341dc784b3cf626ba
ea22bc8679d4431460f714cd3476a32927c7080e
refs/heads/master
2021-01-10T11:29:49.953139
2011-04-25T03:15:18
2011-04-25T03:15:18
50,263,327
0
0
null
null
null
null
GB18030
C++
false
false
7,525
cpp
/* ============================================================================ Name : MainScreenContainer.cpp Author : zengcity Version : 1.0 Copyright : Your copyright notice Description : CMainScreenContainer implementation ============================================================================ */ #include "MainScreenContainer.h" #include <coemain.h> #include <apgtask.h> #include <eikenv.h> #include <apgcli.h> #include <aknlists.h> #include <AknIconArray.h> #include <eikclbd.h> #include "SHPlatform.h" CMainScreenContainer::CMainScreenContainer() { // No implementation required } CMainScreenContainer::~CMainScreenContainer() { if (iListBox) delete iListBox; if (iTaskArray) { iTaskArray->ResetAndDestroy(); delete iTaskArray; } } CMainScreenContainer* CMainScreenContainer::NewLC(const TRect& aRect) { CMainScreenContainer* self = new (ELeave) CMainScreenContainer(); CleanupStack::PushL(self); self->ConstructL(aRect); return self; } CMainScreenContainer* CMainScreenContainer::NewL(const TRect& aRect) { CMainScreenContainer* self = CMainScreenContainer::NewLC(aRect); CleanupStack::Pop(); // self; return self; } void CMainScreenContainer::ConstructL(const TRect& aRect) { CreateWindowL(); iTaskArray = new RSimMsgDataArray(); iListBox = new (ELeave) CAknDoubleGraphicStyleListBox(); iListBox->ConstructL(this, 0); iListBox->SetContainerWindowL(*this); // Creates scrollbar. iListBox->CreateScrollBarFrameL(ETrue); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); // Enable marquee iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); SetIconsL(); UpdateDisplay(); SetRect(aRect); ActivateL(); } // --------------------------------------------------------- // CThemeChangeContainer::CountComponentControls() const // --------------------------------------------------------- // TInt CMainScreenContainer::CountComponentControls() const { TInt count(0); if (iListBox) count++; return count; // return nbr of controls inside this container } // --------------------------------------------------------- // CThemeChangeContainer::ComponentControl(TInt aIndex) const // --------------------------------------------------------- // CCoeControl* CMainScreenContainer::ComponentControl(TInt aIndex) const { switch (aIndex) { case 0: return iListBox; // Returns the pointer to listbox object. default: return NULL; } } // --------------------------------------------------------- // CThemeChangeContainer::HandleControlEventL( // CCoeControl* aControl,TCoeEvent aEventType) // --------------------------------------------------------- // void CMainScreenContainer::HandleControlEventL(CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/) { // TODO: Add your control event handler code here } //------------------------------------------------------------------ //CMainScreenContainer::OfferKeyEventL( // const TKeyEvent& aKeyEvent, TEventCode aType) //------------------------------------------------------------------- // TKeyResponse CMainScreenContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { // See if we have a selection TInt code = aKeyEvent.iCode; switch (code) { //add your code here... case EKeyDownArrow: case EKeyUpArrow: return iListBox->OfferKeyEventL(aKeyEvent, aType); default: break; } return EKeyWasNotConsumed; } // ----------------------------------------------------------------------------- // CMainScreenContainer::Draw() // Draws the display. // ----------------------------------------------------------------------------- // void CMainScreenContainer::Draw(const TRect& /*aRect*/) const { // Get the standard graphics context CWindowGc& gc = SystemGc(); TRect drawRect(Rect()); gc.Clear(drawRect); //add your code here... } // ----------------------------------------------------------------------------- // CMainScreenContainer::SizeChanged() // Called by framework when the view size is changed. // ----------------------------------------------------------------------------- // void CMainScreenContainer::SizeChanged() { if (iListBox) { iListBox->SetRect(Rect()); } DrawNow(); } /* #include <avkon.mbg> #include <avkonicons.hrh> RESOURCE AKN_ICON_ARRAY r_icon_mark { type = EAknIconArraySimple; bmpfile = AVKON_ICON_FILE; icons = { AKN_ICON { iconId = EMbmAvkonQgn_prop_radiobutt_on; maskId = EMbmAvkonQgn_prop_radiobutt_on_mask; }, AKN_ICON { iconId = EMbmAvkonQgn_prop_radiobutt_off; maskId = EMbmAvkonQgn_prop_radiobutt_off_mask; }, AKN_ICON { iconId = EMbmAvkonQgn_prop_mmc_memc_large; maskId = EMbmAvkonQgn_prop_mmc_memc_large_mask; } }; } */ void CMainScreenContainer::SetIconsL() { CAknIconArray* icons = new (ELeave) CAknIconArray(2); CleanupStack::PushL(icons); icons->ConstructFromResourceL(R_ICON_MARK); iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); CleanupStack::Pop(); // icons } //const TInt MAX_TASK_DATA_BUFFER_SIZE = 1024; void CMainScreenContainer::UpdateDisplay() { TInt total; HBufC8* buffer; SHSession().QueryAllLength(total); if (total > 0) { buffer = HBufC8::NewL(total); TPtr8 ptr = buffer->Des(); SHSession().QueryAllData(ptr); CSimMsgServerSession::ParseDataBuffer(buffer, *iTaskArray); CTextListBoxModel* model = iListBox->Model(); CDesCArray* items = static_cast<CDesCArray*> (model->ItemTextArray()); items->Reset(); for (TInt i = 0; i < iTaskArray->Count(); i++) { SimMsgData* task = (*iTaskArray)[i]; TPtrC name = task->iName->Des(); //剔除末尾三个特殊字符 e2 80 a9 // TInt cl = task->iContent->Length() - 3; // if (cl<0) // cl = 0; // cl = cl < KMessageBriefLength ? cl : KMessageBriefLength; TPtrC content = task->iContent->Des().Left(KMessageBriefLength); TBuf<32> time; task->iTime.FormatL(time, KDateFormat); //格式 名字 - 时间 - HBufC* item; TInt len = name.Length() + time.Length() + content.Length() + KListItemFormat().Length() + 4; item = HBufC::NewL(len); item->Des().Format(KListItemFormat, &name, &time, &content); // TBuf<64> item; // item->Des().Append(_L("0\t")); // item->Des().Append(number); // item->Des().Append('\t'); // item->Des().Append(time); items->AppendL(item->Des()); delete item; } delete buffer; iListBox->HandleItemAdditionL(); } } void CMainScreenContainer::RemoveSelectedTask() { TInt index = iListBox->CurrentItemIndex(); if (index >=0 ) { SimMsgData* task = (*iTaskArray)[index]; SHSession().RemoveTask(*task); CTextListBoxModel* model = iListBox->Model(); CDesCArray* items = static_cast<CDesCArray*> (model->ItemTextArray()); items->Delete(index); iListBox->HandleItemAdditionL(); } } void CMainScreenContainer::EditSelectedTask() { TInt index = iListBox->CurrentItemIndex(); if (index >= 0) { SimMsgData* task = (*iTaskArray)[index]; SHSession().RemoveTask(*task); SHModel()->SetEditMessage(task); SHModel()->SetEditModel(CSHModel::EEditmodelModify); SHChangeViewParam(ESimulateMessageEditViewId, KViewChangeFromModify); } }
[ "zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494" ]
[ [ [ 1, 294 ] ] ]
c0a73eb01873a52f4505b7ecc6d9ec27b5519445
4ecb7e18f351ee920a6847c7ebd9010b6a5d34ce
/HD/trunk/HuntingDragon/gametutor/header/CGraphics2D.h
b5e5cab5571d50c5fca6003229fc13b7bff785d4
[]
no_license
dogtwelve/bkiter08-gameloft-internship-2011
505141ea314c234d99652600db5165a22cf041c3
0efc9f009bf12fe4ed36e1abfeb34f346a8c4198
refs/heads/master
2021-01-10T12:16:51.540936
2011-10-27T13:30:50
2011-10-27T13:30:50
46,549,117
0
0
null
null
null
null
UTF-8
C++
false
false
10,607
h
#ifndef __CGRAPHICS2D_H__ #define __CGRAPHICS2D_H__ #include "CGLPipelineDriver.h" #include "SGraphics.h" #include "CImage.h" #include "CCoordinateConverter.h" #include "CViewController.h" #include "CVertex.h" #define EG2D_PIPELINE_MAX_VERTEX_STACK 1000 enum EG2DGLPipelineElementType { EG2DP_ELETYPE_LINE, EG2DP_ELETYPE_TRIANGLE, EG2DP_ELETYPE_RECT, EG2DP_ELETYPE_IMG, }; class CGraphics2D:public CSingleton<CGraphics2D> { struct SGraphics2DGLPipelineVertexData { SPosition2D<float> Pos; SColor<float> Color; SPosition2D<float> TexCoor; }; struct SGraphics3DGLPipelineVertexData { SPosition3D<float> Pos; SColor<float> Color; SPosition2D<float> TexCoor; }; friend class CSingleton<CGraphics2D>; protected: CGraphics2D() { m_pVideoDriver = CGLPipelineDriver::GetInstance(); m_iNumberOfElement = 0; m_iStreamOffset = 0; m_Color = SColor<float>(0.0, 0.0, 0.0, 1.0); } CGLPipelineDriver *m_pVideoDriver; public: void Reset() { __UINT32 w = (CViewController<CVSView>::GetInstance()->GetView()->GetWidth()); __UINT32 h = (CViewController<CVSView>::GetInstance()->GetView()->GetHeight()); Clear(SColor<float>(0, 0, 0, 1)); m_pVideoDriver->Viewport(SRect<__INT32>(0, 0, w, h)); //m_pVideoDriver->LoadIdentity(EGLPD_MATRIXMODE_PROJECTION); m_pVideoDriver->Ortho(0, float(w), 0, float(h) , 0, 1000 ); m_pVideoDriver->EnableAttribPointer(EGLPD_ATTRIB_VERTEX, false); m_pVideoDriver->EnableAttribPointer(EGLPD_ATTRIB_COLOR, false); m_pVideoDriver->EnableAttribPointer(EGLPD_ATTRIB_NORMAL, false); m_pVideoDriver->EnableAttribPointer(EGLPD_ATTRIB_TEXCOOR, false); } void Clear(SColor<float>c) { m_pVideoDriver->Clear(c); } void Clear(SColor<__UINT8> c) { m_pVideoDriver->Clear(SColor<float>(c.Red/255.0f, c.Green/255.0f, c.Blue/255.0f, c.Alpha/255.0f)); } void SetColor(SColor<float> c) { memcpy(&m_Color, &c, sizeof(m_Color)); } void SetColor(SColor<__UINT8> c) { m_Color.Alpha = c.Alpha/255.0f; m_Color.Blue = c.Blue/255.0f; m_Color.Green = c.Green/255.0f; m_Color.Red = c.Red/255.0f; } void DrawRect(SRect<float> rect) { TODO("DrawRect is not implemented"); } void DrawRect(SRect<__INT32> rect) { TODO("DrawRect is not implemented"); } void DrawLine(SPosition2D<float> startpoint, SPosition2D<float> endpoint) { TODO("DrawLine is not implemented"); } void DrawLine(SPosition2D<__INT32> startpoint, SPosition2D<__INT32> endpoint) { TODO("DrawLine is not implemented"); } void DrawTriangle(SPosition2D<float> p1, SPosition2D<float>p2, SPosition2D<float>p3) { TODO("DrawTriangle is not implemented"); } void DrawTriangle(SPosition2D<__INT32> p1, SPosition2D<__INT32> p2, SPosition2D<__INT32> p3) { TODO("DrawTriangle is not implemented"); } void FillRect(SRect<float> rect) { m_Type[m_iNumberOfElement] = EG2DP_ELETYPE_RECT; SGraphics2DGLPipelineVertexData vertex[4] = { {SPosition2D<float>(rect.X, rect.Y + rect.H), m_Color, SPosition2D<float>(0, 0)}, {SPosition2D<float>(rect.X, rect.Y), m_Color, SPosition2D<float>(0, 0)}, {SPosition2D<float>(rect.X + rect.W, rect.Y + rect.H), m_Color, SPosition2D<float>(0, 0)}, {SPosition2D<float>(rect.X + rect.W, rect.Y), m_Color, SPosition2D<float>(0, 0)} }; memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics2DGLPipelineVertexData)*4); m_iNumberOfElement++; m_iStreamOffset += 4; } void FillRect(SRect<__INT32> rect) { SRect<float> rect2(float(rect.X), float(rect.Y), float(rect.W), float(rect.H)); FillRect(rect2); } void FillTriangle(SPosition2D<float> p1, SPosition2D<float>p2, SPosition2D<float>p3) { m_Type[m_iNumberOfElement] = EG2DP_ELETYPE_TRIANGLE; SGraphics2DGLPipelineVertexData vertex[3] = { {p1, m_Color, SPosition2D<float>(0, 0)}, {p2, m_Color, SPosition2D<float>(0, 0)}, {p3, m_Color, SPosition2D<float>(0, 0)} }; memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics2DGLPipelineVertexData)*3); m_iNumberOfElement++; m_iStreamOffset += 3; } void FillTriangle( SPosition2D<float> p1, SPosition2D<float> t1, SPosition2D<float> p2, SPosition2D<float> t2, SPosition2D<float> p3, SPosition2D<float> t3 ) { m_Type[m_iNumberOfElement] = EG2DP_ELETYPE_TRIANGLE; SGraphics2DGLPipelineVertexData vertex[3] = { {p1, m_Color, t1}, {p2, m_Color, t2}, {p3, m_Color, t3} }; memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics2DGLPipelineVertexData)*3); m_iNumberOfElement++; m_iStreamOffset += 3; } void FillTriangle(SPosition2D<__INT32> p1, SPosition2D<__INT32> p2, SPosition2D<__INT32> p3) { FillTriangle(SPosition2D<float>(float(p1.X), float(p1.Y)), SPosition2D<float>(float(p2.X), float(p2.Y)), SPosition2D<float>(float(p3.X), float(p3.Y))); } ////////// Draw Image ////////////// void DrawImage(SPosition2D<float> pos, CImage *img) { m_Type[m_iNumberOfElement] = EG2DP_ELETYPE_IMG; SRect<float> rect(pos.X, pos.Y, float(img->GetWidth()), float(img->GetHeight())); SGraphics2DGLPipelineVertexData vertex[4] = { {SPosition2D<float>(rect.X, rect.Y + rect.H), m_Color, SPosition2D<float>(0, 1)}, {SPosition2D<float>(rect.X, rect.Y), m_Color, SPosition2D<float>(0, 0)}, {SPosition2D<float>(rect.X + rect.W, rect.Y + rect.H), m_Color, SPosition2D<float>(1, 1)}, {SPosition2D<float>(rect.X + rect.W, rect.Y), m_Color, SPosition2D<float>(1, 0)} }; m_pTextureID[m_iNumberOfElement] = img->GetTextureID(); m_pIsUseAlpha[m_iNumberOfElement] = (img->GetPixelFormat() == EIMAGE_FORMAT_R8G8B8A8); memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics2DGLPipelineVertexData)*4); m_iNumberOfElement++; m_iStreamOffset += 4; } void DrawImage(SPosition2D<__INT32> pos, CImage *img) { SPosition2D<float> oglPos; CCoordinateConverter::WindowsToOpenGL(pos, oglPos); DrawImage(oglPos, img); } void DrawImageRegion(SRect<float> border, SRect<float> texCoord, CImage* img) { m_Type[m_iNumberOfElement] = EG2DP_ELETYPE_IMG; // [TODO] need to fix here SGraphics2DGLPipelineVertexData vertex[4] = { {SPosition2D<float>(border.X, border.Y + border.H), m_Color, SPosition2D<float>(texCoord.X, texCoord.Y)}, {SPosition2D<float>(border.X, border.Y), m_Color, SPosition2D<float>(texCoord.X, texCoord.Y + texCoord.H)}, {SPosition2D<float>(border.X + border.W, border.Y + border.H), m_Color, SPosition2D<float>(texCoord.X + texCoord.W, texCoord.Y)}, {SPosition2D<float>(border.X + border.W, border.Y), m_Color, SPosition2D<float>(texCoord.X + texCoord.W, texCoord.Y + texCoord.H)} }; m_pTextureID[m_iNumberOfElement] = img->GetTextureID(); m_pIsUseAlpha[m_iNumberOfElement] = (img->GetPixelFormat() == EIMAGE_FORMAT_R8G8B8A8); memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics2DGLPipelineVertexData)*4); m_iNumberOfElement++; m_iStreamOffset += 4; } void DrawImageRegion(SRect<__INT32> border, SRect<__INT32> texCoord, CImage* img) { SRect<float> fBorder, fTexCoord; CCoordinateConverter::WindowsToOpenGL(border, fBorder); CCoordinateConverter::NormalizeImageCoords(texCoord, fTexCoord, img); DrawImageRegion(fBorder, fTexCoord, img); } //void DrawImageRegion(CVertexPT* v1, CVertexPT* v2, CVertexPT* v3, CImage* img) //{ // m_Type[m_iNumberOfElement] = EG3DP_ELETYPE_TRIANGLE; // //// [TODO] need to fix here // SGraphics3DGLPipelineVertexData vertex[3] = { // {v1->pos, m_Color, v1->texCoord}, // {v2->pos, m_Color, v2->texCoord}, // {v3->pos, m_Color, v3->texCoord} // }; // m_pTextureID[m_iNumberOfElement] = img->GetTextureID(); // m_pIsUseAlpha[m_iNumberOfElement] = (img->GetPixelFormat() == EIMAGE_FORMAT_R8G8B8A8); // memcpy(m_pStream + m_iStreamOffset, vertex, sizeof(SGraphics3DGLPipelineVertexData)*3); // m_iNumberOfElement++; // m_iStreamOffset += 3; //} void Flush() { CGLPipelineDriver* vd = (CGLPipelineDriver*)m_pVideoDriver; __UINT8 * bstream = (__UINT8 *)(m_pStream); __UINT32 stride = sizeof(SGraphics2DGLPipelineVertexData); BREAK_IF(m_iNumberOfElement >= EG2D_PIPELINE_MAX_VERTEX_STACK, "m_iNumberOfElement is out of range"); int numVertex = 0; for (int i = 0; i < m_iNumberOfElement; i++) { switch (m_Type[i]) { case EG2DP_ELETYPE_RECT: case EG2DP_ELETYPE_TRIANGLE: m_pIsUseAlpha[i] = (m_Color.Alpha != 1); vd->EnableTexture2D(false); vd->EnableAttribPointer(EGLPD_ATTRIB_VERTEX, true); vd->EnableAttribPointer(EGLPD_ATTRIB_NORMAL, false); vd->EnableAttribPointer(EGLPD_ATTRIB_COLOR, true); vd->EnableAttribPointer(EGLPD_ATTRIB_TEXCOOR, false); numVertex = 4; if (m_Type[i] == EG2DP_ELETYPE_TRIANGLE) { numVertex = 3; } vd->AttributePointer( EGLPD_ATTRIB_COLOR, 4, EGLPD_PRIYTPE_FLOAT, stride, bstream + sizeof(SPosition2D<float>)); break; case EG2DP_ELETYPE_IMG: vd->EnableTexture2D(true); vd->SetColor<float>(1, 1, 1, 1); vd->EnableAttribPointer(EGLPD_ATTRIB_VERTEX, true); vd->EnableAttribPointer(EGLPD_ATTRIB_NORMAL, false); vd->EnableAttribPointer(EGLPD_ATTRIB_COLOR, false); vd->EnableAttribPointer(EGLPD_ATTRIB_TEXCOOR, true); vd->BindTexture2D(m_pTextureID[i]); vd->AttributePointer( EGLPD_ATTRIB_TEXCOOR, 2, EGLPD_PRIYTPE_FLOAT, stride, bstream + sizeof(SPosition2D<float>) + sizeof(SColor<float>)); numVertex = 4; break; } if (numVertex) { vd->EnableBlending(m_pIsUseAlpha[i]); vd->AttributePointer( EGLPD_ATTRIB_VERTEX, 2, EGLPD_PRIYTPE_FLOAT, stride, bstream); float ident[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; vd->UniformMatrix(ident); vd->DrawElements(EGLPD_RENDERMODE_TRIANGLESTRIP, numVertex); bstream += stride*numVertex; } } m_iNumberOfElement = 0; m_iStreamOffset = 0; } protected: SColor<float> m_Color; int m_iNumberOfElement; int m_iStreamOffset; __UINT32 m_pTextureID[EG2D_PIPELINE_MAX_VERTEX_STACK]; bool m_pIsUseAlpha[EG2D_PIPELINE_MAX_VERTEX_STACK]; SGraphics2DGLPipelineVertexData m_pStream[EG2D_PIPELINE_MAX_VERTEX_STACK]; enum EG2DGLPipelineElementType m_Type[EG2D_PIPELINE_MAX_VERTEX_STACK]; }; #endif
[ [ [ 1, 336 ] ] ]
a486faddba6871b6d09e22d5075a020c278d5bfd
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/source/graphics/graphics3drender.h
0915070b05daac84a6dda759e82c40139968bb04
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
10,614
h
#ifndef maid2_graphics_graphics3drender_h #define maid2_graphics_graphics3drender_h /*! @file @brief 描画を受け持つクラス 3D ver. */ #include"../config/define.h" #include"../auxiliary/mathematics/size.h" #include"../auxiliary/globalpointer.h" #include"graphicscore.h" #include"vertex.h" #include"texture2dbase.h" #include"vertexshader.h" #include"pixelshader.h" #include"inputlayout.h" #include"rasterizerstate.h" #include"depthstencilstate.h" #include"blendstate.h" #include"rendertargetbase.h" #include"samplerstate.h" #include"modelmqo.h" #include"camera.h" #include"shaderconstant.h" #include"graphicscommandcontrol.h" #include"light.h" namespace Maid { class Graphics3DRender : public GlobalPointer<GraphicsCore> { public: Graphics3DRender( GraphicsCommandControl& com ); virtual ~Graphics3DRender(); void Initialize(); bool IsInitializing() const; void SetCamera( const Camera& cam ); void SetDepthWrite( bool IsOn ); void Blt( const POINT3DF& Pos, const ModelMQO& model, float alpha ); void BltS ( const POINT3DF& Pos, const ModelMQO& model, float alpha, const SIZE3DF& Scale ); void BltR ( const POINT3DF& Pos, const ModelMQO& model, float alpha, float Rotate, const VECTOR3DF& vec ); void BltSR( const POINT3DF& Pos, const ModelMQO& model, float alpha, const SIZE3DF& Scale, float Rotate, const VECTOR3DF& vec ); void Blt( const MATRIX4DF& mat, const ModelMQO& model, float alpha ); void BltShadow1( const MATRIX4DF& LightP, const POINT3DF& Pos, const ModelMQO& model ); void BltShadow1S ( const MATRIX4DF& LightP, const POINT3DF& Pos, const ModelMQO& model, const SIZE3DF& Scale ); void BltShadow1R ( const MATRIX4DF& LightP, const POINT3DF& Pos, const ModelMQO& model, float Rotate, const VECTOR3DF& vec ); void BltShadow1SR( const MATRIX4DF& LightP, const POINT3DF& Pos, const ModelMQO& model, const SIZE3DF& Scale, float Rotate, const VECTOR3DF& vec ); void BltShadow1( const MATRIX4DF& LightP, const MATRIX4DF& world, const ModelMQO& model ); void BltShadow2( const POINT3DF& Pos, const ModelMQO& model, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); void BltShadow2S ( const POINT3DF& Pos, const ModelMQO& model, const SIZE3DF& Scale, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); void BltShadow2R ( const POINT3DF& Pos, const ModelMQO& model, float Rotate, const VECTOR3DF& vec, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); void BltShadow2SR( const POINT3DF& Pos, const ModelMQO& model, const SIZE3DF& Scale, float Rotate, const VECTOR3DF& vec, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); void BltShadow2( const MATRIX4DF& world, const ModelMQO& model, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); void SetAmbient( const COLOR_R32G32B32A32F& amb ); void SetLight( const std::vector<LIGHT>& light ); MATRIX4DF GetCameraMatrix() const; enum SPRITEBLENDSTATE { BLENDSTATE_NONE=0, // 何もしない BLENDSTATE_ALPHA, // α合成のみ BLENDSTATE_ADD, // 加算 BLENDSTATE_SUB, // 減算 BLENDSTATE_MUL, // 乗算 BLENDSTATE_SCREEN, // スクリーン BLENDSTATE_DARKEN, // 比較(暗) BLENDSTATE_LIGHTTEN, // 比較(明) BLENDSTATE_REVERSE, // 反転 }; enum SPRITETEXTUREFILTER { TEXTUREFILTER_POINT, TEXTUREFILTER_LINEAR, }; void SetSpriteFilterState( SPRITETEXTUREFILTER filter ); void SetSpriteBlendState( SPRITEBLENDSTATE State ); void SpriteFill ( const POINT3DF& Pos, const COLOR_R32G32B32A32F& Color, const SIZE2DI& Size, const POINT2DI& Center ); void SpriteFillS ( const POINT3DF& Pos, const COLOR_R32G32B32A32F& Color, const SIZE2DI& Size, const POINT2DI& Center, const SIZE2DF& Scale ); void SpriteFillR ( const POINT3DF& Pos, const COLOR_R32G32B32A32F& Color, const SIZE2DI& Size, const POINT2DI& Center, float Rotate, const VECTOR3DF& vec ); void SpriteFillSR( const POINT3DF& Pos, const COLOR_R32G32B32A32F& Color, const SIZE2DI& Size, const POINT2DI& Center, const SIZE2DF& Scale, float Rotate, const VECTOR3DF& vec ); void SpriteFill ( const MATRIX4DF& mat, const COLOR_R32G32B32A32F& Color, const SIZE2DI& Size, const POINT3DF& Center ); void SpriteBlt ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha ); void SpriteBltS ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, const SIZE2DF& Scale ); void SpriteBltR ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, float Rotate, const VECTOR3DF& vec ); void SpriteBltSR( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, const SIZE2DF& Scale, float Rotate, const VECTOR3DF& vec ); void SpriteBlt ( const MATRIX4DF& mat, const Texture2DBase& Texture, const COLOR_R32G32B32A32F& Color, const RECT2DI& rc, const POINT3DF& Center ); void SpriteMaskBlt ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, const Texture2DBase& Mask ); void SpriteMaskBltS ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, const SIZE2DF& Scale, const Texture2DBase& Mask ); void SpriteMaskBltR ( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, float Rotate, const VECTOR3DF& vec, const Texture2DBase& Mask ); void SpriteMaskBltSR( const POINT3DF& Pos, const Texture2DBase& Texture, const RECT2DI& rc, const POINT2DI& Center, float alpha, const SIZE2DF& Scale, float Rotate, const VECTOR3DF& vec, const Texture2DBase& Mask ); void SpriteMaskBlt ( const MATRIX4DF& mat, const Texture2DBase& Texture, const COLOR_R32G32B32A32F& Color, const RECT2DI& rc, const POINT3DF& Center, const Texture2DBase& Mask ); void SpriteMixBlt ( const POINT3DF& Pos, const Texture2DBase& TexBegin, const RECT2DI& BeginRect, const POINT2DI& Center, float alpha, const Texture2DBase& TexEnd, const RECT2DI& EndRect, float pow ); void SpriteMixBltS ( const POINT3DF& Pos, const Texture2DBase& TexBegin, const RECT2DI& BeginRect, const POINT2DI& Center, float alpha, const SIZE2DF& Scale, const Texture2DBase& TexEnd, const RECT2DI& EndRect, float pow ); void SpriteMixBltR ( const POINT3DF& Pos, const Texture2DBase& TexBegin, const RECT2DI& BeginRect, const POINT2DI& Center, float alpha, float Rotate, const VECTOR3DF& vec, const Texture2DBase& TexEnd, const RECT2DI& EndRect, float pow ); void SpriteMixBltSR( const POINT3DF& Pos, const Texture2DBase& TexBegin, const RECT2DI& BeginRect, const POINT2DI& Center, float alpha, const SIZE2DF& Scale, float Rotate, const VECTOR3DF& vec, const Texture2DBase& TexEnd, const RECT2DI& EndRect, float pow ); void SpriteMixBlt ( const MATRIX4DF& mat, const Texture2DBase& TexBegin, const RECT2DI& BeginRect, const POINT3DF& Center, float alpha, const Texture2DBase& TexEnd, const RECT2DI& EndRect, float pow ); protected: bool IsMemberLoading() const; Graphics::IDrawCommand& GetCommand(); void SetupSpriteState(); void MQOShaderCreate(); bool MQOShaderIsLoading()const; void MQOShaderSetup( const MATRIX4DF& world, const MATRIX4DF& wvp, const MQOMATERIAL& mat, float alpha ); void MQOShadowShaderCreate(); bool MQOShadowShaderIsLoading()const; void MQOShadowShaderSetup( const MATRIX4DF& world, const MATRIX4DF& wvp, const MQOMATERIAL& mat, float alpha, const MATRIX4DF& LightMat, const Texture2DBase& ShadowMap, float ShadowPow ); protected: enum STATE { STATE_EMPTY, // まだ初期化されてない STATE_LOADING, // 初期設定中 STATE_WORKING, // 稼動できる }; STATE m_State; SPRITEBLENDSTATE m_SpriteBltState; SPRITETEXTUREFILTER m_SpriteFilter; protected: GraphicsCommandControl& m_CommandCtl; Vertex m_TestVertex; InputLayout m_TestInputLayout; Index m_TestIndex; std::map<int,InputLayout> m_MQOLayout; std::map<int,VertexShader> m_MQOVertexShader; std::map<int,PixelShader> m_MQOPixelShader; BlendState m_MQOBlendState; RasterizerState m_MQORasterizer; std::map<int,InputLayout> m_ShadowLayout; std::map<int,VertexShader> m_ShadowVertexShader; std::map<int,PixelShader> m_ShadowPixelShader; Vertex m_SpriteVertex; // スプライトで使うバッファ ShaderConstant m_SpriteConstant; std::vector<BlendState> m_SpriteBlendState; RasterizerState m_SpriteRasterizer; InputLayout m_SpriteFillLayout; VertexShader m_SpriteFillVertexShader; PixelShader m_SpriteFillPixelShader; InputLayout m_SpriteBltLayout; VertexShader m_SpriteBltVertexShader; PixelShader m_SpriteBltPixelShader210; PixelShader m_SpriteBltPixelShader211; PixelShader m_SpriteBltPixelShader212; InputLayout m_SpriteMaskBltLayout; VertexShader m_SpriteMaskBltVertexShader; PixelShader m_SpriteMaskBltPixelShader220; PixelShader m_SpriteMaskBltPixelShader221; PixelShader m_SpriteMaskBltPixelShader222; PixelShader m_SpriteMaskBltPixelShader223; PixelShader m_SpriteMaskBltPixelShader224; PixelShader m_SpriteMaskBltPixelShader225; InputLayout m_SpriteMixBltLayout; VertexShader m_SpriteMixBltVertexShader; PixelShader m_SpriteMixBltPixelShader230; PixelShader m_SpriteMixBltPixelShader231; PixelShader m_SpriteMixBltPixelShader232; bool m_IsDepthWrite; ShaderConstant m_ShaderConstantVS; ShaderConstant m_ShaderConstantPS; // ピクセルシェーダで使う定数 RasterizerState m_Rasterizer; SamplerState m_Sampler; DepthStencilState m_DepthOn; DepthStencilState m_DepthOff; BlendState m_BlendState; SamplerState m_SamplerLinar; SamplerState m_SamplerPoint; Camera m_Camera; std::vector<LIGHT> m_Light; COLOR_R32G32B32A32F m_Ambient; }; } #endif
[ "[email protected]", "renji2000@471aaf9e-aa7b-11dd-9b86-41075523de00" ]
[ [ [ 1, 124 ], [ 127, 127 ], [ 129, 131 ], [ 135, 223 ] ], [ [ 125, 126 ], [ 128, 128 ], [ 132, 134 ] ] ]
2d2d940b508aa37464eea1ac0216dbdd4d469a83
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/Shared/FXButeMgr.h
fde5c746c824d26fcd8a43992170b433a1a976fb
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
21,357
h
// ----------------------------------------------------------------------- // // // MODULE : FXButeMgr.h // // PURPOSE : FXButeMgr definition - Controls attributes of all weapons // // CREATED : 12/09/99 // // (c) 1999-2002 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #ifndef __FX_BUTE_MGR_H__ #define __FX_BUTE_MGR_H__ #include "GameButeMgr.h" #include "ltbasetypes.h" #include "FXStructs.h" #include "SurfaceDefs.h" #include "ContainerCodes.h" #include "DebrisMgr.h" #ifdef _CLIENTBUILD #include "SpecialFX.h" #include "BaseScaleFX.h" #include "DynamicLightFX.h" #include "SoundFX.h" #endif struct PROJECTILEFX; class CFXButeMgr; extern CFXButeMgr* g_pFXButeMgr; #define FXBMGR_DEFAULT_FILE "Attributes\\Fx.txt" #define FXBMGR_INVALID_ID 255 #define FXBMGR_MAX_FILE_PATH 64 #define FXBMGR_MAX_NAME_LENGTH 32 #define IMPACT_MAX_DEBRISFX_TYPES 10 #define IMPACT_MAX_SCALEFX_TYPES 25 #define IMPACT_MAX_PEXPLFX_TYPES 5 #define IMPACT_MAX_DLIGHTFX_TYPES 5 #define IMPACT_MAX_PDEBRISFX_TYPES 3 #define IMPACT_MAX_PSHOWERFX 5 #define PV_MAX_SCALEFX_TYPES 10 #define PV_MAX_DLIGHTFX_TYPES 10 #define PV_MAX_SOUNDFX_TYPES 10 struct PROJECTILECLASSDATA { PROJECTILECLASSDATA() { szName[0] = '\0'; } virtual ~PROJECTILECLASSDATA() {} virtual LTBOOL Init(CButeMgr & buteMgr, char* aTagName); virtual void Cache(CFXButeMgr* pFXButeMgr) {} char szName[FXBMGR_MAX_NAME_LENGTH]; }; typedef CTList<PROJECTILECLASSDATA*> ProjClassDataList; struct PROXCLASSDATA : public PROJECTILECLASSDATA { PROXCLASSDATA(); virtual ~PROXCLASSDATA() {} LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); char szArmSound[FXBMGR_MAX_FILE_PATH]; char szActivateSound[FXBMGR_MAX_FILE_PATH]; int nActivateRadius; int nArmSndRadius; int nActivateSndRadius; LTFLOAT fArmDelay; LTFLOAT fActivateDelay; }; struct KITTYCLASSDATA : public PROJECTILECLASSDATA { KITTYCLASSDATA(); virtual ~KITTYCLASSDATA(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); char *pArmSound; char *pActivateSound; char *pArmedFX; char *pArmedFXRed; char *pArmedFXBlue; bool bLoopArmSound; bool bLoopArmedFX; int nActivateRadius; int nDetonateRadius; int nSoundRadius; LTFLOAT fArmDelay; LTFLOAT fDetonateTime; LTFLOAT fChaseVelocity; }; struct BEARTRAPCLASSDATA : public PROJECTILECLASSDATA { BEARTRAPCLASSDATA(); virtual ~BEARTRAPCLASSDATA(); LTBOOL Init( CButeMgr & buteMgr, char *aTagName ); int nDetonateRadius; LTFLOAT fArmDelay; }; struct BANANACLASSDATA : public PROJECTILECLASSDATA { BANANACLASSDATA(); ~BANANACLASSDATA(); LTBOOL Init( CButeMgr &buteMgr, char *aTagName ); int nDetonateRadius; float fArmDelay; }; struct SPEARCLASSDATA : public PROJECTILECLASSDATA { SPEARCLASSDATA(); ~SPEARCLASSDATA(); LTBOOL Init( CButeMgr &buteMgr, char *aTagName ); float fStickPercent; bool bCanWallStick; LTVector vDimsScale; }; struct SPAWNCLASSDATA : public PROJECTILECLASSDATA { SPAWNCLASSDATA(); virtual ~SPAWNCLASSDATA(); LTBOOL Init( CButeMgr &buteMgr, char *aTagName ); char *szSpawnObject; CButeListReader blrObjectProps; LTBOOL bStickToWorld; }; struct DISCCLASSDATA : public PROJECTILECLASSDATA { DISCCLASSDATA(); virtual ~DISCCLASSDATA(); LTBOOL Init( CButeMgr &buteMgr, char *aTagName ); LTFLOAT fInitialAngleMin; LTFLOAT fInitialAngleMax; LTFLOAT fInitialAngleSurge; LTFLOAT fReturnVelocity; LTFLOAT fReturnHeightOffset; char szReturnFXName[ FXBMGR_MAX_NAME_LENGTH ]; LTFLOAT fTurnRateMin; LTFLOAT fTurnRateMax; LTFLOAT fTurnRateSurge; LTFLOAT fIncidentAngleToControlLineMin; LTFLOAT fIncidentAngleToControlLineMax; LTFLOAT fIncidentAngleToControlLineSurge; LTFLOAT fIncidentAngleToControlLineDecayMin; LTFLOAT fIncidentAngleToControlLineDecayMax; LTFLOAT fIncidentAngleToControlLineDecaySurge; // player view impact effect to play for the swat block) // (when the player is impacted by a disc while blocking) char szSwatDefendPVFXName[ FXBMGR_MAX_NAME_LENGTH ]; // player view effect to play when the user's defense timing is // really really close (critical "blow") char szSwatCriticalDefendPVFXName[ FXBMGR_MAX_NAME_LENGTH ]; // number 0.0f-1.0f, when the disc hits this threshold, play the // critical block (1.0f == 100% == maximum defense) LTFLOAT fSwatCriticalDefendThreshold; // player view effect to play for "persistant" blocking (the hold block) // (when the player is impacted by a disc while blocking) char szHoldDefendPVFXName[ FXBMGR_MAX_NAME_LENGTH ]; // player view effect to play for forarm blocking // (when the player is impacted by a disc while blocking) char szArmDefendPVFXName[ FXBMGR_MAX_NAME_LENGTH ]; // // defense stuff // // swat defense timing values float fSwatDefendStartDefendPercentage; float fSwatDefendEndDefendPercentage; float fSwatDefendMidpoint; float fSwatDefendMaxDefendPercentage; float fSwatDefendStartMaxDefendPercentage; float fSwatDefendEndMaxDefendPercentage; // hold defense timing values float fHoldDefendStartDefendPercentage; float fHoldDefendEndDefendPercentage; float fHoldDefendMaxDefendPercentage; float fHoldDefendStartMaxDefendPercentage; float fHoldDefendEndMaxDefendPercentage; // swat defense orientation values float fSwatDefendOrientationMinDefendPercentage; float fSwatDefendOrientationMaxDefendPercentage; float fSwatDefendOrientationDeadZone; float fSwatDefendOrientationMaxZone; // swat defense orientation values float fHoldDefendOrientationMinDefendPercentage; float fHoldDefendOrientationMaxDefendPercentage; float fHoldDefendOrientationDeadZone; float fHoldDefendOrientationMaxZone; // (this is yucky :( forgive me) // This is true if the class is actually a ClusterDiscClassData // so that the code doesn't have to special case specific // weapons. Luckily, this is set automatically. bool bClusterDiscInfo; }; struct CLUSTERDISCCLASSDATA : public DISCCLASSDATA { CLUSTERDISCCLASSDATA(); virtual ~CLUSTERDISCCLASSDATA(); LTBOOL Init( CButeMgr &buteMgr, char *aTagName ); // horizontal spread float fShardHorizontalSpreadMin; float fShardHorizontalSpreadMax; float fShardHorizontalSpreadSurge; // randomization of the shard direction float fShardHorizontalPerturbMin; float fShardHorizontalPerturbMax; float fShardHorizontalPerturbSurge; // vertical spread float fShardVerticalSpreadMin; float fShardVerticalSpreadMax; float fShardVerticalSpreadSurge; // shard projectile name char szShardWeaponName[ FXBMGR_MAX_NAME_LENGTH ]; // number of shards to emit int nShardsTotalMin; int nShardsTotalMax; int nShardsTotalSurge; // number of shards perturb int nShardsTotalPerturbMin; int nShardsTotalPerturbMax; int nShardsTotalPerturbSurge; }; struct CLUSTERAUTOBURSTDISCCLASSDATA : public CLUSTERDISCCLASSDATA { CLUSTERAUTOBURSTDISCCLASSDATA(); virtual ~CLUSTERAUTOBURSTDISCCLASSDATA(); LTBOOL Init(CButeMgr &buteMgr,char *aTagName); float fMinBurstDistance; float fMaxBurstDistance; }; struct PROJECTILEFX { PROJECTILEFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szFlareSprite[FXBMGR_MAX_FILE_PATH]; char szSound[FXBMGR_MAX_FILE_PATH]; char szClass[FXBMGR_MAX_FILE_PATH]; char szModel[FXBMGR_MAX_FILE_PATH]; char szSkin[FXBMGR_MAX_FILE_PATH]; // ClientFX effect to spawn when the projectile launches char szFXName[FXBMGR_MAX_NAME_LENGTH]; int dwFXFlags; // effects to play when the disc ricochets off world geometry char szRicochetFXName[ FXBMGR_MAX_NAME_LENGTH ]; // the maximum angle, in RAIDIANS, that the disc will ricochet off // world geometry (this angle is specified in relation to the // surface, NOT the normal) // // (Note, the illustration only works with a nonproportional font) // normal // | / // | / incident vector // | / // | / // | / // |/max ricochet angle // -----+----------------- // LTFLOAT fMaxRicochetAngle; // maximum number of ricochets allowed int nMaxRicochets; int nVelocity; int nAltVelocity; LTFLOAT fFireOffset; LTFLOAT fLifeTime; LTFLOAT fGravityOverride; int nFlags; LTVector vLightColor; int nLightRadius; int nSoundRadius; LTFLOAT fFlareScale; uint32 dwObjectFlags; LTVector vModelScale; int nSmokeTrailType; // (boolean) true if the projectile can hit projecitle of the same kind int nCanImpactSameKind; // Data specific to our class (i.e., szClass)... PROJECTILECLASSDATA* pClassData; }; typedef CTList<PROJECTILEFX*> ProjectileFXList; struct PUSHERFX; struct IMPACTFX { IMPACTFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szSound[FXBMGR_MAX_FILE_PATH]; char szMark[FXBMGR_MAX_FILE_PATH]; int nSoundRadius; int nAISoundRadius; LTBOOL bAIIgnoreSurface; int nAIStimulusType; int nAIAlarmLevel; int nFlags; LTFLOAT fMarkScale; LTVector vTintColor; LTFLOAT fTintRampUp; LTFLOAT fTintRampDown; LTFLOAT fTintMaxTime; LTVector vBlastColor; LTFLOAT fBlastTimeMin; LTFLOAT fBlastTimeMax; LTFLOAT fBlastFadeMin; LTFLOAT fBlastFadeMax; LTBOOL bDoSurfaceFX; LTBOOL bIgnoreFlesh; LTBOOL bIgnoreLiquid; PUSHERFX* pPusherFX; char szFXName[FXBMGR_MAX_NAME_LENGTH]; }; typedef CTList<IMPACTFX*> ImpactFXList; // ImpactFX Create Struct struct IFXCS { IFXCS() : vPos ( 0.0f, 0.0f, 0.0f ), vDir ( 0.0f, 0.0f, 0.0f ), vSurfNormal ( 0.0f, 0.0f, 0.0f ), rSurfRot ( 0.0f, 0.0f, 0.0f, 1.0f ), eSurfType ( ST_UNKNOWN ), eCode ( CC_NO_CONTAINER ), bPlaySound ( LTFALSE ), fBlastRadius ( 0.0f ), fTintRange ( 0.0f ) { } LTVector vPos; // Position of FX LTVector vDir; // Direction for scale fx LTVector vSurfNormal; // Normal of surface of impact LTRotation rSurfRot; // Rotation aligned with surface normal SurfaceType eSurfType; // Type of surface impacting on ContainerCode eCode; // Container code fx is currently in LTBOOL bPlaySound; // Should the sound be played LTFLOAT fBlastRadius; // Radius for blast mark LTFLOAT fTintRange; // Max range for screen tints }; struct BEAMFX; struct FIREFX { FIREFX(); ~FIREFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char *szName; char *szShellModel; char *szShellSkin; char *szFXName; char *szBeamFXName; int nFlags; LTVector vShellScale; }; typedef CTList<FIREFX*> FireFXList; struct PEXPLFX { PEXPLFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szFile[FXBMGR_MAX_FILE_PATH]; LTVector vPosOffset; int nNumPerPuff; int nNumEmitters; int nNumSteps; LTBOOL bCreateDebris; LTBOOL bRotateDebris; LTBOOL bIgnoreWind; LTBOOL bDoBubbles; LTBOOL bAdditive; LTBOOL bMultiply; LTVector vColor1; LTVector vColor2; LTVector vMinVel; LTVector vMaxVel; LTVector vMinDriftVel; LTVector vMaxDriftVel; LTFLOAT fLifeTime; LTFLOAT fFadeTime; LTFLOAT fOffsetTime; LTFLOAT fRadius; LTFLOAT fGravity; }; typedef CTList<PEXPLFX*> PExplFXList; struct DLIGHTFX { DLIGHTFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; LTVector vColor; LTFLOAT fMinRadius; LTFLOAT fMaxRadius; LTFLOAT fMinTime; LTFLOAT fMaxTime; LTFLOAT fRampUpTime; LTFLOAT fRampDownTime; }; typedef CTList<DLIGHTFX*> DLightFXList; struct PVFX { PVFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szSocket[FXBMGR_MAX_NAME_LENGTH]; int nNumScaleFXTypes; int aScaleFXTypes[PV_MAX_SCALEFX_TYPES]; int nNumDLightFX; int aDLightFXTypes[PV_MAX_DLIGHTFX_TYPES]; int nNumSoundFX; int aSoundFXTypes[PV_MAX_SOUNDFX_TYPES]; }; typedef CTList<PVFX*> PVFXList; struct CParticleMuzzleFX { CParticleMuzzleFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); char szName[FXBMGR_MAX_NAME_LENGTH]; int nId; LTVector vColor1; LTVector vColor2; LTFLOAT fLength; LTFLOAT fDuration; LTFLOAT fRadius; LTFLOAT fMaxScale; int nNumParticles; char szFile[FXBMGR_MAX_FILE_PATH]; LTBOOL bAdditive; LTBOOL bMultiply; }; typedef CTList<CParticleMuzzleFX*> ParticleMuzzleFXList; struct CMuzzleFX { CMuzzleFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); char szName[FXBMGR_MAX_NAME_LENGTH]; int nId; float fDuration; CParticleMuzzleFX* pPMuzzleFX; CScaleFX* pScaleFX; DLIGHTFX* pDLightFX; }; typedef CTList<CMuzzleFX*> MuzzleFXList; struct TRACERFX { TRACERFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szTexture[FXBMGR_MAX_FILE_PATH]; int nFrequency; float fVelocity; float fWidth; float fInitialAlpha; float fFinalAlpha; LTVector vColor; }; typedef CTList<TRACERFX*> TracerFXList; struct BEAMFX { BEAMFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szTexture[FXBMGR_MAX_FILE_PATH]; float fDuration; float fWidth; float fInitialAlpha; float fFinalAlpha; LTVector vColor; LTBOOL bAlignUp; LTBOOL bAlignFlat; }; typedef CTList<BEAMFX*> BeamFXList; struct SOUNDFX { SOUNDFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; char szFile[FXBMGR_MAX_FILE_PATH]; LTBOOL bLoop; LTFLOAT fRadius; LTFLOAT fPitchShift; }; typedef CTList<SOUNDFX*> SoundFXList; struct PUSHERFX { PUSHERFX(); LTBOOL Init(CButeMgr & buteMgr, char* aTagName); void Cache(CFXButeMgr* pFXButeMgr); int nId; char szName[FXBMGR_MAX_NAME_LENGTH]; LTFLOAT fRadius; LTFLOAT fStartDelay; LTFLOAT fDuration; LTFLOAT fStrength; }; typedef CTList<PUSHERFX*> PusherFXList; struct SPRINKLEFX { SPRINKLEFX(); virtual ~SPRINKLEFX(); LTBOOL Init( CButeMgr &ButeMgr, char *aTagName ); void Cache( CFXButeMgr *pFXButeMgr ); int nId; char *szName; char *szFileName; char *szSkinName; uint32 dwCount; float fSpeed; float fSize; float fSpawnRadius; LTVector vAnglesVel; LTVector vColorMin; LTVector vColorMax; }; typedef CTList<SPRINKLEFX*> SprinkleFXList; class CFXButeMgr : public CGameButeMgr { public : CFXButeMgr(); ~CFXButeMgr(); LTBOOL Init(const char* szAttributeFile=FXBMGR_DEFAULT_FILE); void Term(); void Reload(); #if defined(_CLIENTBUILD) || defined(__PSX2) CSpecialFX* CreateScaleFX(CScaleFX* pScaleFX, const LTVector &vPos, const LTVector &vDir, const LTVector* pvSurfaceNormal, const LTRotation* prRot, CBaseScaleFX* pFX=LTNULL); CSpecialFX* CreatePShowerFX(CPShowerFX* pPShowerFX, const LTVector &vPos, const LTVector &vDir, const LTVector &vSurfaceNormal); CSpecialFX* CreatePolyDebrisFX(CPolyDebrisFX* pPolyDebrisFX, const LTVector &vPos, const LTVector &vDir, const LTVector &vSurfaceNormal); CSpecialFX* CreatePExplFX(PEXPLFX* pPExplFX, const LTRotation &rSurfaceRot, SurfaceType eSurfaceType, const LTVector &vPos, ContainerCode eCode); CSpecialFX* CreateDLightFX(DLIGHTFX* pDLightFX, const LTVector &vPos, CDynamicLightFX* pFX=LTNULL); CSpecialFX* CreateBeamFX(BEAMFX* pBeamFX, const LTVector &vStartPos, const LTVector &vEndPos); void CreateImpactFX(IMPACTFX* pImpactFX, IFXCS & cs); CSpecialFX* CreateSoundFX(SOUNDFX* pSoundFX, const LTVector &vPos, CSoundFX* pFX); void CreatePusherFX(PUSHERFX* pPusherFX, const LTVector &vPos); #endif // _CLIENTBUILD SPRINKLEFX* GetSprinkleFX( int nSprinkleFXId ); SPRINKLEFX* GetSprinkleFX( char *pName ); PUSHERFX* GetPusherFX(int nFXId); PUSHERFX* GetPusherFX(char* pName); SOUNDFX* GetSoundFX(int nSoundFXId); SOUNDFX* GetSoundFX(char* pName); TRACERFX* GetTracerFX(int nTracerFXId); TRACERFX* GetTracerFX(char* pName); BEAMFX* GetBeamFX(int nBeamFXId); BEAMFX* GetBeamFX(char* pName); CMuzzleFX* GetMuzzleFX(int nMuzzleFXId); CMuzzleFX* GetMuzzleFX(char* pName); CParticleMuzzleFX* GetParticleMuzzleFX(int nParticleMuzzleFXId); CParticleMuzzleFX* GetParticleMuzzleFX(char* pName); PVFX* GetPVFX(int nPVFXId); PVFX* GetPVFX(char* pName); CScaleFX* GetScaleFX(int nScaleFXId); CScaleFX* GetScaleFX(char* pName); CPShowerFX* GetPShowerFX(int nPShowerFXId); CPShowerFX* GetPShowerFX(char* pName); CPolyDebrisFX* GetPolyDebrisFX(int nPolyDebrisFXId); CPolyDebrisFX* GetPolyDebrisFX(char* pName); PEXPLFX* GetPExplFX(int nPExplFXId); PEXPLFX* GetPExplFX(char* pName); DLIGHTFX* GetDLightFX(int nDLightFXId); DLIGHTFX* GetDLightFX(char* pName); #ifndef _CLIENTBUILD int GetNumImpactFX() const { return m_ImpactFXList.GetLength(); } LTBOOL ReadImpactFXProp(char* pPropName, uint8 & nImpactFXId); #endif // _CLIENTBUILD IMPACTFX* GetImpactFX(int nImpactFXId); IMPACTFX* GetImpactFX(char* pName); PROJECTILEFX* GetProjectileFX(int nProjFXId); PROJECTILEFX* GetProjectileFX(char* pName); PROJECTILECLASSDATA* GetProjectileClassData(char* pName); FIREFX* GetFireFX(int nFireFXId); FIREFX* GetFireFX(char* pName); protected : ProjectileFXList m_ProjectileFXList; // All projectile fx types ProjClassDataList m_ProjClassDataList;// All projectile class data ImpactFXList m_ImpactFXList; // All impact fx types FireFXList m_FireFXList; // All fire fx types ScaleFXList m_ScaleFXList; // All scale fx types PExplFXList m_PExplFXList; // All particle explosion fx types DLightFXList m_DLightFXList; // All dynamic light fx types PShowerFXList m_PShowerFXList; // All particle shower fx PolyDebrisFXList m_PolyDebrisFXList; // All poly debris fx PVFXList m_PVFXList; // All player-view fx ParticleMuzzleFXList m_PartMuzzleFXList; // All particle muzzle fx MuzzleFXList m_MuzzleFXList; // All weapon muzzle fx TracerFXList m_TracerFXList; // All weapon tracer fx BeamFXList m_BeamFXList; // All weapon beam fx SoundFXList m_SoundFXList; // All sound fx PusherFXList m_PusherFXList; // All pusher fx SprinkleFXList m_SprinkleFXList; // All sprinkle fx }; //////////////////////////////////////////////////////////////////////////// // // CFXButeMgrPlugin is used to help facilitate populating the DEdit object // properties that use FXButeMgr // //////////////////////////////////////////////////////////////////////////// #ifndef _CLIENTBUILD #ifndef __PSX2 #include "iobjectplugin.h" class CFXButeMgrPlugin : public IObjectPlugin { public: virtual LTRESULT PreHook_EditStringList( const char* szRezPath, const char* szPropName, char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength); LTBOOL PopulateStringList(char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength); protected : CDebrisMgrPlugin m_DebrisMgrPlugin; static CFXButeMgr sm_FXButeMgr; }; #endif // !__PSX2 #endif // _CLIENTBUILD #endif // __FX_BUTE_MGR_H__
[ [ [ 1, 849 ] ] ]
6721eeea2097d1dcfaa502b5ca51d954ed9a55a1
95a3e8914ddc6be5098ff5bc380305f3c5bcecb2
/src/FusionForever_lib/SwarmMissile.cpp
829ef5a6c44ec9b086dd7e3b836c09f56ac5e63f
[]
no_license
danishcake/FusionForever
8fc3b1a33ac47177666e6ada9d9d19df9fc13784
186d1426fe6b3732a49dfc8b60eb946d62aa0e3b
refs/heads/master
2016-09-05T16:16:02.040635
2010-04-24T11:05:10
2010-04-24T11:05:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,852
cpp
#include "StdAfx.h" #include "SwarmMissile.h" #include "BillboardDeco.h" #include "Puff.h" bool SwarmMissile::initialised_ = false; int SwarmMissile::fill_dl_ = 0; int SwarmMissile::fill_verts_index_ = 0; SwarmMissile::SwarmMissile(Vector3f _position, BaseEntity* _target) : HomingProjectile(_target) { if(!initialised_) { InitialiseGraphics(); initialised_ = true; } fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_); fill_.SetDisplayList(fill_dl_); fill_.SetFillColor(GLColor(255,255,0)); fill_.GetFillColor().a = 127; lifetime_ = 5; damage_ = 70; turn_rate_ = 150; scalar_speed_ = 200; velocity_.y = scalar_speed_; position_ = _position; mass_ = 25; } SwarmMissile::~SwarmMissile(void) { } void SwarmMissile::Hit(std::vector<Decoration_ptr>& _spawn, std::vector<Projectile_ptr>& /*_projectile_spawn*/) { Puff* p = new Puff(); p->SetPosition(ltv_position_); _spawn.push_back(Decoration_ptr(p)); BillboardDeco* d = BillboardDeco::RandomExplosion(); d->SetPosition(ltv_position_); _spawn.push_back(Decoration_ptr(d)); } void SwarmMissile::InitialiseGraphics() { boost::shared_ptr<std::vector<Vector3f>> temp_fill = boost::shared_ptr<std::vector<Vector3f>>(new std::vector<Vector3f>()); temp_fill->push_back(Vector3f(-1,-2,0)); temp_fill->push_back(Vector3f(-1, 2,0)); temp_fill->push_back(Vector3f(0 , 2,0)); temp_fill->push_back(Vector3f(0 , 2,0)); temp_fill->push_back(Vector3f(1 ,-2,0)); temp_fill->push_back(Vector3f(-1,-2,0)); fill_verts_index_ = Datastore::Instance().AddVerts(temp_fill); fill_dl_ = Filled::CreateFillDisplayList(temp_fill); } void SwarmMissile::Tick(float _timespan, std::vector<Decoration_ptr>& _spawn_dec, Matrix4f _transform) { HomingProjectile::Tick(_timespan, _spawn_dec, _transform); }
[ "Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7", "[email protected]" ]
[ [ [ 1, 35 ], [ 37, 66 ] ], [ [ 36, 36 ] ] ]
8dd3f09f7d9717ccd64b3543483d34f62c689cb0
f744f8897adce6654cdfe6466eaf4d0fad4ba661
/src/view/ConcreteDisplay.cpp
ff6b5bf1c833e3b4e995830b4c64ceef340bd8c8
[]
no_license
pizibing/bones-animation
37919ab3750683a5da0cc849f80d1e0f5b37c89c
92ce438e28e3020c0e8987299c11c4b74ff98ed5
refs/heads/master
2016-08-03T05:34:19.294712
2009-09-16T14:59:32
2009-09-16T14:59:32
33,969,248
0
0
null
null
null
null
UTF-8
C++
false
false
3,319
cpp
#include <gl/glut.h> #include <gl/glext.h> #include <assert.h> #include "../data/SimpleLine.h" #include "../matrixlib/Vector3D.h" #include "../data/VBOMesh.h" #include "Display.h" #include "ConcreteDisplay.h" // declare some VBO function which is defined in main.cpp extern PFNGLBINDBUFFERARBPROC pglBindBufferARB; #define glBindBufferARB pglBindBufferARB ConcreteDisplay::ConcreteDisplay(void){ } ConcreteDisplay::~ConcreteDisplay(void){ } // display a set of VBOMesh // toDisplay specify the VBOMeshes to display // num is the number of VBOMesh to display // isWire specify whether to display in wire model or solid model // vertices in VBOMesh will be treated as triangles void ConcreteDisplay::display(bool isWire,const VBOMesh* toDisplay,int num){ //wire model if(isWire){ } //solid model else{ //for each VBOMesh for(int i = 0; i < num; i++){ glPushMatrix(); VBOMesh vbomesh= toDisplay[i]; //set matrix glMultMatrixf(vbomesh.getMatrix()); //if has material, set material if(vbomesh.getHasMaterial()){ //set ambient glMaterialfv(GL_FRONT,GL_AMBIENT,vbomesh.getAmbient()); // set diffuse glMaterialfv(GL_FRONT,GL_DIFFUSE,vbomesh.getDiffuse()); // set specular glMaterialfv(GL_FRONT,GL_SPECULAR,vbomesh.getSpecular()); // set emission glMaterialfv(GL_FRONT,GL_EMISSION,vbomesh.getEmission()); // set shininess glMaterialf(GL_FRONT,GL_SHININESS,vbomesh.getShininess()); } //set vertices glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbomesh.getVertices()); glVertexPointer(3,GL_FLOAT,0,0); glEnableClientState(GL_VERTEX_ARRAY); //if has texture, set texture if(vbomesh.getHasTexture()){ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,vbomesh.getTexID()); glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbomesh.getTextures()); glTexCoordPointer(2,GL_FLOAT,0,0); glEnableClientState(GL_TEXTURE_COORD_ARRAY); } //if has normal, set normal if(vbomesh.getHasNormal()){ glEnable(GL_LIGHTING); glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbomesh.getNormals()); glNormalPointer(GL_FLOAT,0,0); glEnableClientState(GL_NORMAL_ARRAY); } // draw element glDrawArrays(GL_TRIANGLES, 0, vbomesh.getSize()); // release bind buffer glBindBufferARB(GL_ARRAY_BUFFER_ARB,0); // set back client state glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisable(GL_NORMAL_ARRAY); //back to default glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glPopMatrix(); } } } // display a group of lines // toDisplay specifies the array of lines to display // num is the length of this array void ConcreteDisplay::display(const SimpleLine* toDisplay, int num){ // toDisplay should not be null assert(toDisplay); // num should not be smaller than 0 assert(num >= 0); // draw lines // set light, texture, color glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glColor3f(0,0.5f,0); // set line width glLineWidth(2); glBegin(GL_LINES); // for each line for(int i = 0; i < num; i++){ SimpleLine line = toDisplay[i]; // draw line glVertex3fv(line.getDot1()); glVertex3fv(line.getDot2()); } glEnd(); }
[ [ [ 1, 117 ] ] ]
0731222fd7a308997c0e4bf1a60fd25902b515a0
33b5565fb265463ed201c31f38ba3bd305a4e5d9
/FLHook/tags/Latest/src/source/HkFuncTools.cpp
99526cd9040be429437d8846db14390a20d32870
[]
no_license
HeIIoween/FLHook-And-88-Flak-m0tah
be1ee2fa0e240c24160dda168b8b23ad6aec2b48
3f0737f7456ef3eed5dd67cfec1b838d32b8b5e1
refs/heads/master
2021-05-07T14:00:34.880461
2011-01-28T00:21:41
2011-01-28T00:21:41
109,712,726
1
0
null
null
null
null
UTF-8
C++
false
false
18,137
cpp
#include <math.h> #include <float.h> #include "hook.h" #include "CInGame.h" /////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint HkGetClientIdFromAccount(CAccount *acc) { struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { CAccount *cur; memcpy(&cur, (char*)pPD + 0x400, 4); if(cur == acc) { uint iClientID = HkGetClientIdFromPD(pPD); return iClientID; } } return -1; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint HkGetClientIdFromPD(struct PlayerData *pPD) { char *p1 = (char*)pPD; char *p2 = (char*)&Players; memcpy(&p2, p2, 4); return (uint)(((p1 - p2) / 0x418) + 1); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// CAccount* HkGetAccountByCharname(wstring wscCharname) { flstr *str = CreateWString(wscCharname.c_str()); CAccount *acc = Players.FindAccountFromCharacterName(*str); FreeWString(str); return acc; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint HkGetClientIdFromCharname(wstring wscCharname) { CAccount *acc = HkGetAccountByCharname(wscCharname); if(!acc) return -1; uint iClientID = HkGetClientIdFromAccount(acc); if(iClientID == -1) return -1; wchar_t *wszActiveCharname = (wchar_t*)Players.GetActiveCharacterName(iClientID); if(!wszActiveCharname) return -1; wstring wscActiveCharname = wszActiveCharname; wscActiveCharname = ToLower(wscActiveCharname); if(wscActiveCharname.compare(ToLower(wscCharname)) != 0) return -1; return iClientID; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// wstring HkGetAccountID(CAccount *acc) { wchar_t *wszID; memcpy(&wszID, (char*)acc+8, sizeof(wszID)); return wszID; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool HkIsEncoded(string scFilename) { bool bRet = false; FILE *f = fopen(scFilename.c_str(), "r"); if(!f) return false; char szMagic[] = "FLS1"; char szFile[sizeof(szMagic)] = ""; fread(szFile, 1, sizeof(szMagic), f); if(!strncmp(szMagic, szFile, sizeof(szMagic) - 1)) bRet = true; fclose(f); return bRet; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool HkIsInCharSelectMenu(wstring wscCharname) { CAccount *acc = HkGetAccountByCharname(wscCharname); if(!acc) return false; uint iClientID = HkGetClientIdFromAccount(acc); if(iClientID == -1) return false; uint iBase = 0; uint iSystem = 0; pub::Player::GetBase(iClientID, iBase); pub::Player::GetSystem(iClientID, iSystem); if(!iBase && !iSystem) return true; else return false; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool HkIsInCharSelectMenu(uint iClientID) { uint iBase = 0; uint iSystem = 0; pub::Player::GetBase(iClientID, iBase); pub::Player::GetSystem(iClientID, iSystem); if(!iBase && !iSystem) return true; else return false; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool HkIsValidClientID(uint iClientID) { struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { uint iID = HkGetClientIdFromPD(pPD); if(iID == iClientID) return true; } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkResolveId(wstring wscCharname, uint &iClientID) { wscCharname = ToLower(wscCharname); if(wscCharname.find(L"id ") == 0) { uint iID = 0; swscanf(wscCharname.c_str(), L"id %u", &iID); if(!HkIsValidClientID(iID)) return HKE_INVALID_CLIENT_ID; iClientID = iID; return HKE_OK; } return HKE_INVALID_ID_STRING; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkResolveShortCut(wstring wscShortcut, uint &_iClientID) { wscShortcut = ToLower(wscShortcut); if(wscShortcut.find(L"sc ") != 0) return HKE_INVALID_SHORTCUT_STRING; wscShortcut = wscShortcut.substr(3); uint iClientIDFound = -1; struct PlayerData *pPD = 0; while(pPD = Players.traverse_active(pPD)) { uint iClientID = HkGetClientIdFromPD(pPD); const wchar_t *wszCharname = Players.GetActiveCharacterName(iClientID); if(!wszCharname) continue; wstring wscCharname = wszCharname; if(ToLower(wscCharname).find(wscShortcut) != -1) { if(iClientIDFound == -1) iClientIDFound = iClientID; else return HKE_AMBIGUOUS_SHORTCUT; } } if(iClientIDFound == -1) return HKE_NO_MATCHING_PLAYER; _iClientID = iClientIDFound; return HKE_OK; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint HkGetClientIDByShip(uint iShip) { for(uint i = 0; (i <= Players.GetMaxPlayerCount()); i++) { if(ClientInfo[i].iShip == iShip || ClientInfo[i].iShipOld == iShip) return i; } return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkGetAccountDirName(CAccount *acc, wstring &wscDir) { _GetFLName GetFLName = (_GetFLName)((char*)hModServer + 0x66370); wstring wscID = HkGetAccountID(acc); char szDir[1024] = ""; GetFLName(szDir, wscID.c_str()); wscDir = stows(szDir); return HKE_OK; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkGetAccountDirName(wstring wscCharname, wstring &wscDir) { HK_GET_CLIENTID(iClientID, wscCharname); CAccount *acc; if(iClientID != -1) acc = Players.FindAccountFromClientID(iClientID); else { if(!(acc = HkGetAccountByCharname(wscCharname))) return HKE_CHAR_DOES_NOT_EXIST; } return HkGetAccountDirName(acc, wscDir); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkGetCharFileName(wstring wscCharname, wstring &wscFilename) { HK_GET_CLIENTID(iClientID, wscCharname); // getchafilename from clientid if(iClientID != -1) wscCharname = Players.GetActiveCharacterName(iClientID); _GetFLName GetFLName = (_GetFLName)((char*)hModServer + 0x66370); char szBuf[1024] = ""; GetFLName(szBuf, wscCharname.c_str()); wscFilename = stows(szBuf); return HKE_OK; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// wstring HkGetBaseNickByID(uint iBaseID) { char szBasename[1024] = ""; pub::GetBaseNickname(szBasename, sizeof(szBasename), iBaseID); return stows(szBasename); } string HkGetBaseNickSByID(uint iBaseID) { char szBasename[1024] = ""; pub::GetBaseNickname(szBasename, sizeof(szBasename), iBaseID); return szBasename; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// wstring HkGetSystemNickByID(uint iSystemID) { char szSystemname[1024] = ""; pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID); return stows(szSystemname); } string HkGetSystemNickSByID(uint iSystemID) { char szSystemname[1024] = ""; pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID); return szSystemname; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// wstring HkGetPlayerSystem(uint iClientID) { uint iSystemID; pub::Player::GetSystem(iClientID, iSystemID); char szSystemname[1024] = ""; pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID); return stows(szSystemname); } string HkGetPlayerSystemS(uint iClientID) { uint iSystemID; pub::Player::GetSystem(iClientID, iSystemID); char szSystemname[1024] = ""; pub::GetSystemNickname(szSystemname, sizeof(szSystemname), iSystemID); return szSystemname; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HkLockAccountAccess(CAccount *acc, bool bKick) { char szJMP[] = { '\xEB' }; char szJBE[] = { '\x76' }; flstr *strAccID = CreateWString(HkGetAccountID(acc).c_str()); if(!bKick) WriteProcMem((void*)0x06D52A6A, &szJMP, 1); Players.LockAccountAccess(*strAccID); // also kicks player on this account if(!bKick) WriteProcMem((void*)0x06D52A6A, &szJBE, 1); FreeWString(strAccID); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HkUnlockAccountAccess(CAccount *acc) { flstr *strAccID = CreateWString(HkGetAccountID(acc).c_str()); Players.UnlockAccountAccess(*strAccID); FreeWString(strAccID); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HkGetItemsForSale(uint iBaseID, list<uint> &lstItems) { lstItems.clear(); char szNOP[] = { '\x90', '\x90'}; char szJNZ[] = { '\x75', '\x1D'}; WriteProcMem(SRV_ADDR(ADDR_SRV_GETCOMMODITIES), &szNOP, 2); // patch, else we only get commodities uint iArray[1024]; int iSize = sizeof(iArray)/sizeof(uint); pub::Market::GetCommoditiesForSale(iBaseID, (uint*const)&iArray, &iSize); WriteProcMem(SRV_ADDR(ADDR_SRV_GETCOMMODITIES), &szJNZ, 2); for(int i = 0; (i < iSize); i++) lstItems.push_back(iArray[i]); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// IObjInspectImpl* HkGetInspect(uint iClientID) { uint iShip; pub::Player::GetShip(iClientID, iShip); uint iDunno; IObjInspectImpl *inspect; if(!GetShipInspect(iShip, inspect, iDunno)) { return 0; } else return inspect; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// CEquipManager* HkGetEquipMan(uint iShip) { uint iDunno; IObjInspectImpl *inspect; if(!GetShipInspect(iShip, inspect, iDunno)) return 0; char *szShip = (char*)inspect; szShip += 0x10; char *szEquip = *((char**)szShip); szEquip += 0xE4; return (CEquipManager*)szEquip; } CEquipManager* HkGetEquipMan(IObjInspectImpl *inspect) { char *szShip = (char*)inspect; szShip += 0x10; char *szEquip = *((char**)szShip); szEquip += 0xE4; return (CEquipManager*)szEquip; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// ENGINE_STATE HkGetEngineState(uint iClientID) { if(ClientInfo[iClientID].bTradelane) return ES_TRADELANE; else if(ClientInfo[iClientID].bCruiseActivated) return ES_CRUISE; else if(ClientInfo[iClientID].bThrusterActivated) return ES_THRUSTER; else if(!ClientInfo[iClientID].bEngineKilled) return ES_ENGINE; else return ES_KILLED; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct EQ_ITEM { EQ_ITEM *next; uint i2; ushort s1; ushort sID; uint iGoodID; uint i3; bool bMounted; char sz[3]; uint i6; uint iCount; bool bMission; }; HK_ERROR HkGetGoodIDFromSID(uint iClientID, ushort sGoodID, uint &iGoodID) { char *szClassPtr; memcpy(&szClassPtr, &Players, 4); szClassPtr += 0x418 * (iClientID - 1); EQ_ITEM *eqLst; memcpy(&eqLst, szClassPtr + 0x27C, 4); EQ_ITEM *eq; eq = eqLst->next; while(eq != eqLst) { if(eq->sID==sGoodID) { iGoodID = eq->iGoodID; return HKE_OK; } eq = eq->next; } return HKE_INVALID_GOOD; } HK_ERROR HkGetSIDFromGoodID(uint iClientID, ushort &sGoodID, uint iGoodID) { char *szClassPtr; memcpy(&szClassPtr, &Players, 4); szClassPtr += 0x418 * (iClientID - 1); EQ_ITEM *eqLst; memcpy(&eqLst, szClassPtr + 0x27C, 4); EQ_ITEM *eq; eq = eqLst->next; while(eq != eqLst) { if(eq->iGoodID==iGoodID) { sGoodID = eq->sID; return HKE_OK; } eq = eq->next; } return HKE_INVALID_GOOD; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// HK_ERROR HkRestartServer() { bool bFoundTaskkill = false; char systemDir[MAX_PATH]; GetSystemDirectory(systemDir, sizeof(systemDir)); WIN32_FIND_DATA findData; string path = systemDir; path += "\\taskkill.exe"; HANDLE hFile = FindFirstFile(path.c_str(), &findData); if(hFile!=INVALID_HANDLE_VALUE) bFoundTaskkill = true; FindClose(hFile); char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); path = szCurDir; path += "\\taskkill.exe"; hFile = FindFirstFile(path.c_str(), &findData); if(hFile!=INVALID_HANDLE_VALUE) bFoundTaskkill = true; FindClose(hFile); if(!bFoundTaskkill) return HKE_NO_TASKKILL; string commands = "/C taskkill -im flserver.exe&&flserver.exe " + set_scHkRestartOpt; ShellExecute(NULL, "open", "cmd", commands.c_str(), szCurDir, SW_HIDE); FLHookInitUnload(); return HKE_OK; } HK_ERROR HkShutdownServer() { bool bFoundTaskkill = false; char systemDir[MAX_PATH]; GetSystemDirectory(systemDir, sizeof(systemDir)); WIN32_FIND_DATA findData; string path = systemDir; path += "\\taskkill.exe"; HANDLE hFile = FindFirstFile(path.c_str(), &findData); if(hFile!=INVALID_HANDLE_VALUE) bFoundTaskkill = true; FindClose(hFile); char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); path = szCurDir; path += "\\taskkill.exe"; hFile = FindFirstFile(path.c_str(), &findData); if(hFile!=INVALID_HANDLE_VALUE) bFoundTaskkill = true; FindClose(hFile); if(!bFoundTaskkill) return HKE_NO_TASKKILL; ShellExecute(NULL, "open", "taskkill", "-im flserver.exe", NULL, SW_HIDE); FLHookInitUnload(); return HKE_OK; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// float HkDistance3D(Vector v1, Vector v2) { float sq1 = v1.x-v2.x, sq2 = v1.y-v2.y, sq3 = v1.z-v2.z; return sqrt( sq1*sq1 + sq2*sq2 + sq3*sq3 ); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// float HkGetAdjustedDistance(uint iShip1, uint iShip2) { Vector v1, v2; Matrix m1, m2; pub::SpaceObj::GetLocation(iShip1, v1, m1); pub::SpaceObj::GetLocation(iShip2, v2, m2); uint iDunno; IObjInspectImpl *inspect1; GetShipInspect(iShip1, inspect1, iDunno); IObjInspectImpl *inspect2; GetShipInspect(iShip1, inspect2, iDunno); float fDistance = HkDistance3D(v1, v2) - inspect1->cobject()->hierarchy_radius() - inspect2->cobject()->hierarchy_radius(); return fDistance>0 ? fDistance : 0.0f; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// Quaternion HkMatrixToQuaternion(Matrix m) { Quaternion quaternion; quaternion.w = sqrt( max( 0, 1 + m.data[0][0] + m.data[1][1] + m.data[2][2] ) ) / 2; quaternion.x = sqrt( max( 0, 1 + m.data[0][0] - m.data[1][1] - m.data[2][2] ) ) / 2; quaternion.y = sqrt( max( 0, 1 - m.data[0][0] + m.data[1][1] - m.data[2][2] ) ) / 2; quaternion.z = sqrt( max( 0, 1 - m.data[0][0] - m.data[1][1] + m.data[2][2] ) ) / 2; quaternion.x = (float)_copysign( quaternion.x, m.data[2][1] - m.data[1][2] ); quaternion.y = (float)_copysign( quaternion.y, m.data[0][2] - m.data[2][0] ); quaternion.z = (float)_copysign( quaternion.z, m.data[1][0] - m.data[0][1] ); return quaternion; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// uint HkGetSpaceObjFromBaseID(uint iBaseID) { Universe::IBase *base = Universe::get_base(iBaseID); if(!base) return 0; return base->iSpaceObjID; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// string HkGetStringFromIDS(uint iIDS) //Only works for names { if(!iIDS) return ""; uint iDLL = iIDS / 0x10000; iIDS -= iDLL * 0x10000; char szBuf[512]; if(LoadStringA(vDLLs[iDLL], iIDS, szBuf, 512)) return szBuf; return ""; } wstring HkGetWStringFromIDS(uint iIDS) //Only works for names { if(!iIDS) return L""; uint iDLL = iIDS / 0x10000; iIDS -= iDLL * 0x10000; wchar_t wszBuf[512]; if(LoadStringW(vDLLs[iDLL], iIDS, wszBuf, 512)) return wszBuf; return L""; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// __declspec(naked) CEqObj * __stdcall HkGetEqObjFromObjRW(struct IObjRW *objRW) { __asm { push ecx push edx mov ecx, [esp+12] mov edx, [ecx] call dword ptr[edx+0x150] pop edx pop ecx ret 4 } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// list<RepCB> *lstSaveFactions; _RepCallback saveCallback; bool __stdcall RepCallback(RepCB *rep) { __asm push ecx lstSaveFactions->push_back(*rep); __asm pop ecx return true; } list<RepCB> HkGetFactions() { list<RepCB> lstFactions; lstSaveFactions = &lstFactions; void *callback = (void*)RepCallback; void **obj = &callback; Reputation::enumerate((Reputation::RepGroupCB*)&obj); return lstFactions; } bool __stdcall RepEnumCallback(RepCB *rep) { __asm push ecx bool bRet = saveCallback(rep); __asm pop ecx return bRet; } void HkEnumFactions(_RepCallback callback) { saveCallback = callback; void *enumCallback = (void*)RepEnumCallback; void **obj = &enumCallback; Reputation::enumerate((Reputation::RepGroupCB*)&obj); }
[ "M0tah@62241663-6891-49f9-b8c1-0f2e53ca0faf" ]
[ [ [ 1, 675 ] ] ]
cd449aa45d7d256a42796f4513c3d7699cfc882f
814b49df11675ac3664ac0198048961b5306e1c5
/Code/Engine/PhysX/PhysicsManager.cpp
24b5f023cc5c5e7076087e6eff391b2309376fa6
[]
no_license
Atridas/biogame
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
3b8e95b215da4d51ab856b4701c12e077cbd2587
refs/heads/master
2021-01-13T00:55:50.502395
2011-10-31T12:58:53
2011-10-31T12:58:53
43,897,729
0
0
null
null
null
null
ISO-8859-1
C++
false
false
27,809
cpp
#define __DONT_INCLUDE_MEM_LEAKS__ #include "base.h" #include "Assert.h" #include "PhysicsManager.h" //#include "Logger.h" #include "ScriptManager.h" //#include "Base/Math/Matrix44.h" #include "XML\XMLTreeNode.h" //#include "luabind.hpp" ////----PhysX Includes------------- #undef min #undef max #include "NxPhysics.h" #include "NxControllerManager.h" #include "NxCapsuleController.h" ////-------------------------------- #include "PhysicUserAllocator.h" #include "PhysicCookingMesh.h" #include "PhysicController.h" #include "PhysicActor.h" #include "PhysicSphericalJoint.h" #include "PhysicRevoluteJoint.h" #include "PhysicTriggerReport.h" #include "PhysicFixedJoint.h" #include "RenderManager.h" #include "Utils/Exception.h" #include "Utils/MemLeaks.h" #define MAX_ARISTAS 10 //---------------------------------------------------------------------------- // Init data //---------------------------------------------------------------------------- bool CPhysicsManager::Init (const string& _physXConfig) { m_szConfigFileName = _physXConfig; m_pMyAllocator = new CPhysicUserAllocator; assert(m_pMyAllocator); m_bIsOk = (m_pMyAllocator != NULL); if (m_bIsOk) { LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: Inicializando la libreria PhysX"); // Initialize PhysicsSDK NxPhysicsSDKDesc desc; NxSDKCreateError errorCode = NXCE_NO_ERROR; m_pPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, m_pMyAllocator, NULL, desc, &errorCode); /*Precompilation Directives*/ #if defined( _DEBUG ) #define USE_DEBUGGER #ifdef USE_DEBUGGER m_pPhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect("127.0.0.1"); #endif #endif m_bIsOk = (m_pPhysicsSDK != NULL); if (m_bIsOk) { LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: Creado el PhysXSDK"); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: -------PhsX Settings---"); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: El valor del SkinWidth es: %f", m_InitParams.m_fSkinWidth); m_pPhysicsSDK->setParameter(NX_SKIN_WIDTH, m_InitParams.m_fSkinWidth); //CODI PER PRINTAR INFO DELS JOINTS m_pPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1); m_pPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 1); m_pPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, 1); m_pPhysicsSDK->setParameter(NX_CONTINUOUS_CD, 1); // Create a scene LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: El valor de la gravedad es: %f", m_InitParams.m_fGravity); NxSceneDesc sceneDesc; sceneDesc.gravity = NxVec3(0.0f, m_InitParams.m_fGravity, 0.0f); m_pScene = m_pPhysicsSDK->createScene(sceneDesc); m_bIsOk = (m_pScene != NULL); if (m_bIsOk) { LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: Solo hay un material, con los siguientes params"); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: DefaultMaterial->Restitution %f:", m_InitParams.m_Restitution_DefMat); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: DefaultMaterial->StaticFriction %f:", m_InitParams.m_StaticFriction_DefMat); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: DefaultMaterial->DynamicFriction %f:", m_InitParams.m_DynamicFriction_DefMat); LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: ----END PhsX Settings---"); // Set default material NxMaterial* defaultMaterial = m_pScene->getMaterialFromIndex(0); defaultMaterial->setRestitution(m_InitParams.m_Restitution_DefMat); defaultMaterial->setStaticFriction(m_InitParams.m_StaticFriction_DefMat); defaultMaterial->setDynamicFriction(m_InitParams.m_DynamicFriction_DefMat); // Create a controllerManager m_pControllerManager = NxCreateControllerManager(m_pMyAllocator); m_bIsOk = (m_pControllerManager != NULL); if (m_bIsOk) { LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: Creado el controlador de caracteres"); m_pCookingMesh = new CPhysicCookingMesh(); assert(m_pCookingMesh); m_bIsOk = m_pCookingMesh->Init(m_pPhysicsSDK, m_pMyAllocator); if (m_bIsOk) { LOGGER->AddNewLog(ELL_INFORMATION, "PhysicsManager:: Creado el CookingMesh"); } }// isOk m_pControllerManager? }//isOk m_pScene? }//isOk m_pPhysicsSDK ? }//isOk m_pMyAllocator ? if (!m_bIsOk) { std::string msg_error = "PhysicsManager::Init-> Error en la inicializacion de PhysX"; LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); Release(); throw CException(__FILE__, __LINE__, msg_error); } else { CXMLTreeNode l_xmlPhysX; if(!l_xmlPhysX.LoadFile(_physXConfig.c_str())) { LOGGER->AddNewLog(ELL_WARNING, "No s'ha pogut carregar el fitxer d'init del PhysX Manager \"%s\"", _physXConfig.c_str()); } else { for(int i = 0; i < ECG_LAST_GROUP; ++i) { for(int j = i+1; j < ECG_LAST_GROUP; ++j) { m_pScene->setGroupCollisionFlag(i,j,false); } } LOGGER->AddNewLog(ELL_INFORMATION, "Carregant init del PhysX Manager \"%s\"", _physXConfig.c_str()); int l_iNumC = l_xmlPhysX.GetNumChildren(); for(int i = 0; i < l_iNumC; ++i) { CXMLTreeNode l_xmlCollision = l_xmlPhysX(i); if(strcmp(l_xmlCollision.GetName(), "collision") == 0) { string l_szGroup1 = l_xmlCollision.GetPszISOProperty("group1","",true); string l_szGroup2 = l_xmlCollision.GetPszISOProperty("group2","",true); int l_iGroup1 = GetCollisionGroup(l_szGroup1); int l_iGroup2 = GetCollisionGroup(l_szGroup2); m_CollisionMasks[l_iGroup1] |= 1 << l_iGroup1; m_CollisionMasks[l_iGroup1] |= 1 << l_iGroup2; m_CollisionMasks[l_iGroup2] |= 1 << l_iGroup1; m_CollisionMasks[l_iGroup2] |= 1 << l_iGroup2; m_pScene->setGroupCollisionFlag(l_iGroup1,l_iGroup2,true); LOGGER->AddNewLog(ELL_INFORMATION, "Colisió etre el grup %d (%s) i el grup %d (%s)", l_iGroup1, l_szGroup1.c_str(), l_iGroup2, l_szGroup2.c_str()); } else if(!l_xmlCollision.IsComment()) { LOGGER->AddNewLog(ELL_WARNING, "Element no reconegut \"%s\"", l_xmlCollision.GetName()); } } } } return m_bIsOk; } //---------------------------------------------------------------------------- // Finalize data //---------------------------------------------------------------------------- void CPhysicsManager::Done () { if (IsOk()) { Release(); m_bIsOk = false; } } //---------------------------------------------------------------------------- // Free memory //---------------------------------------------------------------------------- void CPhysicsManager::Release () { CHECKED_DELETE(m_pCookingMesh); if( m_pControllerManager != NULL ) { m_pControllerManager->purgeControllers(); NxReleaseControllerManager(m_pControllerManager); } if(m_pScene != NULL) { m_pPhysicsSDK->releaseScene(*m_pScene); m_pScene = NULL; } if(m_pPhysicsSDK != NULL) { NxReleasePhysicsSDK(m_pPhysicsSDK); m_pPhysicsSDK = NULL; } CHECKED_DELETE(m_pMyAllocator); } //---------------------------------------------------------------------------- // Debug Render //---------------------------------------------------------------------------- void CPhysicsManager::DebugRender (CRenderManager* render) { assert( m_pScene != NULL ); if( !m_bDebugRenderMode ) return; // Render all actors in the scene int nbActors = m_pScene->getNbActors(); NxActor** actors = m_pScene->getActors(); while(nbActors--) { NxActor* actor = *actors++; DrawActor(actor, render); } } void CPhysicsManager::DrawActor (NxActor* actor, CRenderManager* render) { CPhysicUserData* physicUserData = NULL; physicUserData =(CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData assert(physicUserData); if( !physicUserData->GetPaint()) { return; } NxShape*const* shapes = actor->getShapes(); NxU32 nShapes = actor->getNbShapes(); nShapes = actor->getNbShapes(); while (nShapes--) { switch(shapes[nShapes]->getType()) { case NX_SHAPE_PLANE: { CColor color = physicUserData->GetColor(); float distance = shapes[nShapes]->isPlane()->getPlane().d; NxVec3 normal = shapes[nShapes]->isPlane()->getPlane().normal; Vect3f n(normal.x,normal.y,normal.z); render->DrawPlane(100.f, n, distance,color,40,40); } break; case NX_SHAPE_BOX: { NxF32 m_aux[16]; shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux); Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12], m_aux[1], m_aux[5], m_aux[9], m_aux[13], m_aux[2], m_aux[6], m_aux[10], m_aux[14], m_aux[3], m_aux[7], m_aux[11], m_aux[15]); render->SetTransform(m); NxVec3 boxDim = shapes[nShapes]->isBox()->getDimensions(); CColor color = physicUserData->GetColor(); render->DrawCube(Vect3f(boxDim.x*2,boxDim.y*2,boxDim.z*2), color); //render->DrawCube(boxDim.y*2,color); } break; case NX_SHAPE_SPHERE: { NxF32 m_aux[16]; shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux); Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12], m_aux[1], m_aux[5], m_aux[9], m_aux[13], m_aux[2], m_aux[6], m_aux[10], m_aux[14], m_aux[3], m_aux[7], m_aux[11], m_aux[15]); render->SetTransform(m); NxReal radius = shapes[nShapes]->isSphere()->getRadius(); CColor color = physicUserData->GetColor(); render->DrawSphere(radius,color,MAX_ARISTAS); } break; case NX_SHAPE_CAPSULE: { NxF32 m_aux[16]; shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux); Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12], m_aux[1], m_aux[5], m_aux[9], m_aux[13], m_aux[2], m_aux[6], m_aux[10], m_aux[14], m_aux[3], m_aux[7], m_aux[11], m_aux[15]); Mat44f translation, total; translation.SetIdentity(); render->SetTransform(m); const NxReal & radius = shapes[nShapes]->isCapsule()->getRadius(); const NxReal & height = shapes[nShapes]->isCapsule()->getHeight(); CColor color = physicUserData->GetColor(); translation.Translate(Vect3f(0.f, (height*0.5f), 0.f)); total = m * translation; render->SetTransform(total); render->DrawSphere(radius, color,MAX_ARISTAS); translation.Translate( Vect3f(0.f, -(height*0.5f), 0.f )); total = m * translation; render->SetTransform(total); render->DrawSphere(radius, color,MAX_ARISTAS); } break; case NX_SHAPE_CONVEX: break; case NX_SHAPE_MESH: { NxShape* mesh = shapes[nShapes]; NxTriangleMeshDesc meshDesc; mesh->isTriangleMesh()->getTriangleMesh().saveToDesc(meshDesc); typedef NxVec3 Point; typedef struct _Triangle { NxU32 p0; NxU32 p1; NxU32 p2; } Triangle; NxU32 nbVerts = meshDesc.numVertices; NxU32 nbTriangles = meshDesc.numTriangles; Point* points = (Point *)meshDesc.points; Triangle* triangles = (Triangle *)meshDesc.triangles; CColor color = physicUserData->GetColor(); NxF32 m_aux[16]; mesh->getGlobalPose().getColumnMajor44(m_aux); Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12], m_aux[1], m_aux[5], m_aux[9], m_aux[13], m_aux[2], m_aux[6], m_aux[10], m_aux[14], m_aux[3], m_aux[7], m_aux[11], m_aux[15]); render->SetTransform(m); Vect3f a,b,c; while(nbTriangles--) { a = Vect3f(points[triangles->p0].x, points[triangles->p0].y,points[triangles->p0].z); b = Vect3f(points[triangles->p1].x, points[triangles->p1].y,points[triangles->p1].z); c = Vect3f(points[triangles->p2].x, points[triangles->p2].y,points[triangles->p2].z); render->DrawLine(a, b, color); render->DrawLine(b, c, color); render->DrawLine(c, a, color); triangles++; } } break; case NX_SHAPE_WHEEL: { //TODO... } break; default: { //TODO... } break; } } } //---------------------------------------------------------------------------- // Run Physics //---------------------------------------------------------------------------- void CPhysicsManager::Update (float elapsedTime) { assert( m_pScene != NULL ); assert( m_pControllerManager != NULL ); // Start simulation (non blocking) m_pScene->simulate(elapsedTime); // Fetch simulation results m_pScene->flushStream(); //m_pScene->fetchResults(NX_RIGID_BODY_FINISHED, true); } void CPhysicsManager::WaitForSimulation() { m_pScene->fetchResults(NX_RIGID_BODY_FINISHED, true); NxReal maxTimestep; NxTimeStepMethod method; NxU32 maxIter; NxU32 numSubSteps; m_pScene->getTiming(maxTimestep, maxIter, method, &numSubSteps); if(numSubSteps) { m_pControllerManager->updateControllers(); } } void CPhysicsManager::SetTriggerReport (CPhysicTriggerReport* report) { assert(m_pScene); assert(report); NxUserTriggerReport* nxUserTriggerReport = (NxUserTriggerReport*) report; m_pScene->setUserTriggerReport(report); } void CPhysicsManager::SetCollisionReport(CPhysicCollisionReport* report) { assert(m_pScene); assert(report); NxUserContactReport* nxContactReport = (NxUserContactReport*) report; m_pScene->setUserContactReport(nxContactReport); } bool CPhysicsManager::AddPhysicActor (CPhysicActor* actor) { assert(actor != NULL); assert( m_pScene != NULL ); bool isOk = false; NxActor* nxActor; NxActorDesc* actorDesc = actor->GetActorDesc(); assert(actorDesc!=NULL); nxActor = m_pScene->createActor( *actorDesc ); if (nxActor!=NULL) { nxActor->userData = actor->GetUserData(); actor->CreateActor(nxActor); isOk = true; } return isOk; } bool CPhysicsManager::ReleasePhysicActor (CPhysicActor* actor) { assert(actor != NULL); assert(m_pScene != NULL); assert(m_pPhysicsSDK != NULL); bool isOk = false; NxActor* nxActor = actor->GetPhXActor(); if( nxActor != 0) { NxArray<NxCCDSkeleton*> skeletons; for (NxU32 i = 0; i < nxActor->getNbShapes(); i++) { NxShape* shape = nxActor->getShapes()[i]; if (shape->getCCDSkeleton() != NULL) { skeletons.pushBack(shape->getCCDSkeleton()); } } for (NxU32 i = 0; i < skeletons.size(); i++) { m_pPhysicsSDK->releaseCCDSkeleton(*skeletons[i]); } m_pScene->releaseActor(*nxActor); nxActor = 0; } //TODO!!!! return true; } bool CPhysicsManager::AddPhysicSphericalJoint (CPhysicSphericalJoint* joint) { assert(joint != NULL); assert( m_pScene != NULL ); bool isOk = false; NxJoint* nxJoint; NxSphericalJointDesc* jointDesc = joint->GetPhXDescJoint(); assert(jointDesc!=NULL); nxJoint = m_pScene->createJoint(*jointDesc); if (nxJoint!=NULL) { joint->CreateJoint(nxJoint); isOk = true; } return isOk; } bool CPhysicsManager::RelasePhysicSphericalJoint (CPhysicSphericalJoint* joint) { assert(joint); assert(m_pScene); NxJoint* phXJoint = joint->GetPhXJoint(); m_pScene->releaseJoint(*phXJoint); phXJoint = 0; return true; } bool CPhysicsManager::AddPhysicRevoluteJoint (CPhysicRevoluteJoint* joint) { assert(joint != NULL); assert( m_pScene != NULL ); bool isOk = false; NxJoint* nxJoint; NxRevoluteJointDesc* jointDesc = joint->GetPhXDescJoint(); assert(jointDesc!=NULL); nxJoint = m_pScene->createJoint(*jointDesc); if (nxJoint!=NULL) { joint->CreateJoint(nxJoint); isOk = true; } return isOk; } bool CPhysicsManager::RelasePhysicRevoluteJoint (CPhysicRevoluteJoint* joint) { assert(joint); assert(m_pScene); NxJoint* phXJoint = joint->GetPhXJoint(); m_pScene->releaseJoint(*phXJoint); phXJoint = 0; return true; } bool CPhysicsManager::AddPhysicFixedJoint (CPhysicFixedJoint* joint) { assert(joint != NULL); assert( m_pScene != NULL ); bool isOk = false; NxJoint* nxJoint; NxFixedJointDesc* jointDesc = joint->GetPhXDescJoint(); assert(jointDesc!=NULL); nxJoint = m_pScene->createJoint(*jointDesc); if (nxJoint!=NULL) { joint->CreateJoint(nxJoint); isOk = true; } return isOk; } bool CPhysicsManager::RelasePhysicFixedJoint (CPhysicFixedJoint* joint) { assert(joint); assert(m_pScene); NxJoint* phXJoint = joint->GetPhXJoint(); m_pScene->releaseJoint(*phXJoint); phXJoint = 0; return true; } bool CPhysicsManager::AddPhysicController (CPhysicController* controller) { assert(controller != NULL); assert(m_pScene != NULL); assert(m_pControllerManager != NULL); bool isOK = false; NxController* nxController = controller->GetPhXController(); NxCapsuleControllerDesc* nxControllerDesc = controller->GetPhXControllerDesc(); assert(nxControllerDesc!=NULL); assert(nxController==NULL); //Nos aseguramos que no hayan registrado ya un actor en la escena nxController = m_pControllerManager->createController(m_pScene, *nxControllerDesc ); if (m_pControllerManager!= NULL) { controller->CreateController(nxController, m_pScene); nxController->getActor()->userData = controller->GetUserData(); //NxShape*const* shape = nxController->getActor()->getShapes(); //shape[0]->setGroup(controller->); isOK = true; } return isOK; } bool CPhysicsManager::ReleasePhysicController (CPhysicController* controller) { assert(controller != NULL); assert(m_pControllerManager != NULL); bool isOk = false; NxController* nxController = controller->GetPhXController(); if (nxController != NULL) { m_pControllerManager->releaseController( *nxController ); } //TODO!!!! return true; } NxCCDSkeleton* CPhysicsManager::CreateCCDSkeleton (float size) { assert( m_pPhysicsSDK != NULL ); NxU32 triangles[3 * 12] = { 0,1,3, 0,3,2, 3,7,6, 3,6,2, 1,5,7, 1,7,3, 4,6,7, 4,7,5, 1,0,4, 5,1,4, 4,0,2, 4,2,6 }; NxVec3 points[8]; //static mesh points[0].set( size, -size, -size); points[1].set( size, -size, size); points[2].set( size, size, -size); points[3].set( size, size, size); points[4].set(-size, -size, -size); points[5].set(-size, -size, size); points[6].set(-size, size, -size); points[7].set(-size, size, size); NxSimpleTriangleMesh stm; stm.numVertices = 8; stm.numTriangles = 6*2; stm.pointStrideBytes = sizeof(NxVec3); stm.triangleStrideBytes = sizeof(NxU32)*3; stm.points = points; stm.triangles = triangles; stm.flags |= NX_MF_FLIPNORMALS; return m_pPhysicsSDK->createCCDSkeleton(stm); } CPhysicUserData* CPhysicsManager::RaycastClosestActor (const Vect3f posRay, const Vect3f& dirRay, uint32 impactMask, SCollisionInfo& info ) { //NxUserRaycastReport::ALL_SHAPES assert(m_pScene != NULL); NxRay ray; ray.dir = NxVec3(dirRay.x, dirRay.y, dirRay.z); ray.orig = NxVec3(posRay.x, posRay.y, posRay.z); NxRaycastHit hit; NxShape* closestShape = NULL; closestShape = m_pScene->raycastClosestShape(ray, NX_ALL_SHAPES, hit, impactMask); if (!closestShape) { //No hemos tocado a ningún objeto físico de la escena. return NULL; } NxActor* actor = &closestShape->getActor(); CPhysicUserData* impactObject =(CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData assert(impactObject); info.m_fDistance = hit.distance; info.m_Normal = Vect3f(hit.worldNormal.x, hit.worldNormal.y, hit.worldNormal.z ); info.m_CollisionPoint = Vect3f(hit.worldImpact.x, hit.worldImpact.y, hit.worldImpact.z ); return impactObject; } CPhysicUserData* CPhysicsManager::RaycastClosestActorShoot (const Vect3f posRay, const Vect3f& dirRay, uint32 impactMask, SCollisionInfo& info, float _fPower) { //NxUserRaycastReport::ALL_SHAPES assert(m_pScene != NULL); NxRay ray; ray.dir = NxVec3(dirRay.x, dirRay.y, dirRay.z); ray.orig = NxVec3(posRay.x, posRay.y, posRay.z); NxRaycastHit hit; NxShape* closestShape = NULL; closestShape = m_pScene->raycastClosestShape(ray, NX_ALL_SHAPES, hit, impactMask); if (!closestShape) { //No hemos tokado a ningún objeto físico de la escena. return NULL; } NxActor* actor = &closestShape->getActor(); CPhysicUserData* impactObject =(CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData assert(impactObject); info.m_fDistance = hit.distance; info.m_Normal = Vect3f(hit.worldNormal.x, hit.worldNormal.y, hit.worldNormal.z ); info.m_CollisionPoint = Vect3f(hit.worldImpact.x, hit.worldImpact.y, hit.worldImpact.z ); Vect3f l_vDirection(dirRay.x-posRay.x,dirRay.y-posRay.y,dirRay.z-posRay.z); l_vDirection.Normalize(); NxVec3 l_vDirectionVec(dirRay.x,dirRay.y,dirRay.z); NxF32 coeff = actor->getMass() * _fPower; actor->addForceAtLocalPos(l_vDirectionVec*coeff, NxVec3(0,0,0), NX_IMPULSE,true); return impactObject; } void CPhysicsManager::OverlapSphereActor (float radiusSphere, const Vect3f& posSphere, std::vector<CPhysicUserData*> &impactObjects, uint32 impactMask) { assert(m_pScene); NxSphere worldSphere(NxVec3(posSphere.x,posSphere.y,posSphere.z), radiusSphere); NxU32 nbShapes = m_pScene->getNbDynamicShapes(); NxShape** shapes = new NxShape* [nbShapes]; for (NxU32 i = 0; i < nbShapes; i++) { shapes[i] = NULL; } m_pScene->overlapSphereShapes(worldSphere, NX_ALL_SHAPES, nbShapes, shapes, NULL,impactMask); for (NxU32 i = 0; i < nbShapes; i++) { if( shapes[i] != NULL ) { NxActor* actor = &shapes[i]->getActor(); CPhysicUserData* physicObject = (CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle ID assert(physicObject); //Antes de meterlo comprobamos que no exista ya (un objeto fisico puede estar compuesto por varias shapes) std::vector<CPhysicUserData*>::iterator it(impactObjects.begin()); std::vector<CPhysicUserData*>::iterator itEnd(impactObjects.end()); bool find = false; while (it!=itEnd) { CPhysicUserData* id = *it; if( id == physicObject) find = true; ++it; } if(!find) impactObjects.push_back(physicObject); } } delete shapes; } void CPhysicsManager::OverlapSphereActorGrenade (float radiusSphere, const Vect3f& posSphere, std::vector<CPhysicUserData*> impactObjects, float _fPower) { assert(m_pScene); NxSphere worldSphere(NxVec3(posSphere.x,posSphere.y,posSphere.z), radiusSphere); NxU32 nbShapes = m_pScene->getNbDynamicShapes(); NxShape** shapes = new NxShape* [nbShapes]; for (NxU32 i = 0; i < nbShapes; i++) { shapes[i] = NULL; } //NX_DYNAMIC_SHAPES m_pScene->overlapSphereShapes(worldSphere, NX_DYNAMIC_SHAPES, nbShapes, shapes, NULL); for (NxU32 i = 0; i < nbShapes; i++) { if( shapes[i] != NULL ) { NxActor* actor = &shapes[i]->getActor(); CPhysicUserData* physicObject = (CPhysicUserData*)actor->userData; //Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle ID assert(physicObject); //Antes de meterlo comprobamos que no exista ya (un objeto fisico puede estar compuesto por varias shapes) std::vector<CPhysicUserData*>::iterator it(impactObjects.begin()); std::vector<CPhysicUserData*>::iterator itEnd(impactObjects.end()); bool find = false; while (it!=itEnd) { CPhysicUserData* id = *it; if( id == physicObject) find = true; ++it; } if(!find) { impactObjects.push_back(physicObject); physicObject->SetColor(colRED); ApplyExplosion(actor,posSphere,radiusSphere,_fPower); } } //delete &shapes[i]; } delete shapes; /*for (NxU32 i = 0; i < nbShapes; i++) { delete &shapes[i]; }*/ } void CPhysicsManager::RegisterFunctions (CScriptManager* scriptManager) { //lua_State* l_pLUAState = scriptManager->GetLuaState(); //using namespace luabind; // //// ahora registramos lo que querramos // module(l_pLUAState) // [ // // registramos la clase CPhysicsManager // class_<CPhysicsManager>(CScriptRegister::SetClassName("CPhysicsManager")) // // registramos su constructor // .def(constructor<>()) // // registramos sus funciones publicas // .def( CScriptRegister::PushFunctionName(AUTO_COMPLETE), &CScriptRegister::AutoComplete) // .def( CScriptRegister::PushFunctionName(HELP,"void","void", // "Muestra todas las funciones de esta clase"), // &CScriptRegister::Help) // .def( CScriptRegister::PushFunctionName("setDebugRender", "void", "bool flag", // "Setea a true/false la visibilidad de todos los objetos físicos de la escena"), // &CPhysicsManager::SetDebugRenderMode) // .def( CScriptRegister::PushFunctionName("getDebugRender", "bool", "void", // "Obtiene si se visualiza o no los objetos físicos de la escena"), // &CPhysicsManager::GetDebugRenderMode) // ]; } void CPhysicsManager::ApplyExplosion(NxActor* _pActor,const Vect3f& _vPosSphere, float _fEffectRadius, float _fPower) { Vect3f l_vVelocityDirection; Vect3f l_vActorPosition; float l_fDistance; float l_fTotalPower; NxVec3 l_vPos = _pActor->getGlobalPosition(); l_vActorPosition = Vect3f(l_vPos.x,l_vPos.y,l_vPos.z); l_vVelocityDirection = l_vActorPosition-_vPosSphere; l_vVelocityDirection.Normalize(); l_fDistance = _vPosSphere.Distance(l_vActorPosition); l_fTotalPower = _fPower*((_fEffectRadius-l_fDistance)/_fEffectRadius); NxF32 coeff = _pActor->getMass() * l_fTotalPower; NxVec3 l_vDirection(l_vVelocityDirection.x,l_vVelocityDirection.y,l_vVelocityDirection.z); _pActor->addForceAtLocalPos(l_vDirection*coeff, NxVec3(0,0,0), NX_IMPULSE,true); } int GetCollisionGroup(const string& _szGroup) { if(_szGroup == "escenari") { return ECG_ESCENARI; } else if(_szGroup == "personatge") { return ECG_PERSONATGE; } else if(_szGroup == "enemic") { return ECG_ENEMICS; } else if(_szGroup == "trigger") { return ECG_TRIGGERS; } else if(_szGroup == "trigger mal") { return ECG_MALGLOBAL; } else if(_szGroup == "cobertura") { return ECG_COBERTURES; } else if(_szGroup == "objecte dinamic") { return ECG_OBJECTES_DINAMICS; } else if(_szGroup == "explosio") { return ECG_EXPLOSIONS; } else if(_szGroup == "ray shoot") { return ECG_RAY_SHOOT; } else if(_szGroup == "ray shoot player") { return ECG_RAY_SHOOT_PLAYER; } else if(_szGroup == "force") { return ECG_FORCE; } else if(_szGroup == "camera") { return ECG_CAMERA; } else if(_szGroup == "ragdoll") { return ECG_RAGDOLL; } else if(_szGroup == "ragdoll player") { return ECG_RAGDOLL_PLAYER; } else if(_szGroup == "ray ia graph") { return ECG_RAY_IA_GRAPH; } else if(_szGroup == "vigia") { return ECG_VIGIA; } else { return 0; } }
[ "galindix@576ee6d0-068d-96d9-bff2-16229cd70485", "atridas87@576ee6d0-068d-96d9-bff2-16229cd70485", "sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485", "mudarra@576ee6d0-068d-96d9-bff2-16229cd70485", "Atridas87@576ee6d0-068d-96d9-bff2-16229cd70485" ]
[ [ [ 1, 9 ], [ 12, 32 ], [ 35, 39 ], [ 41, 41 ], [ 44, 134 ], [ 182, 402 ], [ 404, 404 ], [ 406, 407 ], [ 423, 431 ], [ 440, 600 ], [ 604, 661 ], [ 663, 676 ], [ 678, 680 ], [ 682, 731 ], [ 733, 743 ], [ 745, 769 ], [ 773, 883 ] ], [ [ 10, 11 ], [ 33, 34 ], [ 40, 40 ], [ 42, 43 ], [ 135, 143 ], [ 152, 181 ], [ 601, 603 ], [ 884, 902 ], [ 907, 922 ], [ 951, 955 ] ], [ [ 144, 151 ], [ 403, 403 ], [ 405, 405 ], [ 408, 422 ], [ 432, 439 ], [ 662, 662 ], [ 677, 677 ], [ 681, 681 ], [ 732, 732 ], [ 744, 744 ], [ 903, 906 ], [ 923, 942 ], [ 947, 950 ] ], [ [ 770, 772 ] ], [ [ 943, 946 ] ] ]
f357c753d85c90d84bf57f91f7354a592927ec2f
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Applications/Miscellaneous/ClodPolyline/ClodPolyline.h
ec6c8b02057e813cdcdf3ed7c32ec832eac25ab7
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08T15:27:44.784437
2011-06-19T15:23:39
2011-06-19T15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
850
h
// Magic Software, Inc. // http://www.magic-software.com // http://www.wild-magic.com // Copyright (c) 2003. All Rights Reserved // // The Wild Magic Library (WML) source code is supplied under the terms of // the license agreement http://www.magic-software.com/License/WildMagic.pdf // and may not be copied or disclosed except in accordance with the terms of // that agreement. #ifndef CLODPOLYLINE_H #define CLODPOLYLINE_H #include "WmlApplication2.h" #include "Polyline3.h" class ClodPolyline : public Application2 { public: ClodPolyline (); virtual ~ClodPolyline (); virtual bool OnInitialize (); virtual void OnTerminate (); virtual void OnDisplay (); virtual void OnKeyDown (unsigned char ucKey, int iX, int iY); protected: Polyline3* m_pkPolyline; int m_iLOD; }; #endif
[ [ [ 1, 33 ] ] ]
71d9ac8d619409fa685e92b077b1f146fdb9a630
4d01363b089917facfef766868fb2b1a853605c7
/src/Graphics/Glut/GlutDisplay.h
a914f0ffbfa4044ff7adab5e27e1c983474b0fa9
[]
no_license
FardMan69420/aimbot-57
2bc7075e2f24dc35b224fcfb5623083edcd0c52b
3f2b86a1f86e5a6da0605461e7ad81be2a91c49c
refs/heads/master
2022-03-20T07:18:53.690175
2009-07-21T22:45:12
2009-07-21T22:45:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,161
h
#ifndef glutdisplay_h #define glutdisplay_h #include <string> #include <sstream> #include <vector> #include "GraphicIncludes.h" #include "../MeshRenderer.h" #include "../Drawable.h" #include "../Camera.h" #include "../HUD/PlayerHUD.h" #include "../HUD/DevConsole.h" using std::stringstream; using std::string; using std::vector; class GlutDisplay : public ScreenBoundsUser { private: float gamma; double fieldOfView; double screenAspect; stringstream ss; vector<Drawable*> drawables; vector<Drawable*> orthographics; Camera* camera; public: GlutDisplay(Camera* cam); void initGraphicsOptions(); void displayFunction(); void reshapeFunction(int w, int h); void updateCamera(); void addDrawable(Drawable* drawable); void addOrthographic(Drawable* drawable); void removeDrawable(Drawable* drawable); void enterOrthoProjection(); void exitOrthoProjection(); void setFOV(float fov); float getFOV(); float getGamma(); double getScreenAspect(); static bool zSort(Drawable* a, Drawable* b); static void displayDelegate(); static void reshapeDelegate(int w, int h); }; #endif
[ "daven.hughes@92c3b6dc-493d-11de-82d9-516ade3e46db" ]
[ [ [ 1, 57 ] ] ]
1f3e75979bc99256cbf116f82081513b71092c98
80716d408715377e88de1fc736c9204b87a12376
/OnSipCommon/Utils.cpp
456a71674d22d84bb1f310f4d499e2bcf9016f15
[]
no_license
junction/jn-tapi
b5cf4b1bb010d696473cabcc3d5950b756ef37e9
a2ef6c91c9ffa60739ecee75d6d58928f4a5ffd4
refs/heads/master
2021-03-12T23:38:01.037779
2011-03-10T01:08:40
2011-03-10T01:08:40
199,317
2
2
null
null
null
null
UTF-8
C++
false
false
10,430
cpp
#include "stdafx.h" #include "Utils.h" #include <time.h> #include <sys\timeb.h> #include <time.h> #include <windows.h> #include <string> #include <vector> #include <iterator> #include <algorithm> #include "logger.h" #include "atlenc.h" #include <assert.h> using namespace std; // Format the current time using the specified strftime format values //static // Added special non-strftime flag to output milliseconds, %t tstring DateTimeOperations::FormatNow(const TCHAR* format) { // Get current time (with milliseconds) struct _timeb timebuffer; _ftime_s(&timebuffer); // Convert time to 'tm' type for string formatting struct tm tmx; localtime_s(&tmx,&timebuffer.time); // Get # of milliseconds as string tstring szms = Strings::stringFormat(_T("%04d"),timebuffer.millitm); // Create new copy of format string to be updated with milliseconds tstring szFormat = format; szFormat = Strings::replace(szFormat,_T("%t"),szms); // Format the time using strftime format types TCHAR str[200]; _tcsftime( str, sizeof(str)/sizeof(TCHAR), szFormat.c_str(), &tmx ); // Return back as tstring return tstring(str); } // Return the formatted string for the specified time //static tstring DateTimeOperations::getTimeString(time_t& t) { TCHAR buf[256]; _tctime_s( buf, sizeof(buf)/sizeof(TCHAR), &t); return tstring(buf); } // Convert time_t to system time in struct tm struct tm DateTimeOperations::GetUTCTime(time_t& t) { // Convert to system time struct tm tm; gmtime_s(&tm,&t); return tm; } tstring DateTimeOperations::getUTCTimeString(time_t& t) { // Convert to UTC time struct tm tm; tm = GetUTCTime(t); // Convert to string return Strings::stringFormat("%i-%02i-%02iT%02i:%02i:%02iZ", tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } //************************************************************* //************************************************************* //static the sip address (e.g. "sip:[email protected]" into the // name and domain parts. The prefix "sip:" is optional. // Returns false if sipaddress is not in correct format. bool Utils::ParseSIP(const tstring& sipAddress,tstring* userName,tstring* domain) { tstring sipaddr = Strings::trim(sipAddress); if ( sipaddr.empty() ) return false; // Remove "sip:" prefix if ( Strings::startsWith( Strings::tolower(sipaddr), _T("sip:") ) ) sipaddr = sipaddr.substr(4); // Ensure has "@" if ( !Strings::contains(sipaddr,_T("@")) ) return false; // Break up values by "@" tstring_vector vals = Strings::split(sipaddr,"@"); if ( vals.size() != 2 ) return false; *userName = vals[0]; *domain = vals[1]; // If domain does not contain a ".", then an error if ( !Strings::contains(*domain,_T(".")) ) return false; return true; } //************************************************************* //************************************************************* tstring_vector Strings::split(const tstring& str, const tstring& delimiters) { tstring_vector tokens; // Skip delimiters at beginning. string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiters, lastPos); while (string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } return tokens; } tstring Strings::trim_right (const tstring & s, const tstring & t) { tstring d (s); tstring::size_type i (d.find_last_not_of (t)); if (i == tstring::npos) return _T(""); else return d.erase (d.find_last_not_of (t) + 1) ; } tstring Strings::trim_left (const tstring & s, const tstring & t) { tstring d (s); return d.erase (0, s.find_first_not_of (t)) ; } tstring Strings::trim (const tstring & s, const tstring & t) { tstring d (s); return trim_left (trim_right (d, t), t) ; } // returns a lower case version of the string tstring Strings::tolower (const tstring & s) { tstring d (s); transform (d.begin (), d.end (), d.begin (), (int(*)(int)) ::tolower); return d; } // returns an upper case version of the string tstring Strings::toupper (const tstring & s) { tstring d (s); transform (d.begin (), d.end (), d.begin (), (int(*)(int)) ::toupper); return d; } // string find-and-replace // source = string to have replaced text // target = string to be searched within source and replaced // replacement = new string to be replaced where target exists // returns new modified string tstring Strings::replace(const tstring& source, const tstring& target, const tstring& replacement) { tstring str = source; tstring::size_type pos = 0, // where we are now found; // where the found data is if (target.size () > 0) // searching for nothing will cause a loop { while ((found = str.find (target, pos)) != tstring::npos) { str.replace (found, target.size (), replacement); pos = found + replacement.size (); } } return str; }; // Strip all non-numeric values from string tstring Strings::stripNonNumeric(const tstring& str) { const TCHAR* pstr = str.data(); tstring strReturn; while ( *pstr ) { if (is_tdigit(*pstr) ) strReturn += *pstr; pstr++; } return strReturn; } // case insensitive compare of strings bool Strings::stringsSame(const tstring& str1,const tstring& str2) { return _tcsicmp(str1.c_str(), str2.c_str()) == 0; } // Returns true if 'str' starts with 'chars' bool Strings::startsWith(const tstring& str,const tstring& chars) { return str.find(chars) == 0; } // Returns true if 'str' ends with 'chars' bool Strings::endsWith(const tstring& str,const tstring& chars) { size_t i = str.rfind(chars); return (i != tstring::npos) && (i == (str.length() - chars.length())); } // Returns true if 'str' contains 'chars' bool Strings::contains(const tstring& str,const tstring& chars) { return str.find(chars) != tstring::npos; } tstring Strings::stringFormat(const TCHAR* format, ...) { va_list v; va_start(v,format); // Get required length of characters, add 1 for NULL int len = _vsctprintf(format,v) + 1; // Allocate the string buffer TCHAR* str = new TCHAR[len]; _vstprintf_s(str,len,format,v); va_end(v); // Convert to string tstring ret(str); // Free memory and return formatted tstring delete[] str; return ret; } //static // string converts from widechar to multibyte string Strings::convert(const wstring& src) { string ret; ret.resize(src.size()); size_t i; wcstombs_s(&i, (char *) ret.data(), ret.size()+1, src.data(), ret.size() ); return ret; } //static // string converts from mulibyte to widechar wstring Strings::convert(const string& src) { size_t i; wstring ret; ret.resize(src.size()); mbstowcs_s(&i,(wchar_t *)ret.data(),ret.size()+1, src.data(), ret.size()); return ret; } const TCHAR * toStrip = _T(" \n\r\t"); tstring Strings::lstrip(const tstring& s) { tstring::size_type n = s.find_first_not_of(toStrip); return n == tstring::npos ? tstring() : s.substr(n); } tstring Strings::rstrip(const tstring& s) { tstring::size_type n = s.find_last_not_of(toStrip); return n == tstring::npos ? tstring() : s.substr(0, n+1); } tstring Strings::strip(const tstring& s) { return lstrip(rstrip(s)); } tstring Strings::repr(const tstring& _s) { string s = Strings::T_TO_S(_s); string r; for (unsigned i = 0; i < s.size(); i++) { if (s[i] == '\n') r += "\\n"; else if (s[i] == '\r') r += "\\r"; else if (s[i] == '\t') r += "\\t"; else r += s[i]; } return Strings::S_TO_T(r); } // Do an XOR of each character in strInput with the charXor. // Returns back the XOR string tstring Strings::_xorWithChar(const tstring& strInput,TCHAR charXor) { // Create the return string tstring strOutput; strOutput.resize(strInput.size()); // Do XOR on each of the chars unsigned count = 0; tstring::const_iterator iter = strInput.begin(); while ( iter != strInput.end() ) strOutput[count++] = (*iter++) ^ charXor; return strOutput; } // Do an XOR of each char in strInput with each char in stringXor // Returns back the new XOR string tstring Strings::_xor(const tstring& strInput,const tstring& stringXor) { tstring retString = strInput; for ( tstring::const_iterator iter = stringXor.begin(); iter != stringXor.end(); ++iter ) retString = _xorWithChar(retString,*iter); return retString; } // Simple decrypt on 'instr' using the key string Strings::decryptString(const string& strInput,const string& decryptKey) { // Convert the base64 into bytes char output[1024]; int len=(int)sizeof(output); BOOL ret = Base64Decode( strInput.data(), strInput.size(), (BYTE *)output, &len ); _ASSERT(ret); // Put bytes back into a string string retString; retString.resize(len); for ( int i=0; i<len; ++i ) retString[i] = output[i]; // decrypt the string using the xor chars return _xor(retString,reverseString(decryptKey)); } // Do a simple encrypt on strInput with each character in the encryptKey string Strings::encryptString(const string& strInput,const string& encryptKey) { // Encrypt the string string strRet = _xor(strInput,encryptKey); // Convert the string to base64 char output[1024]; int len=(int)sizeof(output); BOOL ret = Base64Encode( (const BYTE*) strRet.data(), strRet.size(), output, &len, ATL_BASE64_FLAG_NOPAD | ATL_BASE64_FLAG_NOCRLF ); _ASSERT(ret); // Put the base64 bytes into the return value strRet.resize(len); for ( int i=0; i<len; ++i ) strRet[i] = output[i]; return strRet; } // Returns a reverse copy of 'str' tstring Strings::reverseString(const tstring& strInput) { // Create return string of same size tstring retString; retString.resize(strInput.size()); // Reverse the string unsigned count=0; tstring::const_reverse_iterator iter = strInput.rbegin(); while ( iter != strInput.rend() ) retString[count++] = *iter++; return retString; }
[ "Owner@.(none)", "Ron@.(none)", "[email protected]" ]
[ [ [ 1, 12 ], [ 15, 53 ], [ 73, 75 ], [ 126, 151 ], [ 153, 159 ], [ 161, 186 ], [ 200, 289 ] ], [ [ 13, 14 ], [ 54, 72 ], [ 76, 125 ], [ 290, 371 ] ], [ [ 152, 152 ], [ 160, 160 ], [ 187, 199 ] ] ]
5ac1ab41ac89033d5b05a0ec457cce318e4e7f4e
317f62189c63646f81198d1692bed708d8f18497
/common/network/components/router/router.h
47fe22aa0403bedffc648daebd529fb7612c06cd
[ "MIT" ]
permissive
mit-carbon/Graphite-Cycle-Level
8fb41d5968e0a373fd4adbf0ad400a9aa5c10c90
db3f1e986ddc10f3e5f3a5d4b68bd6a9885969b3
refs/heads/master
2021-01-25T07:08:46.628355
2011-11-23T08:53:18
2011-11-23T08:53:18
1,930,686
1
0
null
null
null
null
UTF-8
C++
false
false
810
h
#pragma once #include "fixed_types.h" class Router { public: class Id { public: Id(): _core_id(INVALID_CORE_ID), _index(-1) {} Id(core_id_t core_id, SInt32 index): _core_id(core_id), _index(index) {} ~Id() {} bool operator==(const Id& router_id) const { return ((_core_id == router_id._core_id) && (_index == router_id._index)); } bool operator!=(const Id& router_id) const { return ((_core_id != router_id._core_id) || (_index != router_id._index)); } bool operator<(const Id& router_id) const { return ( (_core_id < router_id._core_id) || \ ((_core_id == router_id._core_id) && (_index < router_id._index)) ) ; } core_id_t _core_id; SInt32 _index; }; };
[ [ [ 1, 29 ] ] ]
0e192eee6121dbad2265c1c25b61cb5c9658e191
38926bfe477f933a307f51376dd3c356e7893ffc
/Source/SDKs/STLPORT/stlport/stl/_alloc_old.h
6ca57704c1a90ead3bc6c30073a5a09afc2b2ee9
[ "LicenseRef-scancode-stlport-4.5" ]
permissive
richmondx/dead6
b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161
955f76f35d94ed5f991871407f3d3ad83f06a530
refs/heads/master
2021-12-05T14:32:01.782047
2008-01-01T13:13:39
2008-01-01T13:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,617
h
template<class _Tp, class _Alloc> class __simple_alloc { typedef _Alloc __alloc_type; public: typedef typename _Alloc::value_type __alloc_value_type; typedef _Tp value_type; static size_t _STLP_CALL __chunk(size_t __n) { return (sizeof(__alloc_value_type)==sizeof(value_type)) ? __n : ((__n*sizeof(value_type)+sizeof(__alloc_value_type)-1)/sizeof(__alloc_value_type)); } static _Tp* _STLP_CALL allocate(size_t __n) { return 0 == __n ? 0 : (_Tp*) __alloc_type::allocate(__chunk(__n)); } static void _STLP_CALL deallocate(_Tp * __p, size_t __n) { __alloc_type::deallocate((__alloc_value_type*)__p, __chunk(__n)); } }; // Allocator adaptor to turn an SGI-style allocator (e.g. alloc, malloc_alloc) // into a standard-conforming allocator. Note that this adaptor does // *not* assume that all objects of the underlying alloc class are // identical, nor does it assume that all of the underlying alloc's // member functions are static member functions. Note, also, that // __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>. template <class _Tp, class _Alloc> struct __allocator : public _Alloc { typedef _Alloc __underlying_alloc; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef const _Tp* const_pointer; typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; # if defined (_STLP_MEMBER_TEMPLATE_CLASSES) template <class _Tp1> struct rebind { typedef __allocator<_Tp1, _Alloc> other; }; # endif __allocator() _STLP_NOTHROW {} __allocator(const _Alloc& ) _STLP_NOTHROW {} __allocator(const __allocator<_Tp, _Alloc>& __a) _STLP_NOTHROW : _Alloc(__a) {} # if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) template <class _Tp1> __allocator(const __allocator<_Tp1, _Alloc>& __a) _STLP_NOTHROW : _Alloc(__a) {} # endif # ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG ~__allocator() _STLP_NOTHROW {} # endif pointer address(reference __x) const { return &__x; } # if !defined (__WATCOM_CPLUSPLUS__) const_pointer address(const_reference __x) const { return &__x; } # endif // __n is permitted to be 0. _Tp* allocate(size_type __n, const void* = 0) { if (__n > max_size()) __THROW_BAD_ALLOC; return __n != 0 ? __STATIC_CAST(_Tp*,__underlying_alloc::allocate(__n * sizeof(_Tp))) : 0; } // __p is not permitted to be a null pointer. void deallocate(pointer __p, size_type __n) { if (__p) __underlying_alloc::deallocate(__p, __n * sizeof(_Tp)); } size_type max_size() const _STLP_NOTHROW { return size_t(-1) / sizeof(_Tp); } void construct(pointer __p, const_reference __val) { _STLP_STD::_Copy_Construct(__p, __val); } void destroy(pointer __p) { _STLP_STD::_Destroy(__p); } const __underlying_alloc& __get_underlying_alloc() const { return *this; } }; #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION template <class _Alloc> class __allocator<void, _Alloc> { typedef size_t size_type; typedef ptrdiff_t difference_type; typedef void* pointer; typedef const void* const_pointer; typedef void value_type; #ifdef _STLP_MEMBER_TEMPLATE_CLASSES template <class _Tp1> struct rebind { typedef __allocator<_Tp1, _Alloc> other; }; #endif }; #endif template <class _Tp, class _Alloc> inline bool _STLP_CALL operator==(const __allocator<_Tp, _Alloc>& __a1, const __allocator<_Tp, _Alloc>& __a2) { return __a1.__get_underlying_alloc() == __a2.__get_underlying_alloc(); } #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE template <class _Tp, class _Alloc> inline bool _STLP_CALL operator!=(const __allocator<_Tp, _Alloc>& __a1, const __allocator<_Tp, _Alloc>& __a2) { return __a1.__get_underlying_alloc() != __a2.__get_underlying_alloc(); } #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ // Comparison operators for all of the predifined SGI-style allocators. // This ensures that __allocator<malloc_alloc> (for example) will // work correctly. #ifndef _STLP_NON_TYPE_TMPL_PARAM_BUG template <int inst> inline bool _STLP_CALL operator==(const __malloc_alloc<inst>&, const __malloc_alloc<inst>&) { return true; } #ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER template <int __inst> inline bool _STLP_CALL operator!=(const __malloc_alloc<__inst>&, const __malloc_alloc<__inst>&) { return false; } #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ inline bool _STLP_CALL operator==(const __new_alloc&, const __new_alloc&) { return true; } # ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE inline bool _STLP_CALL operator!=(const __new_alloc&, const __new_alloc&) { return false; } # endif template <bool __threads, int __inst> inline bool _STLP_CALL operator==(const __node_alloc<__threads, __inst>&, const __node_alloc<__threads, __inst>&) { return true; } #if defined( _STLP_FUNCTION_TMPL_PARTIAL_ORDER ) template <bool __threads, int __inst> inline bool _STLP_CALL operator!=(const __node_alloc<__threads, __inst>&, const __node_alloc<__threads, __inst>&) { return false; } #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ #endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */ template <class _Alloc> inline bool _STLP_CALL operator==(const __debug_alloc<_Alloc>&, const __debug_alloc<_Alloc>&) { return true; } # ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE template <class _Alloc> inline bool _STLP_CALL operator!=(const __debug_alloc<_Alloc>&, const __debug_alloc<_Alloc>&) { return false; } # endif #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) // Versions for the predefined SGI-style allocators. template <class _Tp, int __inst> struct _Alloc_traits<_Tp, __malloc_alloc<__inst> > { typedef __allocator<_Tp, __malloc_alloc<__inst> > allocator_type; }; template <class _Tp, bool __threads, int __inst> struct _Alloc_traits<_Tp, __node_alloc<__threads, __inst> > { typedef __allocator<_Tp, __node_alloc<__threads, __inst> > allocator_type; }; template <class _Tp, class _Alloc> struct _Alloc_traits<_Tp, __debug_alloc<_Alloc> > { typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type; }; // Versions for the __allocator adaptor used with the predefined // SGI-style allocators. template <class _Tp, class _Tp1, class _Alloc> struct _Alloc_traits<_Tp, __allocator<_Tp1, _Alloc > > { typedef __allocator<_Tp, _Alloc > allocator_type; }; #endif #if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) // Versions for the predefined SGI-style allocators. # if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) typedef __malloc_alloc<0> __malloc_alloc_dfl; typedef __node_alloc<false, 0> __single_client_node_alloc; typedef __node_alloc<true, 0> __multithreaded_node_alloc; template <class _Tp> inline __allocator<_Tp, __malloc_alloc_dfl >& _STLP_CALL __stl_alloc_rebind(__malloc_alloc_dfl& __a, const _Tp*) { return (__allocator<_Tp, __malloc_alloc_dfl >&)__a; } template <class _Tp> inline __allocator<_Tp, __single_client_node_alloc >& _STLP_CALL __stl_alloc_rebind(__single_client_node_alloc& __a, const _Tp*) { return (__allocator<_Tp, __single_client_node_alloc >&)__a; } template <class _Tp> inline __allocator<_Tp, __multithreaded_node_alloc >& _STLP_CALL __stl_alloc_rebind(__multithreaded_node_alloc& __a, const _Tp*) { return (__allocator<_Tp, __multithreaded_node_alloc >&)__a; } template <class _Tp> inline __allocator<_Tp, __malloc_alloc_dfl > _STLP_CALL __stl_alloc_create(const __malloc_alloc_dfl&, const _Tp*) { return __allocator<_Tp, __malloc_alloc_dfl > (); } template <class _Tp> inline __allocator<_Tp, __single_client_node_alloc > _STLP_CALL __stl_alloc_create(const __single_client_node_alloc&, const _Tp*) { return __allocator<_Tp, __single_client_node_alloc >(); } template <class _Tp> inline __allocator<_Tp, __multithreaded_node_alloc > _STLP_CALL __stl_alloc_create(const __multithreaded_node_alloc&, const _Tp*) { return __allocator<_Tp, __multithreaded_node_alloc >(); } # else template <class _Tp, int __inst> inline __allocator<_Tp, __malloc_alloc<__inst> >& _STLP_CALL __stl_alloc_rebind(__malloc_alloc<__inst>& __a, const _Tp*) { return (__allocator<_Tp, __malloc_alloc<__inst> >&)__a; } template <class _Tp, bool __threads, int __inst> inline __allocator<_Tp, __node_alloc<__threads, __inst> >& _STLP_CALL __stl_alloc_rebind(__node_alloc<__threads, __inst>& __a, const _Tp*) { return (__allocator<_Tp, __node_alloc<__threads, __inst> >&)__a; } template <class _Tp, int __inst> inline __allocator<_Tp, __malloc_alloc<__inst> > _STLP_CALL __stl_alloc_create(const __malloc_alloc<__inst>&, const _Tp*) { return __allocator<_Tp, __malloc_alloc<__inst> >(); } template <class _Tp, bool __threads, int __inst> inline __allocator<_Tp, __node_alloc<__threads, __inst> > _STLP_CALL __stl_alloc_create(const __node_alloc<__threads, __inst>&, const _Tp*) { return __allocator<_Tp, __node_alloc<__threads, __inst> >(); } # endif template <class _Tp, class _Alloc> inline __allocator<_Tp, __debug_alloc<_Alloc> > _STLP_CALL __stl_alloc_create(const __debug_alloc<_Alloc>&, const _Tp*) { return __allocator<_Tp, __debug_alloc<_Alloc> >(); } template <class _Tp, class _Alloc> inline __allocator<_Tp, __debug_alloc<_Alloc> >& _STLP_CALL __stl_alloc_rebind(__debug_alloc<_Alloc>& __a, const _Tp*) { return (__allocator<_Tp, __debug_alloc<_Alloc> >&)__a; } template <class _Tp> inline __allocator<_Tp, __new_alloc > _STLP_CALL __stl_alloc_create(const __new_alloc&, const _Tp*) { return __allocator<_Tp, __new_alloc >(); } template <class _Tp> inline __allocator<_Tp, __new_alloc >& _STLP_CALL __stl_alloc_rebind(__new_alloc& __a, const _Tp*) { return (__allocator<_Tp, __new_alloc >&)__a; } template <class _Tp1, class _Alloc, class _Tp2> inline __allocator<_Tp2, _Alloc>& _STLP_CALL __stl_alloc_rebind(__allocator<_Tp1, _Alloc>& __a, const _Tp2*) { return (__allocator<_Tp2, _Alloc>&)__a; } template <class _Tp1, class _Alloc, class _Tp2> inline __allocator<_Tp2, _Alloc> _STLP_CALL __stl_alloc_create(const __allocator<_Tp1, _Alloc>&, const _Tp2*) { return __allocator<_Tp2, _Alloc>(); } #endif
[ [ [ 1, 305 ] ] ]
bf09e3f0de59f9a228519c92077b65254707de6d
5b3221bdc6edd8123287b2ace0a971eb979d8e2d
/Fiew/ToolBucket.cpp
5f4d79d8769ee5ee6b095fb37bfe94b7631f7610
[]
no_license
jackiejohn/fedit-image-editor
0a4b67b46b88362d45db6a2ba7fa94045ad301e2
fd6a87ed042e8adf4bf88ddbd13f2e3b475d985a
refs/heads/master
2021-05-29T23:32:39.749370
2009-02-25T21:01:11
2009-02-25T21:01:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,704
cpp
#include "stdafx.h" #include "Core.h" ToolBucket::ToolBucket() : ToolDrawingStrict(new FwCHAR(TOOL_FILBUC),NULL,ICC_FILBUC) { this->isPreselect = false; this->sourceBmp = NULL; this->cursor = Tool::createToolCursor(19,15,ICC_FILBUC); this->cursorBackup = this->cursor; } ToolBucket::~ToolBucket() { if( this->sourceBmp != NULL ) delete this->sourceBmp; DestroyIcon(this->cursorBackup); } void ToolBucket::capMouseDown(WPARAM wParam, LPARAM lParam, int button) { switch(button){ case LEFT: if( this->isLayerReady() == false ) return; if( this->chicore->getWorkspace()->getSelection() == NULL ){ this->setMouseCapture(); this->sourceBmp = this->chicore->getWorkspace()->getSelectedLayerProjection(true); this->callColor(&this->colorPick); this->callMagic(wParam,lParam); this->isDraw = true; } else { this->isPreselect = true; } break; } } void ToolBucket::capMouseMove(WPARAM wParam, LPARAM lParam) { this->loadCursor(); if( this->isDraw == true ){ Color temp; this->callColor(&temp); if( temp.GetValue() != this->colorPick.GetValue() ){ this->colorPick = temp; this->callMagic(wParam,lParam); } } } void ToolBucket::capMouseUp(WPARAM wParam, LPARAM lParam, int button) { switch(button){ case LEFT: this->setMouseRelease(); this->isDraw = false; if( this->chicore->getWorkspace()->getSelection() != NULL ){ if( this->chicore->getWorkspace()->getSelection()->IsVisible( this->mouse.x,this->mouse.y) ){ if( this->sourceBmp != NULL ) delete this->sourceBmp; this->sourceBmp = NULL; this->beginPaint(); this->drawgfx->FillPath( this->brushColor, this->chicore->getWorkspace()->getSelection() ); Rect bounds; this->chicore->getWorkspace()->getSelection()->GetBounds(&bounds); SetRect( &this->srcrect, bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y + bounds.Height ); this->endPaint(); } } if( this->isPreselect == false ) this->chicore->getWorkspace()->setSelection(NULL); this->isPreselect = false; break; } } void ToolBucket::callColor(Color *color) { this->chicore->getWorkspace()->getSelectedLayer()->getRender()->GetPixel( this->mouse.x, this->mouse.y, color); } void ToolBucket::callMagic(WPARAM wParam, LPARAM lParam) { this->chicore->getWorkspace()->setSelection( ToolSelectWand::doMagic( this->sourceBmp, NULL, this->mouse.x, this->mouse.y, 0, 0, this->size ) ); this->chicore->getDrawer()->invalidate(); }
[ [ [ 1, 124 ] ] ]
16fae6650a5ec6f056f7d7a50936f807e0e41396
629e4fdc23cb90c0144457e994d1cbb7c6ab8a93
/lib/font/font.cpp
59d84b50afb6bb366e7ecd728884b723bf423139
[]
no_license
akin666/ice
4ed846b83bcdbd341b286cd36d1ef5b8dc3c0bf2
7cfd26a246f13675e3057ff226c17d95a958d465
refs/heads/master
2022-11-06T23:51:57.273730
2011-12-06T22:32:53
2011-12-06T22:32:53
276,095,011
0
0
null
null
null
null
UTF-8
C++
false
false
10,106
cpp
/* * font.cpp * * Created on: 4.8.2011 * Author: akin * * parts taken from freetype-gl * those parts are under BSD, but, others ARE NOT. */ #include "font.h" #include <iostream> #include <dio/filedio> #include <iterator> #include <ft2build.h> #include FT_FREETYPE_H #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include <math.h> #include "edtaa3func.h" #include <system/utf8tools.h> #include <glm/transform> #define DEFAULT_TEXTURE_SIZE 64 #define DEFAULT_TEXTURE_PADDING 1 namespace ice { class FTSingleton { private: static FTSingleton *singleton; public: FTSingleton(){} virtual ~FTSingleton(){} static FTSingleton &get() { if( singleton == NULL ) { singleton = new FTSingleton; FT_Error error = FT_Init_FreeType( &(singleton->library) ); if ( error ) { std::cout << "FT_Error Failed to initialize FTLibrary " << std::endl; ::exit( -1 ); } } return *singleton; } FT_Library library; }; FTSingleton *FTSingleton::singleton = NULL; class FTFontData { public: FT_Error error; FT_Face face; ~FTFontData() { FT_Done_Face( face ); } }; Font::Font() : filedata(NULL) { data = new FTFontData; } Font::~Font() { if( filedata != NULL ) { delete[] filedata; filedata = NULL; } if( data != NULL ) { delete (FTFontData*)data; data = NULL; } } void Font::updateMatrix() { textureMatrix = glm::scale( glm::mat4(1.0f) , glm::vec3( 1.0f / (float)atlas.getDimension().x , 1.0f / (float)atlas.getDimension().y , 1.0f ) ); } bool Font::initialize( DIO& dio ) { if( filedata == NULL ) { size_t hres = 10; FT_Matrix matrix = { (int)((1.0/hres) * 0x10000L), (int)((0.0) * 0x10000L), (int)((0.0) * 0x10000L), (int)((1.0) * 0x10000L) }; size = 72; border = 1; gamma = 1.0f; if( !dio.isOk() || dio.empty() ) { return false; } const unsigned int len = dio.getDataSize(); filedata = new unsigned char[len]; dio.readBlock( filedata , len ); FTFontData& ftdata = (*(FTFontData*)data); ftdata.error = FT_New_Memory_Face( FTSingleton::get().library, filedata, // first byte in memory len, // size in bytes 0, // face_index &ftdata.face ); if( ftdata.error ) { std::cout << "FT_Error failed to load font " << std::endl; delete[] filedata; filedata = NULL; return false; } // Select charmap ftdata.error = FT_Select_Charmap( ftdata.face , FT_ENCODING_UNICODE ); if( ftdata.error ) { std::cout << "FT_Error failed to load font: unicode select error " << std::endl; delete[] filedata; filedata = NULL; return false; } // Set char size ftdata.error = FT_Set_Char_Size( ftdata.face, 0, size*64, 72*hres, 72 ); if( ftdata.error ) { std::cout << "FT_Error failed to load font: char size select error " << std::endl; delete[] filedata; filedata = NULL; return false; } FT_Set_Transform( ftdata.face, &matrix, NULL ); atlas.initialize( glm::ivec2( DEFAULT_TEXTURE_SIZE , DEFAULT_TEXTURE_SIZE ) , DEFAULT_TEXTURE_PADDING , ALPHA ); updateMatrix(); return true; } return false; } float Font::getSize() const { return size; } bool Font::initialize( const std::string filename ) { FileDIO dio; dio.open( filename ); return initialize( dio ); } bool Font::loadSingleGlyph( UNICODE code ) { if( filedata != NULL ) { std::map< UNICODE , Glyph >::iterator iter = glyphs.find( code ); if( iter != glyphs.end() ) { // Already loaded. return true; } FTFontData& ftdata = (*(FTFontData*)data); const unsigned int glyph_index = FT_Get_Char_Index( ftdata.face , code ); Glyph glyph; glyph.setUnicode( code ); if( glyph_index == 0 ) { glyph.setEmpty( true ); glyphs[ code ] = glyph; return true; } glyph.setEmpty( false ); ftdata.error = FT_Load_Glyph( ftdata.face , glyph_index, FT_LOAD_DEFAULT | FT_LOAD_FORCE_AUTOHINT ); if( ftdata.error ) { std::cout << "FT_Error failed to load glyph:" << std::endl; return false; } // Set rendering, making sure that there is a BITMAP if( ftdata.face->glyph->format != FT_GLYPH_FORMAT_BITMAP ) { ftdata.error = FT_Render_Glyph( ftdata.face->glyph, FT_RENDER_MODE_NORMAL ); if( ftdata.error ) { std::cout << "FT_Error failed to render glyph:" << std::endl; return false; } } FT_GlyphSlot slot = ftdata.face->glyph; const int real_width = slot->bitmap.width; const int real_height = slot->bitmap.rows; const int owidth = real_width + 2*border; const int oheight = real_height + 2*border; if( real_width < 1 || real_height < 1 ) { std::cout << "Font " << code << " is zero sized" << std::endl; return false; } // Gamma correction (sort of) // TODO! // int x, y; // unsigned char c; // for( x = 0 ; x < slot->bitmap.width ; ++x ) // { // for( y=0; y < slot->bitmap.rows ; ++y ) // { // c = *(unsigned char *)(slot->bitmap.buffer + y*slot->bitmap.pitch + x ); // c = (unsigned char) ( pow(c/255.0, gamma) * 255); // *(unsigned char *)(slot->bitmap.buffer + y*slot->bitmap.pitch + x ) = c; // } // } unsigned char buffa[ owidth * oheight ]; memset( buffa , 0 , owidth * oheight *sizeof(unsigned char) ); int target,source; for( int i = real_height - 1 ; i >= 0 ; --i ) { target = (i * owidth) + border; source = (real_height - i - 1) * slot->bitmap.pitch; // flip memcpy( buffa + target , slot->bitmap.buffer + source , real_width ); } glyph.setTextureSize( glm::ivec2( owidth , oheight ) ); if( !atlas.request( glyph.getTextureDimensions() , glyph.getTextureLocation() ) ) { atlas.resize( atlas.getDimension() * 2 ); updateMatrix(); if( !atlas.request( glyph.getTextureDimensions() , glyph.getTextureLocation() ) ) { std::cout << "FT_Error failed resize atlas." << std::endl; return false; } } // Send to texture atlas.getTexture().renderSubTexture( glyph.getTextureLocation() , glyph.getTextureDimensions() , buffa ); // Populate glyph data glyph.setSize( glm::vec2( slot->bitmap.width , slot->bitmap.rows ) ); glyph.setOffset( glm::vec2( slot->bitmap_left , slot->bitmap_top ) ); // Discard hinting to get advance FT_Load_Glyph( ftdata.face , glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING); glyph.setAdvance( glm::vec2( ftdata.face->glyph->advance.x / 64.0f , ftdata.face->glyph->advance.y / 64.0f ) ); // send finally the data glyphs[ code ] = glyph; } return false; } void Font::cacheGlyphs( std::string utf8text ) { // Parse string, convert to unicode, the glyphs that need converting. std::vector<UNICODE> tmp; if( utf8tools::decodeTo( utf8text , tmp ) ) { for( unsigned int i = 0 ; i < tmp.size() ; ++i ) { loadSingleGlyph( tmp[i] ); } } } bool Font::load( const UNICODE glyph ) { return loadSingleGlyph( glyph ); } bool Font::load( const std::vector<UNICODE>& data ) { bool ret = true; for( unsigned int i = 0 ; i < data.size() ; ++i ) { if( !loadSingleGlyph( data[i] ) ) { ret = false; } } return ret; } std::map< UNICODE, Glyph >& Font::getGlyphs() { return glyphs; } void Font::bind() { atlas.getTexture().bind(); } GTexture& Font::getTexture() { return atlas.getTexture(); } glm::mat4x4& Font::getTextureMatrix() { return textureMatrix; } } /* namespace ice */ /* ========================================================================= * Freetype GL - A C OpenGL Freetype engine * Platform: Any * WWW: http://code.google.com/p/freetype-gl/ * ------------------------------------------------------------------------- * Copyright 2011 Nicolas P. Rougier. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of Nicolas P. Rougier. * ========================================================================= */
[ "akin@lich", "akin@localhost" ]
[ [ [ 1, 12 ], [ 14, 25 ], [ 27, 169 ], [ 171, 404 ] ], [ [ 13, 13 ], [ 26, 26 ], [ 170, 170 ] ] ]
82afde2cf7352488798b4bbb6e84b5328114efdd
629e4fdc23cb90c0144457e994d1cbb7c6ab8a93
/lib/graphics/framebuffer.cpp
0244d255323276f6774ffcd37dd892de2de3e1f4
[]
no_license
akin666/ice
4ed846b83bcdbd341b286cd36d1ef5b8dc3c0bf2
7cfd26a246f13675e3057ff226c17d95a958d465
refs/heads/master
2022-11-06T23:51:57.273730
2011-12-06T22:32:53
2011-12-06T22:32:53
276,095,011
0
0
null
null
null
null
UTF-8
C++
false
false
2,697
cpp
/* * framebuffer.cpp * * Created on: 3.4.2010 * Author: akin */ #include "framebuffer.h" #include <system/opengl> #include "texture/gtexture.h" namespace ice { Framebuffer::Framebuffer() { m_depth = 0; m_width = 0; m_height = 0; m_id = 0; } Framebuffer::~Framebuffer() { if( m_id != 0 ) { glDeleteFramebuffers( 1 , &m_id ); m_id = 0; } GL_TEST_ERROR("Framebuffer Destructor") } void Framebuffer::attachTexture( GTexture& texture ) { attachTexture( texture.getWidth() , texture.getHeight() , texture.getTextureId() ); } void Framebuffer::attachTexture( unsigned int width , unsigned int height , unsigned int texture_id ) { m_width = width; m_height = height; bind(); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id , 0); GL_TEST_ERROR("Framebuffer attachTexture") } void Framebuffer::attachDepth() { bind(); glGenRenderbuffers(1, &m_depth); glBindRenderbuffer(GL_RENDERBUFFER, m_depth); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_width, m_height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depth); GL_TEST_ERROR("Framebuffer attachDepth") } void Framebuffer::removeDepth() { if( m_depth == 0 ) { return; } glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); GL_TEST_ERROR("Framebuffer removeDepth") m_depth = 0; } unsigned int Framebuffer::getDepthId() { return m_depth; } void Framebuffer::bind() { if( m_id == 0 ) { glGenFramebuffers(1 , &m_id ); GL_TEST_ERROR("Framebuffer Construction") } glBindFramebuffer( GL_FRAMEBUFFER , m_id ); GL_TEST_ERROR("Framebuffer bind") } int Framebuffer::getWidth() { return m_width; } int Framebuffer::getHeight() { return m_height; } bool Framebuffer::invariant() { GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); switch( status ) { case GL_FRAMEBUFFER_COMPLETE : return true; case GL_FRAMEBUFFER_UNDEFINED : case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER : case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER : case GL_FRAMEBUFFER_UNSUPPORTED : case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE : case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS : default: return false; } return true; } void Framebuffer::bindDefault() { glBindFramebuffer( GL_FRAMEBUFFER , 0 ); GL_TEST_ERROR("Framebuffer bindDefault") } }
[ "akin@lich", "akin@localhost" ]
[ [ [ 1, 8 ], [ 11, 131 ] ], [ [ 9, 10 ] ] ]
bb306f399d3880190a15a70f19bb5ca6cf636096
279b68f31b11224c18bfe7a0c8b8086f84c6afba
/playground/barfan/0.0.1-DEV-01/request.hpp
1b1808d506d8bfb46c58f43e6e0c75eb0b7acc72
[]
no_license
bogus/findik
83b7b44b36b42db68c2b536361541ee6175bb791
2258b3b3cc58711375fe05221588d5a068da5ea8
refs/heads/master
2020-12-24T13:36:19.550337
2009-08-16T21:46:57
2009-08-16T21:46:57
32,120,100
0
0
null
null
null
null
UTF-8
C++
false
false
1,059
hpp
#ifndef FINDIK_IO_REQUEST_HPP #define FINDIK_IO_REQUEST_HPP #include <string> #include <vector> #include <boost/asio.hpp> #include "header.hpp" namespace findik { namespace io { /// A request received from a client. class request { public: request(); enum method_type { get, post, head, put, delete_, trace, options, connect } method; std::string uri; unsigned int http_version_major; unsigned int http_version_minor; std::vector<header> headers; std::string & host(); unsigned int port (); std::string & get_uri (); unsigned int content_length(); void to_streambuf(boost::asio::streambuf & sbuf_); bool has_content(); const std::string & content_raw(); void push_to_content(char input); private: std::string content_raw_; boost::asio::streambuf content_; std::string host_; unsigned int port_; unsigned int content_length_; }; } // namespace server3 } // namespace http #endif // FINDIK_IO_REQUEST_HPP
[ "barfan@d40773b4-ada0-11de-b0a2-13e92fe56a31" ]
[ [ [ 1, 68 ] ] ]
ca14e6383e3b2c99cea6836d39fadf829781ae12
95a3e8914ddc6be5098ff5bc380305f3c5bcecb2
/src/FusionForever_Editor/enumproperty.cpp
12add6fb47e1524b8ddd266086d32c505c4dc310
[]
no_license
danishcake/FusionForever
8fc3b1a33ac47177666e6ada9d9d19df9fc13784
186d1426fe6b3732a49dfc8b60eb946d62aa0e3b
refs/heads/master
2016-09-05T16:16:02.040635
2010-04-24T11:05:10
2010-04-24T11:05:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
827
cpp
#include "enumproperty.h" #include <Property.h> EnumProperty::EnumProperty(QWidget *parent, Property* _property) : QComboBox(parent), property_(_property) { setEditable(false); Enumeration options = property_->GetEnumeration(); for(Enumeration::iterator it = options.begin(); it != options.end(); ++it) { addItem(it->second.c_str(), QVariant(it->first)); } if(property_->HasGetter()) { int index = findText(property_->GetEnumerationItem().c_str()); if(index != -1) setCurrentIndex(index); } QObject::connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int))); } EnumProperty::~EnumProperty() { } void EnumProperty::onIndexChanged(int _index) { if(property_->HasSetter()) { property_->SetEnumerationValue(itemData(currentIndex()).toInt()); } }
[ [ [ 1, 34 ] ] ]
387574520d344090fd9e896078fbfda71dbbcaa4
b149036815b87fb8770046f13ad2536586bd9c81
/EasyBMP.cpp
f11080bbe82cc92776b1c3209dc24c304e7e4c51
[]
no_license
KoppeKTop/NewCA
1dca3e31f73e81fb963ab22258a4ecf482e45fe4
98f62917bd1bfefccca7360b20bf29635bd4c061
refs/heads/master
2016-09-11T10:20:44.122987
2010-07-23T19:42:25
2010-07-23T19:42:25
695,579
0
0
null
null
null
null
UTF-8
C++
false
false
50,010
cpp
/************************************************* * * * EasyBMP Cross-Platform Windows Bitmap Library * * * * Author: Paul Macklin * * email: [email protected] * * support: http://easybmp.sourceforge.net * * * * file: EasyBMP.cpp * * date added: 03-31-2006 * * date modified: 12-01-2006 * * version: 1.06 * * * * License: BSD (revised/modified) * * Copyright: 2005-6 by the EasyBMP Project * * * * description: Actual source file * * * *************************************************/ #include "EasyBMP.h" /* These functions are defined in EasyBMP.h */ bool EasyBMPwarnings = true; void SetEasyBMPwarningsOff( void ) { EasyBMPwarnings = false; } void SetEasyBMPwarningsOn( void ) { EasyBMPwarnings = true; } bool GetEasyBMPwarningState( void ) { return EasyBMPwarnings; } /* These functions are defined in EasyBMP_DataStructures.h */ int IntPow( int base, int exponent ) { int i; int output = 1; for( i=0 ; i < exponent ; i++ ) { output *= base; } return output; } BMFH::BMFH() { bfType = 19778; bfReserved1 = 0; bfReserved2 = 0; } void BMFH::SwitchEndianess( void ) { bfType = FlipWORD( bfType ); bfSize = FlipDWORD( bfSize ); bfReserved1 = FlipWORD( bfReserved1 ); bfReserved2 = FlipWORD( bfReserved2 ); bfOffBits = FlipDWORD( bfOffBits ); return; } BMIH::BMIH() { biPlanes = 1; biCompression = 0; biXPelsPerMeter = DefaultXPelsPerMeter; biYPelsPerMeter = DefaultYPelsPerMeter; biClrUsed = 0; biClrImportant = 0; } void BMIH::SwitchEndianess( void ) { biSize = FlipDWORD( biSize ); biWidth = FlipDWORD( biWidth ); biHeight = FlipDWORD( biHeight ); biPlanes = FlipWORD( biPlanes ); biBitCount = FlipWORD( biBitCount ); biCompression = FlipDWORD( biCompression ); biSizeImage = FlipDWORD( biSizeImage ); biXPelsPerMeter = FlipDWORD( biXPelsPerMeter ); biYPelsPerMeter = FlipDWORD( biYPelsPerMeter ); biClrUsed = FlipDWORD( biClrUsed ); biClrImportant = FlipDWORD( biClrImportant ); return; } void BMIH::display( void ) { using namespace std; cout << "biSize: " << (int) biSize << endl << "biWidth: " << (int) biWidth << endl << "biHeight: " << (int) biHeight << endl << "biPlanes: " << (int) biPlanes << endl << "biBitCount: " << (int) biBitCount << endl << "biCompression: " << (int) biCompression << endl << "biSizeImage: " << (int) biSizeImage << endl << "biXPelsPerMeter: " << (int) biXPelsPerMeter << endl << "biYPelsPerMeter: " << (int) biYPelsPerMeter << endl << "biClrUsed: " << (int) biClrUsed << endl << "biClrImportant: " << (int) biClrImportant << endl << endl; } void BMFH::display( void ) { using namespace std; cout << "bfType: " << (int) bfType << endl << "bfSize: " << (int) bfSize << endl << "bfReserved1: " << (int) bfReserved1 << endl << "bfReserved2: " << (int) bfReserved2 << endl << "bfOffBits: " << (int) bfOffBits << endl << endl; } /* These functions are defined in EasyBMP_BMP.h */ RGBApixel BMP::GetPixel( int i, int j ) const { using namespace std; bool Warn = false; if( i >= Width ) { i = Width-1; Warn = true; } if( i < 0 ) { i = 0; Warn = true; } if( j >= Height ) { j = Height-1; Warn = true; } if( j < 0 ) { j = 0; Warn = true; } if( Warn && EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to access non-existent pixel;" << endl << " Truncating request to fit in the range [0," << Width-1 << "] x [0," << Height-1 << "]." << endl; } return Pixels[i][j]; } bool BMP::SetPixel( int i, int j, RGBApixel NewPixel ) { Pixels[i][j] = NewPixel; return true; } bool BMP::SetColor( int ColorNumber , RGBApixel NewColor ) { using namespace std; if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to change color table for a BMP object" << endl << " that lacks a color table. Ignoring request." << endl; } return false; } if( !Colors ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to set a color, but the color table" << endl << " is not defined. Ignoring request." << endl; } return false; } if( ColorNumber >= TellNumberOfColors() ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Requested color number " << ColorNumber << " is outside the allowed" << endl << " range [0," << TellNumberOfColors()-1 << "]. Ignoring request to set this color." << endl; } return false; } Colors[ColorNumber] = NewColor; return true; } // RGBApixel BMP::GetColor( int ColorNumber ) const RGBApixel BMP::GetColor( int ColorNumber ) { RGBApixel Output; Output.Red = 255; Output.Green = 255; Output.Blue = 255; Output.Alpha = 0; using namespace std; if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to access color table for a BMP object" << endl << " that lacks a color table. Ignoring request." << endl; } return Output; } if( !Colors ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Requested a color, but the color table" << endl << " is not defined. Ignoring request." << endl; } return Output; } if( ColorNumber >= TellNumberOfColors() ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Requested color number " << ColorNumber << " is outside the allowed" << endl << " range [0," << TellNumberOfColors()-1 << "]. Ignoring request to get this color." << endl; } return Output; } Output = Colors[ColorNumber]; return Output; } BMP::BMP() { Width = 1; Height = 1; BitDepth = 24; Pixels = new RGBApixel* [Width]; Pixels[0] = new RGBApixel [Height]; Colors = NULL; XPelsPerMeter = 0; YPelsPerMeter = 0; MetaData1 = NULL; SizeOfMetaData1 = 0; MetaData2 = NULL; SizeOfMetaData2 = 0; } // BMP::BMP( const BMP& Input ) BMP::BMP( BMP& Input ) { // first, make the image empty. Width = 1; Height = 1; BitDepth = 24; Pixels = new RGBApixel* [Width]; Pixels[0] = new RGBApixel [Height]; Colors = NULL; XPelsPerMeter = 0; YPelsPerMeter = 0; MetaData1 = NULL; SizeOfMetaData1 = 0; MetaData2 = NULL; SizeOfMetaData2 = 0; // now, set the correct bit depth SetBitDepth( Input.TellBitDepth() ); // set the correct pixel size SetSize( Input.TellWidth() , Input.TellHeight() ); // set the DPI information from Input SetDPI( Input.TellHorizontalDPI() , Input.TellVerticalDPI() ); // if there is a color table, get all the colors if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) { for( int k=0 ; k < TellNumberOfColors() ; k++ ) { SetColor( k, Input.GetColor( k )); } } // get all the pixels for( int j=0; j < Height ; j++ ) { for( int i=0; i < Width ; i++ ) { Pixels[i][j] = *Input(i,j); // Pixels[i][j] = Input.GetPixel(i,j); // *Input(i,j); } } } BMP::~BMP() { int i; for(i=0;i<Width;i++) { delete [] Pixels[i]; } delete [] Pixels; if( Colors ) { delete [] Colors; } if( MetaData1 ) { delete [] MetaData1; } if( MetaData2 ) { delete [] MetaData2; } } RGBApixel* BMP::operator()(int i, int j) { using namespace std; bool Warn = false; if( i >= Width ) { i = Width-1; Warn = true; } if( i < 0 ) { i = 0; Warn = true; } if( j >= Height ) { j = Height-1; Warn = true; } if( j < 0 ) { j = 0; Warn = true; } if( Warn && EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to access non-existent pixel;" << endl << " Truncating request to fit in the range [0," << Width-1 << "] x [0," << Height-1 << "]." << endl; } return &(Pixels[i][j]); } // int BMP::TellBitDepth( void ) const int BMP::TellBitDepth( void ) { return BitDepth; } // int BMP::TellHeight( void ) const int BMP::TellHeight( void ) { return Height; } // int BMP::TellWidth( void ) const int BMP::TellWidth( void ) { return Width; } // int BMP::TellNumberOfColors( void ) const int BMP::TellNumberOfColors( void ) { int output = IntPow( 2, BitDepth ); if( BitDepth == 32 ) { output = IntPow( 2, 24 ); } return output; } bool BMP::SetBitDepth( int NewDepth ) { using namespace std; if( NewDepth != 1 && NewDepth != 4 && NewDepth != 8 && NewDepth != 16 && NewDepth != 24 && NewDepth != 32 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: User attempted to set unsupported bit depth " << NewDepth << "." << endl << " Bit depth remains unchanged at " << BitDepth << "." << endl; } return false; } BitDepth = NewDepth; if( Colors ) { delete [] Colors; } int NumberOfColors = IntPow( 2, BitDepth ); if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) { Colors = new RGBApixel [NumberOfColors]; } else { Colors = NULL; } if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) { CreateStandardColorTable(); } return true; } bool BMP::SetSize(int NewWidth , int NewHeight ) { using namespace std; if( NewWidth <= 0 || NewHeight <= 0 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: User attempted to set a non-positive width or height." << endl << " Size remains unchanged at " << Width << " x " << Height << "." << endl; } return false; } int i,j; for(i=0;i<Width;i++) { delete [] Pixels[i]; } delete [] Pixels; Width = NewWidth; Height = NewHeight; Pixels = new RGBApixel* [ Width ]; for(i=0; i<Width; i++) { Pixels[i] = new RGBApixel [ Height ]; } for( i=0 ; i < Width ; i++) { for( j=0 ; j < Height ; j++ ) { Pixels[i][j].Red = 255; Pixels[i][j].Green = 255; Pixels[i][j].Blue = 255; Pixels[i][j].Alpha = 0; } } return true; } bool BMP::WriteToFile( const char* FileName ) { using namespace std; if( !EasyBMPcheckDataSize() ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Data types are wrong size!" << endl << " You may need to mess with EasyBMP_DataTypes.h" << endl << " to fix these errors, and then recompile." << endl << " All 32-bit and 64-bit machines should be" << endl << " supported, however." << endl << endl; } return false; } FILE* fp = fopen( FileName, "wb" ); if( fp == NULL ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Cannot open file " << FileName << " for output." << endl; } fclose( fp ); return false; } // some preliminaries double dBytesPerPixel = ( (double) BitDepth ) / 8.0; double dBytesPerRow = dBytesPerPixel * (Width+0.0); dBytesPerRow = ceil(dBytesPerRow); int BytePaddingPerRow = 4 - ( (int) (dBytesPerRow) )% 4; if( BytePaddingPerRow == 4 ) { BytePaddingPerRow = 0; } double dActualBytesPerRow = dBytesPerRow + BytePaddingPerRow; double dTotalPixelBytes = Height * dActualBytesPerRow; double dPaletteSize = 0; if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) { dPaletteSize = IntPow(2,BitDepth)*4.0; } // leave some room for 16-bit masks if( BitDepth == 16 ) { dPaletteSize = 3*4; } double dTotalFileSize = 14 + 40 + dPaletteSize + dTotalPixelBytes; // write the file header BMFH bmfh; bmfh.bfSize = (ebmpDWORD) dTotalFileSize; bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfOffBits = (ebmpDWORD) (14+40+dPaletteSize); if( IsBigEndian() ) { bmfh.SwitchEndianess(); } fwrite( (char*) &(bmfh.bfType) , sizeof(ebmpWORD) , 1 , fp ); fwrite( (char*) &(bmfh.bfSize) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmfh.bfReserved1) , sizeof(ebmpWORD) , 1 , fp ); fwrite( (char*) &(bmfh.bfReserved2) , sizeof(ebmpWORD) , 1 , fp ); fwrite( (char*) &(bmfh.bfOffBits) , sizeof(ebmpDWORD) , 1 , fp ); // write the info header BMIH bmih; bmih.biSize = 40; bmih.biWidth = Width; bmih.biHeight = Height; bmih.biPlanes = 1; bmih.biBitCount = BitDepth; bmih.biCompression = 0; bmih.biSizeImage = (ebmpDWORD) dTotalPixelBytes; if( XPelsPerMeter ) { bmih.biXPelsPerMeter = XPelsPerMeter; } else { bmih.biXPelsPerMeter = DefaultXPelsPerMeter; } if( YPelsPerMeter ) { bmih.biYPelsPerMeter = YPelsPerMeter; } else { bmih.biYPelsPerMeter = DefaultYPelsPerMeter; } bmih.biClrUsed = 0; bmih.biClrImportant = 0; // indicates that we'll be using bit fields for 16-bit files if( BitDepth == 16 ) { bmih.biCompression = 3; } if( IsBigEndian() ) { bmih.SwitchEndianess(); } fwrite( (char*) &(bmih.biSize) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biWidth) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biHeight) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biPlanes) , sizeof(ebmpWORD) , 1 , fp ); fwrite( (char*) &(bmih.biBitCount) , sizeof(ebmpWORD) , 1 , fp ); fwrite( (char*) &(bmih.biCompression) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biSizeImage) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biXPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biYPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); fwrite( (char*) &(bmih.biClrUsed) , sizeof(ebmpDWORD) , 1 , fp); fwrite( (char*) &(bmih.biClrImportant) , sizeof(ebmpDWORD) , 1 , fp); // write the palette if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) { int NumberOfColors = IntPow(2,BitDepth); // if there is no palette, create one if( !Colors ) { if( !Colors ) { Colors = new RGBApixel [NumberOfColors]; } CreateStandardColorTable(); } int n; for( n=0 ; n < NumberOfColors ; n++ ) { fwrite( (char*) &(Colors[n]) , 4 , 1 , fp ); } } // write the pixels int i,j; if( BitDepth != 16 ) { ebmpBYTE* Buffer; int BufferSize = (int) ( (Width*BitDepth)/8.0 ); while( 8*BufferSize < Width*BitDepth ) { BufferSize++; } while( BufferSize % 4 ) { BufferSize++; } Buffer = new ebmpBYTE [BufferSize]; for( j=0 ; j < BufferSize; j++ ) { Buffer[j] = 0; } j=Height-1; while( j > -1 ) { bool Success = false; if( BitDepth == 32 ) { Success = Write32bitRow( Buffer, BufferSize, j ); } if( BitDepth == 24 ) { Success = Write24bitRow( Buffer, BufferSize, j ); } if( BitDepth == 8 ) { Success = Write8bitRow( Buffer, BufferSize, j ); } if( BitDepth == 4 ) { Success = Write4bitRow( Buffer, BufferSize, j ); } if( BitDepth == 1 ) { Success = Write1bitRow( Buffer, BufferSize, j ); } if( Success ) { int BytesWritten = (int) fwrite( (char*) Buffer, 1, BufferSize, fp ); if( BytesWritten != BufferSize ) { Success = false; } } if( !Success ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Could not write proper amount of data." << endl; } j = -1; } j--; } delete [] Buffer; } if( BitDepth == 16 ) { // write the bit masks ebmpWORD BlueMask = 31; // bits 12-16 ebmpWORD GreenMask = 2016; // bits 6-11 ebmpWORD RedMask = 63488; // bits 1-5 ebmpWORD ZeroWORD; if( IsBigEndian() ) { RedMask = FlipWORD( RedMask ); } fwrite( (char*) &RedMask , 2 , 1 , fp ); fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); if( IsBigEndian() ) { GreenMask = FlipWORD( GreenMask ); } fwrite( (char*) &GreenMask , 2 , 1 , fp ); fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); if( IsBigEndian() ) { BlueMask = FlipWORD( BlueMask ); } fwrite( (char*) &BlueMask , 2 , 1 , fp ); fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); int DataBytes = Width*2; int PaddingBytes = ( 4 - DataBytes % 4 ) % 4; // write the actual pixels for( j=Height-1 ; j >= 0 ; j-- ) { // write all row pixel data i=0; int WriteNumber = 0; while( WriteNumber < DataBytes ) { ebmpWORD TempWORD; ebmpWORD RedWORD = (ebmpWORD) ((Pixels[i][j]).Red / 8); ebmpWORD GreenWORD = (ebmpWORD) ((Pixels[i][j]).Green / 4); ebmpWORD BlueWORD = (ebmpWORD) ((Pixels[i][j]).Blue / 8); TempWORD = (RedWORD<<11) + (GreenWORD<<5) + BlueWORD; if( IsBigEndian() ) { TempWORD = FlipWORD( TempWORD ); } fwrite( (char*) &TempWORD , 2, 1, fp); WriteNumber += 2; i++; } // write any necessary row padding WriteNumber = 0; while( WriteNumber < PaddingBytes ) { ebmpBYTE TempBYTE; fwrite( (char*) &TempBYTE , 1, 1, fp); WriteNumber++; } } } fclose(fp); return true; } bool BMP::ReadFromFile( const char* FileName ) { using namespace std; if( !EasyBMPcheckDataSize() ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Data types are wrong size!" << endl << " You may need to mess with EasyBMP_DataTypes.h" << endl << " to fix these errors, and then recompile." << endl << " All 32-bit and 64-bit machines should be" << endl << " supported, however." << endl << endl; } return false; } FILE* fp = fopen( FileName, "rb" ); if( fp == NULL ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Cannot open file " << FileName << " for input." << endl; } SetBitDepth(1); SetSize(1,1); return false; } // read the file header BMFH bmfh; bool NotCorrupted = true; NotCorrupted &= SafeFread( (char*) &(bmfh.bfType) , sizeof(ebmpWORD), 1, fp); bool IsBitmap = false; if( IsBigEndian() && bmfh.bfType == 16973 ) { IsBitmap = true; } if( !IsBigEndian() && bmfh.bfType == 19778 ) { IsBitmap = true; } if( !IsBitmap ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " is not a Windows BMP file!" << endl; } fclose( fp ); return false; } NotCorrupted &= SafeFread( (char*) &(bmfh.bfSize) , sizeof(ebmpDWORD) , 1, fp); NotCorrupted &= SafeFread( (char*) &(bmfh.bfReserved1) , sizeof(ebmpWORD) , 1, fp); NotCorrupted &= SafeFread( (char*) &(bmfh.bfReserved2) , sizeof(ebmpWORD) , 1, fp); NotCorrupted &= SafeFread( (char*) &(bmfh.bfOffBits) , sizeof(ebmpDWORD) , 1 , fp); if( IsBigEndian() ) { bmfh.SwitchEndianess(); } // read the info header BMIH bmih; NotCorrupted &= SafeFread( (char*) &(bmih.biSize) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biWidth) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biHeight) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biPlanes) , sizeof(ebmpWORD) , 1, fp); NotCorrupted &= SafeFread( (char*) &(bmih.biBitCount) , sizeof(ebmpWORD) , 1, fp); NotCorrupted &= SafeFread( (char*) &(bmih.biCompression) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biSizeImage) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biXPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biYPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biClrUsed) , sizeof(ebmpDWORD) , 1 , fp); NotCorrupted &= SafeFread( (char*) &(bmih.biClrImportant) , sizeof(ebmpDWORD) , 1 , fp); if( IsBigEndian() ) { bmih.SwitchEndianess(); } // a safety catch: if any of the header information didn't read properly, abort // future idea: check to see if at least most is self-consistent if( !NotCorrupted ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " is obviously corrupted." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } XPelsPerMeter = bmih.biXPelsPerMeter; YPelsPerMeter = bmih.biYPelsPerMeter; // if bmih.biCompression 1 or 2, then the file is RLE compressed if( bmih.biCompression == 1 || bmih.biCompression == 2 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " is (RLE) compressed." << endl << " EasyBMP does not support compression." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } // if bmih.biCompression > 3, then something strange is going on // it's probably an OS2 bitmap file. if( bmih.biCompression > 3 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " is in an unsupported format." << endl << " (bmih.biCompression = " << bmih.biCompression << ")" << endl << " The file is probably an old OS2 bitmap or corrupted." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } if( bmih.biCompression == 3 && bmih.biBitCount != 16 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " uses bit fields and is not a" << endl << " 16-bit file. This is not supported." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } // set the bit depth int TempBitDepth = (int) bmih.biBitCount; if( TempBitDepth != 1 && TempBitDepth != 4 && TempBitDepth != 8 && TempBitDepth != 16 && TempBitDepth != 24 && TempBitDepth != 32 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " has unrecognized bit depth." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } SetBitDepth( (int) bmih.biBitCount ); // set the size if( (int) bmih.biWidth <= 0 || (int) bmih.biHeight <= 0 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: " << FileName << " has a non-positive width or height." << endl; } SetSize(1,1); SetBitDepth(1); fclose(fp); return false; } SetSize( (int) bmih.biWidth , (int) bmih.biHeight ); // some preliminaries double dBytesPerPixel = ( (double) BitDepth ) / 8.0; double dBytesPerRow = dBytesPerPixel * (Width+0.0); dBytesPerRow = ceil(dBytesPerRow); int BytePaddingPerRow = 4 - ( (int) (dBytesPerRow) )% 4; if( BytePaddingPerRow == 4 ) { BytePaddingPerRow = 0; } // if < 16 bits, read the palette if( BitDepth < 16 ) { // determine the number of colors specified in the // color table int NumberOfColorsToRead = ((int) bmfh.bfOffBits - 54 )/4; if( NumberOfColorsToRead > IntPow(2,BitDepth) ) { NumberOfColorsToRead = IntPow(2,BitDepth); } if( NumberOfColorsToRead < TellNumberOfColors() ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: file " << FileName << " has an underspecified" << endl << " color table. The table will be padded with extra" << endl << " white (255,255,255,0) entries." << endl; } } int n; for( n=0; n < NumberOfColorsToRead ; n++ ) { SafeFread( (char*) &(Colors[n]) , 4 , 1 , fp); } for( n=NumberOfColorsToRead ; n < TellNumberOfColors() ; n++ ) { RGBApixel WHITE; WHITE.Red = 255; WHITE.Green = 255; WHITE.Blue = 255; WHITE.Alpha = 0; SetColor( n , WHITE ); } } // skip blank data if bfOffBits so indicates int BytesToSkip = bmfh.bfOffBits - 54;; if( BitDepth < 16 ) { BytesToSkip -= 4*IntPow(2,BitDepth); } if( BitDepth == 16 && bmih.biCompression == 3 ) { BytesToSkip -= 3*4; } if( BytesToSkip < 0 ) { BytesToSkip = 0; } if( BytesToSkip > 0 && BitDepth != 16 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Extra meta data detected in file " << FileName << endl << " Data will be skipped." << endl; } ebmpBYTE* TempSkipBYTE; TempSkipBYTE = new ebmpBYTE [BytesToSkip]; SafeFread( (char*) TempSkipBYTE , BytesToSkip , 1 , fp); delete [] TempSkipBYTE; } // This code reads 1, 4, 8, 24, and 32-bpp files // with a more-efficient buffered technique. int i,j; if( BitDepth != 16 ) { int BufferSize = (int) ( (Width*BitDepth) / 8.0 ); while( 8*BufferSize < Width*BitDepth ) { BufferSize++; } while( BufferSize % 4 ) { BufferSize++; } ebmpBYTE* Buffer; Buffer = new ebmpBYTE [BufferSize]; j= Height-1; while( j > -1 ) { int BytesRead = (int) fread( (char*) Buffer, 1, BufferSize, fp ); if( BytesRead < BufferSize ) { j = -1; if( EasyBMPwarnings ) { cout << "EasyBMP Error: Could not read proper amount of data." << endl; } } else { bool Success = false; if( BitDepth == 1 ) { Success = Read1bitRow( Buffer, BufferSize, j ); } if( BitDepth == 4 ) { Success = Read4bitRow( Buffer, BufferSize, j ); } if( BitDepth == 8 ) { Success = Read8bitRow( Buffer, BufferSize, j ); } if( BitDepth == 24 ) { Success = Read24bitRow( Buffer, BufferSize, j ); } if( BitDepth == 32 ) { Success = Read32bitRow( Buffer, BufferSize, j ); } if( !Success ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Could not read enough pixel data!" << endl; } j = -1; } } j--; } delete [] Buffer; } if( BitDepth == 16 ) { int DataBytes = Width*2; int PaddingBytes = ( 4 - DataBytes % 4 ) % 4; // set the default mask ebmpWORD BlueMask = 31; // bits 12-16 ebmpWORD GreenMask = 992; // bits 7-11 ebmpWORD RedMask = 31744; // bits 2-6 // read the bit fields, if necessary, to // override the default 5-5-5 mask if( bmih.biCompression != 0 ) { // read the three bit masks ebmpWORD TempMaskWORD; // ebmpWORD ZeroWORD; SafeFread( (char*) &RedMask , 2 , 1 , fp ); if( IsBigEndian() ) { RedMask = FlipWORD(RedMask); } SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); SafeFread( (char*) &GreenMask , 2 , 1 , fp ); if( IsBigEndian() ) { GreenMask = FlipWORD(GreenMask); } SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); SafeFread( (char*) &BlueMask , 2 , 1 , fp ); if( IsBigEndian() ) { BlueMask = FlipWORD(BlueMask); } SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); } // read and skip any meta data if( BytesToSkip > 0 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Extra meta data detected in file " << FileName << endl << " Data will be skipped." << endl; } ebmpBYTE* TempSkipBYTE; TempSkipBYTE = new ebmpBYTE [BytesToSkip]; SafeFread( (char*) TempSkipBYTE , BytesToSkip , 1 , fp); delete [] TempSkipBYTE; } // determine the red, green and blue shifts int GreenShift = 0; ebmpWORD TempShiftWORD = GreenMask; while( TempShiftWORD > 31 ) { TempShiftWORD = TempShiftWORD>>1; GreenShift++; } int BlueShift = 0; TempShiftWORD = BlueMask; while( TempShiftWORD > 31 ) { TempShiftWORD = TempShiftWORD>>1; BlueShift++; } int RedShift = 0; TempShiftWORD = RedMask; while( TempShiftWORD > 31 ) { TempShiftWORD = TempShiftWORD>>1; RedShift++; } // read the actual pixels for( j=Height-1 ; j >= 0 ; j-- ) { i=0; int ReadNumber = 0; while( ReadNumber < DataBytes ) { ebmpWORD TempWORD; SafeFread( (char*) &TempWORD , 2 , 1 , fp ); if( IsBigEndian() ) { TempWORD = FlipWORD(TempWORD); } ReadNumber += 2; ebmpWORD Red = RedMask & TempWORD; ebmpWORD Green = GreenMask & TempWORD; ebmpWORD Blue = BlueMask & TempWORD; ebmpBYTE BlueBYTE = (ebmpBYTE) 8*(Blue>>BlueShift); ebmpBYTE GreenBYTE = (ebmpBYTE) 8*(Green>>GreenShift); ebmpBYTE RedBYTE = (ebmpBYTE) 8*(Red>>RedShift); (Pixels[i][j]).Red = RedBYTE; (Pixels[i][j]).Green = GreenBYTE; (Pixels[i][j]).Blue = BlueBYTE; i++; } ReadNumber = 0; while( ReadNumber < PaddingBytes ) { ebmpBYTE TempBYTE; SafeFread( (char*) &TempBYTE , 1, 1, fp); ReadNumber++; } } } fclose(fp); return true; } bool BMP::CreateStandardColorTable( void ) { using namespace std; if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to create color table at a bit" << endl << " depth that does not require a color table." << endl << " Ignoring request." << endl; } return false; } if( BitDepth == 1 ) { int i; for( i=0 ; i < 2 ; i++ ) { Colors[i].Red = i*255; Colors[i].Green = i*255; Colors[i].Blue = i*255; Colors[i].Alpha = 0; } return true; } if( BitDepth == 4 ) { int i = 0; int j,k,ell; // simplify the code for the first 8 colors for( ell=0 ; ell < 2 ; ell++ ) { for( k=0 ; k < 2 ; k++ ) { for( j=0 ; j < 2 ; j++ ) { Colors[i].Red = j*128; Colors[i].Green = k*128; Colors[i].Blue = ell*128; i++; } } } // simplify the code for the last 8 colors for( ell=0 ; ell < 2 ; ell++ ) { for( k=0 ; k < 2 ; k++ ) { for( j=0 ; j < 2 ; j++ ) { Colors[i].Red = j*255; Colors[i].Green = k*255; Colors[i].Blue = ell*255; i++; } } } // overwrite the duplicate color i=8; Colors[i].Red = 192; Colors[i].Green = 192; Colors[i].Blue = 192; for( i=0 ; i < 16 ; i++ ) { Colors[i].Alpha = 0; } return true; } if( BitDepth == 8 ) { int i=0; int j,k,ell; // do an easy loop, which works for all but colors // 0 to 9 and 246 to 255 for( ell=0 ; ell < 4 ; ell++ ) { for( k=0 ; k < 8 ; k++ ) { for( j=0; j < 8 ; j++ ) { Colors[i].Red = j*32; Colors[i].Green = k*32; Colors[i].Blue = ell*64; Colors[i].Alpha = 0; i++; } } } // now redo the first 8 colors i=0; for( ell=0 ; ell < 2 ; ell++ ) { for( k=0 ; k < 2 ; k++ ) { for( j=0; j < 2 ; j++ ) { Colors[i].Red = j*128; Colors[i].Green = k*128; Colors[i].Blue = ell*128; i++; } } } // overwrite colors 7, 8, 9 i=7; Colors[i].Red = 192; Colors[i].Green = 192; Colors[i].Blue = 192; i++; // 8 Colors[i].Red = 192; Colors[i].Green = 220; Colors[i].Blue = 192; i++; // 9 Colors[i].Red = 166; Colors[i].Green = 202; Colors[i].Blue = 240; // overwrite colors 246 to 255 i=246; Colors[i].Red = 255; Colors[i].Green = 251; Colors[i].Blue = 240; i++; // 247 Colors[i].Red = 160; Colors[i].Green = 160; Colors[i].Blue = 164; i++; // 248 Colors[i].Red = 128; Colors[i].Green = 128; Colors[i].Blue = 128; i++; // 249 Colors[i].Red = 255; Colors[i].Green = 0; Colors[i].Blue = 0; i++; // 250 Colors[i].Red = 0; Colors[i].Green = 255; Colors[i].Blue = 0; i++; // 251 Colors[i].Red = 255; Colors[i].Green = 255; Colors[i].Blue = 0; i++; // 252 Colors[i].Red = 0; Colors[i].Green = 0; Colors[i].Blue = 255; i++; // 253 Colors[i].Red = 255; Colors[i].Green = 0; Colors[i].Blue = 255; i++; // 254 Colors[i].Red = 0; Colors[i].Green = 255; Colors[i].Blue = 255; i++; // 255 Colors[i].Red = 255; Colors[i].Green = 255; Colors[i].Blue = 255; return true; } return true; } bool SafeFread( char* buffer, int size, int number, FILE* fp ) { using namespace std; int ItemsRead; if( feof(fp) ) { return false; } ItemsRead = (int) fread( buffer , size , number , fp ); if( ItemsRead < number ) { return false; } return true; } void BMP::SetDPI( int HorizontalDPI, int VerticalDPI ) { XPelsPerMeter = (int) ( HorizontalDPI * 39.37007874015748 ); YPelsPerMeter = (int) ( VerticalDPI * 39.37007874015748 ); } // int BMP::TellVerticalDPI( void ) const int BMP::TellVerticalDPI( void ) { if( !YPelsPerMeter ) { YPelsPerMeter = DefaultYPelsPerMeter; } return (int) ( YPelsPerMeter / (double) 39.37007874015748 ); } // int BMP::TellHorizontalDPI( void ) const int BMP::TellHorizontalDPI( void ) { if( !XPelsPerMeter ) { XPelsPerMeter = DefaultXPelsPerMeter; } return (int) ( XPelsPerMeter / (double) 39.37007874015748 ); } /* These functions are defined in EasyBMP_VariousBMPutilities.h */ BMFH GetBMFH( const char* szFileNameIn ) { using namespace std; BMFH bmfh; FILE* fp; fp = fopen( szFileNameIn,"rb"); if( !fp ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Cannot initialize from file " << szFileNameIn << "." << endl << " File cannot be opened or does not exist." << endl; } bmfh.bfType = 0; return bmfh; } SafeFread( (char*) &(bmfh.bfType) , sizeof(ebmpWORD) , 1 , fp ); SafeFread( (char*) &(bmfh.bfSize) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmfh.bfReserved1) , sizeof(ebmpWORD) , 1 , fp ); SafeFread( (char*) &(bmfh.bfReserved2) , sizeof(ebmpWORD) , 1 , fp ); SafeFread( (char*) &(bmfh.bfOffBits) , sizeof(ebmpDWORD) , 1 , fp ); fclose( fp ); if( IsBigEndian() ) { bmfh.SwitchEndianess(); } return bmfh; } BMIH GetBMIH( const char* szFileNameIn ) { using namespace std; BMFH bmfh; BMIH bmih; FILE* fp; fp = fopen( szFileNameIn,"rb"); if( !fp ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Cannot initialize from file " << szFileNameIn << "." << endl << " File cannot be opened or does not exist." << endl; } return bmih; } // read the bmfh, i.e., first 14 bytes (just to get it out of the way); ebmpBYTE TempBYTE; int i; for( i = 14 ; i > 0 ; i-- ) { SafeFread( (char*) &TempBYTE , sizeof(ebmpBYTE) , 1, fp ); } // read the bmih SafeFread( (char*) &(bmih.biSize) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biWidth) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biHeight) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biPlanes) , sizeof(ebmpWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biBitCount) , sizeof(ebmpWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biCompression) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biSizeImage) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biXPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biYPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biClrUsed) , sizeof(ebmpDWORD) , 1 , fp ); SafeFread( (char*) &(bmih.biClrImportant) , sizeof(ebmpDWORD) , 1 , fp ); fclose( fp ); if( IsBigEndian() ) { bmih.SwitchEndianess(); } return bmih; } void DisplayBitmapInfo( const char* szFileNameIn ) { using namespace std; FILE* fp; fp = fopen( szFileNameIn,"rb"); if( !fp ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: Cannot initialize from file " << szFileNameIn << "." << endl << " File cannot be opened or does not exist." << endl; } return; } fclose( fp ); // don't duplicate work! Just use the functions from above! BMFH bmfh = GetBMFH(szFileNameIn); BMIH bmih = GetBMIH(szFileNameIn); cout << "File information for file " << szFileNameIn << ":" << endl << endl; cout << "BITMAPFILEHEADER:" << endl << "bfType: " << bmfh.bfType << endl << "bfSize: " << bmfh.bfSize << endl << "bfReserved1: " << bmfh.bfReserved1 << endl << "bfReserved2: " << bmfh.bfReserved2 << endl << "bfOffBits: " << bmfh.bfOffBits << endl << endl; cout << "BITMAPINFOHEADER:" << endl << "biSize: " << bmih.biSize << endl << "biWidth: " << bmih.biWidth << endl << "biHeight: " << bmih.biHeight << endl << "biPlanes: " << bmih.biPlanes << endl << "biBitCount: " << bmih.biBitCount << endl << "biCompression: " << bmih.biCompression << endl << "biSizeImage: " << bmih.biSizeImage << endl << "biXPelsPerMeter: " << bmih.biXPelsPerMeter << endl << "biYPelsPerMeter: " << bmih.biYPelsPerMeter << endl << "biClrUsed: " << bmih.biClrUsed << endl << "biClrImportant: " << bmih.biClrImportant << endl << endl; return; } int GetBitmapColorDepth( const char* szFileNameIn ) { BMIH bmih = GetBMIH( szFileNameIn ); return (int) bmih.biBitCount; } void PixelToPixelCopy( BMP& From, int FromX, int FromY, BMP& To, int ToX, int ToY) { *To(ToX,ToY) = *From(FromX,FromY); return; } void PixelToPixelCopyTransparent( BMP& From, int FromX, int FromY, BMP& To, int ToX, int ToY, RGBApixel& Transparent ) { if( From(FromX,FromY)->Red != Transparent.Red || From(FromX,FromY)->Green != Transparent.Green || From(FromX,FromY)->Blue != Transparent.Blue ) { *To(ToX,ToY) = *From(FromX,FromY); } return; } void RangedPixelToPixelCopy( BMP& From, int FromL , int FromR, int FromB, int FromT, BMP& To, int ToX, int ToY ) { // make sure the conventions are followed if( FromB < FromT ) { int Temp = FromT; FromT = FromB; FromB = Temp; } // make sure that the copied regions exist in both bitmaps if( FromR >= From.TellWidth() ) { FromR = From.TellWidth()-1; } if( FromL < 0 ){ FromL = 0; } if( FromB >= From.TellHeight() ) { FromB = From.TellHeight()-1; } if( FromT < 0 ){ FromT = 0; } if( ToX+(FromR-FromL) >= To.TellWidth() ) { FromR = To.TellWidth()-1+FromL-ToX; } if( ToY+(FromB-FromT) >= To.TellHeight() ) { FromB = To.TellHeight()-1+FromT-ToY; } int i,j; for( j=FromT ; j <= FromB ; j++ ) { for( i=FromL ; i <= FromR ; i++ ) { PixelToPixelCopy( From, i,j, To, ToX+(i-FromL), ToY+(j-FromT) ); } } return; } void RangedPixelToPixelCopyTransparent( BMP& From, int FromL , int FromR, int FromB, int FromT, BMP& To, int ToX, int ToY , RGBApixel& Transparent ) { // make sure the conventions are followed if( FromB < FromT ) { int Temp = FromT; FromT = FromB; FromB = Temp; } // make sure that the copied regions exist in both bitmaps if( FromR >= From.TellWidth() ) { FromR = From.TellWidth()-1; } if( FromL < 0 ){ FromL = 0; } if( FromB >= From.TellHeight() ) { FromB = From.TellHeight()-1; } if( FromT < 0 ){ FromT = 0; } if( ToX+(FromR-FromL) >= To.TellWidth() ) { FromR = To.TellWidth()-1+FromL-ToX; } if( ToY+(FromB-FromT) >= To.TellHeight() ) { FromB = To.TellHeight()-1+FromT-ToY; } int i,j; for( j=FromT ; j <= FromB ; j++ ) { for( i=FromL ; i <= FromR ; i++ ) { PixelToPixelCopyTransparent( From, i,j, To, ToX+(i-FromL), ToY+(j-FromT) , Transparent); } } return; } bool CreateGrayscaleColorTable( BMP& InputImage ) { using namespace std; int BitDepth = InputImage.TellBitDepth(); if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Warning: Attempted to create color table at a bit" << endl << " depth that does not require a color table." << endl << " Ignoring request." << endl; } return false; } int i; int NumberOfColors = InputImage.TellNumberOfColors(); ebmpBYTE StepSize; if( BitDepth != 1 ) { StepSize = 255/(NumberOfColors-1); } else { StepSize = 255; } for( i=0 ; i < NumberOfColors ; i++ ) { ebmpBYTE TempBYTE = i*StepSize; RGBApixel TempColor; TempColor.Red = TempBYTE; TempColor.Green = TempBYTE; TempColor.Blue = TempBYTE; TempColor.Alpha = 0; InputImage.SetColor( i , TempColor ); } return true; } bool BMP::Read32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width*4 > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { memcpy( (char*) &(Pixels[i][Row]), (char*) Buffer+4*i, 4 ); } return true; } bool BMP::Read24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width*3 > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { memcpy( (char*) &(Pixels[i][Row]), Buffer+3*i, 3 ); } return true; } bool BMP::Read8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { int Index = Buffer[i]; *( this->operator()(i,Row) )= GetColor(Index); } return true; } bool BMP::Read4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int Shifts[2] = {4 ,0 }; int Masks[2] = {240,15}; int i=0; int j; int k=0; if( Width > 2*BufferSize ) { return false; } while( i < Width ) { j=0; while( j < 2 && i < Width ) { int Index = (int) ( (Buffer[k]&Masks[j]) >> Shifts[j]); *( this->operator()(i,Row) )= GetColor(Index); i++; j++; } k++; } return true; } bool BMP::Read1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int Shifts[8] = {7 ,6 ,5 ,4 ,3,2,1,0}; int Masks[8] = {128,64,32,16,8,4,2,1}; int i=0; int j; int k=0; if( Width > 8*BufferSize ) { return false; } while( i < Width ) { j=0; while( j < 8 && i < Width ) { int Index = (int) ( (Buffer[k]&Masks[j]) >> Shifts[j]); *( this->operator()(i,Row) )= GetColor(Index); i++; j++; } k++; } return true; } bool BMP::Write32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width*4 > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { memcpy( (char*) Buffer+4*i, (char*) &(Pixels[i][Row]), 4 ); } return true; } bool BMP::Write24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width*3 > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { memcpy( (char*) Buffer+3*i, (char*) &(Pixels[i][Row]), 3 ); } return true; } bool BMP::Write8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int i; if( Width > BufferSize ) { return false; } for( i=0 ; i < Width ; i++ ) { Buffer[i] = FindClosestColor( Pixels[i][Row] ); } return true; } bool BMP::Write4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int PositionWeights[2] = {16,1}; int i=0; int j; int k=0; if( Width > 2*BufferSize ) { return false; } while( i < Width ) { j=0; int Index = 0; while( j < 2 && i < Width ) { Index += ( PositionWeights[j]* (int) FindClosestColor( Pixels[i][Row] ) ); i++; j++; } Buffer[k] = (ebmpBYTE) Index; k++; } return true; } bool BMP::Write1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) { int PositionWeights[8] = {128,64,32,16,8,4,2,1}; int i=0; int j; int k=0; if( Width > 8*BufferSize ) { return false; } while( i < Width ) { j=0; int Index = 0; while( j < 8 && i < Width ) { Index += ( PositionWeights[j]* (int) FindClosestColor( Pixels[i][Row] ) ); i++; j++; } Buffer[k] = (ebmpBYTE) Index; k++; } return true; } ebmpBYTE BMP::FindClosestColor( RGBApixel& input ) { using namespace std; int i=0; int NumberOfColors = TellNumberOfColors(); ebmpBYTE BestI = 0; int BestMatch = 999999; while( i < NumberOfColors ) { RGBApixel Attempt = GetColor( i ); int TempMatch = IntSquare( (int) Attempt.Red - (int) input.Red ) + IntSquare( (int) Attempt.Green - (int) input.Green ) + IntSquare( (int) Attempt.Blue - (int) input.Blue ); if( TempMatch < BestMatch ) { BestI = (ebmpBYTE) i; BestMatch = TempMatch; } if( BestMatch < 1 ) { i = NumberOfColors; } i++; } return BestI; } bool EasyBMPcheckDataSize( void ) { using namespace std; bool ReturnValue = true; if( sizeof( ebmpBYTE ) != 1 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: ebmpBYTE has the wrong size (" << sizeof( ebmpBYTE ) << " bytes)," << endl << " Compared to the expected 1 byte value" << endl; } ReturnValue = false; } if( sizeof( ebmpWORD ) != 2 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: ebmpWORD has the wrong size (" << sizeof( ebmpWORD ) << " bytes)," << endl << " Compared to the expected 2 byte value" << endl; } ReturnValue = false; } if( sizeof( ebmpDWORD ) != 4 ) { if( EasyBMPwarnings ) { cout << "EasyBMP Error: ebmpDWORD has the wrong size (" << sizeof( ebmpDWORD ) << " bytes)," << endl << " Compared to the expected 4 byte value" << endl; } ReturnValue = false; } return ReturnValue; } bool Rescale( BMP& InputImage , char mode, int NewDimension ) { using namespace std; int CapMode = toupper( mode ); BMP OldImage( InputImage ); if( CapMode != 'P' && CapMode != 'W' && CapMode != 'H' && CapMode != 'F' ) { if( EasyBMPwarnings ) { char ErrorMessage [1024]; sprintf( ErrorMessage, "EasyBMP Error: Unknown rescale mode %c requested\n" , mode ); cout << ErrorMessage; } return false; } int NewWidth =0; int NewHeight =0; int OldWidth = OldImage.TellWidth(); int OldHeight= OldImage.TellHeight(); if( CapMode == 'P' ) { NewWidth = (int) floor( OldWidth * NewDimension / 100.0 ); NewHeight = (int) floor( OldHeight * NewDimension / 100.0 ); } if( CapMode == 'F' ) { if( OldWidth > OldHeight ) { CapMode = 'W'; } else { CapMode = 'H'; } } if( CapMode == 'W' ) { double percent = (double) NewDimension / (double) OldWidth; NewWidth = NewDimension; NewHeight = (int) floor( OldHeight * percent ); } if( CapMode == 'H' ) { double percent = (double) NewDimension / (double) OldHeight; NewHeight = NewDimension; NewWidth = (int) floor( OldWidth * percent ); } if( NewWidth < 1 ) { NewWidth = 1; } if( NewHeight < 1 ) { NewHeight = 1; } InputImage.SetSize( NewWidth, NewHeight ); InputImage.SetBitDepth( 24 ); int I,J; double ThetaI,ThetaJ; for( int j=0; j < NewHeight-1 ; j++ ) { ThetaJ = (double)(j*(OldHeight-1.0)) /(double)(NewHeight-1.0); J = (int) floor( ThetaJ ); ThetaJ -= J; for( int i=0; i < NewWidth-1 ; i++ ) { ThetaI = (double)(i*(OldWidth-1.0)) /(double)(NewWidth-1.0); I = (int) floor( ThetaI ); ThetaI -= I; InputImage(i,j)->Red = (ebmpBYTE) ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*(OldImage(I,J)->Red) +(ThetaI-ThetaI*ThetaJ)*(OldImage(I+1,J)->Red) +(ThetaJ-ThetaI*ThetaJ)*(OldImage(I,J+1)->Red) +(ThetaI*ThetaJ)*(OldImage(I+1,J+1)->Red) ); InputImage(i,j)->Green = (ebmpBYTE) ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*OldImage(I,J)->Green +(ThetaI-ThetaI*ThetaJ)*OldImage(I+1,J)->Green +(ThetaJ-ThetaI*ThetaJ)*OldImage(I,J+1)->Green +(ThetaI*ThetaJ)*OldImage(I+1,J+1)->Green ); InputImage(i,j)->Blue = (ebmpBYTE) ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*OldImage(I,J)->Blue +(ThetaI-ThetaI*ThetaJ)*OldImage(I+1,J)->Blue +(ThetaJ-ThetaI*ThetaJ)*OldImage(I,J+1)->Blue +(ThetaI*ThetaJ)*OldImage(I+1,J+1)->Blue ); } InputImage(NewWidth-1,j)->Red = (ebmpBYTE) ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Red) + ThetaJ*(OldImage(OldWidth-1,J+1)->Red) ); InputImage(NewWidth-1,j)->Green = (ebmpBYTE) ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Green) + ThetaJ*(OldImage(OldWidth-1,J+1)->Green) ); InputImage(NewWidth-1,j)->Blue = (ebmpBYTE) ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Blue) + ThetaJ*(OldImage(OldWidth-1,J+1)->Blue) ); } for( int i=0 ; i < NewWidth-1 ; i++ ) { ThetaI = (double)(i*(OldWidth-1.0)) /(double)(NewWidth-1.0); I = (int) floor( ThetaI ); ThetaI -= I; InputImage(i,NewHeight-1)->Red = (ebmpBYTE) ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Red) + ThetaI*(OldImage(I,OldHeight-1)->Red) ); InputImage(i,NewHeight-1)->Green = (ebmpBYTE) ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Green) + ThetaI*(OldImage(I,OldHeight-1)->Green) ); InputImage(i,NewHeight-1)->Blue = (ebmpBYTE) ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Blue) + ThetaI*(OldImage(I,OldHeight-1)->Blue) ); } *InputImage(NewWidth-1,NewHeight-1) = *OldImage(OldWidth-1,OldHeight-1); return true; }
[ [ [ 1, 1905 ] ] ]
c21aacf6f92a34e492cb32e934de620c1b9061a8
611fc0940b78862ca89de79a8bbeab991f5f471a
/src/Teki/Boss/LightKobitoRed.h
09fe5974464e702982b4cc34238270784e3ca1eb
[]
no_license
LakeIshikawa/splstage2
df1d8f59319a4e8d9375b9d3379c3548bc520f44
b4bf7caadf940773a977edd0de8edc610cd2f736
refs/heads/master
2021-01-10T21:16:45.430981
2010-01-29T08:57:34
2010-01-29T08:57:34
37,068,575
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
533
h
#pragma once #include "LightKobito.h" #include "..\\..\\Management\\GameControl.h" /* 青で殺される */ class LightKobitoRed : public LightKobito { public: LightKobitoRed(); LightKobitoRed( Majo* mParent ); ~LightKobitoRed(); TEKI_SETUP; void _Move(); void ResponseAka(); void ResponseMidori(){} void ResponseAo(){} void ResponseMushoku(){} void NoLight(){} int GetAtHtPointX() { return mX + mSizeX/2; } int GetAtHtPointY() { return mY + mSizeY/2; } private: void Init(); };
[ "lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b" ]
[ [ [ 1, 32 ] ] ]
c55b02a015845166a569e713634cfc9092f9ccf6
e4bad8b090b8f2fd1ea44b681e3ac41981f50220
/trunk/gui/hello/quitwin.cpp
8c249b955910fb48a829cc85e2a47d56be15990b
[]
no_license
BackupTheBerlios/abeetles-svn
92d1ce228b8627116ae3104b4698fc5873466aff
803f916bab7148290f55542c20af29367ef2d125
refs/heads/master
2021-01-22T12:02:24.457339
2007-08-15T11:18:14
2007-08-15T11:18:14
40,670,857
0
0
null
null
null
null
UTF-8
C++
false
false
1,179
cpp
#include "hello.h" #include "quitwin.h" #include "SlidComp.h" #include <QApplication> #include <QVBoxLayout> #include <QLCDNumber> #include <QSlider> #include <QSpinBox> #include <QGridLayout> QuitWin::QuitWin(QWidget * parent):QWidget(parent) { //resize(200, 120); MyPushButton * quitBut = new MyPushButton(tr("Quit")); //quitBut->setGeometry(62, 40, 75, 30); quitBut->setFont(QFont("Times", 18, QFont::Bold)); connect(quitBut, SIGNAL(clicked()), qApp, SLOT(quit())); QPushButton * but2 = new QPushButton(tr("Enlarge")); //but2->setGeometry(85,35,100,45); connect(but2,SIGNAL(clicked()), this, SLOT(showMaximized())); SlidComp * slidComp = 0; QGridLayout *grid = new QGridLayout; int I,J; SlidComp * prevSC=0; for(I=0;I<4;I++) for (J=0;J<4;J++) { slidComp = new SlidComp(); grid->addWidget(slidComp,I,J); if (prevSC!=0) connect(slidComp,SIGNAL(valueChanged(int)),prevSC,SLOT(setValue(int))); prevSC=slidComp; } QVBoxLayout * layout = new QVBoxLayout(); layout->addWidget(quitBut); layout->addLayout(grid); setLayout(layout); }
[ "ibart@60a5a0de-1a2f-0410-942a-f28f22aea592" ]
[ [ [ 1, 46 ] ] ]
b5622e616fa421e49f63374cf913ce0a6830acac
9738ebb36adfaa6f06fe2ba452aec6fcb8a06a5e
/heimdall-frontend/Source/aboutform.h
879df86faaee498d3a59d9b480000a7483979df9
[]
no_license
superweapons/Heimdall-fc
9f4ea33e4da6ffd209a7fb7afa51616eb2007832
73d77ddbf2f26c2d416b0ef4a57040e64ad86df2
refs/heads/master
2021-01-15T19:39:54.452631
2011-11-16T02:54:26
2011-11-16T02:54:26
2,785,073
1
1
null
null
null
null
UTF-8
C++
false
false
1,361
h
/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna 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.*/ // Qt #include <QWidget> // Heimdall Frontend #include "ui_aboutform.h" namespace HeimdallFrontend { class AboutForm : public QWidget, public Ui::AboutForm { public: explicit AboutForm(QWidget *parent = 0); }; }
[ [ [ 1, 1 ], [ 24, 26 ] ], [ [ 2, 23 ], [ 27, 35 ] ] ]
9b8dc7a13f2b907f869c7090eae1f27e26a5ccba
5095bbe94f3af8dc3b14a331519cfee887f4c07e
/apsim/Plant/source/Phenology/CWVernalPhase.cpp
6d5bdba7ecdac61d9aaf51a8ef6a3cc49ede325c
[]
no_license
sativa/apsim_development
efc2b584459b43c89e841abf93830db8d523b07a
a90ffef3b4ed8a7d0cce1c169c65364be6e93797
refs/heads/master
2020-12-24T06:53:59.364336
2008-09-17T05:31:07
2008-09-17T05:31:07
64,154,433
0
0
null
null
null
null
UTF-8
C++
false
false
4,899
cpp
#include "StdPlant.h" #include "CWVernalPhase.h" #include "Environment.h" #include "Phenology.h" CWVernalPhase::CWVernalPhase(ScienceAPI& scienceAPI, plantInterface& p, const string& stage_name) : Phase (scienceAPI, p, stage_name) { reset(); } void CWVernalPhase::reset(void) { Phase::reset(); vern_eff = 0.0; photop_eff = 0.0; cumvd = 0.0; } void CWVernalPhase::read() { Phase::read(); scienceAPI.read("vern_sens", vern_sens, 0.0f, 10.0f); scienceAPI.read("photop_sens", photop_sens, 0.0f, 10.0f); scienceAPI.read("twilight", twilight, -90.0f, 90.0f); y_tt.read(scienceAPI, "x_temp", "oC", 0.0, 100.0, "y_tt", "oC days", 0.0, 100.0); } void CWVernalPhase::process() { Phase::process(); vernalisation(); } // vernalisation & photoperiod stresses void CWVernalPhase::vernalisation() { float tempcr = crown_temp_nwheat (plant.environment().maxt(), plant.environment().mint(), 0.0); dlt_cumvd = wheat_vernaliz_days(plant.environment().maxt() ,plant.environment().mint() ,tempcr, 0.0 , cumvd); //maximum vernalisation requirement is 50 days vern_eff = wheat_vernaliz_effect(vern_sens, cumvd, dlt_cumvd, 50.0); float photoperiod = plant.environment().dayLength(twilight); photop_eff = wheat_photoperiod_effect(photoperiod, photop_sens); // Thermal time is calculated from crown temperature dlt_tt = y_tt[tempcr]; cumvd += dlt_cumvd; } // Crown temperature from nwheat float CWVernalPhase::crown_temp_nwheat (float maxt, float mint, float snow) { // Calculate max crown temperature float cx; if (maxt < 0.) cx = 2.0 + maxt * (0.4 + 0.0018 * pow(snow - 15., 2)); else cx = maxt; // Calculate min crown temperature float cn; if (mint < 0.) cn = 2.0 + mint * (0.4 + 0.0018 * pow(snow - 15., 2)); else cn = mint; return ((cn+cx)/2.0); } //+ Mission Statement // Photoperiod factor float CWVernalPhase::wheat_photoperiod_effect(float photoperiod, float p_photop_sen) { float photop_eff = 1.0; if (plant.phenology().inPhase("eme2ej")) { float photop_sen_factor = p_photop_sen * 0.002; photop_eff = 1. - photop_sen_factor * pow(20. - photoperiod, 2); photop_eff = bound (photop_eff, 0.0, 1.0); } return photop_eff; } //+ Purpose // Calculate daily vernalisation and accumulate to g_cumvd //+ Mission Statement // Calculate todays vernalization (used to affect phenology) //+ Notes // Nwheat originally had the following if logic for determining whether // vernalisation is calculated for today // if ( cumvd .lt. reqvd // : .and. // : (istage .eq.emerg .or. istage .eq. germ) ) // :then // // In order to remove the explicit value 'reqvd' and make the stages // more flexibile this logic was replaced. - NIH 14/07/98 float CWVernalPhase::wheat_vernaliz_days(float g_maxt //Daily maximum Temperature ,float g_mint //Daily minimum temperature ,float tempcr //Crown temperature ,float //g_snow //Snow depth of the day (mm) ,float g_cumvd) //cumulative vernalisation days till yesterday { float dlt_cumvd = 0.0; if (plant.phenology().inPhase("vernalisation")) { if (g_mint < 15.0 && g_maxt > 0.0) { // Cold float vd,vd1,vd2; vd1 = 1.4 - 0.0778 * tempcr; vd2 = 0.5 + 13.44 / pow(g_maxt-g_mint + 3., 2) * tempcr; vd = min (vd1, vd2); dlt_cumvd = l_bound (vd, 0.0); } if (g_maxt > 30. && g_cumvd + dlt_cumvd < 10.) { // high temperature will reduce vernalization dlt_cumvd = - 0.5*(g_maxt - 30.); dlt_cumvd = - min(-(dlt_cumvd), g_cumvd); } } return dlt_cumvd; } //+ Purpose // Vernalisation factor float CWVernalPhase::wheat_vernaliz_effect(float p_vern_sens ,float cumvd ,float dlt_cumvd ,float reqvd) { float vfac; // vernalization factor float vern_sens_fac; float vern_effect = 1.0; if (plant.phenology().inPhase("eme2ej")) { if (reqvd < 0.0) { reqvd = 50.0; } vern_sens_fac = p_vern_sens* 0.0054545 + 0.0003; vfac = 1. - vern_sens_fac * (reqvd - (cumvd+dlt_cumvd)); vern_effect = bound (vfac, 0.0, 1.0); } return vern_effect; }
[ "hol353@8bb03f63-af10-0410-889a-a89e84ef1bc8" ]
[ [ [ 1, 157 ] ] ]
1e9cf96583a340a0958d95f7d4eeb3c305be90e0
d7341605cc13521c9b6201f8eeaf54637028c139
/geometrymanipulation/Vertex.cpp
9960b716174996686d79ce17852bd930b9bab5d5
[]
no_license
alyshamsy/geometrymanipulation
eaa041cb00d264197251e904d01c324a43b54172
a954abb3287046af2b5b5913f047955de4af5dc7
refs/heads/master
2021-01-01T06:17:34.464534
2010-11-06T22:28:59
2010-11-06T22:28:59
32,115,408
0
0
null
null
null
null
UTF-8
C++
false
false
1,532
cpp
#include <iostream> #include "Vertex.h" using namespace std; /* The default constructor of the vertex which initiates the x, y and z components to be 0 */ Vertex::Vertex() { this->x = 0.0; this->y = 0.0; this->z = 0.0; } /* The parameter constructor which takes in 3 parameters a, b and c and assigns them to x, y and z respectively */ Vertex::Vertex(double a, double b, double c) { this->x = a; this->y = b; this->z = c; } /* The copy constructor which copies the contents of the source vertex to the local vertex */ Vertex::Vertex(const Vertex& source): x(source.x), y(source.y), z(source.z) { } /* The default constructor */ Vertex::~Vertex() { } /* The setter method which takes in 3 parameters a, b and c and assigns them to x, y and z respectively */ void Vertex::set_vertex(double a, double b, double c) { this->x = a; this->y = b; this->z = c; } /* The assignment operator is used to equate the local vertex to the value provided by the parameter and returns the local vertex */ Vertex& Vertex::operator=(const Vertex& rhs) { if(this == &rhs) return (*this); this->x = rhs.x; this->y = rhs.y; this->z = rhs.z; return (*this); } /* The equals operation which checks if the values of the parameter vertex is the same as the local vertex and returns true else returns false */ bool Vertex::operator==(const Vertex& rhs) { if(this->x == rhs.x && this->y == rhs.y && this->z == rhs.z) { return true; } else { return false; } }
[ "aly.shamsy@0e4503ba-cb77-8eec-d99c-736657fff920" ]
[ [ [ 1, 71 ] ] ]
2a58105ea93e28718ad90fae9328ece748724f79
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/ui/src/GameLoggerWindow.cpp
6c05da5332bfeaf0a3fb2e7794c98469b24963c2
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,978
cpp
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * 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 * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #include "UiPrerequisites.h" #include "Creature.h" #include "GameLoggerWindow.h" #include "ListboxWrappedTextItem.h" namespace rl { CEGUI::colour GameLoggerWindow::COLOR_CHARACTER( 0xFFFF7F7F); CEGUI::colour GameLoggerWindow::COLOR_DIALOG( 0xFFFF7FFF); CEGUI::colour GameLoggerWindow::COLOR_FIGHT( 0xFFFFFF7F); CEGUI::colour GameLoggerWindow::COLOR_MISC( 0xFFFFFFFF); GameLoggerWindow::GameLoggerWindow() : CeGuiWindow("gameloggerwindow.xml", WND_SHOW) { mLog = getListbox ("GameLogger/Log"); bindCloseToCloseButton(); } void GameLoggerWindow::logEvent(const CeGuiString& text, const CEGUI::colour color) { CEGUI::ListboxWrappedTextItem* item = new CEGUI::ListboxWrappedTextItem(text); item->setTextColours(color); mLog->insertItem(item, NULL); } void GameLoggerWindow::logDialogEvent(const CeGuiString& speaker, const CeGuiString& text) { logEvent(speaker+": '"+text+"'", COLOR_DIALOG); } void GameLoggerWindow::logFightEvent(const CeGuiString& text) { logEvent(text, COLOR_FIGHT); } void GameLoggerWindow::logCharacterEvent(const CeGuiString& text) { logEvent(text, COLOR_CHARACTER); } void GameLoggerWindow::logMiscEvent(const CeGuiString& text) { logEvent(text, COLOR_MISC); } }
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 63 ] ] ]
aa2031939403a88a933e5b5bec830c9c7c2eb9f9
3d1740e8f494b7611320feb98388b1c3eb522be9
/pymgfetch/src/pymgfetchDllMain.cpp
bb2a00fbee18c859580d932e5daf9bbc9d22422b
[]
no_license
SymbiSoft/pymgfetch
2bce15faad3596882944de7c95839151e4171c73
3f21602bac734183a40e7278a1388f9bd122044b
refs/heads/master
2021-01-10T15:04:51.855335
2009-09-04T09:36:42
2009-09-04T09:36:42
48,182,406
0
0
null
null
null
null
UTF-8
C++
false
false
862
cpp
/* ============================================================================ Name : pymgfetchDll.cpp Author : Thomas Reitmaier Copyright : Copyright Thomas Reitmaier. Description : pymgfetchDll.cpp - main DLL source ============================================================================ */ // Include Files #include <e32std.h> // GLDEF_C #include "pymgfetch.pan" // panic codes // Global Functions GLDEF_C void Panic(TpymgfetchPanic aPanic) // Panics the thread with given panic code { User::Panic(_L("pymgfetch"), aPanic); } // Exported Functions #ifndef EKA2 // for EKA1 only EXPORT_C TInt E32Dll(TDllReason /*aReason*/) // Called when the DLL is loaded and unloaded. Note: have to define // epoccalldllentrypoints in MMP file to get this called in THUMB. { return KErrNone; } #endif
[ [ [ 1, 33 ] ] ]
3defe69e6711ac36942f789520b742856737ec14
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor/GumpView.cpp
8c367efa3e2255df68eb2c12c7dc3f72db9ba604
[]
no_license
bravesoftdz/iris-svn
8f30b28773cf55ecf8951b982370854536d78870
c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4
refs/heads/master
2021-12-05T18:32:54.525624
2006-08-21T13:10:54
2006-08-21T13:10:54
null
0
0
null
null
null
null
UHC
C++
false
false
1,762
cpp
// GumpView.cpp : 구현 파일입니다. // #include "stdafx.h" #include "GumpEditor.h" #include "GumpView.h" #include ".\gumpview.h" // CGumpView IMPLEMENT_DYNCREATE(CGumpView, CView) CGumpView::CGumpView() { } CGumpView::~CGumpView() { } BEGIN_MESSAGE_MAP(CGumpView, CView) END_MESSAGE_MAP() // CGumpView 그리기입니다. void CGumpView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: 여기에 그리기 코드를 추가합니다. if (!m_pDib) return; CRect rect; GetClientRect(rect); CSize sizeWnd = rect.Size(); CSize sizeDib = m_pDib->GetDimensions(); if (sizeDib.cx <= 0 || sizeDib.cy <= 0) return; double ratio = min(float(sizeWnd.cx) / sizeDib.cx, float(sizeWnd.cy) / sizeDib.cy); if (ratio < 1.0) { sizeDib = CSize(int(sizeDib.cx * ratio), int(sizeDib.cy * ratio)); } CPoint point; point.x = max(0, sizeWnd.cx /2 - sizeDib.cx/2); point.y = max(0, sizeWnd.cy /2 - sizeDib.cy/2); CRect rcBound(point.x-1, point.y-1, point.x+sizeDib.cx+1, point.y+sizeDib.cy+1); CPen pen(PS_DOT, 1, RGB(128,128,128)); CPen* pOld = pDC->SelectObject(&pen); pDC->Rectangle(rcBound); pDC->SelectObject(pOld); m_pDib->Draw(pDC, point, sizeDib); } // CGumpView 진단입니다. #ifdef _DEBUG void CGumpView::AssertValid() const { CView::AssertValid(); } void CGumpView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif //_DEBUG // CGumpView 메시지 처리기입니다. void CGumpView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다. } void CGumpView::SetGump(CGumpPtr pDib) { m_pDib = pDib; Invalidate(); }
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 90 ] ] ]
81a23f86702925851eaa036690c8c7533b0d16d3
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/WheelAnimalController/include/TV.h
17db4e2554e531a8441b1fe2a4e0f1d4a7a0ef2a
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
447
h
#ifndef __Orz_TV_h__ #define __Orz_TV_h__ #include "WheelAnimalControllerConfig.h" #include "Something.h" class OSMScene; namespace Orz { class TV { public: TV(Ogre::SceneNode * sn); virtual ~TV(void); SomethingRise * getRise(float speed); void clear(void); void setNumber(int i = 1); private: Ogre::SceneNode * _sn; boost::shared_ptr<OSMScene> _osm; SomethingRisePtr _rise; }; } #endif
[ [ [ 1, 30 ] ] ]
00f20416d48fed544e32fea7d66abba3efd199b1
e88d7be833457f612c50d68b10a25874a29a44fc
/cpp/serial/ASIOSerialPort.cpp
d9ec1a11ed80c149a13d544310233d4bea1c29ba
[]
no_license
amelim/BeagleBoardUAV
d78bd844c5aa4ab39307010db26a00fe5e3846fc
7d4e4c1a1dbc90c54638b515678dc955cb283b9b
refs/heads/master
2020-04-15T02:26:13.800846
2000-01-01T00:06:22
2000-01-01T00:06:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,697
cpp
/* * ASIOSerialPort.cpp * * Created on: Nov 8, 2012 * Author: Matthew Barulic */ #include "ASIOSerialPort.h" #include <iostream> ASIOSerialPort::ASIOSerialPort(std::string port_name, size_t baud) : port(ioservice, port_name) { if( !port.is_open() ) { std::cerr << "Failed to open serial port: " << port_name << std::endl; exit(1); } try { port.set_option(boost::asio::serial_port_base::baud_rate(baud)); port.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none)); port.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one)); } catch(...) { std::cerr << "Failed to set all options on port: " << port_name << std::endl; exit(1); } _packetHasBeenDefined = false; _hasEncounteredStartByte = false; _line = ""; } void ASIOSerialPort::startEvents() { _eventsEnabled = true; eventThread = boost::thread(boost::bind(&ASIOSerialPort::eventThreadRun, this)); } void ASIOSerialPort::stopEvents() { _eventsEnabled = false; } void ASIOSerialPort::eventThreadRun() { while(isConnected() && _eventsEnabled) { char in = read(); onNewByte(in); if(in == '\n' || in == '\r') { onNewLine(_line); _line = ""; } else { _line += in; } } } void ASIOSerialPort::close() { port.close(); } bool ASIOSerialPort::isConnected() { return port.is_open(); } void ASIOSerialPort::write(std::string s) { boost::asio::write(port, boost::asio::buffer(s.c_str(),s.size())); } void ASIOSerialPort::write(char *msg, int length) { boost::asio::write(port, boost::asio::buffer(msg, length)); } std::string ASIOSerialPort::readln() { char c; std::string line; int nTimes = 0; while(true) { try { boost::asio::read(port, boost::asio::buffer(&c,1)); } catch(boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >& err) { std::cerr << "Error reading stream. Device may have been unplugged." << std::endl; std::cout<<"Error reading stream. Device may have been unplugged."<<std::endl; std::cout<<nTimes<<std::endl; return line; } switch(c) { case '\r': _eventsEnabled = true; return line; break; case '\n': return line; break; default: line += c; nTimes++; //std::cout<<nTimes<<std::endl; break; } if(_packetHasBeenDefined) { if(c==_packetStartByte) { _packet = ""; _hasEncounteredStartByte = true; } if(_hasEncounteredStartByte) { _packet += c; } if(c==_packetEndByte) { onNewPacket(_packet); _hasEncounteredStartByte = false; } } } return ""; } char ASIOSerialPort::read() { char in; try { boost::asio::read(port, boost::asio::buffer(&in, 1)); } catch (boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >& err) { std::cerr << "Error reading stream. Device may have been unplugged." << std::endl; return 0; } return in; } char* ASIOSerialPort::read(int numBytes) { char* bytes = new char[numBytes]; for(int i = 0; i < numBytes; i++) { bytes[i] = read(); } return bytes; } void ASIOSerialPort::definePacket(char startByte, char endByte) { _packetStartByte = startByte; _packetEndByte = endByte; _packetHasBeenDefined = true; } ASIOSerialPort::~ASIOSerialPort() { }
[ [ [ 1, 152 ] ] ]
cbe222d6b0718e160f8f26dabf09e51f43ec7493
596928863fb6e2a7250efab1bfb4c0568d3d3dd8
/nnp/calcpoly.cpp
f51b054a9c114766b0ee7cb26491d83a25b8d0a4
[]
no_license
emhuff/probwts
9a6f75dadc126bfc72da3344b5b481996d289942
987bfe37f29596c1eb47bd96ee66d7407ad4adf6
refs/heads/master
2021-01-15T14:32:13.197871
2011-09-24T00:57:53
2011-09-24T00:57:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,815
cpp
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <sys/time.h> #include "kdtrees.h" void sort2(vector<double> &arr, vector<double> &brr); void find_NR_NMAG(const char *filename, int *NR, int *NMAG); void read_data(const char *filename, int NR, int NMAG, double *zs, double *zp, double *sed, double *mags); //void read_data(const char *filename, int NR, int NMAG, double *zs, double *weight, double *ra, double *dec, int *id, double *mags); int smuthistwei(vector<double> &hx,vector<double> &hy, vector<double> &rhos, vector<double> &wei, int res); void swap(double& a,double& b); void gaussj(vector<vector<double> > &a, vector<vector<double> > &b); void covsrt(vector<vector<double> > &covar, vector<bool> &ia, const int mfit); void lfit(vector<vector<double> > &x, vector<double> &y, vector<double> &sig, vector<double> &a,vector<bool> &ia, vector<vector<double> > &covar, double &chisq, void funcs(vector<double>, vector<double> &)); void func(vector<double > var, vector<double> &a); double evalfit(vector<double> var, vector<double> &afunc, vector<double> &a); int factorial(int number); double rmin=0.; double rmax=1.35; int order=1; int main(int argc, char **argv) { if (argc < 4) { fprintf(stderr, "Usage: %s train_tbl photo_tbl NNEAR \n", argv[0]); exit(1); } int NNEAR = 100; if (argc>3) NNEAR=atoi(argv[3]); if (argc>4) order=atoi(argv[4]); if (argc>5) rmin=atof(argv[4]); if (argc>6) rmax=atof(argv[5]); // cout<<"rmin = "<<rmin<<" rmax = "<<rmax<<endl; //int res = atoi(argv[5]); int tNR, tNMAG; int pNR, pNMAG; FILE *out = fopen("output.etbl", "w"); if (out == NULL) { fprintf(stderr, "Error: failed to open file %s\n", "output.etbl"); exit(1); } find_NR_NMAG(argv[1], &tNR, &tNMAG); find_NR_NMAG(argv[2], &pNR, &pNMAG); int *tid=(int*)malloc(sizeof(double)*tNR); double *tzp1 = (double*)malloc(sizeof(double)*tNR); double *tzs1 = (double*)malloc(sizeof(double)*tNR); double *twei = (double*)malloc(sizeof(double)*tNR); double *tm = (double*)malloc(sizeof(double)*tNR*tNMAG); double *tra = (double*)malloc(sizeof(double)*tNR); double *tdec = (double*)malloc(sizeof(double)*tNR); int *pid=(int*)malloc(sizeof(double)*pNR); double *pzp1 = (double*)malloc(sizeof(double)*pNR); double *pzs1 = (double*)malloc(sizeof(double)*pNR); double *pwei = (double*)malloc(sizeof(double)*pNR); double *pm = (double*)malloc(sizeof(double)*pNR*pNMAG); double *pra = (double*)malloc(sizeof(double)*pNR); double *pdec = (double*)malloc(sizeof(double)*pNR); //dmatrix **blah= blah(NNEAR,NNEAR); vector<vector<double> > blah ( 6, vector<double> ( 8 ) ); if (tNMAG != pNMAG) { fprintf(stderr, "number of magnitudes does not match\n"); exit(3); } read_data(argv[1], tNR, tNMAG, tzs1, tzp1, twei, tm); read_data(argv[2], pNR, pNMAG, pzs1, pzp1, pwei, pm); vector<double> ds(NNEAR); vector<int> indx(NNEAR); vector<double> zp1temp(NNEAR); vector<double> zs1temp(NNEAR); vector<double> weitemp1(NNEAR); vector<vector<double> > mtemp (NNEAR, vector <double> (tNMAG)); vector<double> sig(NNEAR); int ncoeffs; ncoeffs=factorial(tNMAG+order)/(factorial(tNMAG)*factorial(order)); if (order<1 || order >3) { cout<<"The order of the polynomial you speficied is not allowed!!!"<<endl; exit(1); } vector<double> a(ncoeffs); double chisq; vector<bool>ia(ncoeffs); vector<vector<double> > covar (ncoeffs, vector <double> (ncoeffs)); for (int i=0;i<ncoeffs;i++){ ia[i]=1; } for (int i=0;i<NNEAR;i++){ sig[i]=1.; } //============================================================================= ///////////////////////////////////// //Construct KD-tree for training set/ ///////////////////////////////////// const int dim=5; //Copy tm into vector of points: vector< Point<dim> > mptt(tNR); for (int i=0;i<tNR;i++){ vector<double> mmag(dim); for(int j=0;j<dim;j++){ mmag[j]=tm[j+dim*i]; } Point<dim> pt; pt.x[0]=mmag[0]; pt.x[1]=mmag[1]; pt.x[2]=mmag[2]; pt.x[3]=mmag[3]; if (dim>4) pt.x[4]=mmag[4]; if (dim>5) pt.x[5]=mmag[5]; if (dim>6) pt.x[6]=mmag[6]; if (dim>7) pt.x[7]=mmag[7]; if (dim>8) pt.x[8]=mmag[8]; if (dim>9) pt.x[9]=mmag[9]; mptt[i]=pt; } //Construct kd-tree kdtree<dim> kdt(mptt); //=========================================================================== //Copy pm into vector of points: vector< Point<dim> > mptp(pNR); for (int i=0;i<pNR;i++){ vector<double> mmag(dim); for(int j=0;j<dim;j++){ mmag[j]=pm[j+dim*i]; } Point<dim> pt; pt.x[0]=mmag[0]; pt.x[1]=mmag[1]; pt.x[2]=mmag[2]; pt.x[3]=mmag[3]; if (dim>4) pt.x[4]=mmag[4]; if (dim>5) pt.x[5]=mmag[5]; if (dim>6) pt.x[6]=mmag[6]; if (dim>7) pt.x[7]=mmag[7]; if (dim>8) pt.x[8]=mmag[8]; if (dim>9) pt.x[9]=mmag[9]; mptp[i]=pt; } ///////////////////////////////////////////////////////// //Find Nth nearest training set neighbors (nnt)for / //each object (Ot) in photometric set / ///////////////////////////////////////////////////////// const int nmax =100000; int *nnt=new int[NNEAR]; double *ndt=new double[NNEAR]; int *listp=new int[nmax]; int *nnp;//=new int[NNEAR]; double *ndp;//=new double[NNEAR]; vector<double> nNNEAR(tNR); vector<double> distNNEAR(tNR); for (int i=0;i<nmax;i++) listp[i]=0; vector<double> nNN(tNR); vector<double> distNN(tNR); vector<int> nret(tNR); int t10 = pNR / 10; timeval *t1 = new timeval(); timeval *t2 = new timeval(); gettimeofday(t1, NULL); for(int i=0; i<pNR; ++i) { //cout << i << endl; if (i % t10 == 0) { gettimeofday(t2, NULL); printf(" %4.2f, time taken per step = %4.2f\n", (float)(i/t10)*10.0, (1000.*(t2->tv_sec-t1->tv_sec) + 0.001*(t2->tv_usec - t1->tv_usec))/t10); gettimeofday(t1, NULL); fflush(NULL); } kdt.nneigh(NNEAR,ndt,nnt,mptp[i]); for(int j=0;j<NNEAR;j++){ zs1temp[j]=tzs1[nnt[j]]; zp1temp[j]=tzp1[nnt[j]]; weitemp1[j]=twei[nnt[j]]; for(int k=0;k<tNMAG;k++){ mtemp[j][k]=tm[k+nnt[j]*tNMAG]; } } //============================================== //Fitting part //============================================== //find best-fitting coefficients lfit(mtemp,zs1temp,sig,a,ia,covar,chisq,func); //evaluate fit at the magnitudes of the photometric set object vector<double> afunc(ncoeffs); vector<double> mmagtemp(dim); for(int j=0;j<dim;j++){ mmagtemp[j]=pm[j+dim*i]; } double yyy=evalfit(mmagtemp,afunc,a); fprintf(out, "%lf %lf \n", pzs1[i], yyy); } fclose(out); return 0; } void sort2(vector<double> &arr, vector<double> &brr){ const int M=7,NSTACK=50; int i,ir,j,k,jstack=-1,l=0; double a,b; vector<int> istack(NSTACK); int n=arr.size(); ir=n-1; for (;;) { if (ir-l < M) { for (j=l+1;j<=ir;j++) { a=arr[j]; b=brr[j]; for (i=j-1;i>=l;i--) { if (arr[i] <= a) break; arr[i+1]=arr[i]; brr[i+1]=brr[i]; } arr[i+1]=a; brr[i+1]=b; } if (jstack < 0) break; ir=istack[jstack--]; l=istack[jstack--]; } else { k=(l+ir) >> 1; swap(arr[k],arr[l+1]); swap(brr[k],brr[l+1]); if (arr[l] > arr[ir]) { swap(arr[l],arr[ir]); swap(brr[l],brr[ir]); } if (arr[l+1] > arr[ir]) { swap(arr[l+1],arr[ir]); swap(brr[l+1],brr[ir]); } if (arr[l] > arr[l+1]) { swap(arr[l],arr[l+1]); swap(brr[l],brr[l+1]); } i=l+1; j=ir; a=arr[l+1]; b=brr[l+1]; for (;;) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; swap(arr[i],arr[j]); swap(brr[i],brr[j]); } arr[l+1]=arr[j]; arr[j]=a; brr[l+1]=brr[j]; brr[j]=b; jstack += 2; if (jstack >= NSTACK){ printf("NSTACK too small in sort2."); exit(1); } if (ir-i+1 >= j-l) { istack[jstack]=ir; istack[jstack-1]=i; ir=j-1; } else { istack[jstack]=j-1; istack[jstack-1]=l; l=i; } } } } void find_NR_NMAG(const char *filename, int *NR, int *NMAG) { //This function is used to find out the number of rows and number of magnitudes in a table file //Find out the number of rows FILE *in = fopen(filename, "r"); char line[256]; char *token = NULL; fgets(line, 256, in); token = strtok(line, " \n"); *NMAG = 0; int NS = 3; while (token != NULL) { (*NMAG)++; token = strtok(NULL, " \n"); } *NMAG = *NMAG - NS; //Find out the number of rows *NR = 0; while (!feof(in)) { (*NR)++; fgets(line, 256, in); } printf("NR = %d, NMAG = %d\n", *NR, *NMAG); } void read_data(const char *filename, int NR, int NMAG, double *zs, double *zp, double *sed, double *mags) { FILE *in = fopen(filename, "r"); if (in == NULL) { fprintf(stderr, "Error: failed to open file %s\n", filename); exit(1); } int i, j; for(i=0; i<NR; ++i) { fscanf(in, "%lf %lf %lf", &zs[i], &zp[i], &sed[i]); for(j=0; j<NMAG; ++j) { fscanf(in, "%lf", &mags[i*NMAG + j]); // mags[i*NMAG+j] = (mags[i*NMAG+j]-10.0)/22.0; } } fclose(in); } // void read_data(const char *filename, int NR, int NMAG, double *zs, double *weight, double *ra, double *dec, int *id, double *mags) { // FILE *in = fopen(filename, "r"); // if (in == NULL) { // fprintf(stderr, "Error: failed to open file %s\n", filename); // exit(1); // } // int i, j; // for(i=0; i<NR; ++i) { // fscanf(in, "%lf %lf %d %lf %lf", &ra[i],&dec[i],&id[i],&zs[i], &weight[i]); // for(j=0; j<NMAG; ++j) { // fscanf(in, "%lf", &mags[i*NMAG + j]); // // mags[i*NMAG+j] = (mags[i*NMAG+j]-10.0)/22.0; // } // } // fclose(in); // } int smuthistwei(vector<double> &hx,vector<double> &hy, vector<double> &rhos, vector<double> &wei, int res) { //first, find the min and the max of the data //int option = 1; int size=rhos.size(); int ndiv=hy.size(); //res=size/res; double hfwth, rho_min=rmin, rho_max=rmax; vector<double> xmin(ndiv),xmax(ndiv); double count=0; double drho = (rho_max - rho_min)/(double)res; double step=(rho_max - rho_min - drho)/((double)ndiv-1.); for (int i = 0; i < ndiv; ++i) { xmin[i] = rho_min + step*(double)i; xmax[i] = xmin[i] + drho; hy[i] = 0.; hx[i]=(xmin[i]+xmax[i])/2.; } double sumwei=0.; for (int i = 0; i < size; ++i) { sumwei+=wei[i]; } for (int j = 0; j < ndiv; ++j) { if (j == ndiv-1){ xmax[j]=xmax[j]+0.0001; } for (int i = 0; i < size; ++i) { if ((rhos[i] >= xmin[j]) && (rhos[i] < xmax[j])){ if (sumwei != 0){ hy[j]+=wei[i]/sumwei; } else hy[j] =0.; } } count +=hy[j]; } return 0; } double calcSigma(vector<double> &zs, vector<double> &zp) { if (zs.size() < 2) { return 0.0; } double r = 0.0; for(int i=0; i<zs.size(); ++i) { r += (zs[i]-zp[i])*(zs[i]-zp[i]); } return sqrt(r/zs.size()); } double calcSigma68(vector<double> &zs, vector<double> &zp, vector<double> &wei) { if (zs.size() < 2) { return 0.0; } double ws=0.,ws1=0.; vector<double> d(zs.size()), wfrac(zs.size()); for(int i=0; i<zs.size(); ++i) { d[i] = fabs(zs[i]-zp[i]); ws+=wei[i]; } sort2(d,wei); int s68=0,k=0; for(int i=0; i<zs.size(); ++i) { ws1+=wei[i]; //wfrac[i]=ws1/ws; k=i; if ((ws1/ws) > 0.68) break; } s68=k; return d[s68]; } void swap(double& a,double& b) //swaps values of a and b { double temp = a; a = b; b = temp; } void covsrt(vector<vector<double> > &covar, vector<bool> &ia, const int mfit) { int i,j,k; int ma=ia.size(); for (i=mfit;i<ma;i++) for (j=0;j<i+1;j++) covar[i][j]=covar[j][i]=0.0; k=mfit-1; for (j=ma-1;j>=0;j--) { if (ia[j]) { for (i=0;i<ma;i++) swap(covar[i][k],covar[i][j]); for (i=0;i<ma;i++) swap(covar[k][i],covar[j][i]); k--; } } } void gaussj(vector<vector<double> > &a, vector<vector<double> > &b) { int i,icol,irow,j,k,l,ll; double big,dum,pivinv; int n=a.size(); int m=b[0].size(); vector<int> indxc(n),indxr(n),ipiv(n); for (j=0;j<n;j++) ipiv[j]=0; for (i=0;i<n;i++) { big=0.0; for (j=0;j<n;j++) if (ipiv[j] != 1) for (k=0;k<n;k++) { if (ipiv[k] == 0) { if (fabs(a[j][k]) >= big) { big=fabs(a[j][k]); irow=j; icol=k; } } } ++(ipiv[icol]); if (irow != icol) { for (l=0;l<n;l++) swap(a[irow][l],a[icol][l]); for (l=0;l<m;l++) swap(b[irow][l],b[icol][l]); } indxr[i]=irow; indxc[i]=icol; if (a[icol][icol] == 0.0) cerr<<"gaussj: Singular Matrix"<<endl; pivinv=1.0/a[icol][icol]; a[icol][icol]=1.0; for (l=0;l<n;l++) a[icol][l] *= pivinv; for (l=0;l<m;l++) b[icol][l] *= pivinv; for (ll=0;ll<n;ll++) if (ll != icol) { dum=a[ll][icol]; a[ll][icol]=0.0; for (l=0;l<n;l++) a[ll][l] -= a[icol][l]*dum; for (l=0;l<m;l++) b[ll][l] -= b[icol][l]*dum; } } for (l=n-1;l>=0;l--) { if (indxr[l] != indxc[l]) for (k=0;k<n;k++) swap(a[k][indxr[l]],a[k][indxc[l]]); } } void lfit(vector<vector<double> > &x, vector<double> &y, vector<double> &sig, vector<double> &a, vector<bool> &ia, vector<vector<double> > &covar, double &chisq, void funcs(vector<double>, vector<double> &)) { for (int j=0;j<a.size();j++){ a[j]=0.; } int i,j,k,l,m,mfit=0; double ym,wt,sum,sig2i; int ndat=x.size(); int nmag=x[0].size(); int ma=a.size(); vector<double> afunc(ma); vector<vector<double> > beta(ma,vector<double>(1)); for (j=0;j<ma;j++) if (ia[j]) mfit++; if (mfit == 0) cerr<<"lfit: no parameters to be fitted"<<endl; for (j=0;j<mfit;j++) { for (k=0;k<mfit;k++) covar[j][k]=0.0; beta[j][0]=0.0; } //cout<<"mfit = "<<mfit<<endl; for (i=0;i<ndat;i++) { vector<double> tempmag(nmag); for (int ii=0;ii<nmag;ii++){ tempmag[ii]=x[i][ii]; } funcs(tempmag,afunc); ym=y[i]; if (mfit < ma) { for (j=0;j<ma;j++) if (!ia[j]) ym -= a[j]*afunc[j]; } sig2i=1.0/(sig[i]*sig[i]); for (j=0,l=0;l<ma;l++) { if (ia[l]) { wt=afunc[l]*sig2i; for (k=0,m=0;m<=l;m++) if (ia[m]) covar[j][k++] += wt*afunc[m]; beta[j++][0] += ym*wt; } } } for (j=1;j<mfit;j++) for (k=0;k<j;k++) covar[k][j]=covar[j][k]; vector<vector<double> > temp (mfit,vector<double>(mfit)); for (j=0;j<mfit;j++) for (k=0;k<mfit;k++) temp[j][k]=covar[j][k]; gaussj(temp,beta); for (j=0;j<mfit;j++) for (k=0;k<mfit;k++) covar[j][k]=temp[j][k]; for (j=0,l=0;l<ma;l++) if (ia[l]) a[l]=beta[j++][0]; chisq=0.0; for (i=0;i<ndat;i++) { vector<double> tempmag(nmag); for (int ii=0;ii<nmag;ii++){ tempmag[ii]=x[i][ii]; } funcs(tempmag,afunc); sum=0.0; for (j=0;j<ma;j++) sum += a[j]*afunc[j]; chisq += ((y[i]-sum)/sig[i])*((y[i]-sum)/sig[i]); } covsrt(covar,ia,mfit); } int factorial(int number) { int temp; if(number <= 1) return 1; temp = number * factorial(number - 1); return temp; } void func(vector<double> var, vector<double> &a){ int size=a.size(); int sizevar=var.size(); int cor=0; int tot=1; a[0]=1.0; for (int i=0;i<sizevar;i++){ a[i+1]=var[i]; } if (size>sizevar +1){ for (int i=0;i<sizevar;i++){ cor+=i; for (int j=i;j<sizevar;j++){ a[i*sizevar +j+1+sizevar-cor]=var[i]*var[j]; } } } int part=sizevar*(sizevar+1)/2+sizevar +1; if (size>sizevar*(sizevar+1)/2+sizevar +1){ int count=0; for (int i=0;i<sizevar;i++){ for (int j=i;j<sizevar;j++){ for (int k=j;k<sizevar;k++){ a[count+part]=var[i]*var[j]*var[k]; count++; } } } } } double evalfit(vector<double> var, vector<double> &afunc, vector<double> &a){ double y=0.; func(var,afunc); int size=a.size(); int size2=afunc.size(); if(size!=size2) { cout<<"Sizes don't match in evalfit"<<endl; exit(1); } for (int i=0;i<size;i++){ y+=a[i]*afunc[i]; } return y; }
[ [ [ 1, 676 ] ] ]
69b70cc62d0500dc74d1d1029f84ae5d6eb88bf4
5a05acb4caae7d8eb6ab4731dcda528e2696b093
/GameEngine/Gfx/IndexBuffer.cpp
a014ae86196bc7ba9084da0051f627d294d37e9e
[]
no_license
andreparker/spiralengine
aea8b22491aaae4c14f1cdb20f5407a4fb725922
36a4942045f49a7255004ec968b188f8088758f4
refs/heads/master
2021-01-22T12:12:39.066832
2010-05-07T00:02:31
2010-05-07T00:02:31
33,547,546
0
0
null
null
null
null
UTF-8
C++
false
false
493
cpp
#include "IndexBuffer.hpp" #include "IndexFormatImpl.hpp" using namespace Spiral; using namespace boost; bool IndexBuffer::Create( const IndexFormat& format, boost::int32_t indexCount, bool bManaged /*= false */ ) { SetIndexCount( indexCount ); SetIndexType( format.GetType() ); return DoCreate( format, indexCount, bManaged ); } IndexBuffer::IndexBuffer(): m_indexCount(0), m_type( IndexFormat::IF_INVALID ), m_resource() { } IndexBuffer::~IndexBuffer() { }
[ "DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e" ]
[ [ [ 1, 26 ] ] ]
efd6e7efea444a5546fd449b048cd7b5f18cd96b
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/infostudio/InfoStudio/yellowpageDlg.h
495296574438436f2f53d65db0e55c0819afc9dc
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,115
h
#pragma once #include <atlctrlx.h> #include "Resource.h" #include "condef.h" #include "webinfo.h" #include "infomanage.h" extern CInfoManage* _pInfoManage; class CYellowPageDlg : public CDialogImpl<CYellowPageDlg> { public: CYellowPageDlg() { } ~CYellowPageDlg() { } enum {IDD = IDD_YELLOWPAGEDLG}; BEGIN_MSG_MAP( CYellowPageDlg ) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_ID_HANDLER(IDOK, OnOk) COMMAND_ID_HANDLER(IDCANCEL, OnCancel) MSG_WM_SIZE(OnSize) END_MSG_MAP() BOOL PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN) { if(::IsDialogMessage(m_hWnd, pMsg)) return TRUE; } } return FALSE; } LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { Init(); InitData(); return 0; } LRESULT OnOk(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { return 0; } LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { return 0; } void OnSize(UINT wParam, CSize size) { DefWindowProc(); int cx = size.cx; int cy = size.cy; if (_listView.m_hWnd) _listView.SetWindowPos(NULL, 0, 0, cx , cy, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); } //funciton void Init() { _listView.Create(m_hWnd,rcDefault,NULL, WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_SHOWSELALWAYS | WS_VSCROLL | WS_HSCROLL); _listView.SetExtendedListViewStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES ); for (int i = 0; i< sizeof(LOGINFIELD) / sizeof (LOGINFIELD[0]); i++) { _listView.InsertColumn(i, LOGINFIELD[i]); _listView.SetColumnWidth(i, LOGINFIELDSIZE[i]); } } void InitData() { int nCount = 0; if ( !_pInfoManage ) return ; for( std::map<int, CWebInfo*>::iterator it = _pInfoManage->_webInfoMap.begin(); it!= _pInfoManage->_webInfoMap.end(); it++ ) { CWebInfo* pWebInfo = it->second; CString strField; strField.Format( _T("%d"), pWebInfo->_id ); LVITEM lvitem; lvitem.mask = LVIF_TEXT | LVIF_IMAGE; lvitem.iItem = nCount; lvitem.iSubItem = 0; lvitem.iImage = 0; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); int iPos = _listView.InsertItem(&lvitem); _listView.SetItemData(iPos, (DWORD_PTR) pWebInfo ); strField = pWebInfo->_strName; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 1; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField = pWebInfo->_strWebUrl; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 2; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField = pWebInfo->_strType; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 3; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField.Format( _T("%d"), pWebInfo->_grade ) ; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 4; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField = pWebInfo->_strUser; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 5; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField = pWebInfo->_strRegisterTime; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 6; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); strField = pWebInfo->_strState; lvitem.mask = LVIF_TEXT; lvitem.iItem = iPos; lvitem.iSubItem = 7; lvitem.pszText = (LPTSTR)strField.GetBuffer(strField.GetLength()); _listView.SetItem(&lvitem); nCount++; } } public: CSortListViewCtrl _listView; };
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 175 ] ] ]
507b5a37cf00735933bef4abcbfc2543c90bd07b
97f1be9ac088e1c9d3fd73d76c63fc2c4e28749a
/3dc/avp/win95/gadgets/consvar.hpp
4149a9b09b8336c5d90b688fdb6b72c5aa885a32
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
SR-dude/AvP-Wine
2875f7fd6b7914d03d7f58e8f0ec4793f971ad23
41a9c69a45aacc2c345570ba0e37ec3dc89f4efa
refs/heads/master
2021-01-23T02:54:33.593334
2011-09-17T11:10:07
2011-09-17T11:10:07
2,375,686
1
0
null
null
null
null
UTF-8
C++
false
false
3,448
hpp
/* consvar.hpp Console variables : i.e. values that can be adjusted at the console */ #ifndef _consvar_hpp #define _consvar_hpp 1 #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) ) #pragma once #endif #ifndef _conssym_hpp #include "conssym.hpp" #endif #ifdef __cplusplus extern "C" { #endif /* Version settings *****************************************************/ /* Constants ***********************************************************/ /* Macros ***************************************************************/ /* Type definitions *****************************************************/ // Abstract base class of console variable // It's abstract because the Get/SetValue functions are pure virtual. // There's a "standard" derived class defined within CONSVAR.CPP // which has a direct link to a global int, and allows direct set/get // For other variables (which might require additional processing), // derive another class from the base and implement the Set/Get pairs // Use single words only as symbols; the command interpreter looks // for spaces class ConsoleVariable : public ConsoleSymbol { public: // Factory method: static ConsoleVariable* MakeSimpleConsoleVariable_Int ( int& Value_ToUse, ProjChar* pProjCh_Symbol_ToUse, ProjChar* pProjCh_Description_ToUse, int MinVal_New, int MaxVal_New, OurBool Cheat = FALSE ); static ConsoleVariable* MakeSimpleConsoleVariable_FixP ( int& Value_ToUse, ProjChar* pProjCh_Symbol_ToUse, ProjChar* pProjCh_Description_ToUse, int MinVal_New, // fixed point value int MaxVal_New, // fixed point value OurBool Cheat = FALSE ); ~ConsoleVariable(); virtual int GetValue(void) const = 0; virtual void SetValue(int Val_New) = 0; virtual void SetValue(float Val_New) = 0; static OurBool Process( ProjChar* pProjCh_In ); // used for proccesing input text. Could decide that the user // was requesting the value of a variable, or was setting a new // value etc; if so, acts accordingly. // return value = was any processing performed? static void ListAllVariables(void); static void CreateAll(void); // hook to create all the console variables // (to make it easy to add new ones) protected: ConsoleVariable ( ProjChar* pProjCh_Symbol_ToUse, ProjChar* pProjCh_Description_ToUse, int MinVal_New, int MaxVal_New, OurBool Cheat = FALSE ); private: void Display(void); // used by the list display and to interrogate an individual variable void ProcessSetValue ( int Val_New ); void ProcessSetValue ( float Val_New ); // used by command processor; sets the value and outputs // a message void OutputResultOfSetValue( int OldVal ); virtual SCString* MakeRangeString(void) = 0; virtual SCString* MakeValueString(int Val) = 0; // Data: protected: int MinVal; int MaxVal; private: SCString* pSCString_Description; static List <ConsoleVariable*> List_pConsoleVar; }; // suggested naming: "ConsoleVar" /* Exported globals *****************************************************/ /* Function prototypes **************************************************/ /* End of the header ****************************************************/ #ifdef __cplusplus }; #endif #endif
[ "a_jagers@ANTHONYJ.(none)" ]
[ [ [ 1, 138 ] ] ]
bce2fa4dd9e2df1c023b81e47d059617edebe6e2
cb318077a36ea2885b66ebdfb61cb37f9096b27d
/MT4ODBCBridge/MT4ODBCBridge.cpp
88d3836b5011db9915044a10040dc8fa4c297fb6
[]
no_license
danmi1258/mt4-odbc-bridge
aede37e60959d60e0b524c0d25f7c4e24164113e
422d2ae4137886babdbf6dff17e594f8d729049f
refs/heads/master
2021-05-26T13:54:46.648670
2011-08-29T10:48:51
2011-08-29T10:48:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,795
cpp
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include "odbcwrapper.h" #include <stdio.h> #include <stdarg.h> #define MT4_EXPFUNC __declspec(dllexport) #define MOB_DEBUG_LOG false /** * Cache to handle multiple connections. * Assuming a connection per thread. */ std::map<int, ODBCWrapper*> conns; int nextConId = 1; HANDLE connsLock; FILE* logFile; HANDLE fileLock; using namespace cppodbc; /** * */ static void log(const char *format, ...) { if (MOB_DEBUG_LOG && logFile) { va_list arg; va_start(arg, format); WaitForSingleObject(fileLock, INFINITE); //TODO: define log file prefix like timestamp, thread ID, etc. vfprintf_s(logFile, format, arg); ReleaseMutex(logFile); va_end(arg); } } /** * */ static void init() { connsLock = CreateMutex(NULL, FALSE, _T("connsLock")); fileLock = CreateMutex(NULL, FALSE, _T("fileLock")); // conns already has an instance. if (MOB_DEBUG_LOG) { WaitForSingleObject(fileLock, INFINITE); //TODO: use env var to determine the log file directory if (_tfopen_s(&logFile, _T("C:\\Users\\onagano\\mobdebug.log"), _T("a")) != 0) logFile = NULL; ReleaseMutex(logFile); } log("init() called.\n"); } /** * */ static void deinit() { log("deinit() called.\n"); WaitForSingleObject(connsLock, INFINITE); for (std::map<int, ODBCWrapper*>::iterator ite = conns.begin(); ite != conns.end(); ite++) { ODBCWrapper *ow = ite->second; if (ow) delete ow; } conns.clear(); ReleaseMutex(connsLock); if (MOB_DEBUG_LOG && logFile) { WaitForSingleObject(fileLock, INFINITE); if (fclose(logFile) == 0) logFile = NULL; ReleaseMutex(logFile); } CloseHandle(connsLock); CloseHandle(fileLock); } /** * The entry point of this DLL. */ BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: init(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: deinit(); break; } return(TRUE); } /** * */ MT4_EXPFUNC int __stdcall MOB_create() { WaitForSingleObject(connsLock, INFINITE); int conId = nextConId++; conns[conId] = new ODBCWrapper(); ReleaseMutex(connsLock); return conId; } /** * */ MT4_EXPFUNC int __stdcall MOB_open(const int conId, const TCHAR *dsn, const TCHAR *username, const TCHAR *password) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->open(dsn, username, password); } /** * */ MT4_EXPFUNC int __stdcall MOB_close(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; delete ow; WaitForSingleObject(connsLock, INFINITE); conns.erase(conId); ReleaseMutex(connsLock); return MOB_OK; } /** * */ MT4_EXPFUNC int __stdcall MOB_isDead(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->isDead(); } /** * */ MT4_EXPFUNC int __stdcall MOB_commit(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->commit(); } /** * */ MT4_EXPFUNC int __stdcall MOB_rollback(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->rollback(); } /** * */ MT4_EXPFUNC int __stdcall MOB_getAutoCommit(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->getAutoCommit(); } /** * */ MT4_EXPFUNC int __stdcall MOB_setAutoCommit(const int conId, const int autoCommit) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->setAutoCommit(autoCommit); } /** * */ MT4_EXPFUNC int __stdcall MOB_execute(const int conId, const TCHAR *sql) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->execute(sql); } /** * */ MT4_EXPFUNC int __stdcall MOB_getLastErrorNo(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->getLastErrorNo(); } /** * */ MT4_EXPFUNC const TCHAR* __stdcall MOB_getLastErrorMesg(const int conId) { ODBCWrapper *ow = conns[conId]; if (!ow) return _T("INVALID CONID"); return ow->getLastErrorMesg(); } /** * */ MT4_EXPFUNC int __stdcall MOB_registerStatement(const int conId, const TCHAR *sql) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->registerStatement(sql); } /** * */ MT4_EXPFUNC int __stdcall MOB_unregisterStatement(const int conId, const int stmtId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->unregisterStatement(stmtId); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindIntParameter(const int conId, const int stmtId, const int slot, int *intp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindIntParameter(stmtId, slot, intp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindDoubleParameter(const int conId, const int stmtId, const int slot, double *dblp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindDoubleParameter(stmtId, slot, dblp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindStringParameter(const int conId, const int stmtId, const int slot, TCHAR *strp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindStringParameter(stmtId, slot, strp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindDatetimeParameter(const int conId, const int stmtId, const int slot, unsigned int *timep) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindDatetimeParameter(stmtId, slot, timep); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindIntColumn(const int conId, const int stmtId, const int slot, int *intp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindIntColumn(stmtId, slot, intp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindDoubleColumn(const int conId, const int stmtId, const int slot, double *dblp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindDoubleColumn(stmtId, slot, dblp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindStringColumn(const int conId, const int stmtId, const int slot, TCHAR *strp) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindStringColumn(stmtId, slot, strp); } /** * */ MT4_EXPFUNC int __stdcall MOB_bindDatetimeColumn(const int conId, const int stmtId, const int slot, unsigned int *timep) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->bindDatetimeColumn(stmtId, slot, timep); } /** * */ MT4_EXPFUNC int __stdcall MOB_executeStatement(const int conId, const int stmtId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->executeStatement(stmtId); } /** * */ MT4_EXPFUNC int __stdcall MOB_selectToFetch(const int conId, const int stmtId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->selectToFetch(stmtId); } /** * */ MT4_EXPFUNC int __stdcall MOB_fetch(const int conId, const int stmtId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->fetch(stmtId); } /** * */ MT4_EXPFUNC int __stdcall MOB_fetchedAll(const int conId, const int stmtId) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->fetchedAll(stmtId); } /** * */ MT4_EXPFUNC int __stdcall MOB_insertTick(const int conId, const int stmtId, unsigned int datetime, int fraction, double *vals, const int size) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->insertTick(stmtId, datetime, fraction, vals, size); } /** * */ MT4_EXPFUNC int __stdcall MOB_insertBar(const int conId, const int stmtId, unsigned int datetime, double *vals, const int size) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->insertBar(stmtId, datetime, vals, size); } /** * */ MT4_EXPFUNC int __stdcall MOB_copyRates(const int conId, const int stmtId, RateInfo *rates, const int size, const int start, const int end) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->copyRates(stmtId, rates, size, start, end); } /** * */ MT4_EXPFUNC double __stdcall MOB_selectDouble(const int conId, const TCHAR *sql, const double defaultVal) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->selectDouble(sql, defaultVal); } /** * */ MT4_EXPFUNC int __stdcall MOB_selectInt(const int conId, const TCHAR *sql, const int defaultVal) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->selectInt(sql, defaultVal); } /** * */ MT4_EXPFUNC unsigned int __stdcall MOB_selectDatetime(const int conId, const TCHAR *sql, const unsigned int defaultVal) { ODBCWrapper *ow = conns[conId]; if (!ow) return MOB_INVALID_CONID; return ow->selectDatetime(sql, defaultVal); } /** * Helper function to retrieve the current time. */ MT4_EXPFUNC unsigned int __stdcall MOB_time() { time_t t; time(&t); return (unsigned int) t; } /** * Helper function to retrieve the current time in local timezone. */ MT4_EXPFUNC unsigned int __stdcall MOB_localtime() { time_t t; struct tm lt; time(&t); localtime_s(&lt, &t); time_t ret = _mkgmtime(&lt); return (unsigned int) ret; } /** * Helper function to copy a string to another. */ MT4_EXPFUNC unsigned int __stdcall MOB_strcpy(TCHAR *dest, const int size, const TCHAR *src) { return _tcsncpy_s(dest, size, src, _TRUNCATE); }
[ "onagano" ]
[ [ [ 1, 457 ] ] ]
2483ad8c3f143ccb9e8ed492bd6148d5c49e66b8
975d45994f670a7f284b0dc88d3a0ebe44458a82
/servidor/WarBugsServer/WarBugsServer/Includes/CPoder.h
48c77238bf96bf2b3ddfb9bff7af15c35b3dd38b
[]
no_license
phabh/warbugs
2b616be17a54fbf46c78b576f17e702f6ddda1e6
bf1def2f8b7d4267fb7af42df104e9cdbe0378f8
refs/heads/master
2020-12-25T08:51:02.308060
2010-11-15T00:37:38
2010-11-15T00:37:38
60,636,297
0
0
null
null
null
null
UTF-8
C++
false
false
2,137
h
#pragma once /* * Classe CPoder * * Autor: Eder Figueiredo * * Objetivo: Descrever os poderes de um personagem * */ #ifndef _CPODER_H_ #define _CPODER_H_ #include "Enumerators.h" #include "CWarBugObject.h" #include "CBuff.h" #include <time.h> //#include "CPersonagemJogador.h" #include "CCenario.h" class CPoder : public CWarBugObject { private: //Skills static void berserkTornado(CPersonagemJogador *user, int level); static void ariete(CPersonagemJogador *user, CPersonagem *target, int level); static void strike(CPersonagemJogador *user, int level); static void piercingShot(CPersonagemJogador *user, int level); static void stunningShot(CPersonagemJogador *user, CPersonagem *target, int level); static void numbingOnion(CPersonagemJogador *user, CPersonagem *target, int level); static void stealItem(CPersonagem *user, CPersonagem *target); static void breakItem(CPersonagem *user, CPersonagem *target); static void stinkGas(CPersonagem *user); static void killingNeedle(CPersonagem *user, CPersonagem *target); static void lightSpeed(CPersonagem *user); static void eat(CPersonagem *user, CPersonagem *target); static void explode(CPersonagem *user); static void invisible(CPersonagem *user); static void summonAnts(); //RaceTypes static void beetleSkills(CPersonagemJogador *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); static void antSkills(CPersonagem *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); static void termiteSkills(CPersonagem *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); static void shaverSkills(CPersonagem *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); static void lizardSkills(CPersonagem *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); static void ladybugSkills(CPersonagem *user, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); public: static void cast(CPersonagem *user, Raca userRace, TipoPoder skillIndex, int skillLevel, CPersonagem *target = NULL); }; #endif
[ [ [ 1, 57 ] ] ]
4a8d8344357e812c88416d9b2c7461acd5f6b5c2
4a5fd612c361afd2ccca1e0d916724502e2c2741
/Source/piece_knight.cpp
925bf229646ed014f3ee41d1577b9583acd63c25
[]
no_license
tiagoc/laig-proj3
0420a2b117ea2608e13009758bb6328c23fce79e
ece8084d7be9556f5f2ad63cc629da9620943546
refs/heads/master
2020-05-28T07:35:49.407681
2011-12-21T00:13:42
2011-12-21T00:13:42
32,113,920
0
0
null
null
null
null
UTF-8
C++
false
false
107,388
cpp
#include "piece_knight.h" /* Exported from Blender */ #define VERTEX_COUNT 1228 #define FACES_COUNT 420 /*#ifndef VERTEX_STRUCT #define VERTEX_STRUCT struct vertex_struct{ float x, y, z; float nx,ny,nz; float u,v; }; #endif*/ struct vertex_struct vertexs_knight[]= { {85.930199, -258.178772, 85.930199, -0.008805, 0.999955, -0.003647, 0.0, 0.0}, {121.524002, -258.178772, 0.000000, -0.008805, 0.999955, -0.003647, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, -0.008805, 0.999955, -0.003647, 0.0, 0.0}, {0.000000, -258.178772, 121.524002, -0.003647, 0.999955, -0.008805, 0.0, 0.0}, {85.930199, -258.178772, 85.930199, -0.003647, 0.999955, -0.008805, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, -0.003647, 0.999955, -0.008805, 0.0, 0.0}, {-85.930199, -258.178772, 85.930199, 0.003647, 0.999955, -0.008805, 0.0, 0.0}, {0.000000, -258.178772, 121.524002, 0.003647, 0.999955, -0.008805, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, 0.003647, 0.999955, -0.008805, 0.0, 0.0}, {-121.524002, -258.178772, 0.000000, 0.008805, 0.999955, -0.003647, 0.0, 0.0}, {-85.930199, -258.178772, 85.930199, 0.008805, 0.999955, -0.003647, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, 0.008805, 0.999955, -0.003647, 0.0, 0.0}, {-85.930199, -258.178772, -85.930199, 0.008805, 0.999955, 0.003647, 0.0, 0.0}, {-121.524002, -258.178772, 0.000000, 0.008805, 0.999955, 0.003647, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, 0.008805, 0.999955, 0.003647, 0.0, 0.0}, {0.000000, -258.178772, -121.524002, 0.003647, 0.999955, 0.008805, 0.0, 0.0}, {-85.930199, -258.178772, -85.930199, 0.003647, 0.999955, 0.008805, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, 0.003647, 0.999955, 0.008805, 0.0, 0.0}, {85.930199, -258.178772, -85.930199, -0.003647, 0.999955, 0.008805, 0.0, 0.0}, {0.000000, -258.178772, -121.524002, -0.003647, 0.999955, 0.008805, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, -0.003647, 0.999955, 0.008805, 0.0, 0.0}, {121.524002, -258.178772, 0.000000, -0.008805, 0.999955, 0.003647, 0.0, 0.0}, {85.930199, -258.178772, -85.930199, -0.008805, 0.999955, 0.003647, 0.0, 0.0}, {0.000000, -259.248779, 0.000000, -0.008805, 0.999955, 0.003647, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, -0.080786, 0.996170, -0.033463, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, -0.080786, 0.996170, -0.033463, 0.0, 0.0}, {121.524002, -258.178772, 0.000000, -0.080786, 0.996170, -0.033463, 0.0, 0.0}, {85.930199, -258.178772, 85.930199, -0.080785, 0.996170, -0.033463, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, -0.080785, 0.996170, -0.033463, 0.0, 0.0}, {121.524002, -258.178772, 0.000000, -0.080785, 0.996170, -0.033463, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, -0.033462, 0.996170, -0.080786, 0.0, 0.0}, {85.930199, -258.178772, 85.930199, -0.033462, 0.996170, -0.080786, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, -0.033462, 0.996170, -0.080786, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, -0.033463, 0.996170, -0.080786, 0.0, 0.0}, {85.930199, -258.178772, 85.930199, -0.033463, 0.996170, -0.080786, 0.0, 0.0}, {0.000000, -258.178772, 121.524002, -0.033463, 0.996170, -0.080786, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, 0.033463, 0.996170, -0.080786, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, 0.033463, 0.996170, -0.080786, 0.0, 0.0}, {0.000000, -258.178772, 121.524002, 0.033463, 0.996170, -0.080786, 0.0, 0.0}, {-85.930199, -258.178772, 85.930199, 0.033463, 0.996170, -0.080785, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, 0.033463, 0.996170, -0.080785, 0.0, 0.0}, {0.000000, -258.178772, 121.524002, 0.033463, 0.996170, -0.080785, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, 0.080786, 0.996170, -0.033462, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, 0.080786, 0.996170, -0.033462, 0.0, 0.0}, {-85.930199, -258.178772, 85.930199, 0.080786, 0.996170, -0.033462, 0.0, 0.0}, {-121.524002, -258.178772, 0.000000, 0.080786, 0.996170, -0.033463, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, 0.080786, 0.996170, -0.033463, 0.0, 0.0}, {-85.930199, -258.178772, 85.930199, 0.080786, 0.996170, -0.033463, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, 0.080786, 0.996170, 0.033463, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, 0.080786, 0.996170, 0.033463, 0.0, 0.0}, {-121.524002, -258.178772, 0.000000, 0.080786, 0.996170, 0.033463, 0.0, 0.0}, {-85.930199, -258.178772, -85.930199, 0.080785, 0.996170, 0.033463, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, 0.080785, 0.996170, 0.033463, 0.0, 0.0}, {-121.524002, -258.178772, 0.000000, 0.080785, 0.996170, 0.033463, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, 0.033462, 0.996170, 0.080786, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, 0.033462, 0.996170, 0.080786, 0.0, 0.0}, {-85.930199, -258.178772, -85.930199, 0.033462, 0.996170, 0.080786, 0.0, 0.0}, {0.000000, -258.178772, -121.524002, 0.033463, 0.996170, 0.080786, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, 0.033463, 0.996170, 0.080786, 0.0, 0.0}, {-85.930199, -258.178772, -85.930199, 0.033463, 0.996170, 0.080786, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, -0.033463, 0.996170, 0.080786, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, -0.033463, 0.996170, 0.080786, 0.0, 0.0}, {0.000000, -258.178772, -121.524002, -0.033463, 0.996170, 0.080786, 0.0, 0.0}, {85.930199, -258.178772, -85.930199, -0.033463, 0.996170, 0.080785, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, -0.033463, 0.996170, 0.080785, 0.0, 0.0}, {0.000000, -258.178772, -121.524002, -0.033463, 0.996170, 0.080785, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, -0.080786, 0.996170, 0.033462, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, -0.080786, 0.996170, 0.033462, 0.0, 0.0}, {85.930199, -258.178772, -85.930199, -0.080786, 0.996170, 0.033462, 0.0, 0.0}, {121.524002, -258.178772, 0.000000, -0.080786, 0.996170, 0.033463, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, -0.080786, 0.996170, 0.033463, 0.0, 0.0}, {85.930199, -258.178772, -85.930199, -0.080786, 0.996170, 0.033463, 0.0, 0.0}, {126.053993, -315.992767, 126.053993, 0.879067, -0.307665, 0.364120, 0.0, 0.0}, {178.266998, -315.992767, 0.000000, 0.879067, -0.307665, 0.364120, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, 0.879067, -0.307665, 0.364120, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, 0.879067, -0.307666, 0.364119, 0.0, 0.0}, {126.053993, -315.992767, 126.053993, 0.879067, -0.307666, 0.364119, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, 0.879067, -0.307666, 0.364119, 0.0, 0.0}, {0.000000, -315.992767, 178.266998, 0.364120, -0.307666, 0.879067, 0.0, 0.0}, {126.053993, -315.992767, 126.053993, 0.364120, -0.307666, 0.879067, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, 0.364120, -0.307666, 0.879067, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, 0.364119, -0.307665, 0.879067, 0.0, 0.0}, {0.000000, -315.992767, 178.266998, 0.364119, -0.307665, 0.879067, 0.0, 0.0}, {141.951996, -251.753784, 141.951996, 0.364119, -0.307665, 0.879067, 0.0, 0.0}, {-126.053993, -315.992767, 126.053993, -0.364120, -0.307665, 0.879067, 0.0, 0.0}, {0.000000, -315.992767, 178.266998, -0.364120, -0.307665, 0.879067, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, -0.364120, -0.307665, 0.879067, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, -0.364119, -0.307666, 0.879067, 0.0, 0.0}, {-126.053993, -315.992767, 126.053993, -0.364119, -0.307666, 0.879067, 0.0, 0.0}, {0.000000, -251.753784, 200.750000, -0.364119, -0.307666, 0.879067, 0.0, 0.0}, {-178.266998, -315.992767, 0.000000, -0.879067, -0.307666, 0.364120, 0.0, 0.0}, {-126.053993, -315.992767, 126.053993, -0.879067, -0.307666, 0.364120, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, -0.879067, -0.307666, 0.364120, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, -0.879067, -0.307665, 0.364119, 0.0, 0.0}, {-178.266998, -315.992767, 0.000000, -0.879067, -0.307665, 0.364119, 0.0, 0.0}, {-141.951996, -251.753784, 141.951996, -0.879067, -0.307665, 0.364119, 0.0, 0.0}, {-126.053993, -315.992767, -126.053993, -0.879067, -0.307665, -0.364120, 0.0, 0.0}, {-178.266998, -315.992767, 0.000000, -0.879067, -0.307665, -0.364120, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, -0.879067, -0.307665, -0.364120, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, -0.879067, -0.307666, -0.364119, 0.0, 0.0}, {-126.053993, -315.992767, -126.053993, -0.879067, -0.307666, -0.364119, 0.0, 0.0}, {-200.750000, -251.753784, 0.000000, -0.879067, -0.307666, -0.364119, 0.0, 0.0}, {0.000000, -315.992767, -178.266998, -0.364120, -0.307666, -0.879067, 0.0, 0.0}, {-126.053993, -315.992767, -126.053993, -0.364120, -0.307666, -0.879067, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, -0.364120, -0.307666, -0.879067, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, -0.364119, -0.307665, -0.879067, 0.0, 0.0}, {0.000000, -315.992767, -178.266998, -0.364119, -0.307665, -0.879067, 0.0, 0.0}, {-141.951996, -251.753784, -141.951996, -0.364119, -0.307665, -0.879067, 0.0, 0.0}, {126.053993, -315.992767, -126.053993, 0.364120, -0.307665, -0.879067, 0.0, 0.0}, {0.000000, -315.992767, -178.266998, 0.364120, -0.307665, -0.879067, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, 0.364120, -0.307665, -0.879067, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, 0.364119, -0.307666, -0.879067, 0.0, 0.0}, {126.053993, -315.992767, -126.053993, 0.364119, -0.307666, -0.879067, 0.0, 0.0}, {0.000000, -251.753784, -200.750000, 0.364119, -0.307666, -0.879067, 0.0, 0.0}, {178.266998, -315.992767, 0.000000, 0.879067, -0.307666, -0.364120, 0.0, 0.0}, {126.053993, -315.992767, -126.053993, 0.879067, -0.307666, -0.364120, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, 0.879067, -0.307666, -0.364120, 0.0, 0.0}, {200.750000, -251.753784, 0.000000, 0.879067, -0.307665, -0.364119, 0.0, 0.0}, {178.266998, -315.992767, 0.000000, 0.879067, -0.307665, -0.364119, 0.0, 0.0}, {141.951996, -251.753784, -141.951996, 0.879067, -0.307665, -0.364119, 0.0, 0.0}, {176.776978, -490.504761, 176.776978, 0.863697, 0.355022, 0.357753, 0.0, 0.0}, {250.000000, -490.504761, 0.000000, 0.863697, 0.355022, 0.357753, 0.0, 0.0}, {178.266998, -315.992767, 0.000000, 0.863697, 0.355022, 0.357753, 0.0, 0.0}, {126.053993, -315.992767, 126.053993, 0.863697, 0.355022, 0.357753, 0.0, 0.0}, {0.000000, -490.504761, 250.000000, 0.357753, 0.355022, 0.863697, 0.0, 0.0}, {176.776978, -490.504761, 176.776978, 0.357753, 0.355022, 0.863697, 0.0, 0.0}, {126.053993, -315.992767, 126.053993, 0.357753, 0.355022, 0.863697, 0.0, 0.0}, {0.000000, -315.992767, 178.266998, 0.357753, 0.355022, 0.863697, 0.0, 0.0}, {-176.776978, -490.504761, 176.776978, -0.357753, 0.355022, 0.863697, 0.0, 0.0}, {0.000000, -490.504761, 250.000000, -0.357753, 0.355022, 0.863697, 0.0, 0.0}, {0.000000, -315.992767, 178.266998, -0.357753, 0.355022, 0.863697, 0.0, 0.0}, {-126.053993, -315.992767, 126.053993, -0.357753, 0.355022, 0.863697, 0.0, 0.0}, {-250.000000, -490.504761, 0.000000, -0.863697, 0.355022, 0.357753, 0.0, 0.0}, {-176.776978, -490.504761, 176.776978, -0.863697, 0.355022, 0.357753, 0.0, 0.0}, {-126.053993, -315.992767, 126.053993, -0.863697, 0.355022, 0.357753, 0.0, 0.0}, {-178.266998, -315.992767, 0.000000, -0.863697, 0.355022, 0.357753, 0.0, 0.0}, {-176.776978, -490.504761, -176.776978, -0.863697, 0.355022, -0.357753, 0.0, 0.0}, {-250.000000, -490.504761, 0.000000, -0.863697, 0.355022, -0.357753, 0.0, 0.0}, {-178.266998, -315.992767, 0.000000, -0.863697, 0.355022, -0.357753, 0.0, 0.0}, {-126.053993, -315.992767, -126.053993, -0.863697, 0.355022, -0.357753, 0.0, 0.0}, {0.000000, -490.504761, -250.000000, -0.357753, 0.355022, -0.863697, 0.0, 0.0}, {-176.776978, -490.504761, -176.776978, -0.357753, 0.355022, -0.863697, 0.0, 0.0}, {-126.053993, -315.992767, -126.053993, -0.357753, 0.355022, -0.863697, 0.0, 0.0}, {0.000000, -315.992767, -178.266998, -0.357753, 0.355022, -0.863697, 0.0, 0.0}, {176.776978, -490.504761, -176.776978, 0.357753, 0.355022, -0.863697, 0.0, 0.0}, {0.000000, -490.504761, -250.000000, 0.357753, 0.355022, -0.863697, 0.0, 0.0}, {0.000000, -315.992767, -178.266998, 0.357753, 0.355022, -0.863697, 0.0, 0.0}, {126.053993, -315.992767, -126.053993, 0.357753, 0.355022, -0.863697, 0.0, 0.0}, {250.000000, -490.504761, 0.000000, 0.863697, 0.355022, -0.357753, 0.0, 0.0}, {176.776978, -490.504761, -176.776978, 0.863697, 0.355022, -0.357753, 0.0, 0.0}, {126.053993, -315.992767, -126.053993, 0.863697, 0.355022, -0.357753, 0.0, 0.0}, {178.266998, -315.992767, 0.000000, 0.863697, 0.355022, -0.357753, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.851083, -0.389080, 0.352526, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.851083, -0.389080, 0.352526, 0.0, 0.0}, {250.000000, -490.504761, 0.000000, 0.851083, -0.389080, 0.352526, 0.0, 0.0}, {176.776978, -490.504761, 176.776978, 0.851084, -0.389077, 0.352528, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.851084, -0.389077, 0.352528, 0.0, 0.0}, {250.000000, -490.504761, 0.000000, 0.851084, -0.389077, 0.352528, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, 0.352527, -0.389076, 0.851084, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.352527, -0.389076, 0.851084, 0.0, 0.0}, {176.776978, -490.504761, 176.776978, 0.352527, -0.389076, 0.851084, 0.0, 0.0}, {0.000000, -490.504761, 250.000000, 0.352528, -0.389080, 0.851082, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, 0.352528, -0.389080, 0.851082, 0.0, 0.0}, {176.776978, -490.504761, 176.776978, 0.352528, -0.389080, 0.851082, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.352526, -0.389080, 0.851083, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, -0.352526, -0.389080, 0.851083, 0.0, 0.0}, {0.000000, -490.504761, 250.000000, -0.352526, -0.389080, 0.851083, 0.0, 0.0}, {-176.776978, -490.504761, 176.776978, -0.352528, -0.389077, 0.851084, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.352528, -0.389077, 0.851084, 0.0, 0.0}, {0.000000, -490.504761, 250.000000, -0.352528, -0.389077, 0.851084, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.851084, -0.389076, 0.352527, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.851084, -0.389076, 0.352527, 0.0, 0.0}, {-176.776978, -490.504761, 176.776978, -0.851084, -0.389076, 0.352527, 0.0, 0.0}, {-250.000000, -490.504761, 0.000000, -0.851082, -0.389080, 0.352528, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.851082, -0.389080, 0.352528, 0.0, 0.0}, {-176.776978, -490.504761, 176.776978, -0.851082, -0.389080, 0.352528, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.851083, -0.389080, -0.352526, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.851083, -0.389080, -0.352526, 0.0, 0.0}, {-250.000000, -490.504761, 0.000000, -0.851083, -0.389080, -0.352526, 0.0, 0.0}, {-176.776978, -490.504761, -176.776978, -0.851084, -0.389077, -0.352528, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.851084, -0.389077, -0.352528, 0.0, 0.0}, {-250.000000, -490.504761, 0.000000, -0.851084, -0.389077, -0.352528, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, -0.352527, -0.389076, -0.851084, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.352527, -0.389076, -0.851084, 0.0, 0.0}, {-176.776978, -490.504761, -176.776978, -0.352527, -0.389076, -0.851084, 0.0, 0.0}, {0.000000, -490.504761, -250.000000, -0.352528, -0.389080, -0.851082, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, -0.352528, -0.389080, -0.851082, 0.0, 0.0}, {-176.776978, -490.504761, -176.776978, -0.352528, -0.389080, -0.851082, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.352526, -0.389080, -0.851083, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, 0.352526, -0.389080, -0.851083, 0.0, 0.0}, {0.000000, -490.504761, -250.000000, 0.352526, -0.389080, -0.851083, 0.0, 0.0}, {176.776978, -490.504761, -176.776978, 0.352528, -0.389077, -0.851084, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.352528, -0.389077, -0.851084, 0.0, 0.0}, {0.000000, -490.504761, -250.000000, 0.352528, -0.389077, -0.851084, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.851084, -0.389076, -0.352527, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.851084, -0.389076, -0.352527, 0.0, 0.0}, {176.776978, -490.504761, -176.776978, 0.851084, -0.389076, -0.352527, 0.0, 0.0}, {250.000000, -490.504761, 0.000000, 0.851082, -0.389080, -0.352528, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.851082, -0.389080, -0.352528, 0.0, 0.0}, {176.776978, -490.504761, -176.776978, 0.851082, -0.389080, -0.352528, 0.0, 0.0}, {167.692001, -606.133057, 167.692001, 0.830863, 0.437293, 0.344153, 0.0, 0.0}, {237.151993, -606.133057, 0.000000, 0.830863, 0.437293, 0.344153, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.830863, 0.437293, 0.344153, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.830867, 0.437286, 0.344153, 0.0, 0.0}, {167.692001, -606.133057, 167.692001, 0.830867, 0.437286, 0.344153, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.830867, 0.437286, 0.344153, 0.0, 0.0}, {0.000000, -606.133057, 237.151993, 0.344154, 0.437286, 0.830866, 0.0, 0.0}, {167.692001, -606.133057, 167.692001, 0.344154, 0.437286, 0.830866, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.344154, 0.437286, 0.830866, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, 0.344151, 0.437293, 0.830864, 0.0, 0.0}, {0.000000, -606.133057, 237.151993, 0.344151, 0.437293, 0.830864, 0.0, 0.0}, {152.550995, -565.448059, 152.550995, 0.344151, 0.437293, 0.830864, 0.0, 0.0}, {-167.692001, -606.133057, 167.692001, -0.344153, 0.437293, 0.830863, 0.0, 0.0}, {0.000000, -606.133057, 237.151993, -0.344153, 0.437293, 0.830863, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, -0.344153, 0.437293, 0.830863, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.344153, 0.437286, 0.830867, 0.0, 0.0}, {-167.692001, -606.133057, 167.692001, -0.344153, 0.437286, 0.830867, 0.0, 0.0}, {0.000000, -565.448059, 215.738998, -0.344153, 0.437286, 0.830867, 0.0, 0.0}, {-237.151993, -606.133057, 0.000000, -0.830866, 0.437286, 0.344154, 0.0, 0.0}, {-167.692001, -606.133057, 167.692001, -0.830866, 0.437286, 0.344154, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.830866, 0.437286, 0.344154, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.830864, 0.437293, 0.344151, 0.0, 0.0}, {-237.151993, -606.133057, 0.000000, -0.830864, 0.437293, 0.344151, 0.0, 0.0}, {-152.550995, -565.448059, 152.550995, -0.830864, 0.437293, 0.344151, 0.0, 0.0}, {-167.692001, -606.133057, -167.692001, -0.830863, 0.437293, -0.344153, 0.0, 0.0}, {-237.151993, -606.133057, 0.000000, -0.830863, 0.437293, -0.344153, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.830863, 0.437293, -0.344153, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.830867, 0.437286, -0.344153, 0.0, 0.0}, {-167.692001, -606.133057, -167.692001, -0.830867, 0.437286, -0.344153, 0.0, 0.0}, {-215.738998, -565.448059, 0.000000, -0.830867, 0.437286, -0.344153, 0.0, 0.0}, {0.000000, -606.133057, -237.151993, -0.344154, 0.437286, -0.830866, 0.0, 0.0}, {-167.692001, -606.133057, -167.692001, -0.344154, 0.437286, -0.830866, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.344154, 0.437286, -0.830866, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, -0.344151, 0.437293, -0.830864, 0.0, 0.0}, {0.000000, -606.133057, -237.151993, -0.344151, 0.437293, -0.830864, 0.0, 0.0}, {-152.550995, -565.448059, -152.550995, -0.344151, 0.437293, -0.830864, 0.0, 0.0}, {167.692001, -606.133057, -167.692001, 0.344153, 0.437293, -0.830863, 0.0, 0.0}, {0.000000, -606.133057, -237.151993, 0.344153, 0.437293, -0.830863, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, 0.344153, 0.437293, -0.830863, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.344153, 0.437286, -0.830867, 0.0, 0.0}, {167.692001, -606.133057, -167.692001, 0.344153, 0.437286, -0.830867, 0.0, 0.0}, {0.000000, -565.448059, -215.738998, 0.344153, 0.437286, -0.830867, 0.0, 0.0}, {237.151993, -606.133057, 0.000000, 0.830866, 0.437286, -0.344154, 0.0, 0.0}, {167.692001, -606.133057, -167.692001, 0.830866, 0.437286, -0.344154, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.830866, 0.437286, -0.344154, 0.0, 0.0}, {215.738998, -565.448059, 0.000000, 0.830864, 0.437293, -0.344151, 0.0, 0.0}, {237.151993, -606.133057, 0.000000, 0.830864, 0.437293, -0.344151, 0.0, 0.0}, {152.550995, -565.448059, -152.550995, 0.830864, 0.437293, -0.344151, 0.0, 0.0}, {86.686996, -607.203003, 86.686996, 0.009339, -0.999949, 0.003868, 0.0, 0.0}, {122.594002, -607.203003, 0.000000, 0.009339, -0.999949, 0.003868, 0.0, 0.0}, {237.151993, -606.133057, 0.000000, 0.009339, -0.999949, 0.003868, 0.0, 0.0}, {167.692001, -606.133057, 167.692001, 0.009339, -0.999949, 0.003868, 0.0, 0.0}, {0.000000, -607.203003, 122.594002, 0.003868, -0.999949, 0.009339, 0.0, 0.0}, {86.686996, -607.203003, 86.686996, 0.003868, -0.999949, 0.009339, 0.0, 0.0}, {167.692001, -606.133057, 167.692001, 0.003868, -0.999949, 0.009339, 0.0, 0.0}, {0.000000, -606.133057, 237.151993, 0.003868, -0.999949, 0.009339, 0.0, 0.0}, {-86.686996, -607.203003, 86.686996, -0.003868, -0.999949, 0.009339, 0.0, 0.0}, {0.000000, -607.203003, 122.594002, -0.003868, -0.999949, 0.009339, 0.0, 0.0}, {0.000000, -606.133057, 237.151993, -0.003868, -0.999949, 0.009339, 0.0, 0.0}, {-167.692001, -606.133057, 167.692001, -0.003868, -0.999949, 0.009339, 0.0, 0.0}, {-122.594002, -607.203003, 0.000000, -0.009339, -0.999949, 0.003868, 0.0, 0.0}, {-86.686996, -607.203003, 86.686996, -0.009339, -0.999949, 0.003868, 0.0, 0.0}, {-167.692001, -606.133057, 167.692001, -0.009339, -0.999949, 0.003868, 0.0, 0.0}, {-237.151993, -606.133057, 0.000000, -0.009339, -0.999949, 0.003868, 0.0, 0.0}, {-86.686996, -607.203003, -86.686996, -0.009339, -0.999949, -0.003868, 0.0, 0.0}, {-122.594002, -607.203003, 0.000000, -0.009339, -0.999949, -0.003868, 0.0, 0.0}, {-237.151993, -606.133057, 0.000000, -0.009339, -0.999949, -0.003868, 0.0, 0.0}, {-167.692001, -606.133057, -167.692001, -0.009339, -0.999949, -0.003868, 0.0, 0.0}, {0.000000, -607.203003, -122.594002, -0.003868, -0.999949, -0.009339, 0.0, 0.0}, {-86.686996, -607.203003, -86.686996, -0.003868, -0.999949, -0.009339, 0.0, 0.0}, {-167.692001, -606.133057, -167.692001, -0.003868, -0.999949, -0.009339, 0.0, 0.0}, {0.000000, -606.133057, -237.151993, -0.003868, -0.999949, -0.009339, 0.0, 0.0}, {86.686996, -607.203003, -86.686996, 0.003868, -0.999949, -0.009339, 0.0, 0.0}, {0.000000, -607.203003, -122.594002, 0.003868, -0.999949, -0.009339, 0.0, 0.0}, {0.000000, -606.133057, -237.151993, 0.003868, -0.999949, -0.009339, 0.0, 0.0}, {167.692001, -606.133057, -167.692001, 0.003868, -0.999949, -0.009339, 0.0, 0.0}, {122.594002, -607.203003, 0.000000, 0.009339, -0.999949, -0.003868, 0.0, 0.0}, {86.686996, -607.203003, -86.686996, 0.009339, -0.999949, -0.003868, 0.0, 0.0}, {167.692001, -606.133057, -167.692001, 0.009339, -0.999949, -0.003868, 0.0, 0.0}, {237.151993, -606.133057, 0.000000, 0.009339, -0.999949, -0.003868, 0.0, 0.0}, {86.686996, -607.203003, 86.686996, 0.026192, -0.999598, 0.010849, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, 0.026192, -0.999598, 0.010849, 0.0, 0.0}, {122.594002, -607.203003, 0.000000, 0.026192, -0.999598, 0.010849, 0.0, 0.0}, {0.000000, -607.203003, 122.594002, 0.010849, -0.999598, 0.026192, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, 0.010849, -0.999598, 0.026192, 0.0, 0.0}, {86.686996, -607.203003, 86.686996, 0.010849, -0.999598, 0.026192, 0.0, 0.0}, {-86.686996, -607.203003, 86.686996, -0.010849, -0.999598, 0.026192, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, -0.010849, -0.999598, 0.026192, 0.0, 0.0}, {0.000000, -607.203003, 122.594002, -0.010849, -0.999598, 0.026192, 0.0, 0.0}, {-122.594002, -607.203003, 0.000000, -0.026192, -0.999598, 0.010849, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, -0.026192, -0.999598, 0.010849, 0.0, 0.0}, {-86.686996, -607.203003, 86.686996, -0.026192, -0.999598, 0.010849, 0.0, 0.0}, {-86.686996, -607.203003, -86.686996, -0.026192, -0.999598, -0.010849, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, -0.026192, -0.999598, -0.010849, 0.0, 0.0}, {-122.594002, -607.203003, 0.000000, -0.026192, -0.999598, -0.010849, 0.0, 0.0}, {0.000000, -607.203003, -122.594002, -0.010849, -0.999598, -0.026192, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, -0.010849, -0.999598, -0.026192, 0.0, 0.0}, {-86.686996, -607.203003, -86.686996, -0.010849, -0.999598, -0.026192, 0.0, 0.0}, {86.686996, -607.203003, -86.686996, 0.010849, -0.999598, -0.026192, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, 0.010849, -0.999598, -0.026192, 0.0, 0.0}, {0.000000, -607.203003, -122.594002, 0.010849, -0.999598, -0.026192, 0.0, 0.0}, {122.594002, -607.203003, 0.000000, 0.026192, -0.999598, -0.010849, 0.0, 0.0}, {0.000000, -610.415283, 0.000000, 0.026192, -0.999598, -0.010849, 0.0, 0.0}, {86.686996, -607.203003, -86.686996, 0.026192, -0.999598, -0.010849, 0.0, 0.0}, {8.450900, 572.315247, -181.432999, 0.367067, 0.907214, -0.205487, 0.0, 0.0}, {8.259550, 572.385193, -181.466003, 0.367067, 0.907214, -0.205487, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.367067, 0.907214, -0.205487, 0.0, 0.0}, {8.561700, 572.285217, -181.365005, 0.367363, 0.908929, -0.197214, 0.0, 0.0}, {8.450900, 572.315247, -181.432999, 0.367363, 0.908929, -0.197214, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.367363, 0.908929, -0.197214, 0.0, 0.0}, {8.585200, 572.305237, -181.270004, 0.371507, 0.885664, -0.278535, 0.0, 0.0}, {8.561700, 572.285217, -181.365005, 0.371507, 0.885664, -0.278535, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.371507, 0.885664, -0.278535, 0.0, 0.0}, {8.514500, 572.365173, -181.156998, 0.365527, 0.897360, -0.247257, 0.0, 0.0}, {8.585200, 572.305237, -181.270004, 0.365527, 0.897360, -0.247257, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.365527, 0.897360, -0.247257, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.326991, 0.930460, -0.165288, 0.0, 0.0}, {8.514500, 572.365173, -181.156998, 0.326991, 0.930460, -0.165288, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.326991, 0.930460, -0.165288, 0.0, 0.0}, {5.802400, 573.475281, -180.399994, 0.393879, 0.918498, -0.034933, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.393879, 0.918498, -0.034933, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.393879, 0.918498, -0.034933, 0.0, 0.0}, {6.333650, 573.225281, -180.772995, 0.366501, 0.925228, -0.098132, 0.0, 0.0}, {5.802400, 573.475281, -180.399994, 0.366501, 0.925228, -0.098132, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.366501, 0.925228, -0.098132, 0.0, 0.0}, {6.825300, 573.005188, -181.056000, 0.386585, 0.921165, -0.044796, 0.0, 0.0}, {6.333650, 573.225281, -180.772995, 0.386585, 0.921165, -0.044796, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.386585, 0.921165, -0.044796, 0.0, 0.0}, {7.270549, 572.805237, -181.257980, 0.367412, 0.924123, -0.104910, 0.0, 0.0}, {6.825300, 573.005188, -181.056000, 0.367412, 0.924123, -0.104910, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.367412, 0.924123, -0.104910, 0.0, 0.0}, {7.662550, 572.635193, -181.386978, 0.372327, 0.924049, -0.086639, 0.0, 0.0}, {7.270549, 572.805237, -181.257980, 0.372327, 0.924049, -0.086639, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, 0.372327, 0.924049, -0.086639, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.482145, 0.518285, 0.706341, 0.0, 0.0}, {8.514500, 572.365173, -181.156998, 0.482145, 0.518285, 0.706341, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.482145, 0.518285, 0.706341, 0.0, 0.0}, {23.144199, 583.375183, -143.578995, 0.833363, 0.270168, -0.482198, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.833363, 0.270168, -0.482198, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.833363, 0.270168, -0.482198, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.018883, -0.867051, 0.497862, 0.0, 0.0}, {5.802400, 573.475281, -180.399994, 0.018883, -0.867051, 0.497862, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, 0.018883, -0.867051, 0.497862, 0.0, 0.0}, {23.144199, 583.375183, -143.578995, 0.456730, 0.778031, -0.431352, 0.0, 0.0}, {5.238400, 573.735168, -179.925995, 0.456730, 0.778031, -0.431352, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, 0.456730, 0.778031, -0.431352, 0.0, 0.0}, {5.802400, 573.475281, -180.399994, -0.418506, -0.908127, 0.012602, 0.0, 0.0}, {6.333650, 573.225281, -180.772995, -0.418506, -0.908127, 0.012602, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, -0.418506, -0.908127, 0.012602, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, -0.513733, 0.735046, -0.442478, 0.0, 0.0}, {5.802400, 573.475281, -180.399994, -0.513733, 0.735046, -0.442478, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, -0.513733, 0.735046, -0.442478, 0.0, 0.0}, {6.333650, 573.225281, -180.772995, -0.552522, -0.191018, -0.811315, 0.0, 0.0}, {6.825300, 573.005188, -181.056000, -0.552522, -0.191018, -0.811315, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.552522, -0.191018, -0.811315, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, -0.816337, 0.298385, -0.494530, 0.0, 0.0}, {6.333650, 573.225281, -180.772995, -0.816337, 0.298385, -0.494530, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.816337, 0.298385, -0.494530, 0.0, 0.0}, {6.825300, 573.005188, -181.056000, -0.442972, -0.084832, -0.892513, 0.0, 0.0}, {7.270549, 572.805237, -181.257980, -0.442972, -0.084832, -0.892513, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.442972, -0.084832, -0.892513, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.754160, 0.133071, -0.643066, 0.0, 0.0}, {6.825300, 573.005188, -181.056000, -0.754160, 0.133071, -0.643066, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.754160, 0.133071, -0.643066, 0.0, 0.0}, {7.270549, 572.805237, -181.257980, -0.342061, -0.078168, -0.936421, 0.0, 0.0}, {7.662550, 572.635193, -181.386978, -0.342061, -0.078168, -0.936421, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.342061, -0.078168, -0.936421, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.626330, 0.037754, -0.778643, 0.0, 0.0}, {7.270549, 572.805237, -181.257980, -0.626330, 0.037754, -0.778643, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.626330, 0.037754, -0.778643, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, -0.461437, -0.027726, -0.886740, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.461437, -0.027726, -0.886740, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.461437, -0.027726, -0.886740, 0.0, 0.0}, {7.662550, 572.635193, -181.386978, -0.242863, -0.114755, -0.963249, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, -0.242863, -0.114755, -0.963249, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.242863, -0.114755, -0.963249, 0.0, 0.0}, {8.259550, 572.385193, -181.466003, -0.219799, -0.083571, -0.971959, 0.0, 0.0}, {5.701450, 539.465271, -178.057007, -0.219799, -0.083571, -0.971959, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.219799, -0.083571, -0.971959, 0.0, 0.0}, {7.994450, 572.495178, -181.453979, -0.091132, -0.111473, -0.989580, 0.0, 0.0}, {8.259550, 572.385193, -181.466003, -0.091132, -0.111473, -0.989580, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.091132, -0.111473, -0.989580, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, 0.087275, -0.109318, -0.990168, 0.0, 0.0}, {5.701450, 539.465271, -178.057007, 0.087275, -0.109318, -0.990168, 0.0, 0.0}, {8.259550, 572.385193, -181.466003, 0.087275, -0.109318, -0.990168, 0.0, 0.0}, {8.450900, 572.315247, -181.432999, 0.130804, -0.107224, -0.985593, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, 0.130804, -0.107224, -0.985593, 0.0, 0.0}, {8.259550, 572.385193, -181.466003, 0.130804, -0.107224, -0.985593, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.392167, -0.091365, -0.915345, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, 0.392167, -0.091365, -0.915345, 0.0, 0.0}, {8.450900, 572.315247, -181.432999, 0.392167, -0.091365, -0.915345, 0.0, 0.0}, {8.561700, 572.285217, -181.365005, 0.509048, -0.065083, -0.858274, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.509048, -0.065083, -0.858274, 0.0, 0.0}, {8.450900, 572.315247, -181.432999, 0.509048, -0.065083, -0.858274, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.961440, 0.095403, -0.257936, 0.0, 0.0}, {8.561700, 572.285217, -181.365005, 0.961440, 0.095403, -0.257936, 0.0, 0.0}, {8.585200, 572.305237, -181.270004, 0.961440, 0.095403, -0.257936, 0.0, 0.0}, {16.071199, 544.425232, -174.072998, 0.622178, -0.034833, -0.782100, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.622178, -0.034833, -0.782100, 0.0, 0.0}, {8.585200, 572.305237, -181.270004, 0.622178, -0.034833, -0.782100, 0.0, 0.0}, {16.071199, 544.425232, -174.072998, 0.869170, 0.328742, 0.369422, 0.0, 0.0}, {8.585200, 572.305237, -181.270004, 0.869170, 0.328742, 0.369422, 0.0, 0.0}, {8.514500, 572.365173, -181.156998, 0.869170, 0.328742, 0.369422, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.761002, 0.041676, -0.647409, 0.0, 0.0}, {16.071199, 544.425232, -174.072998, 0.761002, 0.041676, -0.647409, 0.0, 0.0}, {8.514500, 572.365173, -181.156998, 0.761002, 0.041676, -0.647409, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.922271, 0.157694, -0.352914, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.922271, 0.157694, -0.352914, 0.0, 0.0}, {23.144199, 583.375183, -143.578995, 0.922271, 0.157694, -0.352914, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.905024, 0.154495, -0.396311, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.905024, 0.154495, -0.396311, 0.0, 0.0}, {23.144199, 583.375183, -143.578995, 0.905024, 0.154495, -0.396311, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.876952, 0.430962, 0.212668, 0.0, 0.0}, {23.144199, 583.375183, -143.578995, 0.876952, 0.430962, 0.212668, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, 0.876952, 0.430962, 0.212668, 0.0, 0.0}, {68.059502, 497.305237, -30.664101, 0.907018, 0.372898, -0.195618, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.907018, 0.372898, -0.195618, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, 0.907018, 0.372898, -0.195618, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, -0.787803, 0.369694, 0.492638, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, -0.787803, 0.369694, 0.492638, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, -0.787803, 0.369694, 0.492638, 0.0, 0.0}, {68.059502, 497.305237, -30.664101, 0.819625, 0.560322, 0.119393, 0.0, 0.0}, {3.159730, 610.415222, -115.967003, 0.819625, 0.560322, 0.119393, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, 0.819625, 0.560322, 0.119393, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, -0.984747, -0.150405, -0.087472, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.984747, -0.150405, -0.087472, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, -0.984747, -0.150405, -0.087472, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, 0.207422, 0.925379, 0.317252, 0.0, 0.0}, {-18.674601, 585.425232, -132.130005, 0.207422, 0.925379, 0.317252, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, 0.207422, 0.925379, 0.317252, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.898775, -0.252642, -0.358294, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.898775, -0.252642, -0.358294, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.898775, -0.252642, -0.358294, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, -0.407188, 0.909190, 0.087012, 0.0, 0.0}, {-10.906100, 553.295227, -164.339996, -0.407188, 0.909190, 0.087012, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.407188, 0.909190, 0.087012, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.759082, -0.324386, -0.564419, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.759082, -0.324386, -0.564419, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.759082, -0.324386, -0.564419, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.808039, 0.562703, -0.174467, 0.0, 0.0}, {-5.505000, 545.385193, -172.311005, -0.808039, 0.562703, -0.174467, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.808039, 0.562703, -0.174467, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.538377, -0.255146, -0.803150, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.538377, -0.255146, -0.803150, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.538377, -0.255146, -0.803150, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.873816, 0.349562, -0.338012, 0.0, 0.0}, {-1.907580, 542.265198, -175.356003, -0.873816, 0.349562, -0.338012, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.873816, 0.349562, -0.338012, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.238117, -0.187488, -0.952968, 0.0, 0.0}, {5.701450, 539.465271, -178.057007, -0.238117, -0.187488, -0.952968, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.238117, -0.187488, -0.952968, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.819413, 0.181146, -0.543827, 0.0, 0.0}, {1.874120, 540.285217, -177.261993, -0.819413, 0.181146, -0.543827, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.819413, 0.181146, -0.543827, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, 0.108031, -0.344112, -0.932693, 0.0, 0.0}, {5.701450, 539.465271, -178.057007, 0.108031, -0.344112, -0.932693, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, 0.108031, -0.344112, -0.932693, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, -0.575751, 0.042373, -0.816527, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.575751, 0.042373, -0.816527, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, -0.575751, 0.042373, -0.816527, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, -0.154517, -0.068166, -0.985636, 0.0, 0.0}, {7.036650, 446.915222, -168.968002, -0.154517, -0.068166, -0.985636, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, -0.154517, -0.068166, -0.985636, 0.0, 0.0}, {9.435850, 539.865173, -177.772003, 0.438930, -0.229186, -0.868801, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.438930, -0.229186, -0.868801, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, 0.438930, -0.229186, -0.868801, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.356222, -0.095602, -0.929498, 0.0, 0.0}, {7.036650, 446.915222, -168.968002, 0.356222, -0.095602, -0.929498, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.356222, -0.095602, -0.929498, 0.0, 0.0}, {16.071199, 544.425232, -174.072998, 0.619435, -0.029968, -0.784476, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.619435, -0.029968, -0.784476, 0.0, 0.0}, {12.938600, 541.505188, -176.434998, 0.619435, -0.029968, -0.784476, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.781011, 0.011093, -0.624419, 0.0, 0.0}, {16.071199, 544.425232, -174.072998, 0.781011, 0.011093, -0.624419, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.781011, 0.011093, -0.624419, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.721472, -0.000692, -0.692444, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.721472, -0.000692, -0.692444, 0.0, 0.0}, {18.694901, 548.665222, -170.716003, 0.721472, -0.000692, -0.692444, 0.0, 0.0}, {70.683502, 384.163208, -115.313995, 0.901475, 0.166676, -0.399453, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.901475, 0.166676, -0.399453, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.901475, 0.166676, -0.399453, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.874435, 0.178152, -0.451249, 0.0, 0.0}, {70.683502, 384.163208, -115.313995, 0.874435, 0.178152, -0.451249, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.874435, 0.178152, -0.451249, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.902149, 0.382762, -0.199048, 0.0, 0.0}, {64.348503, 474.115143, -92.077202, 0.902149, 0.382762, -0.199048, 0.0, 0.0}, {68.059502, 497.305237, -30.664101, 0.902149, 0.382762, -0.199048, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.861610, 0.392677, -0.321612, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.861610, 0.392677, -0.321612, 0.0, 0.0}, {68.059502, 497.305237, -30.664101, 0.861610, 0.392677, -0.321612, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.697737, 0.716301, 0.008679, 0.0, 0.0}, {68.059502, 497.305237, -30.664101, 0.697737, 0.716301, 0.008679, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, 0.697737, 0.716301, 0.008679, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.703375, 0.671944, -0.231851, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.703375, 0.671944, -0.231851, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, 0.703375, 0.671944, -0.231851, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.182247, 0.960328, 0.211083, 0.0, 0.0}, {46.251801, 517.905212, 22.366898, 0.182247, 0.960328, 0.211083, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, 0.182247, 0.960328, 0.211083, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, 0.333197, 0.939694, -0.077174, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.333197, 0.939694, -0.077174, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, 0.333197, 0.939694, -0.077174, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, -0.417829, 0.903035, 0.099737, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.417829, 0.903035, 0.099737, 0.0, 0.0}, {-45.660599, 502.085266, 183.246002, -0.417829, 0.903035, 0.099737, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, -0.063425, 0.984178, 0.165442, 0.0, 0.0}, {-25.262299, 527.085266, 42.346500, -0.063425, 0.984178, 0.165442, 0.0, 0.0}, {-45.660599, 502.085266, 183.246002, -0.063425, 0.984178, 0.165442, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.882415, 0.452078, -0.130261, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.882415, 0.452078, -0.130261, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.882415, 0.452078, -0.130261, 0.0, 0.0}, {-45.660599, 502.085266, 183.246002, -0.536161, 0.837064, 0.108886, 0.0, 0.0}, {-65.710999, 512.865173, 1.645430, -0.536161, 0.837064, 0.108886, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.536161, 0.837064, 0.108886, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.923412, 0.232522, -0.305359, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.923412, 0.232522, -0.305359, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.923412, 0.232522, -0.305359, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.831019, 0.545189, -0.110342, 0.0, 0.0}, {-68.195000, 491.165222, -56.838200, -0.831019, 0.545189, -0.110342, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.831019, 0.545189, -0.110342, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.857229, 0.046207, -0.512858, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.857229, 0.046207, -0.512858, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.857229, 0.046207, -0.512858, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.883249, 0.386867, -0.264961, 0.0, 0.0}, {-54.051994, 468.405212, -116.937996, -0.883249, 0.386867, -0.264961, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.883249, 0.386867, -0.264961, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.600932, -0.094516, -0.793692, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, -0.600932, -0.094516, -0.793692, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.600932, -0.094516, -0.793692, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.864588, 0.261378, -0.429149, 0.0, 0.0}, {-34.121799, 454.895203, -151.468002, -0.864588, 0.261378, -0.429149, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.864588, 0.261378, -0.429149, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, -0.156922, -0.099502, -0.982586, 0.0, 0.0}, {7.036650, 446.915222, -168.968002, -0.156922, -0.099502, -0.982586, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, -0.156922, -0.099502, -0.982586, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.681775, 0.033128, -0.730811, 0.0, 0.0}, {-14.299600, 448.865173, -165.757996, -0.681775, 0.033128, -0.730811, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, -0.681775, 0.033128, -0.730811, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, -0.026631, -0.058291, -0.997944, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, -0.026631, -0.058291, -0.997944, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, -0.026631, -0.058291, -0.997944, 0.0, 0.0}, {7.036650, 446.915222, -168.968002, 0.360182, -0.318927, -0.876672, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.360182, -0.318927, -0.876672, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, 0.360182, -0.318927, -0.876672, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, 0.732604, -0.079139, -0.676038, 0.0, 0.0}, {27.640400, 449.095245, -161.296005, 0.732604, -0.079139, -0.676038, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.732604, -0.079139, -0.676038, 0.0, 0.0}, {70.683502, 384.163208, -115.313995, 0.664541, -0.051931, -0.745445, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, 0.664541, -0.051931, -0.745445, 0.0, 0.0}, {45.264900, 455.435242, -142.938995, 0.664541, -0.051931, -0.745445, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.918815, 0.010779, -0.394540, 0.0, 0.0}, {70.683502, 384.163208, -115.313995, 0.918815, 0.010779, -0.394540, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.918815, 0.010779, -0.394540, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.918095, 0.011979, -0.396179, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.918095, 0.011979, -0.396179, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.918095, 0.011979, -0.396179, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.983150, 0.031252, -0.180111, 0.0, 0.0}, {99.358498, 414.675232, -47.701302, 0.983150, 0.031252, -0.180111, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.983150, 0.031252, -0.180111, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.978129, 0.046122, -0.202822, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.978129, 0.046122, -0.202822, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.978129, 0.046122, -0.202822, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.996319, 0.066814, 0.053712, 0.0, 0.0}, {113.509003, 452.225250, 36.055698, 0.996319, 0.066814, 0.053712, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.996319, 0.066814, 0.053712, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.995639, 0.093242, 0.003063, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.995639, 0.093242, 0.003063, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.995639, 0.093242, 0.003063, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.800470, 0.129776, 0.585154, 0.0, 0.0}, {107.004997, 486.115173, 114.542992, 0.800470, 0.129776, 0.585154, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, 0.800470, 0.129776, 0.585154, 0.0, 0.0}, {82.273003, 384.108215, 192.145996, 0.878425, 0.227228, 0.420402, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.878425, 0.227228, 0.420402, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, 0.878425, 0.227228, 0.420402, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, 0.213204, 0.146992, 0.965887, 0.0, 0.0}, {82.273003, 384.108215, 192.145996, 0.213204, 0.146992, 0.965887, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, 0.213204, 0.146992, 0.965887, 0.0, 0.0}, {-45.660599, 502.085266, 183.246002, 0.023556, 0.255967, 0.966399, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, 0.023556, 0.255967, 0.966399, 0.0, 0.0}, {56.238998, 509.395172, 178.826004, 0.023556, 0.255967, 0.966399, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.563411, 0.252345, 0.786696, 0.0, 0.0}, {-97.222496, 370.499176, 159.307007, -0.563411, 0.252345, 0.786696, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, -0.563411, 0.252345, 0.786696, 0.0, 0.0}, {-45.660599, 502.085266, 183.246002, -0.723309, -0.011136, 0.690435, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.723309, -0.011136, 0.690435, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, -0.723309, -0.011136, 0.690435, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.992453, 0.076931, 0.095491, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.992453, 0.076931, 0.095491, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.992453, 0.076931, 0.095491, 0.0, 0.0}, {-97.222496, 370.499176, 159.307007, -0.966932, 0.029285, 0.253347, 0.0, 0.0}, {-103.987999, 472.735168, 121.667999, -0.966932, 0.029285, 0.253347, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.966932, 0.029285, 0.253347, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.987485, 0.046908, -0.150577, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.987485, 0.046908, -0.150577, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.987485, 0.046908, -0.150577, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.998960, 0.005278, -0.045295, 0.0, 0.0}, {-113.872002, 441.905212, 43.779900, -0.998960, 0.005278, -0.045295, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.998960, 0.005278, -0.045295, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.928347, 0.037540, -0.369814, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.928347, 0.037540, -0.369814, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.928347, 0.037540, -0.369814, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.968180, -0.015988, -0.249745, 0.0, 0.0}, {-102.413002, 409.735229, -41.389801, -0.968180, -0.015988, -0.249745, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.968180, -0.015988, -0.249745, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.675561, 0.060407, -0.734826, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, -0.675561, 0.060407, -0.734826, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.675561, 0.060407, -0.734826, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.844110, -0.072851, -0.531198, 0.0, 0.0}, {-75.492996, 383.446198, -111.636002, -0.844110, -0.072851, -0.531198, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.844110, -0.072851, -0.531198, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, -0.258152, 0.068080, -0.963703, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, -0.258152, 0.068080, -0.963703, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.258152, 0.068080, -0.963703, 0.0, 0.0}, {-29.881599, 366.680206, -154.947006, -0.027469, -0.226322, -0.973665, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, -0.027469, -0.226322, -0.973665, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.027469, -0.226322, -0.973665, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.630511, -0.075746, -0.772476, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, 0.630511, -0.075746, -0.772476, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, 0.630511, -0.075746, -0.772476, 0.0, 0.0}, {70.683502, 384.163208, -115.313995, 0.659990, -0.027756, -0.750762, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.659990, -0.027756, -0.750762, 0.0, 0.0}, {23.262400, 366.214233, -156.337997, 0.659990, -0.027756, -0.750762, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.917405, 0.006079, -0.397908, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.917405, 0.006079, -0.397908, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.917405, 0.006079, -0.397908, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.917969, 0.013267, -0.396431, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.917969, 0.013267, -0.396431, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.917969, 0.013267, -0.396431, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.983598, -0.070837, -0.165884, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.983598, -0.070837, -0.165884, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.983598, -0.070837, -0.165884, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.980964, -0.093917, -0.169966, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.980964, -0.093917, -0.169966, 0.0, 0.0}, {103.196999, 330.520203, -41.350498, 0.980964, -0.093917, -0.169966, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.972784, -0.214000, 0.088859, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.972784, -0.214000, 0.088859, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.972784, -0.214000, 0.088859, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.967353, -0.240384, 0.080271, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.967353, -0.240384, 0.080271, 0.0, 0.0}, {119.891998, 350.832214, 43.781601, 0.967353, -0.240384, 0.080271, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.754044, -0.432216, 0.494578, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.754044, -0.432216, 0.494578, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.754044, -0.432216, 0.494578, 0.0, 0.0}, {82.273003, 384.108215, 192.145996, 0.754026, -0.432363, 0.494476, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.754026, -0.432363, 0.494476, 0.0, 0.0}, {117.853989, 369.910217, 125.473999, 0.754026, -0.432363, 0.494476, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, 0.213252, -0.533886, 0.818223, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.213252, -0.533886, 0.818223, 0.0, 0.0}, {82.273003, 384.108215, 192.145996, 0.213252, -0.533886, 0.818223, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, 0.185146, -0.458590, 0.869147, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, 0.185146, -0.458590, 0.869147, 0.0, 0.0}, {82.273003, 384.108215, 192.145996, 0.185146, -0.458590, 0.869147, 0.0, 0.0}, {-97.222496, 370.499176, 159.307007, -0.443309, -0.319401, 0.837532, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.443309, -0.319401, 0.837532, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, -0.443309, -0.319401, 0.837532, 0.0, 0.0}, {-15.025300, 385.212250, 213.455002, -0.450851, -0.406261, 0.794786, 0.0, 0.0}, {-97.222496, 370.499176, 159.307007, -0.450851, -0.406261, 0.794786, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, -0.450851, -0.406261, 0.794786, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.943601, -0.131894, 0.303680, 0.0, 0.0}, {-113.600998, 322.631226, 82.587601, -0.943601, -0.131894, 0.303680, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.943601, -0.131894, 0.303680, 0.0, 0.0}, {-97.222496, 370.499176, 159.307007, -0.941718, -0.170381, 0.290064, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.941718, -0.170381, 0.290064, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.941718, -0.170381, 0.290064, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.998687, -0.035614, -0.036833, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.998687, -0.035614, -0.036833, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.998687, -0.035614, -0.036833, 0.0, 0.0}, {-113.600998, 322.631226, 82.587601, -0.996529, -0.082531, -0.010915, 0.0, 0.0}, {-116.341995, 354.995239, 88.126991, -0.996529, -0.082531, -0.010915, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.996529, -0.082531, -0.010915, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.966359, 0.019326, -0.256468, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.966359, 0.019326, -0.256468, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.966359, 0.019326, -0.256468, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.973204, -0.035868, -0.227130, 0.0, 0.0}, {-112.556000, 337.315247, 2.567440, -0.973204, -0.035868, -0.227130, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.973204, -0.035868, -0.227130, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.827337, 0.089788, -0.554483, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.827337, 0.089788, -0.554483, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.827337, 0.089788, -0.554483, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.862629, -0.019081, -0.505478, 0.0, 0.0}, {-91.665497, 321.018250, -77.375099, -0.862629, -0.019081, -0.505478, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.862629, -0.019081, -0.505478, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, -0.320924, 0.109001, -0.940812, 0.0, 0.0}, {9.902549, 277.795227, -159.903000, -0.320924, 0.109001, -0.940812, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.320924, 0.109001, -0.940812, 0.0, 0.0}, {-50.695000, 307.733215, -140.658005, -0.267413, -0.088665, -0.959494, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, -0.267413, -0.088665, -0.959494, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.267413, -0.088665, -0.959494, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.589646, -0.027631, -0.807189, 0.0, 0.0}, {9.902549, 277.795227, -159.903000, 0.589646, -0.027631, -0.807189, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, 0.589646, -0.027631, -0.807189, 0.0, 0.0}, {73.785500, 314.213196, -110.000992, 0.610320, 0.098318, -0.786030, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.610320, 0.098318, -0.786030, 0.0, 0.0}, {13.498600, 303.470215, -158.154999, 0.610320, 0.098318, -0.786030, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.918494, -0.008199, -0.395350, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.918494, -0.008199, -0.395350, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.918494, -0.008199, -0.395350, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.918193, -0.006854, -0.396074, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.918193, -0.006854, -0.396074, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.918193, -0.006854, -0.396074, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.980314, 0.049927, -0.191027, 0.0, 0.0}, {99.327499, 300.153198, -51.326900, 0.980314, 0.049927, -0.191027, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.980314, 0.049927, -0.191027, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.975318, 0.077262, -0.206847, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.975318, 0.077262, -0.206847, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.975318, 0.077262, -0.206847, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.988516, 0.150495, 0.013702, 0.0, 0.0}, {113.908989, 317.048218, 27.918301, 0.988516, 0.150495, 0.013702, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.988516, 0.150495, 0.013702, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.981863, 0.189065, -0.014128, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.981863, 0.189065, -0.014128, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.981863, 0.189065, -0.014128, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.851108, 0.336540, 0.402934, 0.0, 0.0}, {110.417999, 333.001221, 104.556000, 0.851108, 0.336540, 0.402934, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.851108, 0.336540, 0.402934, 0.0, 0.0}, {86.832001, 309.681213, 185.800003, 0.846896, 0.428258, 0.315217, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.846896, 0.428258, 0.315217, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.846896, 0.428258, 0.315217, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, 0.321661, 0.499009, 0.804689, 0.0, 0.0}, {86.832001, 309.681213, 185.800003, 0.321661, 0.499009, 0.804689, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.321661, 0.499009, 0.804689, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, 0.209553, 0.656056, 0.725036, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, 0.209553, 0.656056, 0.725036, 0.0, 0.0}, {75.415497, 345.036224, 168.438995, 0.209553, 0.656056, 0.725036, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.337775, 0.704738, 0.623901, 0.0, 0.0}, {-92.957001, 306.707184, 180.227005, -0.337775, 0.704738, 0.623901, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, -0.337775, 0.704738, 0.623901, 0.0, 0.0}, {-15.838400, 346.700165, 193.307999, -0.501333, 0.436486, 0.747091, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.501333, 0.436486, 0.747091, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, -0.501333, 0.436486, 0.747091, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.903539, 0.382982, 0.192203, 0.0, 0.0}, {-113.600998, 322.631226, 82.587601, -0.903539, 0.382982, 0.192203, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.903539, 0.382982, 0.192203, 0.0, 0.0}, {-92.957001, 306.707184, 180.227005, -0.908281, 0.294264, 0.297380, 0.0, 0.0}, {-94.542000, 335.147217, 147.244003, -0.908281, 0.294264, 0.297380, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.908281, 0.294264, 0.297380, 0.0, 0.0}, {-113.600998, 322.631226, 82.587601, -0.976848, 0.204505, -0.062818, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.976848, 0.204505, -0.062818, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.976848, 0.204505, -0.062818, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.989072, 0.146324, -0.018066, 0.0, 0.0}, {-113.600998, 322.631226, 82.587601, -0.989072, 0.146324, -0.018066, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.989072, 0.146324, -0.018066, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.962999, 0.101989, -0.249460, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.962999, 0.101989, -0.249460, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.962999, 0.101989, -0.249460, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.978505, 0.029783, -0.204063, 0.0, 0.0}, {-111.518997, 308.051208, 2.745430, -0.978505, 0.029783, -0.204063, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.978505, 0.029783, -0.204063, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.844400, 0.124122, -0.521136, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.844400, 0.124122, -0.521136, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.844400, 0.124122, -0.521136, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.910696, -0.086317, -0.403957, 0.0, 0.0}, {-93.132500, 294.281250, -73.862297, -0.910696, -0.086317, -0.403957, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.910696, -0.086317, -0.403957, 0.0, 0.0}, {9.902549, 277.795227, -159.903000, -0.478360, 0.157961, -0.863840, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, -0.478360, 0.157961, -0.863840, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.478360, 0.157961, -0.863840, 0.0, 0.0}, {-55.951000, 282.658203, -136.876007, -0.317236, -0.509997, -0.799540, 0.0, 0.0}, {9.902549, 277.795227, -159.903000, -0.317236, -0.509997, -0.799540, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.317236, -0.509997, -0.799540, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, 0.593373, -0.218431, -0.774724, 0.0, 0.0}, {9.902549, 277.795227, -159.903000, 0.593373, -0.218431, -0.774724, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.593373, -0.218431, -0.774724, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.568747, -0.104773, -0.815812, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, 0.568747, -0.104773, -0.815812, 0.0, 0.0}, {71.806000, 286.647217, -114.986000, 0.568747, -0.104773, -0.815812, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.915167, 0.005097, -0.403043, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.915167, 0.005097, -0.403043, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.915167, 0.005097, -0.403043, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.916732, 0.016455, -0.399163, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.916732, 0.016455, -0.399163, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.916732, 0.016455, -0.399163, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.980626, -0.047866, -0.189952, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.980626, -0.047866, -0.189952, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.980626, -0.047866, -0.189952, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.981121, -0.043578, -0.188423, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.981121, -0.043578, -0.188423, 0.0, 0.0}, {102.025993, 272.907227, -44.599701, 0.981121, -0.043578, -0.188423, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.990364, -0.135139, 0.030280, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.990364, -0.135139, 0.030280, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.990364, -0.135139, 0.030280, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.991685, -0.123446, 0.036371, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.991685, -0.123446, 0.036371, 0.0, 0.0}, {118.457001, 286.269226, 37.866299, 0.991685, -0.123446, 0.036371, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.868295, -0.297273, 0.397106, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.868295, -0.297273, 0.397106, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.868295, -0.297273, 0.397106, 0.0, 0.0}, {86.832001, 309.681213, 185.800003, 0.865090, -0.258626, 0.429803, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.865090, -0.258626, 0.429803, 0.0, 0.0}, {117.114998, 299.270203, 118.583000, 0.865090, -0.258626, 0.429803, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, 0.296917, -0.504612, 0.810683, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.296917, -0.504612, 0.810683, 0.0, 0.0}, {86.832001, 309.681213, 185.800003, 0.296917, -0.504612, 0.810683, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, 0.286374, -0.480640, 0.828840, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, 0.286374, -0.480640, 0.828840, 0.0, 0.0}, {86.832001, 309.681213, 185.800003, 0.286374, -0.480640, 0.828840, 0.0, 0.0}, {-92.957001, 306.707184, 180.227005, -0.287625, -0.546727, 0.786359, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.287625, -0.546727, 0.786359, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, -0.287625, -0.546727, 0.786359, 0.0, 0.0}, {-4.859590, 313.824219, 219.882996, -0.296081, -0.576869, 0.761287, 0.0, 0.0}, {-92.957001, 306.707184, 180.227005, -0.296081, -0.576869, 0.761287, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, -0.296081, -0.576869, 0.761287, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.798071, -0.419215, 0.432829, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.798071, -0.419215, 0.432829, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.798071, -0.419215, 0.432829, 0.0, 0.0}, {-92.957001, 306.707184, 180.227005, -0.783371, -0.498891, 0.370725, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.783371, -0.498891, 0.370725, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.783371, -0.498891, 0.370725, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.977600, -0.196422, 0.075602, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.977600, -0.196422, 0.075602, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.977600, -0.196422, 0.075602, 0.0, 0.0}, {-118.018997, 296.606201, 113.676003, -0.959093, -0.279592, 0.044373, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.959093, -0.279592, 0.044373, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.959093, -0.279592, 0.044373, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.986393, -0.039524, -0.159584, 0.0, 0.0}, {-100.058998, 244.197205, -52.411201, -0.986393, -0.039524, -0.159584, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.986393, -0.039524, -0.159584, 0.0, 0.0}, {-118.302002, 284.590210, 31.846600, -0.975373, -0.126702, -0.180539, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.975373, -0.126702, -0.180539, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.975373, -0.126702, -0.180539, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.901054, 0.085448, -0.425206, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.901054, 0.085448, -0.425206, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.901054, 0.085448, -0.425206, 0.0, 0.0}, {-100.058998, 244.197205, -52.411201, -0.926508, -0.020028, -0.375743, 0.0, 0.0}, {-101.543999, 272.582214, -50.262501, -0.926508, -0.020028, -0.375743, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.926508, -0.020028, -0.375743, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, -0.531894, 0.142240, -0.834780, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, -0.531894, 0.142240, -0.834780, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.531894, 0.142240, -0.834780, 0.0, 0.0}, {-70.435501, 262.428223, -118.224998, -0.499669, -0.059178, -0.864193, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, -0.499669, -0.059178, -0.864193, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.499669, -0.059178, -0.864193, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.526474, -0.059248, -0.848124, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, 0.526474, -0.059248, -0.848124, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, 0.526474, -0.059248, -0.848124, 0.0, 0.0}, {73.415001, 262.351196, -110.744003, 0.557552, 0.082053, -0.826077, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.557552, 0.082053, -0.826077, 0.0, 0.0}, {2.009820, 255.386230, -159.630005, 0.557552, 0.082053, -0.826077, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.901988, 0.022783, -0.431159, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.901988, 0.022783, -0.431159, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.901988, 0.022783, -0.431159, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.913542, 0.033718, -0.405344, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.913542, 0.033718, -0.405344, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.913542, 0.033718, -0.405344, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.976976, -0.204907, -0.059426, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.976976, -0.204907, -0.059426, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.976976, -0.204907, -0.059426, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.960377, -0.223504, -0.166500, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.960377, -0.223504, -0.166500, 0.0, 0.0}, {98.601997, 239.441223, -53.842999, 0.960377, -0.223504, -0.166500, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.686244, -0.659972, 0.305787, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.686244, -0.659972, 0.305787, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.686244, -0.659972, 0.305787, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.769157, -0.633423, 0.084688, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.769157, -0.633423, 0.084688, 0.0, 0.0}, {113.696991, 247.824219, 21.972401, 0.769157, -0.633423, 0.084688, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.208131, -0.888842, 0.408218, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.208131, -0.888842, 0.408218, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.208131, -0.888842, 0.408218, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.351275, -0.899738, 0.258992, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.351275, -0.899738, 0.258992, 0.0, 0.0}, {112.597000, 256.439209, 96.398689, 0.351275, -0.899738, 0.258992, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, 0.031630, -0.932805, 0.358991, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.031630, -0.932805, 0.358991, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.031630, -0.932805, 0.358991, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, 0.066309, -0.941800, 0.329568, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, 0.066309, -0.941800, 0.329568, 0.0, 0.0}, {87.405502, 264.113220, 157.225998, 0.066309, -0.941800, 0.329568, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.034167, -0.919137, 0.392453, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.034167, -0.919137, 0.392453, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, -0.034167, -0.919137, 0.392453, 0.0, 0.0}, {5.718250, 270.145203, 190.899002, -0.110748, -0.934589, 0.338051, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.110748, -0.934589, 0.338051, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, -0.110748, -0.934589, 0.338051, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.290576, -0.857799, 0.423964, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.290576, -0.857799, 0.423964, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.290576, -0.857799, 0.423964, 0.0, 0.0}, {-78.766502, 268.587219, 158.913986, -0.431927, -0.850549, 0.300010, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.431927, -0.850549, 0.300010, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.431927, -0.850549, 0.300010, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.744487, -0.604315, 0.283801, 0.0, 0.0}, {-88.985489, 188.460205, -52.781399, -0.744487, -0.604315, 0.283801, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.744487, -0.604315, 0.283801, 0.0, 0.0}, {-108.712997, 262.103210, 97.417099, -0.820558, -0.560935, 0.109715, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.820558, -0.560935, 0.109715, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.820558, -0.560935, 0.109715, 0.0, 0.0}, {-100.058998, 244.197205, -52.411201, -0.978364, -0.193897, -0.072162, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.978364, -0.193897, -0.072162, 0.0, 0.0}, {-88.985489, 188.460205, -52.781399, -0.978364, -0.193897, -0.072162, 0.0, 0.0}, {-112.698990, 253.461243, 23.422300, -0.971556, -0.192104, -0.138472, 0.0, 0.0}, {-100.058998, 244.197205, -52.411201, -0.971556, -0.192104, -0.138472, 0.0, 0.0}, {-88.985489, 188.460205, -52.781399, -0.971556, -0.192104, -0.138472, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.870200, 0.015793, -0.492446, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.870200, 0.015793, -0.492446, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.870200, 0.015793, -0.492446, 0.0, 0.0}, {-100.058998, 244.197205, -52.411201, -0.923207, 0.040740, -0.382137, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.923207, 0.040740, -0.382137, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.923207, 0.040740, -0.382137, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, -0.318785, 0.036215, -0.947135, 0.0, 0.0}, {3.574330, 153.243225, -166.013000, -0.318785, 0.036215, -0.947135, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.318785, 0.036215, -0.947135, 0.0, 0.0}, {-74.990997, 236.375244, -113.806999, -0.517494, 0.225846, -0.825344, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, -0.517494, 0.225846, -0.825344, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.517494, 0.225846, -0.825344, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.432660, 0.097513, -0.896268, 0.0, 0.0}, {3.574330, 153.243225, -166.013000, 0.432660, 0.097513, -0.896268, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, 0.432660, 0.097513, -0.896268, 0.0, 0.0}, {71.821999, 233.026245, -114.731995, 0.508312, 0.193448, -0.839165, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.508312, 0.193448, -0.839165, 0.0, 0.0}, {-2.974820, 229.287231, -160.901016, 0.508312, 0.193448, -0.839165, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.906237, -0.010188, -0.422647, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.906237, -0.010188, -0.422647, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.906237, -0.010188, -0.422647, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.920070, -0.013323, -0.391527, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.920070, -0.013323, -0.391527, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.920070, -0.013323, -0.391527, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.988037, 0.054662, -0.144207, 0.0, 0.0}, {82.644501, 175.334229, -95.139801, 0.988037, 0.054662, -0.144207, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.988037, 0.054662, -0.144207, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.986827, 0.054406, -0.152359, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.986827, 0.054406, -0.152359, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.986827, 0.054406, -0.152359, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.985694, 0.142286, 0.090347, 0.0, 0.0}, {89.187500, 191.727234, -44.096401, 0.985694, 0.142286, 0.090347, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.985694, 0.142286, 0.090347, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.980946, 0.147631, 0.126296, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.980946, 0.147631, 0.126296, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.980946, 0.147631, 0.126296, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.851531, 0.274204, 0.446887, 0.0, 0.0}, {82.365997, 207.562195, 5.388580, 0.851531, 0.274204, 0.446887, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.851531, 0.274204, 0.446887, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, 0.676075, 0.307897, 0.669420, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.676075, 0.307897, 0.669420, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.676075, 0.307897, 0.669420, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, -0.011657, 0.381948, 0.924110, 0.0, 0.0}, {-55.488499, -110.935791, 201.720993, -0.011657, 0.381948, 0.924110, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, -0.011657, 0.381948, 0.924110, 0.0, 0.0}, {57.088501, 220.202209, 45.798397, 0.291935, 0.406872, 0.865581, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, 0.291935, 0.406872, 0.865581, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, 0.291935, 0.406872, 0.865581, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, -0.409149, 0.328686, 0.851213, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.409149, 0.328686, 0.851213, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.409149, 0.328686, 0.851213, 0.0, 0.0}, {-55.488499, -110.935791, 201.720993, -0.667330, 0.371345, 0.645580, 0.0, 0.0}, {-2.221530, 225.018250, 63.538101, -0.667330, 0.371345, 0.645580, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.667330, 0.371345, 0.645580, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.886185, 0.198790, 0.418521, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.886185, 0.198790, 0.418521, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.886185, 0.198790, 0.418521, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.967834, 0.205286, 0.145449, 0.0, 0.0}, {-59.855000, 216.703232, 39.046398, -0.967834, 0.205286, 0.145449, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.967834, 0.205286, 0.145449, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.991126, 0.075557, 0.109367, 0.0, 0.0}, {-88.985489, 188.460205, -52.781399, -0.991126, 0.075557, 0.109367, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.991126, 0.075557, 0.109367, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.986040, 0.110033, -0.124970, 0.0, 0.0}, {-82.234001, 203.875244, -2.246310, -0.986040, 0.110033, -0.124970, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.986040, 0.110033, -0.124970, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.924396, -0.008899, -0.381329, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.924396, -0.008899, -0.381329, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.924396, -0.008899, -0.381329, 0.0, 0.0}, {-88.985489, 188.460205, -52.781399, -0.986590, 0.061774, -0.151079, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.986590, 0.061774, -0.151079, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.986590, 0.061774, -0.151079, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.652436, -0.065283, -0.755027, 0.0, 0.0}, {-28.777201, -23.328796, -154.852997, -0.652436, -0.065283, -0.755027, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.652436, -0.065283, -0.755027, 0.0, 0.0}, {-82.251999, 173.175232, -103.002998, -0.872674, -0.002167, -0.488298, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.872674, -0.002167, -0.488298, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.872674, -0.002167, -0.488298, 0.0, 0.0}, {3.574330, 153.243225, -166.013000, 0.008660, -0.064656, -0.997870, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.008660, -0.064656, -0.997870, 0.0, 0.0}, {-28.777201, -23.328796, -154.852997, 0.008660, -0.064656, -0.997870, 0.0, 0.0}, {-58.875999, 160.319214, -144.723007, -0.322745, -0.000688, -0.946486, 0.0, 0.0}, {3.574330, 153.243225, -166.013000, -0.322745, -0.000688, -0.946486, 0.0, 0.0}, {-28.777201, -23.328796, -154.852997, -0.322745, -0.000688, -0.946486, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.447226, -0.005276, -0.894405, 0.0, 0.0}, {3.574330, 153.243225, -166.013000, 0.447226, -0.005276, -0.894405, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.447226, -0.005276, -0.894405, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.656924, -0.062927, -0.751326, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.656924, -0.062927, -0.751326, 0.0, 0.0}, {63.361500, 162.256226, -136.171005, 0.656924, -0.062927, -0.751326, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.915141, -0.038627, -0.401280, 0.0, 0.0}, {66.864998, -120.915771, -116.315002, 0.915141, -0.038627, -0.401280, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.915141, -0.038627, -0.401280, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.917687, -0.035121, -0.395748, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.917687, -0.035121, -0.395748, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.917687, -0.035121, -0.395748, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.982749, -0.049810, -0.178111, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.982749, -0.049810, -0.178111, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.982749, -0.049810, -0.178111, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.983070, -0.048952, -0.176567, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.983070, -0.048952, -0.176567, 0.0, 0.0}, {103.432991, -51.210751, -38.578800, 0.983070, -0.048952, -0.176567, 0.0, 0.0}, {100.329002, -245.950775, 124.471001, 0.993148, -0.063782, 0.097919, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.993148, -0.063782, 0.097919, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.993148, -0.063782, 0.097919, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.994519, -0.074037, 0.073825, 0.0, 0.0}, {100.329002, -245.950775, 124.471001, 0.994519, -0.074037, 0.073825, 0.0, 0.0}, {118.597000, -72.947754, 51.876099, 0.994519, -0.074037, 0.073825, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, 0.649851, -0.100048, 0.753448, 0.0, 0.0}, {100.329002, -245.950775, 124.471001, 0.649851, -0.100048, 0.753448, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.649851, -0.100048, 0.753448, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, 0.761824, -0.185672, 0.620604, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, 0.761824, -0.185672, 0.620604, 0.0, 0.0}, {110.865997, -93.253784, 135.658997, 0.761824, -0.185672, 0.620604, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.255428, -0.072115, 0.964135, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, -0.255428, -0.072115, 0.964135, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, -0.255428, -0.072115, 0.964135, 0.0, 0.0}, {-55.488499, -110.935791, 201.720993, -0.006809, -0.279831, 0.960025, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.006809, -0.279831, 0.960025, 0.0, 0.0}, {52.123997, -110.092773, 202.729996, -0.006809, -0.279831, 0.960025, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.931226, -0.144226, 0.334691, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.931226, -0.144226, 0.334691, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.931226, -0.144226, 0.334691, 0.0, 0.0}, {-55.488499, -110.935791, 201.720993, -0.774062, -0.073476, 0.628832, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.774062, -0.073476, 0.628832, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.774062, -0.073476, 0.628832, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.995165, -0.081299, -0.055114, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.995165, -0.081299, -0.055114, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.995165, -0.081299, -0.055114, 0.0, 0.0}, {-111.610992, -94.938782, 134.505997, -0.995105, -0.049837, 0.085340, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.995105, -0.049837, 0.085340, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.995105, -0.049837, 0.085340, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.958896, -0.061761, -0.276954, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.958896, -0.061761, -0.276954, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.958896, -0.061761, -0.276954, 0.0, 0.0}, {-119.891998, -74.161804, 50.078499, -0.986848, -0.027710, -0.159258, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.986848, -0.027710, -0.159258, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.986848, -0.027710, -0.159258, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.833122, -0.051779, -0.550660, 0.0, 0.0}, {-53.852501, -109.136780, -139.639008, -0.833122, -0.051779, -0.550660, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.833122, -0.051779, -0.550660, 0.0, 0.0}, {-105.925995, -51.729797, -40.365501, -0.925342, 0.001515, -0.379130, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.925342, 0.001515, -0.379130, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.925342, 0.001515, -0.379130, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, -0.488173, 0.158349, -0.858262, 0.0, 0.0}, {-53.852501, -109.136780, -139.639008, -0.488173, 0.158349, -0.858262, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.488173, 0.158349, -0.858262, 0.0, 0.0}, {-28.777201, -23.328796, -154.852997, -0.650605, -0.075995, -0.755604, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, -0.650605, -0.075995, -0.755604, 0.0, 0.0}, {-76.114998, -33.671753, -113.053001, -0.650605, -0.075995, -0.755604, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.178684, -0.008411, -0.983871, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.178684, -0.008411, -0.983871, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, 0.178684, -0.008411, -0.983871, 0.0, 0.0}, {-28.777201, -23.328796, -154.852997, 0.008836, 0.079247, -0.996816, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.008836, 0.079247, -0.996816, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, 0.008836, 0.079247, -0.996816, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.668489, 0.024110, -0.743331, 0.0, 0.0}, {24.747299, -23.397766, -154.384003, 0.668489, 0.024110, -0.743331, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.668489, 0.024110, -0.743331, 0.0, 0.0}, {66.864998, -120.915771, -116.315002, 0.695094, -0.007502, -0.718880, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.695094, -0.007502, -0.718880, 0.0, 0.0}, {72.565002, -33.671753, -111.713997, 0.695094, -0.007502, -0.718880, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.896005, -0.165483, -0.412056, 0.0, 0.0}, {41.119099, -191.952789, -143.770004, 0.896005, -0.165483, -0.412056, 0.0, 0.0}, {66.864998, -120.915771, -116.315002, 0.896005, -0.165483, -0.412056, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.872952, -0.176091, -0.454914, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.872952, -0.176091, -0.454914, 0.0, 0.0}, {66.864998, -120.915771, -116.315002, 0.872952, -0.176091, -0.454914, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, 0.904680, -0.359579, -0.228599, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.904680, -0.359579, -0.228599, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.904680, -0.359579, -0.228599, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.870921, -0.367872, -0.325831, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, 0.870921, -0.367872, -0.325831, 0.0, 0.0}, {97.033997, -158.427765, -43.902100, 0.870921, -0.367872, -0.325831, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, 0.673910, -0.736372, 0.060014, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, 0.673910, -0.736372, 0.060014, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.673910, -0.736372, 0.060014, 0.0, 0.0}, {100.329002, -245.950775, 124.471001, 0.689618, -0.675580, -0.260804, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, 0.689618, -0.675580, -0.260804, 0.0, 0.0}, {110.815994, -204.585770, 45.049900, 0.689618, -0.675580, -0.260804, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, -0.055171, -0.998391, 0.013093, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, -0.055171, -0.998391, 0.013093, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, -0.055171, -0.998391, 0.013093, 0.0, 0.0}, {100.329002, -245.950775, 124.471001, 0.407828, -0.912784, 0.022387, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, 0.407828, -0.912784, 0.022387, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, 0.407828, -0.912784, 0.022387, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.722624, -0.682457, -0.109846, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, -0.722624, -0.682457, -0.109846, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, -0.722624, -0.682457, -0.109846, 0.0, 0.0}, {26.990499, -277.268768, 183.567001, -0.136730, -0.989416, 0.048592, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.136730, -0.989416, 0.048592, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, -0.136730, -0.989416, 0.048592, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.901431, -0.329208, -0.281148, 0.0, 0.0}, {-55.924999, -213.330765, -102.385002, -0.901431, -0.329208, -0.281148, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, -0.901431, -0.329208, -0.281148, 0.0, 0.0}, {-77.352493, -264.158783, 156.904007, -0.643000, -0.757808, -0.110809, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.643000, -0.757808, -0.110809, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, -0.643000, -0.757808, -0.110809, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.892828, -0.106661, -0.437585, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, -0.892828, -0.106661, -0.437585, 0.0, 0.0}, {-55.924999, -213.330765, -102.385002, -0.892828, -0.106661, -0.437585, 0.0, 0.0}, {-109.345001, -226.377777, 84.170502, -0.823959, -0.497779, -0.270753, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.823959, -0.497779, -0.270753, 0.0, 0.0}, {-55.924999, -213.330765, -102.385002, -0.823959, -0.497779, -0.270753, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.730870, 0.080924, -0.677702, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, -0.730870, 0.080924, -0.677702, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, -0.730870, 0.080924, -0.677702, 0.0, 0.0}, {-108.233002, -180.436768, -3.676060, -0.847563, -0.349485, -0.399371, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.847563, -0.349485, -0.399371, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, -0.847563, -0.349485, -0.399371, 0.0, 0.0}, {-53.852501, -109.136780, -139.639008, -0.411734, 0.102151, -0.905561, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, -0.411734, 0.102151, -0.905561, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, -0.411734, 0.102151, -0.905561, 0.0, 0.0}, {-87.015503, -136.834778, -86.860497, -0.794120, -0.164211, -0.585157, 0.0, 0.0}, {-53.852501, -109.136780, -139.639008, -0.794120, -0.164211, -0.585157, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, -0.794120, -0.164211, -0.585157, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, 0.049268, 0.111577, -0.992534, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.049268, 0.111577, -0.992534, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, 0.049268, 0.111577, -0.992534, 0.0, 0.0}, {-53.852501, -109.136780, -139.639008, -0.470549, 0.050874, -0.880906, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, -0.470549, 0.050874, -0.880906, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, -0.470549, 0.050874, -0.880906, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.482452, 0.063345, -0.873629, 0.0, 0.0}, {27.031401, -183.569763, -160.029007, 0.482452, 0.063345, -0.873629, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.482452, 0.063345, -0.873629, 0.0, 0.0}, {-13.307500, -98.059784, -160.656998, 0.190935, 0.151852, -0.969786, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.190935, 0.151852, -0.969786, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.190935, 0.151852, -0.969786, 0.0, 0.0}, {41.119099, -191.952789, -143.770004, 0.764310, 0.035642, -0.643864, 0.0, 0.0}, {27.031401, -183.569763, -160.029007, 0.764310, 0.035642, -0.643864, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.764310, 0.035642, -0.643864, 0.0, 0.0}, {66.864998, -120.915771, -116.315002, 0.702204, 0.020557, -0.711679, 0.0, 0.0}, {41.119099, -191.952789, -143.770004, 0.702204, 0.020557, -0.711679, 0.0, 0.0}, {29.235399, -101.993767, -152.897003, 0.702204, 0.020557, -0.711679, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.001023, 0.801243, -0.598338, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, 0.001023, 0.801243, -0.598338, 0.0, 0.0}, {5.622550, -289.225769, -181.621002, 0.001023, 0.801243, -0.598338, 0.0, 0.0}, {41.119099, -191.952789, -143.770004, 0.895683, -0.166378, -0.412395, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.895683, -0.166378, -0.412395, 0.0, 0.0}, {5.622550, -289.225769, -181.621002, 0.895683, -0.166378, -0.412395, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, -0.541138, 0.840929, 0.002834, 0.0, 0.0}, {6.841350, -289.229767, -181.801987, -0.541138, 0.840929, 0.002834, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, -0.541138, 0.840929, 0.002834, 0.0, 0.0}, {61.237999, -219.961792, -88.773491, 0.892921, -0.381444, -0.239150, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, 0.892921, -0.381444, -0.239150, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, 0.892921, -0.381444, -0.239150, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, -0.203691, 0.978779, -0.022396, 0.0, 0.0}, {6.904150, -289.217773, -181.848999, -0.203691, 0.978779, -0.022396, 0.0, 0.0}, {6.841350, -289.229767, -181.801987, -0.203691, 0.978779, -0.022396, 0.0, 0.0}, {64.460503, -252.681763, -24.553101, 0.592126, -0.805294, -0.029799, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, 0.592126, -0.805294, -0.029799, 0.0, 0.0}, {6.841350, -289.229767, -181.801987, 0.592126, -0.805294, -0.029799, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, 0.966521, -0.020082, 0.255799, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, 0.966521, -0.020082, 0.255799, 0.0, 0.0}, {6.904150, -289.217773, -181.848999, 0.966521, -0.020082, 0.255799, 0.0, 0.0}, {30.551098, -279.519775, 26.920601, -0.060412, -0.996758, 0.053145, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, -0.060412, -0.996758, 0.053145, 0.0, 0.0}, {6.904150, -289.217773, -181.848999, -0.060412, -0.996758, 0.053145, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, 0.712092, -0.498979, 0.493908, 0.0, 0.0}, {6.865300, -289.329773, -181.882996, 0.712092, -0.498979, 0.493908, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, 0.712092, -0.498979, 0.493908, 0.0, 0.0}, {-45.389095, -275.455780, 16.818300, -0.693108, -0.708415, -0.133228, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, -0.693108, -0.708415, -0.133228, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, -0.693108, -0.708415, -0.133228, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, 0.633399, -0.602508, 0.485581, 0.0, 0.0}, {6.865300, -289.329773, -181.882996, 0.633399, -0.602508, 0.485581, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, 0.633399, -0.602508, 0.485581, 0.0, 0.0}, {-55.924999, -213.330765, -102.385002, -0.866800, -0.391066, -0.309394, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, -0.866800, -0.391066, -0.309394, 0.0, 0.0}, {-63.729000, -247.274780, -37.616901, -0.866800, -0.391066, -0.309394, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, 0.287337, -0.197849, 0.937173, 0.0, 0.0}, {6.646550, -289.500763, -181.852997, 0.287337, -0.197849, 0.937173, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, 0.287337, -0.197849, 0.937173, 0.0, 0.0}, {-55.924999, -213.330765, -102.385002, -0.855038, -0.208625, -0.474747, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, -0.855038, -0.208625, -0.474747, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, -0.855038, -0.208625, -0.474747, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, 0.238963, -0.111497, 0.964606, 0.0, 0.0}, {6.484450, -289.562775, -181.820007, 0.238963, -0.111497, 0.964606, 0.0, 0.0}, {6.646550, -289.500763, -181.852997, 0.238963, -0.111497, 0.964606, 0.0, 0.0}, {-36.622299, -189.725769, -147.522995, -0.696883, -0.056207, -0.714979, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, -0.696883, -0.056207, -0.714979, 0.0, 0.0}, {6.646550, -289.500763, -181.852997, -0.696883, -0.056207, -0.714979, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, 0.220287, -0.084999, 0.971725, 0.0, 0.0}, {6.295100, -289.584778, -181.779007, 0.220287, -0.084999, 0.971725, 0.0, 0.0}, {6.484450, -289.562775, -181.820007, 0.220287, -0.084999, 0.971725, 0.0, 0.0}, {-22.047800, -182.088776, -162.328995, -0.405117, 0.057923, -0.912428, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, -0.405117, 0.057923, -0.912428, 0.0, 0.0}, {6.484450, -289.562775, -181.820007, -0.405117, 0.057923, -0.912428, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, 0.211343, -0.086182, 0.973605, 0.0, 0.0}, {6.295100, -289.584778, -181.779007, 0.211343, -0.086182, 0.973605, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, 0.211343, -0.086182, 0.973605, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.049383, 0.116085, -0.992011, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, 0.049383, 0.116085, -0.992011, 0.0, 0.0}, {-5.769250, -178.565765, -169.332993, 0.049383, 0.116085, -0.992011, 0.0, 0.0}, {5.858250, -289.434784, -181.675995, 0.171338, -0.124152, 0.977358, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, 0.171338, -0.124152, 0.977358, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.171338, -0.124152, 0.977358, 0.0, 0.0}, {27.031401, -183.569763, -160.029007, 0.485639, 0.080851, -0.870413, 0.0, 0.0}, {5.858250, -289.434784, -181.675995, 0.485639, 0.080851, -0.870413, 0.0, 0.0}, {10.996200, -179.083771, -168.559006, 0.485639, 0.080851, -0.870413, 0.0, 0.0}, {5.622550, -289.225769, -181.621002, 0.043146, -0.208421, 0.977087, 0.0, 0.0}, {5.858250, -289.434784, -181.675995, 0.043146, -0.208421, 0.977087, 0.0, 0.0}, {27.031401, -183.569763, -160.029007, 0.043146, -0.208421, 0.977087, 0.0, 0.0}, {41.119099, -191.952789, -143.770004, 0.751205, -0.017369, -0.659841, 0.0, 0.0}, {5.622550, -289.225769, -181.621002, 0.751205, -0.017369, -0.659841, 0.0, 0.0}, {27.031401, -183.569763, -160.029007, 0.751205, -0.017369, -0.659841, 0.0, 0.0}, {6.484450, -289.562775, -181.820007, -0.217281, 0.053714, -0.974630, 0.0, 0.0}, {6.295100, -289.584778, -181.779007, -0.217281, 0.053714, -0.974630, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.217281, 0.053714, -0.974630, 0.0, 0.0}, {6.646550, -289.500763, -181.852997, -0.217462, 0.049872, -0.974794, 0.0, 0.0}, {6.484450, -289.562775, -181.820007, -0.217462, 0.049872, -0.974794, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.217462, 0.049872, -0.974794, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, -0.219662, 0.083485, -0.971997, 0.0, 0.0}, {6.646550, -289.500763, -181.852997, -0.219662, 0.083485, -0.971997, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.219662, 0.083485, -0.971997, 0.0, 0.0}, {6.865300, -289.329773, -181.882996, -0.229528, 0.146912, -0.962151, 0.0, 0.0}, {6.775450, -289.417786, -181.875000, -0.229528, 0.146912, -0.962151, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.229528, 0.146912, -0.962151, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, -0.255649, 0.262776, -0.930372, 0.0, 0.0}, {6.865300, -289.329773, -181.882996, -0.255649, 0.262776, -0.930372, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.255649, 0.262776, -0.930372, 0.0, 0.0}, {6.841350, -289.229767, -181.801987, -0.601052, 0.369619, -0.708603, 0.0, 0.0}, {6.904150, -289.217773, -181.848999, -0.601052, 0.369619, -0.708603, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, -0.601052, 0.369619, -0.708603, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, -0.613192, 0.345011, -0.710608, 0.0, 0.0}, {6.841350, -289.229767, -181.801987, -0.613192, 0.345011, -0.710608, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, -0.613192, 0.345011, -0.710608, 0.0, 0.0}, {5.858250, -289.434784, -181.675995, -0.088351, 0.159081, -0.983304, 0.0, 0.0}, {5.622550, -289.225769, -181.621002, -0.088351, 0.159081, -0.983304, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, -0.088351, 0.159081, -0.983304, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.101042, 0.257061, -0.961098, 0.0, 0.0}, {5.858250, -289.434784, -181.675995, -0.101042, 0.257061, -0.961098, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, -0.101042, 0.257061, -0.961098, 0.0, 0.0}, {6.910200, -289.257782, -181.875000, -0.348919, 0.927913, -0.131271, 0.0, 0.0}, {6.084400, -289.547791, -181.729996, -0.348919, 0.927913, -0.131271, 0.0, 0.0}, {6.715800, -289.310791, -181.732986, -0.348919, 0.927913, -0.131271, 0.0, 0.0} }; #define INX_TYPE GL_UNSIGNED_SHORT unsigned short indexes_knight[]={0, 1, 2,3, 4, 5,6, 7, 8, 9, 10, 11,12, 13, 14,15, 16, 17, 18, 19, 20,21, 22, 23,24, 25, 26, 27, 28, 29,30, 31, 32,33, 34, 35, 36, 37, 38,39, 40, 41,42, 43, 44, 45, 46, 47,48, 49, 50,51, 52, 53, 54, 55, 56,57, 58, 59,60, 61, 62, 63, 64, 65,66, 67, 68,69, 70, 71, 72, 73, 74,75, 76, 77,78, 79, 80, 81, 82, 83,84, 85, 86,87, 88, 89, 90, 91, 92,93, 94, 95,96, 97, 98, 99, 100, 101,102, 103, 104,105, 106, 107, 108, 109, 110,111, 112, 113,114, 115, 116, 117, 118, 119,120, 121, 122,123, 120, 122, 124, 125, 126,127, 124, 126,128, 129, 130, 131, 128, 130,132, 133, 134,135, 132, 134, 136, 137, 138,139, 136, 138,140, 141, 142, 143, 140, 142,144, 145, 146,147, 144, 146, 148, 149, 150,151, 148, 150,152, 153, 154, 155, 156, 157,158, 159, 160,161, 162, 163, 164, 165, 166,167, 168, 169,170, 171, 172, 173, 174, 175,176, 177, 178,179, 180, 181, 182, 183, 184,185, 186, 187,188, 189, 190, 191, 192, 193,194, 195, 196,197, 198, 199, 200, 201, 202,203, 204, 205,206, 207, 208, 209, 210, 211,212, 213, 214,215, 216, 217, 218, 219, 220,221, 222, 223,224, 225, 226, 227, 228, 229,230, 231, 232,233, 234, 235, 236, 237, 238,239, 240, 241,242, 243, 244, 245, 246, 247,248, 249, 250,251, 248, 250, 252, 253, 254,255, 252, 254,256, 257, 258, 259, 256, 258,260, 261, 262,263, 260, 262, 264, 265, 266,267, 264, 266,268, 269, 270, 271, 268, 270,272, 273, 274,275, 272, 274, 276, 277, 278,279, 276, 278,280, 281, 282, 283, 284, 285,286, 287, 288,289, 290, 291, 292, 293, 294,295, 296, 297,298, 299, 300, 301, 302, 303,304, 305, 306,307, 308, 309, 310, 311, 312,313, 314, 315,316, 317, 318, 319, 320, 321,322, 323, 324,325, 326, 327, 328, 329, 330,331, 332, 333,334, 335, 336, 337, 338, 339,340, 341, 342,343, 344, 345, 346, 347, 348,349, 350, 351,352, 353, 354, 355, 356, 357,358, 359, 360,361, 362, 363, 364, 365, 366,367, 368, 369,370, 371, 372, 373, 374, 375,376, 377, 378,379, 380, 381, 382, 383, 384,385, 386, 387,388, 389, 390, 391, 392, 393,394, 395, 396,397, 398, 399, 400, 401, 402,403, 404, 405,406, 407, 408, 409, 410, 411,412, 413, 414,415, 416, 417, 418, 419, 420,421, 422, 423,424, 425, 426, 427, 428, 429,430, 431, 432,433, 434, 435, 436, 437, 438,439, 440, 441,442, 443, 444, 445, 446, 447,448, 449, 450,451, 452, 453, 454, 455, 456,457, 458, 459,460, 461, 462, 463, 464, 465,466, 467, 468,469, 470, 471, 472, 473, 474,475, 476, 477,478, 479, 480, 481, 482, 483,484, 485, 486,487, 488, 489, 490, 491, 492,493, 494, 495,496, 497, 498, 499, 500, 501,502, 503, 504,505, 506, 507, 508, 509, 510,511, 512, 513,514, 515, 516, 517, 518, 519,520, 521, 522,523, 524, 525, 526, 527, 528,529, 530, 531,532, 533, 534, 535, 536, 537,538, 539, 540,541, 542, 543, 544, 545, 546,547, 548, 549,550, 551, 552, 553, 554, 555,556, 557, 558,559, 560, 561, 562, 563, 564,565, 566, 567,568, 569, 570, 571, 572, 573,574, 575, 576,577, 578, 579, 580, 581, 582,583, 584, 585,586, 587, 588, 589, 590, 591,592, 593, 594,595, 596, 597, 598, 599, 600,601, 602, 603,604, 605, 606, 607, 608, 609,610, 611, 612,613, 614, 615, 616, 617, 618,619, 620, 621,622, 623, 624, 625, 626, 627,628, 629, 630,631, 632, 633, 634, 635, 636,637, 638, 639,640, 641, 642, 643, 644, 645,646, 647, 648,649, 650, 651, 652, 653, 654,655, 656, 657,658, 659, 660, 661, 662, 663,664, 665, 666,667, 668, 669, 670, 671, 672,673, 674, 675,676, 677, 678, 679, 680, 681,682, 683, 684,685, 686, 687, 688, 689, 690,691, 692, 693,694, 695, 696, 697, 698, 699,700, 701, 702,703, 704, 705, 706, 707, 708,709, 710, 711,712, 713, 714, 715, 716, 717,718, 719, 720,721, 722, 723, 724, 725, 726,727, 728, 729,730, 731, 732, 733, 734, 735,736, 737, 738,739, 740, 741, 742, 743, 744,745, 746, 747,748, 749, 750, 751, 752, 753,754, 755, 756,757, 758, 759, 760, 761, 762,763, 764, 765,766, 767, 768, 769, 770, 771,772, 773, 774,775, 776, 777, 778, 779, 780,781, 782, 783,784, 785, 786, 787, 788, 789,790, 791, 792,793, 794, 795, 796, 797, 798,799, 800, 801,802, 803, 804, 805, 806, 807,808, 809, 810,811, 812, 813, 814, 815, 816,817, 818, 819,820, 821, 822, 823, 824, 825,826, 827, 828,829, 830, 831, 832, 833, 834,835, 836, 837,838, 839, 840, 841, 842, 843,844, 845, 846,847, 848, 849, 850, 851, 852,853, 854, 855,856, 857, 858, 859, 860, 861,862, 863, 864,865, 866, 867, 868, 869, 870,871, 872, 873,874, 875, 876, 877, 878, 879,880, 881, 882,883, 884, 885, 886, 887, 888,889, 890, 891,892, 893, 894, 895, 896, 897,898, 899, 900,901, 902, 903, 904, 905, 906,907, 908, 909,910, 911, 912, 913, 914, 915,916, 917, 918,919, 920, 921, 922, 923, 924,925, 926, 927,928, 929, 930, 931, 932, 933,934, 935, 936,937, 938, 939, 940, 941, 942,943, 944, 945,946, 947, 948, 949, 950, 951,952, 953, 954,955, 956, 957, 958, 959, 960,961, 962, 963,964, 965, 966, 967, 968, 969,970, 971, 972,973, 974, 975, 976, 977, 978,979, 980, 981,982, 983, 984, 985, 986, 987,988, 989, 990,991, 992, 993, 994, 995, 996,997, 998, 999,1000, 1001, 1002, 1003, 1004, 1005,1006, 1007, 1008,1009, 1010, 1011, 1012, 1013, 1014,1015, 1016, 1017,1018, 1019, 1020, 1021, 1022, 1023,1024, 1025, 1026,1027, 1028, 1029, 1030, 1031, 1032,1033, 1034, 1035,1036, 1037, 1038, 1039, 1040, 1041,1042, 1043, 1044,1045, 1046, 1047, 1048, 1049, 1050,1051, 1052, 1053,1054, 1055, 1056, 1057, 1058, 1059,1060, 1061, 1062,1063, 1064, 1065, 1066, 1067, 1068,1069, 1070, 1071,1072, 1073, 1074, 1075, 1076, 1077,1078, 1079, 1080,1081, 1082, 1083, 1084, 1085, 1086,1087, 1088, 1089,1090, 1091, 1092, 1093, 1094, 1095,1096, 1097, 1098,1099, 1100, 1101, 1102, 1103, 1104,1105, 1106, 1107,1108, 1109, 1110, 1111, 1112, 1113,1114, 1115, 1116,1117, 1118, 1119, 1120, 1121, 1122,1123, 1124, 1125,1126, 1127, 1128, 1129, 1130, 1131,1132, 1133, 1134,1135, 1136, 1137, 1138, 1139, 1140,1141, 1142, 1143,1144, 1145, 1146, 1147, 1148, 1149,1150, 1151, 1152,1153, 1154, 1155, 1156, 1157, 1158,1159, 1160, 1161,1162, 1163, 1164, 1165, 1166, 1167,1168, 1169, 1170,1171, 1172, 1173, 1174, 1175, 1176,1177, 1178, 1179,1180, 1181, 1182, 1183, 1184, 1185,1186, 1187, 1188,1189, 1190, 1191, 1192, 1193, 1194,1195, 1196, 1197,1198, 1199, 1200, 1201, 1202, 1203,1204, 1205, 1206,1207, 1208, 1209, 1210, 1211, 1212,1213, 1214, 1215,1216, 1217, 1218, 1219, 1220, 1221,1222, 1223, 1224,1225, 1226, 1227 }; Knight::Knight(){} Knight::~Knight(){} Knight::Knight(unsigned int pos_x, unsigned int pos_y, float color[3]) { this->pos_x=pos_x; this->pos_y=pos_y; for (unsigned int i=0;i<3;i++) this->color[i]=color[i]; } void Knight::render (float scale) { float x = this->get_pos_x(); float y = this->get_pos_y(); glPushMatrix(); glTranslated(y-1,-0.5,-x+1); glPushMatrix(); glScaled(scale,scale,scale); glColor3f(color[0],color[1],color[2]); for(int i=0; i< FACES_COUNT*3; i+=3){ glBegin(GL_TRIANGLES); glNormal3f(vertexs_knight[indexes_knight[i]].nx,vertexs_knight[indexes_knight[i]].ny,vertexs_knight[indexes_knight[i]].nz); glTexCoord2f(vertexs_knight[indexes_knight[i]].u,vertexs_knight[indexes_knight[i]].v); glVertex3f(vertexs_knight[indexes_knight[i]].x,vertexs_knight[indexes_knight[i]].y,vertexs_knight[indexes_knight[i]].z); glNormal3f(vertexs_knight[indexes_knight[i+1]].nx,vertexs_knight[indexes_knight[i+1]].ny,vertexs_knight[indexes_knight[i+1]].nz); glTexCoord2f(vertexs_knight[indexes_knight[i+1]].u,vertexs_knight[indexes_knight[i+1]].v); glVertex3f(vertexs_knight[indexes_knight[i+1]].x,vertexs_knight[indexes_knight[i+1]].y,vertexs_knight[indexes_knight[i+1]].z); glNormal3f(vertexs_knight[indexes_knight[i+2]].nx,vertexs_knight[indexes_knight[i+2]].ny,vertexs_knight[indexes_knight[i+2]].nz); glTexCoord2f(vertexs_knight[indexes_knight[i+2]].u,vertexs_knight[indexes_knight[i+2]].v); glVertex3f(vertexs_knight[indexes_knight[i+2]].x,vertexs_knight[indexes_knight[i+2]].y,vertexs_knight[indexes_knight[i+2]].z); glEnd(); } glPopMatrix(); glPopMatrix(); }
[ "[email protected]@8736d240-d46c-fd57-217c-2e9aadc87275" ]
[ [ [ 1, 1427 ] ] ]
fa6192580c2fc4964720fd2ab0a4af8189b16c73
de2b54a7b68b8fa5d9bdc85bc392ef97dadc4668
/TrackerOnFann21/Filters/ImageFilter.cpp
7f176f2618ffb5bf986ef43d28338067a9ce4332
[]
no_license
kumarasn/tracker
8c7c5b828ff93179078cea4db71f6894a404f223
a3e5d30a3518fe3836f007a81050720cef695345
refs/heads/master
2021-01-10T07:57:09.306936
2009-04-17T15:02:16
2009-04-17T15:02:16
55,039,695
0
0
null
null
null
null
UTF-8
C++
false
false
350
cpp
/* * ImageFilter.cpp * * Created on: 05-feb-2009 * Author: Timpa */ #include "ImageFilter.h" ImageFilter::ImageFilter() { // TODO Auto-generated constructor stub } ImageFilter::~ImageFilter() { // TODO Auto-generated destructor stub } IplImage *ImageFilter::applyFilter(IplImage* scr) { return scr; }
[ "latesisdegrado@048d8772-f3ab-11dd-a8e2-f7cb3c35fcff" ]
[ [ [ 1, 26 ] ] ]
d89033edb44806e6ff4460296bf132f4e70a6408
a1dc22c5f671b7859339aaef69b3461fad583d58
/include/CLibNIFalconDevice.h
a7e03dcace4b46519bb07f7b1b55762d13332083
[]
no_license
remis/chai3d
cd694053f55773ca6883a9ea30047e95e70a33e8
15323a24b97be73df6f7172bc0b41cc09631c94e
refs/heads/master
2021-01-18T08:46:44.253084
2009-05-11T21:51:22
2009-05-11T22:10:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,670
h
//=========================================================================== /* This file is part of the CHAI 3D visualization and haptics libraries. Copyright (C) 2003-2004 by CHAI 3D. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License("GPL") version 2 as published by the Free Software Foundation. For using the CHAI 3D libraries with software that can not be combined with the GNU GPL, and for taking advantage of the additional benefits of our support services, please contact CHAI 3D about acquiring a Professional Edition License. \author: <http://www.chai3d.org> \author: Stephen Sinclair \version 1.0 \date 05/2005 */ //=========================================================================== //--------------------------------------------------------------------------- #ifndef CLibNIFalconDeviceH #define CLibNIFalconDeviceH /*! \file CLibNIFalconDevice.h */ // Allow libnifalcon support to be compiled out #ifndef _DISABLE_LIBNIFALCON_DEVICE_SUPPORT //--------------------------------------------------------------------------- #include "CGenericDevice.h" //--------------------------------------------------------------------------- //=========================================================================== /*! \file CLibNIFalconDevice.h \class cLibNIFalconDevice \brief cLibNIFalconDevice describes an interface to the LibNIFalcon haptic device from MPB Technologies Inc. */ //=========================================================================== class cLibNIFalconDevice : public cGenericDevice { public: // CONSTRUCTOR & DESTRUCTOR: //! Constructor of cLibNIFalconDevice. cLibNIFalconDevice(); //! Destructor of cLibNIFalconDevice. virtual ~cLibNIFalconDevice(); // METHODS: //! Open connection to MPB device. virtual int open(); //! Close connection to MPB device. virtual int close(); //! Initialize MPB device. virtual int initialize(const bool a_resetEncoders=false); //! Set a command to the MPB device. virtual int command(int a_command, void* a_data); protected: //! Reference count used to control access to the dhd dll static int m_activeLibNIFalconDevices; void* m_device; }; #endif // #ifndef _DISABLE_LIBNIFALCON_DEVICE_SUPPORT //--------------------------------------------------------------------------- #endif //---------------------------------------------------------------------------
[ [ [ 1, 73 ] ] ]
9acf7cb5f9d0002d0d2b34db20aacfa124865a90
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/date_time/example/local_time/simple_time_zone.cpp
ecfe3671b555fb2d988daa7cacd21a15e527d60b
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
3,401
cpp
/* A simple example for using a custom_time_zone and a posix_time_zone. */ #include "boost/date_time/local_time/local_time.hpp" #include <iostream> int main() { using namespace boost; using namespace local_time; using namespace gregorian; using posix_time::time_duration; /***** custom_time_zone *****/ // create the dependent objects for a custom_time_zone time_zone_names tzn("Eastern Standard Time", "EST", "Eastern Daylight Time", "EDT"); time_duration utc_offset(-5,0,0); dst_adjustment_offsets adj_offsets(time_duration(1,0,0), time_duration(2,0,0), time_duration(2,0,0)); // rules for this zone are: // start on first Sunday of April at 2 am // end on last Sunday of October at 2 am // so we use a first_last_dst_rule first_day_of_the_week_in_month start_rule(Sunday, Apr); last_day_of_the_week_in_month end_rule(Sunday, Oct); shared_ptr<dst_calc_rule> nyc_rules(new first_last_dst_rule(start_rule, end_rule)); // create more dependent objects for a non-dst custom_time_zone time_zone_names tzn2("Mountain Standard Time", "MST", "", ""); // no dst means empty dst strings time_duration utc_offset2(-7,0,0); dst_adjustment_offsets adj_offsets2(time_duration(0,0,0), time_duration(0,0,0), time_duration(0,0,0)); // no dst means we need a null pointer to the rules shared_ptr<dst_calc_rule> phx_rules; // create the custom_time_zones time_zone_ptr nyc_1(new custom_time_zone(tzn, utc_offset, adj_offsets, nyc_rules)); time_zone_ptr phx_1(new custom_time_zone(tzn2, utc_offset2, adj_offsets2, phx_rules)); /***** posix_time_zone *****/ // create posix_time_zones that are the duplicates of the // custom_time_zones created above. See posix_time_zone documentation // for details on full zone names. std::string nyc_string, phx_string; nyc_string = "EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"; // nyc_string = "EST-05EDT,M4.1.0,M10.5.0"; // shorter when defaults used phx_string = "MST-07"; // no-dst time_zone_ptr nyc_2(new posix_time_zone(nyc_string)); time_zone_ptr phx_2(new posix_time_zone(phx_string)); /***** show the sets are equal *****/ std::cout << "The first zone is in daylight savings from:\n " << nyc_1->dst_local_start_time(2004) << " through " << nyc_1->dst_local_end_time(2004) << std::endl; std::cout << "The second zone is in daylight savings from:\n " << nyc_2->dst_local_start_time(2004) << " through " << nyc_2->dst_local_end_time(2004) << std::endl; std::cout << "The third zone (no daylight savings):\n " << phx_1->std_zone_abbrev() << " and " << phx_1->base_utc_offset() << std::endl; std::cout << "The fourth zone (no daylight savings):\n " << phx_2->std_zone_abbrev() << " and " << phx_2->base_utc_offset() << std::endl; return 0; } /* Copyright 2001-2005: CrystalClear Software, Inc * http://www.crystalclearsoftware.com * * Subject to the Boost Software License, Version 1.0. * (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0) */
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 86 ] ] ]
5f566194296c3d8843160061bbfdbe5903830962
925e7b0a9f5757cad97981b37c6af180c30b2f6e
/nntpServer/nntpServer/Utils/Configuration.cpp
01a4d650b0eb1c1c12c6bff72260748a21c62060
[]
no_license
jmg/nttp-server
08c2b6be2183b00989c8e4ea35dffaef3947385a
0308abe74e793fe0c16676e797ae16150566e1d6
refs/heads/master
2016-09-05T10:53:25.116857
2011-07-16T01:28:32
2011-07-16T01:28:32
2,739,107
0
0
null
null
null
null
UTF-8
C++
false
false
2,543
cpp
#ifndef CONFIG_CPP #define CONFIG_CPP #include "configuration.h" #include <string.h> #include <stdlib.h> #include <windows.h> #include <stdio.h> struct XmlFileClass { HANDLE f; char* Content; int Size; }; typedef struct XmlFileClass * XmlFile; char* MemReserveForChar(int len) { return (char*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1) * sizeof(char)); } char* MemExtendForChar(char* mem, int len) { return (char*) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem,sizeof(char) * (len+1)); } void MemFree(void* mem) { HeapFree(GetProcessHeap(), 0, mem); } int XmlFileGetFileSize(XmlFile xmlFile) { int Fsize = GetFileSize(xmlFile->f, NULL); return Fsize; } char* XmlFileReadFile(XmlFile xmlFile, int from, int to) { DWORD cant; DWORD len = to - from; LPVOID buffer = MemReserveForChar(len+2); int ret = ReadFile(xmlFile->f, buffer, len, &cant, NULL); return (char*)buffer; } char* XmlFileGetEndSection(const char* section) { int i; char* endSection = MemReserveForChar(strlen(section)+3); endSection[0] = '/'; for (i = 1; section[i - 1]; i++) endSection[i] = section[i - 1]; endSection[i] = '\0'; return endSection; } char* SubStractString(char* string, int begin, int end) { int i, j; char* SubStr = MemReserveForChar(end - begin + 2); for (i = begin, j = 0; i <= end; i++, j++) { SubStr[j] = string[i]; } SubStr[j] = '\0'; return SubStr; } char* XmlFileGetParam(XmlFile xmlFile, const char* param) { int len; char* paramValue; int BeginSection = strstr(xmlFile->Content, param) - xmlFile->Content + strlen(param) + 1; char* endParam = XmlFileGetEndSection(param); int EndSection = strstr(xmlFile->Content, endParam) - xmlFile->Content - 2; MemFree(endParam); if (BeginSection < 0 || EndSection < 0) return NULL; paramValue = SubStractString(xmlFile->Content, BeginSection, EndSection); return paramValue; } XmlFile NewXmlFile(char* path) { XmlFile xmlFile = (XmlFile) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct XmlFileClass)); xmlFile->f = CreateFileA(path, FILE_READ_ACCESS, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); xmlFile->Size = XmlFileGetFileSize(xmlFile); xmlFile->Content = XmlFileReadFile(xmlFile, 0, xmlFile->Size); return xmlFile; } void FreeXmlFile(XmlFile xmlFile) { CloseHandle(xmlFile->f); MemFree(xmlFile->Content); MemFree(xmlFile); } XmlFile LoadConfig(char* path) { return NewXmlFile(path); } #endif
[ "jmg.utn@208282a9-e914-21dd-f66b-6e6d9519d739" ]
[ [ [ 1, 98 ] ] ]
e7e4f2fbd5e02485087aab231074ac07a6ce439d
c440e6c62e060ee70b82fc07dfb9a93e4cc13370
/src/gui2/guis/gfilter.h
03ea887243b70e697fb2c00568ced9a0ebae6435
[]
no_license
BackupTheBerlios/pgrtsound-svn
2a3f2ae2afa4482f9eba906f932c30853c6fe771
d7cefe2129d20ec50a9e18943a850d0bb26852e1
refs/heads/master
2020-05-21T01:01:41.354611
2005-10-02T13:09:13
2005-10-02T13:09:13
40,748,578
0
0
null
null
null
null
UTF-8
C++
false
false
736
h
#ifndef GFILTER_H #define GFILTER_H #include "gui.h" #include "mygtkslider.h" #include "../../modules/filter12db.h" #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/button.h> #include <gtkmm/radiobutton.h> /** No description */ class GFilter : public Gui { public: GFilter( Module* mod ); ~GFilter(); virtual Gtk::Widget* GetGui(); REGISTER_GUI( Filter12dB::GetTypeStatic(), GFilter ) void OnApply(); protected: ParameterString* pFilerType; MyGtkSlider slFreq; Gtk::VBox mainBox; Gtk::HBox freqBox; Gtk::Label labelFreq; Gtk::Button buttonApply; Gtk::RadioButton::Group group; Gtk::RadioButton *rbLP, *rbHP; }; #endif // GFILTER_H
[ "ad4m@fa088095-53e8-0310-8a07-f9518708c3e6" ]
[ [ [ 1, 36 ] ] ]
8564cff074bf365048c41807d13c9bc88c0f0e65
b8c3d2d67e983bd996b76825f174bae1ba5741f2
/RTMP/utils/gil_2/libs/gil/opencv/unit_test/convert_color.cpp
1d4a399be6972cff7e4c5354e9a8412ea9c05e34
[]
no_license
wangscript007/rtmp-cpp
02172f7a209790afec4c00b8855d7a66b7834f23
3ec35590675560ac4fa9557ca7a5917c617d9999
refs/heads/master
2021-05-30T04:43:19.321113
2008-12-24T20:16:15
2008-12-24T20:16:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,249
cpp
#include "stdafx.h" #include <boost\test\unit_test.hpp> #include <boost\gil\extension\opencv\convert_color.hpp> #include <boost\gil\extension\io_new\png_all.hpp> using namespace boost::gil; using namespace boost::gil::opencv; BOOST_AUTO_TEST_CASE( test_convert_color ) { rgb32f_image_t src; read_and_convert_image( "..\\in\\in.png", src, png_tag() ); xyz32f_image_t dst( src.dimensions() ); cvtcolor( view( src ) , view( dst ) ); rgb32f_image_t out( src.dimensions() ); cvtcolor( view( dst ) , view( out ) ); write_view( "..\\out\\convert_color.png" , color_converted_view< rgb8_pixel_t >( view( out )) , png_tag() ); } BOOST_AUTO_TEST_CASE( test_convert_color_bit_aligned ) { bgr565_image_t src; rgba8_image_t dst( src.dimensions() ); /* // @todo: not implemented yet cvtcolor( view( src ) , view( dst ) ); */ } /* BOOST_AUTO_TEST_CASE( test_convert_color_using_xyz_colorspace ) { xyz32f_image_t src; rgb32f_image_t dst( src.dimensions() ); cvtcolor( view( src ) , view( dst ) ); } */
[ "fpelliccioni@71ea4c15-5055-0410-b3ce-cda77bae7b57" ]
[ [ [ 1, 57 ] ] ]
281fcfe44c0f752d0456f151ce62fb641406557c
b2b5c3694476d1631322a340c6ad9e5a9ec43688
/Baluchon/PatternDetectionService.cpp
9947cc2c2f832a18a8aa1a9fc5bae9c52e749002
[]
no_license
jpmn/rough-albatross
3c456ea23158e749b029b2112b2f82a7a5d1fb2b
eb2951062f6c954814f064a28ad7c7a4e7cc35b0
refs/heads/master
2016-09-05T12:18:01.227974
2010-12-19T08:03:25
2010-12-19T08:03:25
32,195,707
1
0
null
null
null
null
UTF-8
C++
false
false
7,848
cpp
#include "PatternDetectionService.h" #include "IServiceLayer.h" #include "CameraCaptureService.h" #include "Pattern.h" #include "DetectedPattern.h" #include "math.h" namespace baluchon { namespace core { namespace services { namespace patterndetection { PatternDetectionService::PatternDetectionService(void) { } PatternDetectionService::~PatternDetectionService(void) { } void PatternDetectionService::addPattern(IPattern* pattern) { mPatterns.push_back(new DetectedPattern(pattern)); } IPattern* PatternDetectionService::addPattern(char patternName[]) { IDetectedPattern *pattern = new DetectedPattern(new Pattern(patternName)); if(pattern != 0) { mPatterns.push_back(pattern); } return pattern; } vector<IDetectedPattern*> PatternDetectionService::getPatterns() { return mPatterns; } void PatternDetectionService::init(void) { mCaptureService= new CameraCaptureService(); mCaptureService = (ICaptureService*) mServiceLayer->findService(mCaptureService); mStorage = 0; mMat = cvCreateMat(3,3,CV_32FC1); mModelPoints[0].x = 0; mModelPoints[0].y = 0; mModelPoints[1].y = 0; mModelPoints[3].x = 0; } void PatternDetectionService::initDone(void) { } void PatternDetectionService::execute(void) { CvMat *rotation = cvCreateMat (1, 3, CV_32FC1); CvMat *translation = cvCreateMat (1 , 3, CV_32FC1); for(unsigned int i = 0; i < mPatterns.size(); i++) { mPatterns[i]->getImagePoints()->clear(); } mInitial = mCaptureService->getImage(); if( !mInitial ) { return; } mFrame = cvCreateImage(cvGetSize(mInitial), mInitial->depth, 1); cvCvtColor(mInitial, mFrame, CV_BGR2GRAY); cvThreshold(mFrame, mFrame, 100, 255, CV_THRESH_BINARY); if(mStorage == 0) { mStorage = cvCreateMemStorage(0); } else { cvClearMemStorage(mStorage); } mContours = 0; mResult = 0; cvFindContours(mFrame, mStorage, &mContours, sizeof(CvContour), CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0)); cvZero(mFrame); while(mContours != 0) { //approximates polygonal curves with desired precision mResult = cvApproxPoly(mContours, sizeof(CvContour), mStorage, CV_POLY_APPROX_DP, cvContourPerimeter(mContours)*0.02, 0); //if contour is convex, and area is big enough, and number of vertices is exactly 4, and has at least one child connected component, its GOOD if(cvCheckContourConvexity(mResult) && fabs(cvContourArea(mResult, CV_WHOLE_SEQ)) >= (200) && mResult->total == 4 && mContours->v_next != 0) { //only one child should be connected if(mContours->v_next->h_next == 0) { for(int j = 0; j < 4; j++) { mImagePoints[3-j].x = (float) ((CvPoint*) cvGetSeqElem(mResult, j))->x; mImagePoints[3-j].y = (float) ((CvPoint*) cvGetSeqElem(mResult, j))->y; } //child connected component mChildContours = mContours->v_next; mResult = cvApproxPoly(mChildContours, sizeof(CvContour), mStorage, CV_POLY_APPROX_DP, cvContourPerimeter(mChildContours)*0.02, 0); mSrcPts = cvCreateMat(1,mResult->total,CV_32FC2); mDstPts = cvCreateMat(1,mResult->total,CV_32FC2); for(int i = 0; i < mResult->total; i++) { mSrcPts->data.fl[i*2] = (float) (*((CvPoint*) cvGetSeqElem(mResult, i))).x; mSrcPts->data.fl[i*2+1] = (float) (*((CvPoint*) cvGetSeqElem(mResult, i))).y; } mModelPoints[1].x = 0; mModelPoints[2].x = 0; mModelPoints[2].y = 0; mModelPoints[3].y = 0; for(unsigned int i = 0; i < mPatterns.size(); i++) { if(mResult->total == mPatterns[i]->getPointCount()) { //optimization: if the size of the new pattern is more than 2% of the last one, we recalculate the transform if(mModelPoints[1].x == 0 || fabs(((float) (mPatterns[i]->getWidth() - mPatterns[i-1]->getWidth()))/((float) mPatterns[i]->getWidth())) + fabs(((float) (mPatterns[i]->getHeight() - mPatterns[i-1]->getHeight()))/((float) mPatterns[i]->getHeight())) > 0.02) { mModelPoints[1].x = (float) mPatterns[i]->getWidth(); mModelPoints[2].x = (float) mPatterns[i]->getWidth(); mModelPoints[2].y = (float) mPatterns[i]->getHeight(); mModelPoints[3].y = (float) mPatterns[i]->getHeight(); cvGetPerspectiveTransform(mImagePoints, mModelPoints, mMat); cvPerspectiveTransform(mSrcPts, mDstPts, mMat); } // pattern validity check bool valid = false; int j = 0; int k; int l; while(j < 4 && !valid) { k = 0; while(k < mResult->total && !valid) { l = 0; valid = true; while(l < mResult->total && valid) { // 30 pixels threshold value. if(sqrtf(pow(mDstPts->data.fl[((k+l+mResult->total) % mResult->total)*2] - mPatterns[i]->getSourcePointAt(l, j).x, 2) + pow(mDstPts->data.fl[((k+l+mResult->total) % mResult->total)*2+1] - mPatterns[i]->getSourcePointAt(l, j).y, 2)) > 30) { valid = false; } l++; } if(valid) { vector<CvPoint2D32f> tempPoints; vector<CvPoint2D32f> tempFramePoints; for(int m = 0; m < mResult->total; m++) { tempPoints.push_back(cvPoint2D32f((*((CvPoint*) cvGetSeqElem(mResult, ((k+m+mResult->total) % mResult->total)))).x, (*((CvPoint*) cvGetSeqElem(mResult, ((k+m+mResult->total) % mResult->total)))).y)); } mPatterns[i]->getImagePoints()->push_back(tempPoints); for(int m = 0; m < 4; m++) { tempFramePoints.push_back(mImagePoints[m]); } mPatterns[i]->getImageFramePoints()->push_back(tempFramePoints); } k++; } j++; } } } cvReleaseData(mSrcPts); cvReleaseData(mDstPts); } } mContours = mContours->h_next; } if(mFrame != 0) { cvReleaseImage(&mFrame); } } void PatternDetectionService::reset(void) { } void PatternDetectionService::dispose(void) { } }}}};
[ "[email protected]@bd4f47a5-da4e-a94a-6a47-2669d62bc1a5" ]
[ [ [ 1, 211 ] ] ]
d58d89cb7d96c2a516c38bbd9d8d5b1a1ffcb5ff
46885801c2459416e82517f93b7d452d78b33aff
/source/math/vector2d.cpp
48e71b2e4f127009ea5a6d3e7c5b5c7fa660468b
[]
no_license
libercv/smallengine
aabe92d4743789e8eab4a65d86d5a838ddc2aded
c1645fb99db213b419a81d4815a6645e1be89fe9
refs/heads/master
2021-01-10T08:09:05.991405
2009-04-01T14:52:59
2009-04-01T14:52:59
36,439,082
0
0
null
null
null
null
UTF-8
C++
false
false
1,091
cpp
////////////////////////////////////////////////////////////////////////////////////////// // Vector2d.cpp // Function definitions for 2d vector class // You may use this code however you wish, but if you do, please credit me and // provide a link to my website in a readme file or similar // Downloaded from: www.paulsprojects.net // Created: 8th November 2002 ////////////////////////////////////////////////////////////////////////////////////////// #include "vector2d.h" namespace Small { void Vector2d::Normalize() { float length; float scalefactor; length=GetLength(); if(length==1 || length==0) //return if length is 1 or 0 return; scalefactor = 1.0f/length; x *= scalefactor; y *= scalefactor; } Vector2d Vector2d::GetNormalized() const { Vector2d result(*this); result.Normalize(); return result; } Vector2d operator*(float scaleFactor, const Vector2d & rhs) { return rhs*scaleFactor; } bool Vector2d::operator==(const Vector2d & rhs) const { if(x==rhs.x && y==rhs.y) return true; return false; } }
[ "daviddq@3342a6a6-5e2d-0410-95e1-bf50fdd259a6" ]
[ [ [ 1, 51 ] ] ]
77d35aa6ef2c59d9f23e1a1ad4c11e71676bf015
3970f1a70df104f46443480d1ba86e246d8f3b22
/imebra/src/base/src/baseObject.cpp
e23a09bfa2e7af013d21f5b7740525ae69538a06
[]
no_license
zhan2016/vimrid
9f8ea8a6eb98153300e6f8c1264b2c042c23ee22
28ae31d57b77df883be3b869f6b64695df441edb
refs/heads/master
2021-01-20T16:24:36.247136
2009-07-28T18:32:31
2009-07-28T18:32:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,961
cpp
/* 0.0.46 Imebra: a C++ dicom library. Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 by Paolo Brandoli This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 as published by the Free Software Foundation. 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 AFFERO GENERAL PUBLIC LICENSE Version 3 for more details. You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 along with this program; If not, see http://www.gnu.org/licenses/ ------------------- If you want to use Imebra commercially then you have to buy the commercial license available at http://puntoexe.com After you buy the commercial license then you can use Imebra according to the terms described in the Imebra Commercial License Version 1. A copy of the Imebra Commercial License Version 1 is available in the documentation pages. Imebra is available at http://puntoexe.com The author can be contacted by email at [email protected] or by mail at the following address: Paolo Brandoli Preglov trg 6 1000 Ljubljana Slovenia */ /*! \file baseObject.cpp \brief Implementation of the baseObject class. */ #include "../include/baseObject.h" #include "../include/exception.h" #include <iostream> namespace puntoexe { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // basePtr // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Default constructor // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// basePtr::basePtr() : object(0) { } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Constructor with initialization // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// basePtr::basePtr(baseObject* pObject): object(pObject) { addRef(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Destructor // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// basePtr::~basePtr() { release(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Release // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void basePtr::release() { if(object != 0) { object->release(); object = 0; } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Increase reference counter // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void basePtr::addRef() { if(object != 0) { object->addRef(); } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // baseObject // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Default constructor // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// baseObject::baseObject():m_lockCounter(0), m_bValid(true), m_pExceptionsManager(exceptionsManager::getExceptionsManager()) { } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Constructs the object and set an external lock // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// baseObject::baseObject(ptr<baseObject> externalLock): m_externalLock(externalLock), m_lockCounter(0), m_bValid(true), m_pExceptionsManager(exceptionsManager::getExceptionsManager()) { } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Constructor with optional increase of the exceptions // manager's counter // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// baseObject::baseObject(bool bIncreaseExceptionsManager) : m_lockCounter(0), m_bValid(true) { if(bIncreaseExceptionsManager) { m_pExceptionsManager = exceptionsManager::getExceptionsManager(); } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Return the object used to lock this one // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// baseObject* baseObject::getExternalLock() { if(m_externalLock == 0) { return this; } return m_externalLock->getExternalLock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Return true if the object is referenced once. // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// bool baseObject::isReferencedOnce() { lockCriticalSection lockThis(&m_criticalSection); return m_lockCounter == 1; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Destructor // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// baseObject::~baseObject() { m_bValid = false; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Increase the references counter // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void baseObject::addRef() { if(this == 0) { return; } m_criticalSection.lock(); ++m_lockCounter; m_criticalSection.unlock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Decrease the references counter and delete the object // if the counter reaches 0 // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void baseObject::release() { // Calling release on a non-existing object. // Simply return /////////////////////////////////////////////////////////// if(this == 0) { return; } // Decrease the reference counter /////////////////////////////////////////////////////////// { lockCriticalSection lockThis(&m_criticalSection); if(--m_lockCounter != 0) { return; } } if(!preDelete()) { return; } delete this; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // This function is called by release() just before // the object is deleted. // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// bool baseObject::preDelete() { return true; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Lock the object // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void baseObject::lock() { if(this == 0) { return; } if(m_externalLock != 0) { m_externalLock->lock(); return; } m_criticalSection.lock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Unlock the object // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void baseObject::unlock() { if(this == 0) { return; } if(m_externalLock != 0) { m_externalLock->unlock(); return; } m_criticalSection.unlock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // lockObject // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Lock the specified object // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// lockObject::lockObject(baseObject* pObject) { m_pObject = pObject; if(m_pObject != 0) { m_pObject->lock(); } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Unlock the specified object // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// lockObject::~lockObject() { unlock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Unlock the specified object // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void lockObject::unlock() { if( m_pObject != 0) { m_pObject->unlock(); m_pObject = 0; } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // lockMultipleObject // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Lock the specified objects // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// lockMultipleObjects::lockMultipleObjects(tObjectsList* pObjectsList) { tCriticalSectionsList csList; for(tObjectsList::iterator scanObjects = pObjectsList->begin(); scanObjects != pObjectsList->end(); ++scanObjects) { if((*scanObjects) == 0) { continue; } ptr<baseObject> lockObject = (*scanObjects)->getExternalLock(); csList.push_back(&( (*scanObjects)->m_criticalSection) ); } m_pLockedCS.reset(puntoexe::lockMultipleCriticalSections(&csList)); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Unlock the locked objects // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// lockMultipleObjects::~lockMultipleObjects() { unlock(); } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Unlock the locked objects // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void lockMultipleObjects::unlock() { if(m_pLockedCS.get() == 0) { return; } puntoexe::unlockMultipleCriticalSections(m_pLockedCS.release()); } } // namespace puntoexe
[ [ [ 1, 529 ] ] ]