1
unit LUX.Brep.Cell.TetraFlip;
3
interface //#################################################################### ■
5
uses LUX, LUX.Graph, LUX.Graph.Tree, LUX.Brep, LUX.Brep.Poin_3d;
7
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
9
TTetraPoin<_TPos_> = class;
10
TTetraCell<_TPoin_:class;_TCell_:class> = class;
12
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
14
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TByteArray4
17
_ :array[ 0..3 ] of Byte;
20
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraLink<_TPos_>
22
TTetraLink<_TPoin_:class;_TCell_:class> = record
23
o :TTetraCell<_TPoin_,_TCell_>;
28
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
30
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraPoin<_TPos_>
32
TTetraPoin<_TPos_> = class( TPoin<_TPos_> )
38
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraCell<_TPoin_,_TCell_>
40
TTetraCell<_TPoin_:class;_TCell_:class> = class( TTreeNode<_TCell_> )
43
_Poin :array[ 0..3 ] of _TPoin_;
44
_Cell :array[ 0..3 ] of _TCell_;
48
function GetPoin( const I_:Byte ) :_TPoin_;
49
procedure SetPoin( const I_:Byte; const Poin_:_TPoin_ );
50
function GetCell( const I_:Byte ) :_TCell_;
51
procedure SetCell( const I_:Byte; const Cell_:_TCell_ );
52
function GetVert( const I_:Byte ) :Byte;
53
procedure SetVert( const I_:Byte; const Vert_:Byte );
54
function GetBond( const I_:Byte ) :Byte;
55
procedure SetBond( const I_:Byte; const Bond_:Byte );
56
function GetJoin( const K_,I_:Byte ) :Byte;
57
function GetOpen :Shortint;
59
destructor Destroy; override;
61
property Poin[ const I_:Byte ] :_TPoin_ read GetPoin write SetPoin;
62
property Cell[ const I_:Byte ] :_TCell_ read GetCell write SetCell;
63
property Vert[ const I_:Byte ] :Byte read GetVert write SetVert;
64
property Bond[ const I_:Byte ] :Byte read GetBond write SetBond;
65
property Join[ const K_,I_:Byte ] :Byte read GetJoin ;
66
property Open :Shortint read GetOpen ;
69
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraModel<_TPoin_,_TCell_>
71
TTetraModel<_TPoin_:class;_TCell_:class> = class( TTreeNode<_TCell_> )
74
_PoinModel :TPoinModel<_TPoin_>;
76
constructor Create; override;
77
destructor Destroy; override;
79
property PoinModel :TPoinModel<_TPoin_> read _PoinModel;
81
procedure DeleteChilds; override;
84
const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
86
_VertTable :array[ 0..3 ] of TByteArray4 = ( ( _:( 0, 1, 2, 3 ) ),
89
( _:( 3, 2, 1, 0 ) ) );
91
_BondTable :array[ 1..3 ] of TByteArray4 = ( ( _:( 0, 1, 3, 2 ) ),
93
( _:( 0, 2, 1, 3 ) ) );
95
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
97
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
99
implementation //############################################################### ■
103
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
105
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
107
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraPoin<_TPos_>
109
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
111
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
113
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
115
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraCell<_TPos_>
117
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
119
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
121
/////////////////////////////////////////////////////////////////////// アクセス
123
function TTetraCell<_TPoin_,_TCell_>.GetPoin( const I_:Byte ) :_TPoin_;
125
Result := _Poin[ I_ ];
128
procedure TTetraCell<_TPoin_,_TCell_>.SetPoin( const I_:Byte; const Poin_:_TPoin_ );
130
_Poin[ I_ ] := Poin_;
133
function TTetraCell<_TPoin_,_TCell_>.GetCell( const I_:Byte ) :_TCell_;
135
Result := _Cell[ I_ ];
138
procedure TTetraCell<_TPoin_,_TCell_>.SetCell( const I_:Byte; const Cell_:_TCell_ );
140
_Cell[ I_ ] := Cell_;
143
function TTetraCell<_TPoin_,_TCell_>.GetVert( const I_:Byte ) :Byte;
145
Result := _Vert shr I_ shr I_ and 3;
148
procedure TTetraCell<_TPoin_,_TCell_>.SetVert( const I_:Byte; const Vert_:Byte );
150
_Vert := not ( 3 shl I_ shl I_ ) and _Vert or ( Vert_ shl I_ shl I_ );
153
function TTetraCell<_TPoin_,_TCell_>.GetBond( const I_:Byte ) :Byte;
155
Result := _Bond shr I_ shr I_ and 3;
158
procedure TTetraCell<_TPoin_,_TCell_>.SetBond( const I_:Byte; const Bond_:Byte );
160
_Bond := not ( 3 shl I_ shl I_ ) and _Bond or ( Bond_ shl I_ shl I_ );
163
function TTetraCell<_TPoin_,_TCell_>.GetJoin( const K_,I_:Byte ) :Byte;
165
Result := _VertTable[ Vert[ K_ ] ]._[ _BondTable[ Bond[ K_ ] ]._[ I_ ] ];
168
function TTetraCell<_TPoin_,_TCell_>.GetOpen :Shortint;
170
for Result := 0 to 3 do
172
if not Assigned( _Poin[ Result ] ) then Exit;
178
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
180
destructor TTetraCell<_TPoin_,_TCell_>.Destroy;
183
C0, C1 :TTetraCell<_TPoin_,_TCell_>;
187
C1 := TTetraCell<_TPoin_,_TCell_>( Cell[ I ] );
189
if Assigned( C1 ) then
191
C0 := TTetraCell<_TPoin_,_TCell_>( C1.Cell[ Vert[ I ] ] );
193
if C0 = Self then C1.Cell[ Vert[ I ] ] := nil; {ToDO: 相互接続されていない場合があるらしい}
200
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TTetraModel<_TPos_>
202
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
204
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
206
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
208
constructor TTetraModel<_TPoin_,_TCell_>.Create;
212
_PoinModel := TPoinModel<_TPoin_>.Create;
215
destructor TTetraModel<_TPoin_,_TCell_>.Destroy;
222
/////////////////////////////////////////////////////////////////////// メソッド
224
procedure TTetraModel<_TPoin_,_TCell_>.DeleteChilds;
228
_PoinModel.DeleteChilds;
231
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
233
//############################################################################## □
235
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
237
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
239
end. //######################################################################### ■