This commit is contained in:
2024-08-07 09:12:07 -04:00
parent ca445435a0
commit fdfadd5c7e
1021 changed files with 73601 additions and 0 deletions

BIN
bsptree/BSP16.DSW Normal file

Binary file not shown.

BIN
bsptree/BSP16.IDE Normal file

Binary file not shown.

BIN
bsptree/BSP32.DSW Normal file

Binary file not shown.

BIN
bsptree/BSP32.IDE Normal file

Binary file not shown.

BIN
bsptree/BSP32.OBR Normal file

Binary file not shown.

BIN
bsptree/BSP32.~DE Normal file

Binary file not shown.

BIN
bsptree/BSPRUN16.IDE Normal file

Binary file not shown.

BIN
bsptree/BSPRUN32.DSW Normal file

Binary file not shown.

BIN
bsptree/BSPRUN32.IDE Normal file

Binary file not shown.

15
bsptree/BSPTMPL.CPP Normal file
View File

@@ -0,0 +1,15 @@
#define _EXPAND_BLOCK_TEMPLATES_
#define _EXPAND_VECTOR_TEMPLATES_
#include <common/block.hpp>
#include <common/block.tpp>
#include <common/array.hpp>
#include <bsptree/btree.hpp>
#include <bsptree/btree.tpp>
#include <bsptree/rgbndx.hpp>
#include <bsptree/treendex.hpp>
typedef Array<RGBIndex> bspTreeRGBIndexType;
typedef Array<TreeNodeEx> bspTreeNodeExType;
typedef BTree<RGBIndex> bspTreeBTreeRGBIndexType;

330
bsptree/BSPTREE.BAK Normal file
View File

@@ -0,0 +1,330 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
!IF "$(CFG)" == ""
CFG=bsptree - Win32 Debug
!MESSAGE No configuration specified. Defaulting to bsptree - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "bsptree - Win32 Release" && "$(CFG)" !=\
"bsptree - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Bsptree.mak" CFG="bsptree - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bsptree - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "bsptree - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "bsptree - Win32 Debug"
CPP=cl.exe
!IF "$(CFG)" == "bsptree - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\Bsptree.lib"
CLEAN :
-@erase "$(INTDIR)\Bsptmpl.obj"
-@erase "$(INTDIR)\Rgbtree.obj"
-@erase "$(INTDIR)\Stdtmpl.obj"
-@erase "$(OUTDIR)\Bsptree.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
/Fp"$(INTDIR)/Bsptree.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
CPP_SBRS=.\.
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Bsptree.bsc"
BSC32_SBRS= \
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Bsptree.lib"
LIB32_OBJS= \
"$(INTDIR)\Bsptmpl.obj" \
"$(INTDIR)\Rgbtree.obj" \
"$(INTDIR)\Stdtmpl.obj"
"$(OUTDIR)\Bsptree.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
<<
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "msvcobj"
# PROP Intermediate_Dir "msvcobj"
# PROP Target_Dir ""
OUTDIR=.\msvcobj
INTDIR=.\msvcobj
ALL : "..\exe\msbsp.lib"
CLEAN :
-@erase "$(INTDIR)\Bsptmpl.obj"
-@erase "$(INTDIR)\Rgbtree.obj"
-@erase "$(INTDIR)\Stdtmpl.obj"
-@erase "..\exe\msbsp.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"c:\work\exe\msvc42.pch" /YX /c
CPP_PROJ=/nologo /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
"__FLAT__" /D "STRICT" /Fp"c:\work\exe\msvc42.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\msvcobj/
CPP_SBRS=.\.
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Bsptree.bsc"
BSC32_SBRS= \
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\exe\msbsp.lib"
LIB32_FLAGS=/nologo /out:"..\exe\msbsp.lib"
LIB32_OBJS= \
"$(INTDIR)\Bsptmpl.obj" \
"$(INTDIR)\Rgbtree.obj" \
"$(INTDIR)\Stdtmpl.obj"
"..\exe\msbsp.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "bsptree - Win32 Release"
# Name "bsptree - Win32 Debug"
!IF "$(CFG)" == "bsptree - Win32 Release"
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\Stdtmpl.cpp
!IF "$(CFG)" == "bsptree - Win32 Release"
DEP_CPP_STDTM=\
{$(INCLUDE)}"\.\Btree.hpp"\
{$(INCLUDE)}"\.\Btree.tpp"\
{$(INCLUDE)}"\.\Treenode.hpp"\
{$(INCLUDE)}"\.\Treenode.tpp"\
{$(INCLUDE)}"\Common\array.hpp"\
{$(INCLUDE)}"\Common\Assert.hpp"\
{$(INCLUDE)}"\Common\Block.hpp"\
{$(INCLUDE)}"\Common\Block.tpp"\
{$(INCLUDE)}"\Common\except.hpp"\
{$(INCLUDE)}"\Common\Fixup.hpp"\
{$(INCLUDE)}"\Common\Pointer.hpp"\
{$(INCLUDE)}"\Common\Pvector.hpp"\
{$(INCLUDE)}"\Common\Pvector.tpp"\
{$(INCLUDE)}"\Common\Stdlib.hpp"\
{$(INCLUDE)}"\Common\String.hpp"\
{$(INCLUDE)}"\Common\Types.hpp"\
{$(INCLUDE)}"\Common\Windows.hpp"\
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
DEP_CPP_STDTM=\
{$(INCLUDE)}"\.\Btree.hpp"\
{$(INCLUDE)}"\.\Btree.tpp"\
{$(INCLUDE)}"\.\Treenode.hpp"\
{$(INCLUDE)}"\.\Treenode.tpp"\
{$(INCLUDE)}"\Common\array.hpp"\
{$(INCLUDE)}"\Common\Assert.hpp"\
{$(INCLUDE)}"\Common\Block.hpp"\
{$(INCLUDE)}"\Common\Block.tpp"\
{$(INCLUDE)}"\Common\except.hpp"\
{$(INCLUDE)}"\Common\Fixup.hpp"\
{$(INCLUDE)}"\Common\Pointer.hpp"\
{$(INCLUDE)}"\Common\Pvector.hpp"\
{$(INCLUDE)}"\Common\Pvector.tpp"\
{$(INCLUDE)}"\Common\String.hpp"\
{$(INCLUDE)}"\Common\Types.hpp"\
{$(INCLUDE)}"\Common\Windows.hpp"\
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\Rgbtree.cpp
!IF "$(CFG)" == "bsptree - Win32 Release"
DEP_CPP_RGBTR=\
{$(INCLUDE)}"\.\Btree.hpp"\
{$(INCLUDE)}"\.\Btree.tpp"\
{$(INCLUDE)}"\.\Colorkey.hpp"\
{$(INCLUDE)}"\.\Rgbndx.hpp"\
{$(INCLUDE)}"\.\Rgbstack.hpp"\
{$(INCLUDE)}"\.\Rgbtree.hpp"\
{$(INCLUDE)}"\.\Treendex.hpp"\
{$(INCLUDE)}"\.\Treenode.hpp"\
{$(INCLUDE)}"\.\Treenode.tpp"\
{$(INCLUDE)}"\Common\array.hpp"\
{$(INCLUDE)}"\Common\Assert.hpp"\
{$(INCLUDE)}"\Common\Block.hpp"\
{$(INCLUDE)}"\Common\Block.tpp"\
{$(INCLUDE)}"\Common\except.hpp"\
{$(INCLUDE)}"\Common\Fixup.hpp"\
{$(INCLUDE)}"\Common\Palentry.hpp"\
{$(INCLUDE)}"\Common\Pointer.hpp"\
{$(INCLUDE)}"\Common\Pvector.hpp"\
{$(INCLUDE)}"\Common\Pvector.tpp"\
{$(INCLUDE)}"\Common\Rgbcolor.hpp"\
{$(INCLUDE)}"\Common\Types.hpp"\
{$(INCLUDE)}"\Common\Windows.hpp"\
"$(INTDIR)\Rgbtree.obj" : $(SOURCE) $(DEP_CPP_RGBTR) "$(INTDIR)"
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
DEP_CPP_RGBTR=\
{$(INCLUDE)}"\.\Btree.hpp"\
{$(INCLUDE)}"\.\Btree.tpp"\
{$(INCLUDE)}"\.\Colorkey.hpp"\
{$(INCLUDE)}"\.\Rgbndx.hpp"\
{$(INCLUDE)}"\.\Rgbstack.hpp"\
{$(INCLUDE)}"\.\Rgbtree.hpp"\
{$(INCLUDE)}"\.\Treendex.hpp"\
{$(INCLUDE)}"\.\Treenode.hpp"\
{$(INCLUDE)}"\.\Treenode.tpp"\
{$(INCLUDE)}"\Common\array.hpp"\
{$(INCLUDE)}"\Common\Assert.hpp"\
{$(INCLUDE)}"\Common\Block.hpp"\
{$(INCLUDE)}"\Common\Block.tpp"\
{$(INCLUDE)}"\Common\except.hpp"\
{$(INCLUDE)}"\Common\Fixup.hpp"\
{$(INCLUDE)}"\Common\Palentry.hpp"\
{$(INCLUDE)}"\Common\Pointer.hpp"\
{$(INCLUDE)}"\Common\Pvector.hpp"\
{$(INCLUDE)}"\Common\Pvector.tpp"\
{$(INCLUDE)}"\Common\Rgbcolor.hpp"\
{$(INCLUDE)}"\Common\Types.hpp"\
{$(INCLUDE)}"\Common\Windows.hpp"\
"$(INTDIR)\Rgbtree.obj" : $(SOURCE) $(DEP_CPP_RGBTR) "$(INTDIR)"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\Bsptmpl.cpp
DEP_CPP_BSPTM=\
{$(INCLUDE)}"\.\Btree.hpp"\
{$(INCLUDE)}"\.\Btree.tpp"\
{$(INCLUDE)}"\.\Colorkey.hpp"\
{$(INCLUDE)}"\.\Rgbndx.hpp"\
{$(INCLUDE)}"\.\Treendex.hpp"\
{$(INCLUDE)}"\.\Treenode.hpp"\
{$(INCLUDE)}"\.\Treenode.tpp"\
{$(INCLUDE)}"\Common\array.hpp"\
{$(INCLUDE)}"\Common\Assert.hpp"\
{$(INCLUDE)}"\Common\Block.hpp"\
{$(INCLUDE)}"\Common\Block.tpp"\
{$(INCLUDE)}"\Common\except.hpp"\
{$(INCLUDE)}"\Common\Fixup.hpp"\
{$(INCLUDE)}"\Common\Pointer.hpp"\
{$(INCLUDE)}"\Common\Pvector.hpp"\
{$(INCLUDE)}"\Common\Pvector.tpp"\
{$(INCLUDE)}"\Common\Rgbcolor.hpp"\
{$(INCLUDE)}"\Common\Types.hpp"\
{$(INCLUDE)}"\Common\Windows.hpp"\
"$(INTDIR)\Bsptmpl.obj" : $(SOURCE) $(DEP_CPP_BSPTM) "$(INTDIR)"
# End Source File
# End Target
# End Project
################################################################################

