0024750: Replace instantiations of TCollection generic classes by NCollection templat...
[occt.git] / src / MeshVS / MeshVS_DataSource3D.cxx
CommitLineData
b311480e 1// Created on: 2005-01-21
2// Created by: Alexander SOLOVYOV
973c2be1 3// Copyright (c) 2005-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <MeshVS_DataSource3D.ixx>
17
18//================================================================
19// Function : GetPrismTopology
20// Purpose :
21//================================================================
22Handle( MeshVS_HArray1OfSequenceOfInteger )
23 MeshVS_DataSource3D::GetPrismTopology( const Standard_Integer BasePoints ) const
24{
25 if( myPrismTopos.IsBound( BasePoints ) )
26 return myPrismTopos.Find( BasePoints );
27 else
28 {
29 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePrismTopology( BasePoints );
30 if( !result.IsNull() )
31 ( ( MeshVS_DataSource3D* )this )->myPrismTopos.Bind( BasePoints, result );
32 return result;
33 }
34}
35
36//================================================================
37// Function : GetPyramidTopology
38// Purpose :
39//================================================================
40Handle( MeshVS_HArray1OfSequenceOfInteger )
41 MeshVS_DataSource3D::GetPyramidTopology( const Standard_Integer BasePoints ) const
42{
43 if( myPyramidTopos.IsBound( BasePoints ) )
44 return myPyramidTopos.Find( BasePoints );
45 else
46 {
47 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePyramidTopology( BasePoints );
48 if( !result.IsNull() )
49 ( ( MeshVS_DataSource3D* )this )->myPyramidTopos.Bind( BasePoints, result );
50 return result;
51 }
52}
53
54//================================================================
55// Function : CreatePrismTopology
56// Purpose :
57//================================================================
58Handle( MeshVS_HArray1OfSequenceOfInteger )
59 MeshVS_DataSource3D::CreatePrismTopology( const Standard_Integer BasePoints )
60{
61 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
62
63 if( BasePoints>=3 )
64 {
65 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+2 );
66 Standard_Integer i, next;
67
68 for( i=0; i<BasePoints; i++ )
69 {
70 result->ChangeValue( 1 ).Prepend( i );
71 result->ChangeValue( 2 ).Append( i+BasePoints );
72
73 result->ChangeValue( 3+i ).Prepend( i );
74 result->ChangeValue( 3+i ).Prepend( i+BasePoints );
75 next = ( i+1 ) % BasePoints;
76 result->ChangeValue( 3+i ).Prepend( next+BasePoints );
77 result->ChangeValue( 3+i ).Prepend( next );
78 }
79 }
80
81 return result;
82}
83
84//================================================================
85// Function : CreatePyramidTopology
86// Purpose :
87//================================================================
88Handle( MeshVS_HArray1OfSequenceOfInteger )
89 MeshVS_DataSource3D::CreatePyramidTopology( const Standard_Integer BasePoints )
90{
91 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
92
93 if( BasePoints>=3 )
94 {
95 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+1 );
96
97 for( Standard_Integer i=1; i<=BasePoints; i++ )
98 {
99 result->ChangeValue( 1 ).Prepend( i );
100 result->ChangeValue( 1+i ).Append( 0 );
101 result->ChangeValue( 1+i ).Append( i );
102 result->ChangeValue( 1+i ).Append( i%BasePoints + 1 );
103 }
104 }
105
106 return result;
107}