1 // Created on: 2005-01-21
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <MeshVS_DataSource3D.hxx>
18 #include <Standard_Type.hxx>
20 IMPLEMENT_STANDARD_RTTIEXT(MeshVS_DataSource3D,MeshVS_DataSource)
22 //================================================================
23 // Function : GetPrismTopology
25 //================================================================
26 Handle( MeshVS_HArray1OfSequenceOfInteger )
27 MeshVS_DataSource3D::GetPrismTopology( const Standard_Integer BasePoints ) const
29 if( myPrismTopos.IsBound( BasePoints ) )
30 return myPrismTopos.Find( BasePoints );
33 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePrismTopology( BasePoints );
34 if( !result.IsNull() )
35 ( ( MeshVS_DataSource3D* )this )->myPrismTopos.Bind( BasePoints, result );
40 //================================================================
41 // Function : GetPyramidTopology
43 //================================================================
44 Handle( MeshVS_HArray1OfSequenceOfInteger )
45 MeshVS_DataSource3D::GetPyramidTopology( const Standard_Integer BasePoints ) const
47 if( myPyramidTopos.IsBound( BasePoints ) )
48 return myPyramidTopos.Find( BasePoints );
51 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePyramidTopology( BasePoints );
52 if( !result.IsNull() )
53 ( ( MeshVS_DataSource3D* )this )->myPyramidTopos.Bind( BasePoints, result );
58 //================================================================
59 // Function : CreatePrismTopology
61 //================================================================
62 Handle( MeshVS_HArray1OfSequenceOfInteger )
63 MeshVS_DataSource3D::CreatePrismTopology( const Standard_Integer BasePoints )
65 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
69 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+2 );
70 Standard_Integer i, next;
72 for( i=0; i<BasePoints; i++ )
74 result->ChangeValue( 1 ).Prepend( i );
75 result->ChangeValue( 2 ).Append( i+BasePoints );
77 result->ChangeValue( 3+i ).Prepend( i );
78 result->ChangeValue( 3+i ).Prepend( i+BasePoints );
79 next = ( i+1 ) % BasePoints;
80 result->ChangeValue( 3+i ).Prepend( next+BasePoints );
81 result->ChangeValue( 3+i ).Prepend( next );
88 //================================================================
89 // Function : CreatePyramidTopology
91 //================================================================
92 Handle( MeshVS_HArray1OfSequenceOfInteger )
93 MeshVS_DataSource3D::CreatePyramidTopology( const Standard_Integer BasePoints )
95 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
99 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+1 );
101 for( Standard_Integer i=1; i<=BasePoints; i++ )
103 result->ChangeValue( 1 ).Prepend( i );
104 result->ChangeValue( 1+i ).Append( 0 );
105 result->ChangeValue( 1+i ).Append( i );
106 result->ChangeValue( 1+i ).Append( i%BasePoints + 1 );