13
bsptree/BSPTREE.DEF Normal file
View File

@@ -0,0 +1,13 @@
NAME BSPTREE
DESCRIPTION 'BSPTREE'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE
HEAPSIZE 8191
STACKSIZE 24576
EXPORTS


29
bsptree/BSPTREE.DSW Normal file
View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "bsptree"=.\bsptree.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

32
bsptree/BSPTREE.PLG Normal file
View File

@@ -0,0 +1,32 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: bsptree - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP4E.tmp" with contents
[
/nologo /MTd /GX /Zi /Od /I "\work" /I "\parts" /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "_WINDOWS" /D "WIN32" /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c
"D:\work\BSPTREE\Bsptmpl.cpp"
"D:\work\BSPTREE\Rgbtree.cpp"
"D:\work\BSPTREE\Stdtmpl.cpp"
]
Creating command line "cl.exe @C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP4E.tmp"
Creating command line "link.exe -lib /nologo /out:"..\exe\msbsp.lib" .\msvcobj\Bsptmpl.obj .\msvcobj\Rgbtree.obj .\msvcobj\Stdtmpl.obj "
<h3>Output Window</h3>
Compiling...
Bsptmpl.cpp
Rgbtree.cpp
Stdtmpl.cpp
Generating Code...
Creating library...
<h3>Results</h3>
msbsp.lib - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

163
bsptree/BTREE.BAK Normal file
View File

@@ -0,0 +1,163 @@
#ifndef _BSPTREE_BTREE_HPP_
#define _BSPTREE_BTREE_HPP_
#ifndef _COMMON_ASSERT_HPP_
#include <common/assert.hpp>
#endif
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_PUREVECTOR_HPP_
#include <common/pvector.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_SMARTPOINTER_HPP_
#include <common/pointer.hpp>
#endif
#ifndef _BSPTREE_TREENODE_HPP_
#include <bsptree/treenode.hpp>
#endif
template <class T>
class BTree
{
public:
BTree(void);
virtual ~BTree();
DWORD leaves(void)const;
WORD insert(const T &someItem,DWORD dupsOk=FALSE);
WORD insert(PureVector<T> &vectorItems);
void remove(const T &someItem);
BOOL searchItem(T &someItem);
BOOL searchItem(T &someItem,SmartPointer<T> &nodeItem);
BOOL updateItem(T &someItem);
void treeItems(PureVector<T> &vectoredItems)const;
void treeItems(Block<T> &blockItems)const;
void remove(void);
protected:
virtual TreeNode<T> *insertNode(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &itemData);
virtual TreeNode<T> *insertNodeDuplicate(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &itemData);
virtual T *searchNode(TreeNode<T> *lpRootNode,const T &someItem);
virtual TreeNode<T> *deleteBTree(TreeNode<T> *lpRootNode);
TreeNode<T> *rootNode(void)const;
TreeNode<T> *rootNode(TreeNode<T> *lpRootNode);
private:
BTree(const BTree<T> &someBTree);
BTree<T> &operator=(const BTree<T> &someBTree);
void leaves(DWORD leaves);
void remove(const T &someItem,TreeNode<T> *pCurrNode,TreeNode<T> *pParentNode);
void retrieveNodes(TreeNode<T> *lpRootNode,PureVector<T> &vectoredNodes,WORD &vectorIndex)const;
void retrieveNodes(TreeNode<T> *lpRootNode,Block<T> &blockNodes)const;
TreeNode<T> *mlpRootNode;
DWORD mLeaves;
};
template <class T>
inline
BTree<T>::BTree(void)
: mlpRootNode(0), mLeaves(0)
{
}
template <class T>
inline
BTree<T>::BTree(const BTree<T> &/*someBTree*/)
: mlpRootNode(0), mLeaves(0)
{ // private implementation
}
template <class T>
inline
BTree<T>::~BTree()
{
remove();
}
template <class T>
inline
BTree<T> &BTree<T>::operator=(const BTree<T> &/*someBTree*/)
{ // private implementation
return *this;
}
template <class T>
inline
WORD BTree<T>::insert(const T &someItem,DWORD dupsOk)
{
DWORD itemCount(leaves());
if(dupsOk)
{
if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem))));
else leaves(leaves()+(0!=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem)));
}
else
{
if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNode(mlpRootNode,mlpRootNode,someItem))));
else leaves(leaves()+(0!=insertNode(mlpRootNode,mlpRootNode,someItem)));
}
return (!(itemCount==leaves()));
}
template <class T>
inline
BOOL BTree<T>::searchItem(T &someItem)
{
T *lpTempItem=(searchNode(mlpRootNode,someItem));
if(lpTempItem){someItem=*lpTempItem;return TRUE;}
else return FALSE;
}
template <class T>
inline
BOOL BTree<T>::searchItem(T &someItem,SmartPointer<T> &nodeItem)
{
T *lpTempItem=(searchNode(mlpRootNode,someItem));
if(lpTempItem){nodeItem=lpTempItem;return TRUE;}
return FALSE;
}
template <class T>
inline
void BTree<T>::remove(void)
{
mlpRootNode=deleteBTree(mlpRootNode);
leaves(0);
}
template <class T>
inline
TreeNode<T> *BTree<T>::rootNode(void)const
{
return mlpRootNode;
}
template <class T>
inline
TreeNode<T> *BTree<T>::rootNode(TreeNode<T> *lpRootNode)
{
remove();
return mlpRootNode=lpRootNode;
}
template <class T>
inline
DWORD BTree<T>::leaves(void)const
{
return mLeaves;
}
template <class T>
inline
void BTree<T>::leaves(DWORD leaves)
{
mLeaves=leaves;
}
#if defined(_MSC_VER)
#include <bsptree/btree.tpp>
#endif
#endif

212
bsptree/BTREE.TPP Normal file
View File

@@ -0,0 +1,212 @@
#ifndef _BSPTREE_BTREE_HPP_
#error BTREE.HPP must precede BTREE.TPP
#endif
#ifndef _BSPTREE_BTREE_TPP_
#define _BSPTREE_BTREE_TPP_
template <class T>
BTree<T> &BTree<T>::operator=(const BTree<T> &someBTree)
{
Block<T> items;
remove();
if(!someBTree.leaves())return *this;
someBTree.treeItems(items);
for(int index=0;index<items.size();index++)insert(items[index]);
return *this;
}
template <class T>
void BTree<T>::treeItems(Array<T> &arrayItems)const
{
DWORD itemIndex(0);
arrayItems.size(leaves());
retrieveNodes(mlpRootNode,arrayItems,itemIndex);
}
template <class T>
void BTree<T>::treeItems(Block<T> &blockItems)const
{
blockItems.remove();
retrieveNodes(mlpRootNode,blockItems);
}
template <class T>
void BTree<T>::retrieveNodes(TreeNode<T> *lpRootNode,Block<T> &blockNodes)const
{
if(!lpRootNode)return;
retrieveNodes(lpRootNode->leftNode(),blockNodes);
blockNodes.insert(&lpRootNode->item());
retrieveNodes(lpRootNode->rightNode(),blockNodes);
}
template <class T>
void BTree<T>::retrieveNodes(TreeNode<T> *lpRootNode,Array<T> &arrayNodes,DWORD &arrayIndex)const
{
if(!lpRootNode)return;
retrieveNodes(lpRootNode->leftNode(),arrayNodes,arrayIndex);
arrayNodes[arrayIndex++]=lpRootNode->item();
retrieveNodes(lpRootNode->rightNode(),arrayNodes,arrayIndex);
}
template <class T>
TreeNode<T> *BTree<T>::insertNode(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &someItem)
{
if(!lpCurrentNode)
{
lpCurrentNode=mlpLastNodeInserted=::new TreeNode<T>(someItem);
assert(0!=lpCurrentNode);
if(!lpRootNode)return lpCurrentNode;
if(someItem<lpRootNode->item())lpRootNode->leftNode(lpCurrentNode);
else lpRootNode->rightNode(lpCurrentNode);
return lpCurrentNode;
}
if(someItem<lpCurrentNode->item())return insertNode(lpCurrentNode,lpCurrentNode->leftNode(),someItem);
else if(lpCurrentNode->item()<someItem)return insertNode(lpCurrentNode,lpCurrentNode->rightNode(),someItem);
return 0;
}
template <class T>
TreeNode<T> *BTree<T>::insertNodeDuplicate(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &someItem)
{
if(!lpCurrentNode)
{
lpCurrentNode=mlpLastNodeInserted=::new TreeNode<T>(someItem);
assert(0!=lpCurrentNode);
if(!lpRootNode)return lpCurrentNode;
if(someItem<lpRootNode->item())lpRootNode->leftNode(lpCurrentNode);
else if(someItem==lpRootNode->item())lpRootNode->leftNode(lpCurrentNode);
else lpRootNode->rightNode(lpCurrentNode);
return lpCurrentNode;
}
if(someItem<lpCurrentNode->item())return insertNodeDuplicate(lpCurrentNode,lpCurrentNode->leftNode(),someItem);
else if(someItem==lpCurrentNode->item())return insertNodeDuplicate(lpCurrentNode,lpCurrentNode->leftNode(),someItem);
return insertNodeDuplicate(lpCurrentNode,lpCurrentNode->rightNode(),someItem);
}
template <class T>
T *BTree<T>::searchNode(TreeNode<T> *lpRootNode,const T &someItem)
{
while(lpRootNode&&!(someItem==lpRootNode->item()))
{
if(someItem<lpRootNode->item())lpRootNode=lpRootNode->leftNode();
else lpRootNode=lpRootNode->rightNode();
}
if(!lpRootNode)return 0;
return &lpRootNode->item();
}
template <class T>
bool BTree<T>::searchNodeDuplicate(TreeNode<T> *lpRootNode,const T &someItem,Block<SmartPointer<T> > &items)
{
items.remove();
while(lpRootNode&&!(someItem==lpRootNode->item()))
{
if(someItem<lpRootNode->item())lpRootNode=lpRootNode->leftNode();
else lpRootNode=lpRootNode->rightNode();
}
while(lpRootNode&&someItem==lpRootNode->item())
{
items.insert(&SmartPointer<T>(&lpRootNode->item()));
lpRootNode=lpRootNode->leftNode();
}
return items.size()?true:false;
}
template <class T>
TreeNode<T> *BTree<T>::deleteBTree(TreeNode<T> *lpRootNode)
{
if(!lpRootNode)return 0;
deleteBTree(lpRootNode->leftNode());
deleteBTree(lpRootNode->rightNode());
::delete lpRootNode;
return lpRootNode=0;
}
template <class T>
WORD BTree<T>::insert(Array<T> &vectorItems)
{
WORD size((WORD)vectorItems.size());
WORD insertCount(0);
if(!size)return 0;
for(LONG index=0;index<size;index++)
{
if(!mlpRootNode)insertCount=((0!=(mlpRootNode=insertNode(mlpRootNode,mlpRootNode,vectorItems[index])))?insertCount+1:insertCount);
else insertCount=((0!=insertNode(mlpRootNode,mlpRootNode,vectorItems[index]))?insertCount+1:insertCount);
}
leaves(leaves()+insertCount);
return insertCount;
}
template <class T>
void BTree<T>::remove(const T &someItem)
{
remove(someItem,mlpRootNode,0);
}
template <class T>
void BTree<T>::remove(const T &someItem,TreeNode<T> *pCurrNode,TreeNode<T> *pParentNode)
{
TreeNode<T> *pTmpNode;
if(!pCurrNode)return;
if(someItem<pCurrNode->item())remove(someItem,pCurrNode->leftNode(),pCurrNode);
else if(someItem>pCurrNode->item())remove(someItem,pCurrNode->rightNode(),pCurrNode);
else
{
if(!pCurrNode->leftNode()&&!pCurrNode->rightNode())
{
if(pCurrNode==mlpRootNode)mlpRootNode=0;
if(pParentNode)
{
if(pParentNode->leftNode()==pCurrNode)pParentNode->leftNode(0);
else pParentNode->rightNode(0);
}
}
else if(!pCurrNode->rightNode())
{
if(pParentNode)
{
if(pParentNode->leftNode()==pCurrNode)pParentNode->leftNode(pCurrNode->leftNode());
else pParentNode->rightNode(pCurrNode->leftNode());
}
else mlpRootNode=pCurrNode->leftNode();
}
else if(!pCurrNode->leftNode())
{
if(pParentNode)
{
if(pParentNode->leftNode()==pCurrNode)pParentNode->leftNode(pCurrNode->rightNode());
else pParentNode->rightNode(pCurrNode->rightNode());
}
else mlpRootNode=pCurrNode->rightNode();
}
else
{
TreeNode<T> *pCursorNode=0;
TreeNode<T> *pRootNode=0;
pTmpNode=pCurrNode->leftNode();
while(pTmpNode->rightNode()){pCursorNode=pTmpNode;pTmpNode=pTmpNode->rightNode();}
if(pCursorNode)pCursorNode->rightNode(0);
pRootNode=pTmpNode;
pRootNode->rightNode(pCurrNode->rightNode());
pCursorNode=0;
if(pTmpNode!=pCurrNode->leftNode())
{
while(pTmpNode->leftNode())pTmpNode=pTmpNode->leftNode();
pTmpNode->leftNode(pCurrNode->leftNode());
}
if(!pParentNode)mlpRootNode=pRootNode;
else
{
if(pParentNode->leftNode()==pCurrNode)pParentNode->leftNode(pCurrNode->leftNode());
else pParentNode->rightNode(pCurrNode->leftNode());
}
}
::delete pCurrNode;
leaves(leaves()-1);
}
}
#include <bsptree/treenode.tpp>
#endif

44
bsptree/Bintree.hpp Normal file
View File

@@ -0,0 +1,44 @@
#ifndef _BSPTREE_BINARYTREE_HPP_
#define _BSPTREE_BINARYTREE_HPP_
#ifndef _BSPTREE_BTREE_HPP_
#include <bsptree/btree.hpp>
#endif
template <class T>
class BinaryTree : public BTree<T>
{
public:
BinaryTree(void);
virtual ~BinaryTree();
BinaryTree<T> &operator=(const BinaryTree<T> &someBinaryTree);
TreeNode<T> *rootNode(void);
private:
};
template <class T>
inline
BinaryTree<T>::BinaryTree(void)
{
}
template <class T>
inline
BinaryTree<T>::~BinaryTree()
{
}
template <class T>
inline
BinaryTree<T> &BinaryTree<T>::operator=(const BinaryTree<T> &someBinaryTree)
{
(BTree<T>&)*this=(BTree<T>&)someBinaryTree;
return *this;
}
template <class T>
inline
TreeNode<T> *BinaryTree<T>::rootNode(void)
{
return BTree<T>::rootNode();
}
#endif

198
bsptree/Btree.hpp Normal file
View File

@@ -0,0 +1,198 @@
#ifndef _BSPTREE_BTREE_HPP_
#define _BSPTREE_BTREE_HPP_
#ifndef _COMMON_ASSERT_HPP_
#include <common/assert.hpp>
#endif
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _COMMON_SMARTPOINTER_HPP_
#include <common/pointer.hpp>
#endif
#ifndef _BSPTREE_TREENODE_HPP_
#include <bsptree/treenode.hpp>
#endif
template <class T>
class BTree
{
public:
BTree(void);
virtual ~BTree();
BTree<T> &operator=(const BTree<T> &someBTree);
DWORD leaves(void)const;
WORD insert(const T &someItem,DWORD dupsOk=FALSE);
WORD insert(Array<T> &vectorItems);
void remove(const T &someItem);
BOOL searchItem(T &someItem);
BOOL find(T &someItem);
BOOL searchItem(const T &someItem);
BOOL searchItem(const T &someItem,SmartPointer<T> &nodeItem);
BOOL searchItems(const T &someItem,Block<SmartPointer<T> > &nodeItems);
BOOL updateItem(T &someItem);
void treeItems(Block<T> &blockItems)const;
void treeItems(Array<T> &arrayItems)const;
BOOL lastItemInserted(SmartPointer<T> &lastItemInserted);
void remove(void);
protected:
virtual TreeNode<T> *insertNode(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &itemData);
virtual TreeNode<T> *insertNodeDuplicate(TreeNode<T> *lpRootNode,TreeNode<T> *lpCurrentNode,const T &itemData);
virtual T *searchNode(TreeNode<T> *lpRootNode,const T &someItem);
virtual bool searchNodeDuplicate(TreeNode<T> *lpRootNode,const T &someItem,Block<SmartPointer<T> > &items);
virtual TreeNode<T> *deleteBTree(TreeNode<T> *lpRootNode);
TreeNode<T> *rootNode(void)const;
TreeNode<T> *rootNode(TreeNode<T> *lpRootNode);
void leaves(DWORD leaves);
private:
BTree(const BTree<T> &someBTree);
void remove(const T &someItem,TreeNode<T> *pCurrNode,TreeNode<T> *pParentNode);
void retrieveNodes(TreeNode<T> *lpRootNode,Array<T> &arrayNodes,DWORD &arrayIndex)const;
void retrieveNodes(TreeNode<T> *lpRootNode,Block<T> &blockNodes)const;
TreeNode<T> *mlpRootNode;
TreeNode<T> *mlpLastNodeInserted;
DWORD mLeaves;
};
template <class T>
inline
BTree<T>::BTree(void)
: mlpRootNode(0), mlpLastNodeInserted(0), mLeaves(0)
{
}
template <class T>
inline
BTree<T>::BTree(const BTree<T> &/*someBTree*/)
: mlpRootNode(0), mlpLastNodeInserted(0), mLeaves(0)
{ // private implementation
}
template <class T>
inline
BTree<T>::~BTree()
{
remove();
}
template <class T>
inline
WORD BTree<T>::insert(const T &someItem,DWORD dupsOk)
{
DWORD itemCount(leaves());
if(dupsOk)
{
if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem))));
else leaves(leaves()+(0!=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem)));
}
else
{
if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNode(mlpRootNode,mlpRootNode,someItem))));
else leaves(leaves()+(0!=insertNode(mlpRootNode,mlpRootNode,someItem)));
}
return (!(itemCount==leaves()));
}
template <class T>
inline
BOOL BTree<T>::find(T &someItem)
{
return searchItem(someItem);
}
template <class T>
inline
BOOL BTree<T>::searchItem(T &someItem)
{
T *lpTempItem=(searchNode(mlpRootNode,someItem));
if(lpTempItem){someItem=*lpTempItem;return TRUE;}
else return FALSE;
}
template <class T>
inline
BOOL BTree<T>::searchItem(const T &someItem)
{
T *lpTempItem=(searchNode(mlpRootNode,someItem));
if(lpTempItem)return TRUE;
return FALSE;
}
template <class T>
inline
BOOL BTree<T>::searchItem(const T &someItem,SmartPointer<T> &nodeItem)
{
T *lpTempItem=(searchNode(mlpRootNode,someItem));
if(lpTempItem){nodeItem=lpTempItem;return TRUE;}
return FALSE;
}
template <class T>
inline
BOOL BTree<T>::searchItems(const T &someItem,Block<SmartPointer<T> > &nodeItems)
{
return searchNodeDuplicate(mlpRootNode,someItem,nodeItems);
}
template <class T>
inline
void BTree<T>::remove(void)
{
mlpRootNode=deleteBTree(mlpRootNode);
mlpLastNodeInserted=0;
leaves(0);
}
template <class T>
inline
TreeNode<T> *BTree<T>::rootNode(void)const
{
return mlpRootNode;
}
template <class T>
inline
TreeNode<T> *BTree<T>::rootNode(TreeNode<T> *lpRootNode)
{
remove();
return mlpRootNode=lpRootNode;
}
template <class T>
inline
BOOL BTree<T>::lastItemInserted(SmartPointer<T> &lastItemInserted)
{
if(!mlpLastNodeInserted)return FALSE;
lastItemInserted=&mlpLastNodeInserted->item();
return TRUE;
}
template <class T>
inline
DWORD BTree<T>::leaves(void)const
{
return mLeaves;
}
template <class T>
inline
void BTree<T>::leaves(DWORD leaves)
{
mLeaves=leaves;
}
#if defined(_MSC_VER)
#include <bsptree/btree.tpp>
#endif
#endif

83
bsptree/COLORKEY.HPP Normal file
View File

@@ -0,0 +1,83 @@
#ifndef _BSPTREE_COLORKEY_HPP_
#define _BSPTREE_COLORKEY_HPP_
#ifndef _COMMON_RGBCOLOR_HPP_
#include <common/rgbcolor.hpp>
#endif
class ColorKey
{
public:
enum AltKey{RedKey,GreenKey,BlueKey};
ColorKey(void);
ColorKey(const ColorKey &someColorKey);
~ColorKey();
AltKey colorKey(AltKey colorKey);
AltKey colorKey(void)const;
AltKey prevKey(void);
AltKey nextKey(void);
WORD isLess(const RGBColor &srcRGB,const RGBColor &dstRGB)const;
WORD isLessEqual(const RGBColor &srcRGB,const RGBColor &dstRGB)const;
private:
AltKey mAltKey;
};
inline
ColorKey::ColorKey(void)
: mAltKey(RedKey)
{
}
inline
ColorKey::ColorKey(const ColorKey &someColorKey)
: mAltKey(someColorKey.mAltKey)
{
}
inline
ColorKey::~ColorKey()
{
}
inline
ColorKey::AltKey ColorKey::colorKey(AltKey colorKey)
{
return(mAltKey=colorKey);
}
inline
ColorKey::AltKey ColorKey::colorKey(void)const
{
return mAltKey;
}
inline
ColorKey::AltKey ColorKey::nextKey(void)
{
if(RedKey==mAltKey)return(mAltKey=GreenKey);
else if(GreenKey==mAltKey)return(mAltKey=BlueKey);
else return(mAltKey=RedKey);
}
inline
ColorKey::AltKey ColorKey::prevKey(void)
{
if(RedKey==mAltKey)return(mAltKey=BlueKey);
else if(GreenKey==mAltKey)return(mAltKey=RedKey);
else return(mAltKey=GreenKey);
}
inline
WORD ColorKey::isLess(const RGBColor &srcRGB,const RGBColor &dstRGB)const
{
if(RedKey==mAltKey)return srcRGB.red()<dstRGB.red();
else if(GreenKey==mAltKey)return srcRGB.green()<dstRGB.green();
else return srcRGB.blue()<dstRGB.blue();
}
inline
WORD ColorKey::isLessEqual(const RGBColor &srcRGB,const RGBColor &dstRGB)const
{
if(RedKey==mAltKey)return srcRGB.red()<=dstRGB.red();
else if(GreenKey==mAltKey)return srcRGB.green()<=dstRGB.green();
else return srcRGB.blue()<=dstRGB.blue();
}
#endif

10
bsptree/COMP.RSP Normal file
View File

@@ -0,0 +1,10 @@
/D__FLAT__
/DSTRICT
/IC:\PARTS\MSVC\INCLUDE
/I..
/c
/Zi
/Yd
/FoMSVCOBJ
BSPTMPL.CPP
RGBTREE.CPP

85
bsptree/INORDER.HPP Normal file
View File

@@ -0,0 +1,85 @@
#ifndef _BSPTREE_INORDERSTACK_HPP_
#define _BSPTREE_INORDERSTACK_HPP_
#ifndef _BSPTREE_TREENODE_HPP_
#include <bsptree/treenode.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_SMARTPOINTER_HPP_
#include <common/pointer.hpp>
#endif
template <class T>
class InorderStack : protected Block<SmartPointer<TreeNode<T> > >
{
public:
InorderStack(void);
virtual ~InorderStack();
void push(SmartPointer<TreeNode<T> > &ptrNode);
BOOL pop(SmartPointer<TreeNode<T> > &ptrNode);
void clear(void);
DWORD size(void)const;
private:
InorderStack(const InorderStack<T> &inorderStack);
InorderStack<T> &operator=(const InorderStack<T> &inorderStack);
};
template <class T>
inline
InorderStack<T>::InorderStack(void)
{
}
template <class T>
inline
InorderStack<T>::InorderStack(const InorderStack<T> &inorderStack)
{ // private implementation
*this=inorderStack;
}
template <class T>
inline
InorderStack<T>::~InorderStack()
{
}
template <class T>
inline
InorderStack<T> &InorderStack<T>::operator=(const InorderStack<T> &/*inorderStack*/)
{ // private implementation
return *this;
}
template <class T>
inline
void InorderStack<T>::push(SmartPointer<TreeNode<T> > &ptrNode)
{
insert(&SmartPointer<TreeNode<T> >(ptrNode));
}
template <class T>
inline
BOOL InorderStack<T>::pop(SmartPointer<TreeNode<T> > &ptrNode)
{
int items;
if(!(items=size()))return FALSE;
ptrNode=operator[](items-1);
Block<SmartPointer<TreeNode<T> > >::remove(items-1);
return TRUE;
}
template <class T>
inline
void InorderStack<T>::clear(void)
{
remove();
}
template <class T>
inline
DWORD InorderStack<T>::size(void)const
{
return Block<SmartPointer<TreeNode<T> > >::size();
}
#endif

61
bsptree/ITERATEI.HPP Normal file
View File

@@ -0,0 +1,61 @@
#ifndef _BSPTREE_TREEITERATORINORDER_HPP_
#define _BSPTREE_TREEITERATORINORDER_HPP_
#ifndef _BSPTREE_BINARYTREE_HPP_
#include <bsptree/bintree.hpp>
#endif
#ifndef _BSPTREE_INORDERSTACK_HPP_
#include <bsptree/inorder.hpp>
#endif
template <class T>
class TreeIteratorInorder
{
public:
TreeIteratorInorder(void);
TreeIteratorInorder(BinaryTree<T> &binaryTree);
virtual ~TreeIteratorInorder();
T *operator++(void);
T *operator++(int postFixDummy);
TreeIteratorInorder<T> &operator=(BinaryTree<T> &binaryTree);
void reset(void);
private:
void createInorderStack(BinaryTree<T> &binaryTree);
InorderStack<T> mInorderStack;
};
template <class T>
inline
TreeIteratorInorder<T>::TreeIteratorInorder(void)
{
}
template <class T>
inline
TreeIteratorInorder<T>::TreeIteratorInorder(BinaryTree<T> &binaryTree)
{
createInorderStack(binaryTree);
}
template <class T>
inline
TreeIteratorInorder<T>::~TreeIteratorInorder()
{
}
template <class T>
inline
T *TreeIteratorInorder<T>::operator++(int /*postFixDummy*/)
{
return operator++();
}
template <class T>
inline
void TreeIteratorInorder<T>::reset(void)
{
mInorderStack.clear();
}
#if defined(_MSC_VER)
#include <bsptree/iteratei.tpp>
#endif
#endif

38
bsptree/ITERATEI.TPP Normal file
View File

@@ -0,0 +1,38 @@
#ifndef _BSPTREE_TREEITERATORINORDER_HPP_
#error ITERATE.HPP must precede ITERATEI.TPP
#endif
#ifndef _BSPTREE_TREEITERATORINORDER_TPP_
#define _BSPTREE_TREEITERATORINORDER_TPP_
template <class T>
T *TreeIteratorInorder<T>::operator++(void)
{
if(!mInorderStack.size())return 0;
SmartPointer<TreeNode<T> > currTreeNode;
mInorderStack.pop(currTreeNode);
if(!currTreeNode->rightNode())return &currTreeNode->item();
for(TreeNode<T> *pTreeNode=currTreeNode->rightNode();pTreeNode;pTreeNode=pTreeNode->leftNode())
mInorderStack.push(SmartPointer<TreeNode<T> >(pTreeNode));
return &currTreeNode->item();
}
template <class T>
TreeIteratorInorder<T> &TreeIteratorInorder<T>::operator=(BinaryTree<T> &binaryTree)
{
createInorderStack(binaryTree);
return *this;
}
template <class T>
void TreeIteratorInorder<T>::createInorderStack(BinaryTree<T> &binaryTree)
{
mInorderStack.clear();
TreeNode<T> *pTreeNode=binaryTree.rootNode();
while(pTreeNode)
{
mInorderStack.push(SmartPointer<TreeNode<T> >(pTreeNode));
pTreeNode=pTreeNode->leftNode();
}
}
#endif

6
bsptree/LIB.RSP Normal file
View File

@@ -0,0 +1,6 @@
/OUT:C:\WORK\BSPTREE\MSVCOBJ\MSVCBSP.LIB
/MACHINE:IX86
/SUBSYSTEM:WINDOWS
/DEBUGTYPE:BOTH
MSVCOBJ\BSPTMPL.OBJ
MSVCOBJ\RGBTREE.OBJ

185
bsptree/MAIN.CPP Normal file
View File

@@ -0,0 +1,185 @@
#include <common/pvector.hpp>
#include <common/string.hpp>
//#include <bsptree/treendex.hpp>
//#include <bsptree/btree.hpp>
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
{
BTree<String> treeStrings;
String firstString("SEAN");
String secondString("RONI");
treeStrings.insertItem(firstString,TRUE);
treeStrings.insertItem(secondString,TRUE);
treeStrings.insertItem(secondString,TRUE);
return treeStrings.leaves();
}
#if 0
#include <iostream.h>
#include <fstream.h>
#include <dos.h>
#include <dir.h>
#include <common/block.hpp>
#include <common/block.tpp>
#include <common/pvector.hpp>
#include <common/pvector.tpp>
#include <common/string.hpp>
#include <common/bitmap.hpp>
#include <bsptree/rgbtree.hpp>
void testPhaseThree(String srcBitmap,String dstBitmap);
void testPhaseFour(void);
void main()
{
String bitmapOneName("C:\\WORK\\SCENE\\BMP\\COMPTILE.BMP");
String bitmapTwoName("C:\\WORK\\SCENE\\BMP\\RIDEN.BMP");
Bitmap bitmapOne(bitmapOneName);
Bitmap bitmapTwo(bitmapTwoName);
PurePalette paletteTwo((HPALETTE)bitmapTwo);
PurePalette paletteOne((HPALETTE)bitmapOne);
if(!paletteOne.isIdentityPalette())cout << (LPSTR)bitmapOneName << " is not identity" << endl;
else cout << (LPSTR)bitmapOneName << " is identity" << endl;
paletteOne.identityPalette();
if(!paletteOne.isIdentityPalette())cout << (LPSTR)bitmapOneName << " is not identity" << endl;
else cout << (LPSTR)bitmapOneName << " is identity" << endl;
if(!(paletteOne==paletteTwo))cout << "Palettes are not identical" << endl;
else cout << "Palettes are identical" << endl;
bitmapOne.setPalette(paletteOne);
bitmapOne.saveBitmap("C:\\WORK\\SCENE\\BMP\\RIDEN2.BMP");
#if 0
PurePalette::PaletteIndex paletteIndex;
String bitmapOneName("C:\\WORK\\SCENE\\BMP\\RIDEN.BMP");
String bitmapTwoName("C:\\WORK\\SCENE\\BMP\\RIDEN2.BMP");
String bitmapOrgName("C:\\WORK\\SCENE\\BMP\\RSKY1.BMP");
Bitmap bitmapOne(bitmapOneName);
Bitmap bitmapTwo(bitmapTwoName);
Bitmap bitmapOrg(bitmapOrgName);
PurePalette bitmapOnePalette((HPALETTE)bitmapOne);
PurePalette bitmapTwoPalette((HPALETTE)bitmapTwo);
PurePalette bitmapOrgPalette((HPALETTE)bitmapOrg);
RGBColor rgbColorOne;
RGBColor rgbColorTwo;
RGBColor rgbColorOrg;
BYTE bmOneByte;
BYTE bmTwoByte;
BYTE bmOrgByte;
short bmDelta;
short errors(0);
char ch;
if(bitmapOne.width()!=bitmapTwo.width()||bitmapOne.height()!=bitmapTwo.height())
{cout << "Bitmaps have same dimensions" << endl;return;}
for(short rowIndex=0;rowIndex<bitmapOne.height();rowIndex++)
{
for(short colIndex=0;colIndex<bitmapOne.width();colIndex++)
{
bmOneByte=bitmapOne.getBitmapByte(rowIndex,colIndex);
bmTwoByte=bitmapTwo.getBitmapByte(rowIndex,colIndex);
bmOrgByte=bitmapOrg.getBitmapByte(rowIndex,colIndex);
if(bmOneByte!=bmTwoByte)
{
bitmapOnePalette.getPaletteColor(bmOneByte,rgbColorOne);
bitmapTwoPalette.getPaletteColor(bmTwoByte,rgbColorTwo);
bitmapOrgPalette.getPaletteColor(bmOrgByte,rgbColorOrg);
bmDelta=(short)bmTwoByte-(short)bmOneByte;
if(bmDelta<0)bmDelta=-bmDelta;
cout << "Difference found at (" << rowIndex << "," << colIndex << ") DELTA=" << bmDelta << endl;
cout << (LPSTR)bitmapOneName << " data is " << (short)bmOneByte << " color is " <<
"(" << (short)rgbColorOne.red() << "," << (short)rgbColorOne.green() << "," << (short)rgbColorOne.blue() << ")" << endl;
cout << (LPSTR)bitmapTwoName << " data is " << (short)bmTwoByte << " color is " <<
"(" << (short)rgbColorTwo.red() << "," << (short)rgbColorTwo.green() << "," << (short)rgbColorTwo.blue() << ")" << endl;
cout << (LPSTR)bitmapOrgName << " data is " << (short)bmOrgByte << " color is " <<
"(" << (short)rgbColorOrg.red() << "," << (short)rgbColorOrg.green() << "," << (short)rgbColorOrg.blue() << ")" << endl;
paletteIndex=bitmapTwoPalette.paletteIndex(rgbColorOne);
cout << "(" << (short)rgbColorOne.red() << "," << (short)rgbColorOne.green() << "," << (short)rgbColorOne.blue() << ") index is " << (short)paletteIndex << " in " << (LPSTR)bitmapTwoName << endl;
errors++;
if(!(errors%5))cin >> ch;
if('q'==ch)return;
}
}
}
return;
#endif
}
#if 0
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
{
testPhaseFour();
return FALSE;
}
#endif
void testPhaseFour()
{
ffblk ffblk;
String firstFile;
String secondFile;
String pathFileSpec;
String pathString("C:\\WORK\\ENGINE\\BMP");
String separator("\\");
String extensionString("*.BMP");
pathFileSpec=pathString;
pathFileSpec+=separator;
pathFileSpec+=extensionString;
if(!::findfirst(pathFileSpec,&ffblk,FA_ARCH))
{
firstFile=pathString;
firstFile+=separator;
firstFile+=String(ffblk.ff_name);
while(!::findnext(&ffblk))
{
secondFile=pathString;
secondFile+=separator;
secondFile+=String(ffblk.ff_name);
testPhaseThree(firstFile,secondFile);
firstFile=secondFile;
}
}
}
void testPhaseThree(String srcBitmap,String dstBitmap)
{
PureVector<RGBColor> rgbColorOne;
PureVector<RGBColor> rgbColorTwo;
PureVector<RGBIndex> rgbIndexColorOne;
PureVector<RGBIndex> rgbIndexColorTwo;
RGBTree bspTree;
RGBIndex searchRGB;
WORD errorCount(0);
cout << "Looking at <" << (LPSTR)srcBitmap << ">" << endl << "<" << (LPSTR)dstBitmap << ">" << endl;
Bitmap imageBitmapOne(srcBitmap);
Bitmap imageBitmapTwo(dstBitmap);
PurePalette purePaletteOne((HPALETTE)imageBitmapOne);
PurePalette purePaletteTwo((HPALETTE)imageBitmapTwo);
purePaletteOne.getPaletteColors(rgbColorOne);
purePaletteTwo.getPaletteColors(rgbColorTwo);
rgbIndexColorOne.size(rgbColorOne.size());
rgbIndexColorTwo.size(rgbColorTwo.size());
for(short index=0;index<rgbColorOne.size();index++)rgbIndexColorOne[index]=rgbColorOne[index];
for(index=0;index<rgbColorTwo.size();index++)rgbIndexColorTwo[index]=rgbColorTwo[index];
if((!rgbIndexColorOne.size())||!(rgbIndexColorTwo.size())){cout << "Palette error." << endl;return;}
bspTree.insertItems(rgbIndexColorTwo);
size_t size((WORD)rgbIndexColorOne.size());
cout << "Performing accuracy test..." << endl;
for(int i=0;i<size;i++)
{
searchRGB=rgbIndexColorOne[i];
if(!bspTree.searchItem(searchRGB,RGBTree::SearchExact))
{
cout << "Error : exact match failed " << i << endl;
errorCount++;
}
}
cout << "Accuracy test complete." << endl;
if(errorCount)cout << "Errors " << errorCount << endl;
}
#endif


17
bsptree/MAKE.RSP Normal file
View File

@@ -0,0 +1,17 @@
/D__FLAT__
/DSTRICT
/DWIN32
/D_WINDOWS
/IC:\PARTS\MSVC\INCLUDE
/I..
/Od
/GD
/G4
/Zi
/Yd
/YX
/c
/nologo
/FoMSVCOBJ\
BSPTMPL.CPP
RGBTREE.CPP

BIN
bsptree/MSVCBSP.DSW Normal file

Binary file not shown.

BIN
bsptree/MSVCBSP.IDE Normal file

Binary file not shown.

96
bsptree/RGBNDX.HPP Normal file
View File

@@ -0,0 +1,96 @@
#ifndef _BSPTREE_RGBNDX_HPP_
#define _BSPTREE_RGBNDX_HPP_
#ifndef _COMMON_RGBCOLOR_HPP_
#include <common/rgbcolor.hpp>
#endif
class RGBIndex : public RGBColor
{
public:
RGBIndex(void);
RGBIndex(const RGBIndex &someRGBIndex);
RGBIndex(const RGBColor &someRGBColor,WORD paletteIndex);
RGBIndex(const RGBColor &someRGBColor);
virtual ~RGBIndex();
RGBIndex &operator=(const RGBIndex &someRGBIndex);
RGBIndex &operator=(const RGBColor &someRGBColor);
DWORD paletteIndex(void)const;
void paletteIndex(DWORD paletteIndex);
DWORD reference(void)const;
void reference(DWORD reference);
private:
DWORD mPaletteIndex;
DWORD mReference;
};
inline
RGBIndex::RGBIndex(void)
: mPaletteIndex(0), mReference(0)
{
}
inline
RGBIndex::RGBIndex(const RGBIndex &someRGBIndex)
{
*this=someRGBIndex;
}
inline
RGBIndex::RGBIndex(const RGBColor &someRGBItem,WORD paletteIndex)
: RGBColor(someRGBItem), mPaletteIndex(paletteIndex), mReference(0)
{
}
inline
RGBIndex::RGBIndex(const RGBColor &someRGBColor)
: RGBColor(someRGBColor), mPaletteIndex(0), mReference(0)
{
}
inline
RGBIndex::~RGBIndex()
{
}
inline
DWORD RGBIndex::paletteIndex(void)const
{
return mPaletteIndex;
}
inline
void RGBIndex::paletteIndex(DWORD paletteIndex)
{
mPaletteIndex=paletteIndex;
}
inline
DWORD RGBIndex::reference(void)const
{
return mReference;
}
inline
void RGBIndex::reference(DWORD reference)
{
mReference=reference;
}
inline
RGBIndex &RGBIndex::operator=(const RGBIndex &someRGBIndex)
{
(RGBColor&)*this=(RGBColor&)someRGBIndex;
paletteIndex(someRGBIndex.paletteIndex());
reference(someRGBIndex.reference());
return *this;
}
inline
RGBIndex &RGBIndex::operator=(const RGBColor &someRGBColor)
{
(RGBColor&)*this=someRGBColor;
mPaletteIndex=0;
mReference=0;
return *this;
}
#endif

61
bsptree/RGBREF.HPP Normal file
View File

@@ -0,0 +1,61 @@
#ifndef _BSPTREE_RGBREFERENCE_HPP_
#define _BSPTREE_RGBREFERENCE_HPP_
#ifndef _BSPTREE_RGBNDX_HPP_
#include <bsptree/rgbndx.hpp>
#endif
class RGBReference : public RGBIndex
{
public:
RGBReference(void);
RGBReference(const RGBReference &someRGBReference);
virtual ~RGBReference();
RGBReference &operator=(const RGBReference &someRGBReference);
BOOL operator==(const RGBReference &someRGBReference)const;
BOOL operator>(const RGBReference &someRGBReference)const;
BOOL operator<(const RGBReference &someRGBReference)const;
private:
};
inline
RGBReference::RGBReference(void)
{
}
inline
RGBReference::RGBReference(const RGBReference &someRGBReference)
{
*this=someRGBReference;
}
inline
RGBReference::~RGBReference()
{
}
inline
RGBReference &RGBReference::operator=(const RGBReference &someRGBReference)
{
(RGBIndex&)*this=(RGBIndex&)someRGBReference;
return *this;
}
inline
BOOL RGBReference::operator==(const RGBReference &someRGBReference)const
{
return reference()==someRGBReference.reference();
}
inline
BOOL RGBReference::operator>(const RGBReference &someRGBReference)const
{
return reference()>someRGBReference.reference();
}
inline
BOOL RGBReference::operator<(const RGBReference &someRGBReference)const
{
return reference()<someRGBReference.reference();
}
#endif

86
bsptree/RGBSTACK.HPP Normal file
View File

@@ -0,0 +1,86 @@
#ifndef _BSPTREE_RGBSTACK_HPP_
#define _BSPTREE_RGBSTACK_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _BSPTREE_TREENODEEX_HPP_
#include <bsptree/treendex.hpp>
#endif
#ifndef _BSPTREE_COLORKEY_HPP_
#include <bsptree/colorkey.hpp>
#endif
class RGBStack
{
public:
RGBStack(void);
~RGBStack();
WORD size(void)const;
WORD size(WORD size);
void rewind(void);
TreeNodeEx &currentNode(void);
TreeNodeEx &popNode(void);
void pushNode(const TreeNodeEx &someTreeNodeEx);
private:
enum{MaxItems=100};
Array<TreeNodeEx> mVectoredNodes;
short mStackPointer;
};
inline
RGBStack::RGBStack(void)
: mStackPointer(0)
{
mVectoredNodes.size(MaxItems);
}
inline
RGBStack::~RGBStack()
{
}
inline
WORD RGBStack::size(void)const
{
return mStackPointer;
}
inline
WORD RGBStack::size(WORD size)
{
mVectoredNodes.size(size);
rewind();
return (WORD)mVectoredNodes.size();
}
inline
void RGBStack::rewind(void)
{
mStackPointer=0;
}
inline
TreeNodeEx &RGBStack::currentNode(void)
{
return mVectoredNodes[mStackPointer];
}
inline
TreeNodeEx &RGBStack::popNode(void)
{
if(mStackPointer-1<0)return mVectoredNodes[mStackPointer];
return mVectoredNodes.operator[](--mStackPointer);
}
inline
void RGBStack::pushNode(const TreeNodeEx &someNode)
{
if(mStackPointer>=mVectoredNodes.size())return;
mVectoredNodes[mStackPointer++]=someNode;
}
#endif


98
bsptree/RGBTREE.HPP Normal file
View File

@@ -0,0 +1,98 @@
#ifndef _BSPTREE_RGBTREE_HPP_
#define _BSPTREE_RGBTREE_HPP_
#ifndef _COMMON_PALETTEENTRY_HPP_
#include <common/palentry.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _COMMON_SMARTPOINTER_HPP_
#include <common/pointer.hpp>
#endif
#ifndef _BSPTREE_BTREE_HPP_
#include <bsptree/btree.hpp>
#endif
#ifndef _BSPTREE_RGBNDX_HPP_
#include <bsptree/rgbndx.hpp>
#endif
#ifndef _BSPTREE_COLORKEY_HPP_
#include <bsptree/colorkey.hpp>
#endif
#ifndef _BSPTREE_RGBSTACK_HPP_
#include <bsptree/rgbstack.hpp>
#endif
//#ifndef _COMMON_PVECTOR_TPP_
//#include <common/pvector.tpp>
//#endif
#ifndef _BSPTREE_BTREE_TPP_
#include <bsptree/btree.tpp>
#endif
class RGBTree : public BTree<RGBIndex>, private RGBStack
{
public:
enum SearchType{SearchExact,SearchNearest};
RGBTree(void);
virtual ~RGBTree();
WORD insertItems(Array<RGBIndex> &rgbItems);
WORD insertItem(const RGBIndex &rgbItem);
WORD insertItem(const RGBColor &rgbItem);
WORD insertItem(const PaletteEntry &paletteEntryItem);
BOOL searchItem(RGBIndex &rgbItem,SearchType searchType=SearchExact);
BOOL searchItem(RGBColor &rgbColor,SearchType searchType=SearchExact);
BOOL searchItem(RGBIndex &rgbItem,SmartPointer<RGBIndex> &rgbIndex,SearchType searchType=SearchExact);
void setThreshold(WORD threshold);
void deleteTree(void);
private:
enum {DefaultThreshold=10,MaxThreshold=255,CenterColor=128};
TreeNode<RGBIndex> *insertNode(TreeNode<RGBIndex> *lpRootNode,TreeNode<RGBIndex> *lpCurrentNode,const RGBIndex &rgbItem);
RGBIndex *searchNodeExact(TreeNode<RGBIndex> *lpRootNode,const RGBIndex &rgbItem);
RGBIndex *searchNodeNearest(TreeNode<RGBIndex> *lpRootNode,const RGBIndex &rgbItem);
WORD middleIndex(Array<RGBIndex> &rgbItems)const;
Array<RGBIndex> mVectoredColors;
ColorKey mColorKey;
WORD mThreshold;
};
inline
RGBTree::RGBTree(void)
: mThreshold(DefaultThreshold)
{
}
inline
RGBTree::~RGBTree()
{
}
inline
void RGBTree::setThreshold(WORD threshold)
{
mThreshold=threshold;
}
inline
void RGBTree::deleteTree(void)
{
remove();
}
inline
WORD RGBTree::insertItem(const RGBColor &rgbItem)
{
RGBIndex rgbIndex(rgbItem);
return insertItem(rgbIndex);
}
inline
WORD RGBTree::insertItem(const PaletteEntry &paletteEntryItem)
{
RGBIndex rgbIndex;
rgbIndex.red(paletteEntryItem.red());
rgbIndex.green(paletteEntryItem.green());
rgbIndex.blue(paletteEntryItem.blue());
return insertItem(rgbIndex);
}
#endif

174
bsptree/Rgbtree.cpp Normal file
View File

@@ -0,0 +1,174 @@
#include <bsptree/rgbtree.hpp>
WORD RGBTree::insertItems(Array<RGBIndex> &rgbItems)
{
size_t size((size_t)rgbItems.size());
short indexDescending;
short indexAscending;
if(!size)return FALSE;
indexDescending=middleIndex(rgbItems);
indexAscending=indexDescending+1;
for(;indexDescending>=0;indexDescending--)insertItem(rgbItems[indexDescending]);
for(;indexAscending<size;indexAscending++)insertItem(rgbItems[indexAscending]);
return size;
}
WORD RGBTree::middleIndex(Array<RGBIndex> &rgbItems)const
{
RGBColor middleItem(CenterColor,CenterColor,CenterColor);
size_t size((size_t)rgbItems.size());
LONG minDistance(0xFFFFFFL);
LONG tmpDistance;
WORD centerIndex;
for(short rgbIndex=0;rgbIndex<size;rgbIndex++)
{
tmpDistance=rgbItems[rgbIndex]-middleItem;
if(tmpDistance<minDistance){minDistance=tmpDistance;centerIndex=rgbIndex;}
}
return centerIndex;
}
TreeNode<RGBIndex> *RGBTree::insertNode(TreeNode<RGBIndex> *lpRootNode,TreeNode<RGBIndex> *lpCurrentNode,const RGBIndex &rgbItem)
{
if(!lpCurrentNode)
{
lpCurrentNode=new TreeNode<RGBIndex>(rgbItem);
assert(0!=lpCurrentNode);
if(!lpRootNode)return lpCurrentNode;
mColorKey.prevKey();
if(mColorKey.isLess(rgbItem,lpRootNode->item()))lpRootNode->leftNode(lpCurrentNode);
else lpRootNode->rightNode(lpCurrentNode);
return lpCurrentNode;
}
if(!(rgbItem==lpCurrentNode->item()))
{
if(mColorKey.isLess(rgbItem,lpCurrentNode->item()))
{
mColorKey.nextKey();
return insertNode(lpCurrentNode,lpCurrentNode->leftNode(),rgbItem);
}
else
{
mColorKey.nextKey();
return insertNode(lpCurrentNode,lpCurrentNode->rightNode(),rgbItem);
}
}
return 0;
}
RGBIndex *RGBTree::searchNodeExact(TreeNode<RGBIndex> *lpRootNode,const RGBIndex &rgbItem)
{
while(lpRootNode&&!(rgbItem==lpRootNode->item()))
{
if(mColorKey.isLess(rgbItem,lpRootNode->item()))lpRootNode=lpRootNode->leftNode();
else lpRootNode=lpRootNode->rightNode();
mColorKey.nextKey();
}
if(lpRootNode)return &lpRootNode->item();
return 0;
}
RGBIndex *RGBTree::searchNodeNearest(TreeNode<RGBIndex> *lpRootNode,const RGBIndex &rgbItem)
{
TreeNode<RGBIndex> *lpLastNode=0;
TreeNode<RGBIndex> *lpTempNode;
LONG minDistance(0xFFFFFFL);
RGBIndex lowerRGB(rgbItem);
RGBIndex upperRGB(rgbItem);
RGBIndex *lpBestRGB=0;
LONG tmpDistance;
ColorKey colorKey;
if(!lpRootNode)return 0;
rewind();
lowerRGB-=mThreshold;
upperRGB+=mThreshold;
pushNode(TreeNodeEx(*lpRootNode,colorKey));
while(size()&&minDistance)
{
popNode();
lpTempNode=&currentNode();
if(lpLastNode==lpRootNode)break;
else lpLastNode=lpRootNode;
colorKey=currentNode();
while(lpTempNode&&minDistance)
{
if(colorKey.isLessEqual(lowerRGB,lpTempNode->item()))
{
if(colorKey.isLessEqual(lpTempNode->item(),upperRGB))
{
pushNode(TreeNodeEx(*lpTempNode,colorKey));
tmpDistance=lpTempNode->item()-rgbItem;
if(!tmpDistance)return &lpTempNode->item();
if(tmpDistance<minDistance){minDistance=tmpDistance;lpBestRGB=&lpTempNode->item();}
}
}
if(colorKey.isLess(rgbItem,lpTempNode->item()))lpTempNode=lpTempNode->leftNode();
else lpTempNode=lpTempNode->rightNode();
colorKey.nextKey();
}
}
return lpBestRGB;
}
WORD RGBTree::insertItem(const RGBIndex &rgbItem)
{
mColorKey.colorKey(ColorKey::RedKey);
if(!rootNode())
{
if(!rootNode(insertNode(rootNode(),rootNode(),rgbItem)))return FALSE;
leaves(leaves()+1);
return TRUE;
}
else
{
if(!insertNode(rootNode(),rootNode(),rgbItem))return FALSE;
leaves(leaves()+1);
return TRUE;
}
}
BOOL RGBTree::searchItem(RGBColor &rgbColor,SearchType searchType)
{
RGBIndex rgbIndex(rgbColor);
if(!searchItem(rgbIndex,searchType))return FALSE;
rgbColor=(RGBColor&)rgbIndex;
return TRUE;
}
BOOL RGBTree::searchItem(RGBIndex &rgbItem,SearchType searchType)
{
RGBIndex *lpItem;
WORD currentThreshold(mThreshold);
if(!rootNode())return FALSE;
mColorKey.colorKey(ColorKey::RedKey);
lpItem=searchNodeExact(rootNode(),rgbItem);
if(lpItem){rgbItem=*lpItem;return TRUE;}
else if(SearchExact==searchType)return FALSE;
setThreshold(MaxThreshold);
lpItem=searchNodeNearest(rootNode(),rgbItem);
setThreshold(currentThreshold);
if(lpItem){rgbItem=*lpItem;return TRUE;}
return FALSE;
}
BOOL RGBTree::searchItem(RGBIndex &rgbItem,SmartPointer<RGBIndex> &rgbIndex,SearchType searchType)
{
RGBIndex *lpItem;
WORD currentThreshold(mThreshold);
if(!rootNode())return FALSE;
mColorKey.colorKey(ColorKey::RedKey);
lpItem=searchNodeExact(rootNode(),rgbItem);
if(lpItem){rgbIndex=lpItem;return TRUE;}
else if(SearchExact==searchType)return FALSE;
setThreshold(MaxThreshold);
lpItem=searchNodeNearest(rootNode(),rgbItem);
setThreshold(currentThreshold);
if(lpItem){rgbIndex=lpItem;return TRUE;}
return FALSE;
}

56
bsptree/SCRAPS.TXT Normal file
View File

@@ -0,0 +1,56 @@
template <class T>
T *BTree<T>::searchNode(TreeNode<T> *lpRootNode,const T &someItem)
{
if(!lpRootNode)return 0;
while(!(someItem==lpRootNode->item()))
{
if(someItem<lpRootNode->item())lpRootNode=lpRootNode->leftNode();
else lpRootNode=lpRootNode->rightNode();
}
return &lpRootNode->item();
}
template <class T>
T *BTree<T>::searchNode(TreeNode<T> *lpRootNode,const T &someItem)
{
if(!lpRootNode)return 0;
while(!(someItem==lpRootNode->item()))
{
if(someItem<lpRootNode->item())lpRootNode=lpRootNode->leftNode();
else lpRootNode=lpRootNode->rightNode();
}
return &lpRootNode->item();
}
#if 0
template <class T>
void BTree<T>::remove(const T &someItem,TreeNode<T> *pRootNode)
{
TreeNode<T> *pTmpNode;
if(!pRootNode)return;
if(someItem<pRootNode->item())remove(someItem,pRootNode->leftNode());
else if(someItem>pRootNode->item())remove(someItem,pRootNode->rightNode());
else
{
pTmpNode=pRootNode;
if(!pTmpNode->rightNode())pRootNode=pTmpNode->leftNode();
else if(!pTmpNode->leftNode())pRootNode=pTmpNode->rightNode();
else
{
TreeNode<T> *pLeftNode=pTmpNode->leftNode();
while(pLeftNode->rightNode())pLeftNode=pLeftNode->rightNode();
pTmpNode=pLeftNode;
pLeftNode=pLeftNode->leftNode();
}
if(mlpRootNode==pTmpNode)mlpRootNode=pRootNode;
delete pTmpNode;
leaves(leaves()-1);
}
}
#endif
// ptrNode=operator[](0);
// Block<SmartPointer<TreeNode<T> > >::remove(int(0));

1
bsptree/SMK.TXT Normal file
View File

@@ -0,0 +1 @@
C:\WORK\BSPTREE\MSVCOBJ\msvcbsp.lib c:\work\bsptree\msvcbsp.ide ( msvcobj\bsptmpl.obj msvcobj\rgbtree.obj ) LIB( C:\MSVC\LIB ) []

16
bsptree/STDTMPL.CPP Normal file
View File

@@ -0,0 +1,16 @@
#ifndef _MSC_VER
#define _EXPAND_BLOCK_TEMPLATES_
#define _EXPAND_VECTOR_TEMPLATES_
#include <common/string.hpp>
#include <common/block.hpp>
#include <common/block.tpp>
#include <common/pvector.hpp>
#include <common/pvector.tpp>
#include <bsptree/btree.hpp>
#include <bsptree/btree.tpp>
typedef Block<String> a;
typedef PureVector<String> b;
typedef BTree<String> c;
#endif

BIN
bsptree/TDCONFIG.TDW Normal file

Binary file not shown.

BIN
bsptree/TREE.DSK Normal file

Binary file not shown.

BIN
bsptree/TREE.PRJ Normal file

Binary file not shown.

46
bsptree/TREENDEX.HPP Normal file
View File

@@ -0,0 +1,46 @@
#ifndef _BSPTREE_TREENODEEX_HPP_
#define _BSPTREE_TREENODEEX_HPP_
#ifndef _BSPTREE_TREENODE_HPP_
#include <bsptree/treenode.hpp>
#endif
#ifndef _BSPTREE_COLORKEY_HPP_
#include <bsptree/colorkey.hpp>
#endif
#ifndef _BSPTREE_RGBNDX_HPP_
#include <bsptree/rgbndx.hpp>
#endif
class TreeNodeEx : public TreeNode<RGBIndex>, public ColorKey
{
public:
TreeNodeEx(void);
TreeNodeEx(const TreeNodeEx &someTreeNodeEx);
TreeNodeEx(const TreeNode<RGBIndex> &someTreeNode,const ColorKey &someColorKey);
~TreeNodeEx();
private:
};
inline
TreeNodeEx::TreeNodeEx(void)
{
}
inline
TreeNodeEx::TreeNodeEx(const TreeNodeEx &someTreeNodeEx)
{
((TreeNode<RGBIndex> &)*this)=(TreeNode<RGBIndex>&)someTreeNodeEx;
((ColorKey&)*this)=(ColorKey&)(ColorKey&)someTreeNodeEx;
}
inline
TreeNodeEx::TreeNodeEx(const TreeNode<RGBIndex> &someTreeNode,const ColorKey &someColorKey)
{
((TreeNode<RGBIndex>&)*this)=someTreeNode;
((ColorKey&)*this)=someColorKey;
}
inline
TreeNodeEx::~TreeNodeEx()
{
}
#endif

83
bsptree/TREENODE.HPP Normal file
View File

@@ -0,0 +1,83 @@
#ifndef _BSPTREE_TREENODE_HPP_
#define _BSPTREE_TREENODE_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
template <class T>
class TreeNode
{
public:
TreeNode(void);
TreeNode(const T &someItem);
TreeNode(const TreeNode<T> &someTreeNode);
virtual ~TreeNode();
void leftNode(TreeNode<T> *lpLeftNode);
void rightNode(TreeNode<T> *lpRightNode);
TreeNode<T> *leftNode(void);
TreeNode<T> *rightNode(void);
T &item(void);
WORD operator==(const TreeNode<T> &someTreeNode)const;
TreeNode<T> &operator=(const TreeNode<T> &someTreeNode);
private:
TreeNode<T> *mlpLeftNode;
TreeNode<T> *mlpRightNode;
T *mlpItem;
};
template <class T>
inline
TreeNode<T>::~TreeNode()
{
::delete mlpItem;
}
template <class T>
inline
void TreeNode<T>::leftNode(TreeNode<T> *lpLeftNode)
{
mlpLeftNode=lpLeftNode;
}
template <class T>
inline
void TreeNode<T>::rightNode(TreeNode<T> *lpRightNode)
{
mlpRightNode=lpRightNode;
}
template <class T>
inline
TreeNode<T> *TreeNode<T>::leftNode(void)
{
return mlpLeftNode;
}
template <class T>
inline
TreeNode<T> *TreeNode<T>::rightNode(void)
{
return mlpRightNode;
}
template <class T>
inline
T &TreeNode<T>::item(void)
{
return *mlpItem;
}
template <class T>
inline
TreeNode<T> &TreeNode<T>::operator=(const TreeNode<T> &someTreeNode)
{
leftNode(((TreeNode<T>&)someTreeNode).leftNode());
rightNode(((TreeNode<T>&)someTreeNode).rightNode());
*mlpItem=*someTreeNode.mlpItem;
return *this;
}
#if defined(_MSC_VER)
#include <bsptree/treenode.hpp>
#endif
#endif

34
bsptree/TREENODE.TPP Normal file
View File

@@ -0,0 +1,34 @@
#ifndef _BSPTREE_TREENODE_HPP_
#error TREENODE.HPP must precede TREENODE.TPP
#endif
template <class T>
TreeNode<T>::TreeNode(void)
: mlpLeftNode(0), mlpRightNode(0)
{
mlpItem=::new T;
}
template <class T>
TreeNode<T>::TreeNode(const TreeNode<T> &someTreeNode)
{
mlpItem=::new T;
*this=someTreeNode;
}
template <class T>
TreeNode<T>::TreeNode(const T &someItem)
: mlpLeftNode(0), mlpRightNode(0)
{
mlpItem=::new T(someItem);
}
template <class T>
WORD TreeNode<T>::operator==(const TreeNode<T> &someTreeNode)const
{
return (mlpRightNode==someTreeNode.mlpRightNode&&
mlpLeftNode==someTreeNode.mlpLeftNode&&
*mlpItem==*someTreeNode.mlpItem);
}

138
bsptree/bsptree.001 Normal file
View File

@@ -0,0 +1,138 @@
# Microsoft Developer Studio Project File - Name="bsptree" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=bsptree - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bsptree.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bsptree.mak" CFG="bsptree - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bsptree - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "bsptree - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
!IF "$(CFG)" == "bsptree - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\Debug"
# PROP BASE Intermediate_Dir ".\Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\msvcobj"
# PROP Intermediate_Dir ".\msvcobj"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MTd /GX /Z7 /Od /I "\work" /I "\parts" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"c:\work\exe\msvc42.pch" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\exe\msbsp.lib"
!ENDIF
# Begin Target
# Name "bsptree - Win32 Release"
# Name "bsptree - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\Bsptmpl.cpp
# End Source File
# Begin Source File
SOURCE=.\Rgbtree.cpp
# End Source File
# Begin Source File
SOURCE=.\Stdtmpl.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\Btree.hpp
# End Source File
# Begin Source File
SOURCE=.\Colorkey.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbndx.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbstack.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbtree.hpp
# End Source File
# Begin Source File
SOURCE=.\Treendex.hpp
# End Source File
# Begin Source File
SOURCE=.\Treenode.hpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\Btree.tpp
# End Source File
# Begin Source File
SOURCE=.\Treenode.tpp
# End Source File
# End Target
# End Project

46
bsptree/bsptree.dep Normal file
View File

@@ -0,0 +1,46 @@
# Microsoft Developer Studio Generated Dependency File, included by bsptree.mak
.\Bsptmpl.cpp : \
"..\..\parts\mssdk\include\basetsd.h"\
"..\common\array.hpp"\
"..\common\Assert.hpp"\
"..\common\Block.hpp"\
"..\common\Block.tpp"\
"..\common\except.hpp"\
"..\common\pointer.hpp"\
"..\common\Rgbcolor.hpp"\
"..\common\Stdlib.hpp"\
"..\common\String.hpp"\
"..\common\Windows.hpp"\
".\Btree.hpp"\
".\Btree.tpp"\
".\Colorkey.hpp"\
".\Rgbndx.hpp"\
".\Treendex.hpp"\
".\Treenode.hpp"\
".\Treenode.tpp"\
.\Rgbtree.cpp : \
"..\..\parts\mssdk\include\basetsd.h"\
"..\common\array.hpp"\
"..\common\Assert.hpp"\
"..\common\Block.hpp"\
"..\common\Block.tpp"\
"..\common\except.hpp"\
"..\common\Palentry.hpp"\
"..\common\pointer.hpp"\
"..\common\Rgbcolor.hpp"\
"..\common\Stdlib.hpp"\
"..\common\String.hpp"\
"..\common\Windows.hpp"\
".\Btree.hpp"\
".\Btree.tpp"\
".\Colorkey.hpp"\
".\Rgbndx.hpp"\
".\Rgbstack.hpp"\
".\Rgbtree.hpp"\
".\Treendex.hpp"\
".\Treenode.hpp"\
".\Treenode.tpp"\

145
bsptree/bsptree.dsp Normal file
View File

@@ -0,0 +1,145 @@
# Microsoft Developer Studio Project File - Name="bsptree" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=bsptree - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bsptree.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bsptree.mak" CFG="bsptree - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bsptree - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "bsptree - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "bsptree - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MT /GX /D "NDEBUG" /D "STRICT" /D "WIN32" /D "_WINDOWS" /D "__FLAT__" /YX /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\Debug"
# PROP BASE Intermediate_Dir ".\Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\msvcobj"
# PROP Intermediate_Dir ".\msvcobj"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /Gz /MTd /GX /Zi /Od /I "\work" /I "\parts" /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "_WINDOWS" /D "WIN32" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\exe\msbsp.lib"
!ENDIF
# Begin Target
# Name "bsptree - Win32 Release"
# Name "bsptree - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\Bsptmpl.cpp
# End Source File
# Begin Source File
SOURCE=.\Rgbtree.cpp
# End Source File
# Begin Source File
SOURCE=.\Stdtmpl.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\Btree.hpp
# End Source File
# Begin Source File
SOURCE=.\Colorkey.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbndx.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbstack.hpp
# End Source File
# Begin Source File
SOURCE=.\Rgbtree.hpp
# End Source File
# Begin Source File
SOURCE=.\Treendex.hpp
# End Source File
# Begin Source File
SOURCE=.\Treenode.hpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\Btree.tpp
# End Source File
# Begin Source File
SOURCE=.\Treenode.tpp
# End Source File
# End Target
# End Project

165
bsptree/bsptree.mak Normal file
View File

@@ -0,0 +1,165 @@
# Microsoft Developer Studio Generated NMAKE File, Based on bsptree.dsp
!IF "$(CFG)" == ""
CFG=bsptree - Win32 Release
!MESSAGE No configuration specified. Defaulting to bsptree - Win32 Release.
!ENDIF
!IF "$(CFG)" != "bsptree - Win32 Release" && "$(CFG)" != "bsptree - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bsptree.mak" CFG="bsptree - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bsptree - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "bsptree - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "bsptree - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\bsptree.lib"
CLEAN :
-@erase "$(INTDIR)\Bsptmpl.obj"
-@erase "$(INTDIR)\Rgbtree.obj"
-@erase "$(INTDIR)\Stdtmpl.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\bsptree.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MT /GX /D "NDEBUG" /D "STRICT" /D "WIN32" /D "_WINDOWS" /D "__FLAT__" /Fp"$(INTDIR)\bsptree.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\bsptree.bsc"
BSC32_SBRS= \
LIB32=link.exe -lib
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\bsptree.lib"
LIB32_OBJS= \
"$(INTDIR)\Bsptmpl.obj" \
"$(INTDIR)\Rgbtree.obj" \
"$(INTDIR)\Stdtmpl.obj"
"$(OUTDIR)\bsptree.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
<<
!ELSEIF "$(CFG)" == "bsptree - Win32 Debug"
OUTDIR=.\msvcobj
INTDIR=.\msvcobj
ALL : "..\exe\msbsp.lib"
CLEAN :
-@erase "$(INTDIR)\Bsptmpl.obj"
-@erase "$(INTDIR)\Rgbtree.obj"
-@erase "$(INTDIR)\Stdtmpl.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "..\exe\msbsp.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /Gr /MDd /GX /Zi /Od /I "\work" /I "\parts" /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "_WINDOWS" /D "WIN32" /Fp"$(INTDIR)\bsptree.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\bsptree.bsc"
BSC32_SBRS= \
LIB32=link.exe -lib
LIB32_FLAGS=/nologo /out:"..\exe\msbsp.lib"
LIB32_OBJS= \
"$(INTDIR)\Bsptmpl.obj" \
"$(INTDIR)\Rgbtree.obj" \
"$(INTDIR)\Stdtmpl.obj"
"..\exe\msbsp.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
$(LIB32) @<<
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
<<
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("bsptree.dep")
!INCLUDE "bsptree.dep"
!ELSE
!MESSAGE Warning: cannot find "bsptree.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "bsptree - Win32 Release" || "$(CFG)" == "bsptree - Win32 Debug"
SOURCE=.\Bsptmpl.cpp
"$(INTDIR)\Bsptmpl.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\Rgbtree.cpp
"$(INTDIR)\Rgbtree.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\Stdtmpl.cpp
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

BIN
bsptree/bsptree.mdp Normal file

Binary file not shown.

BIN
bsptree/bsptree.opt Normal file

Binary file not shown.