0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[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
42cf5bc1 16
17#include <MeshVS_DataSource3D.hxx>
18#include <Standard_Type.hxx>
7fd59977 19
92efcf78 20IMPLEMENT_STANDARD_RTTIEXT(MeshVS_DataSource3D,MeshVS_DataSource)
21
7fd59977 22//================================================================
23// Function : GetPrismTopology
24// Purpose :
25//================================================================
26Handle( MeshVS_HArray1OfSequenceOfInteger )
27 MeshVS_DataSource3D::GetPrismTopology( const Standard_Integer BasePoints ) const
28{
29 if( myPrismTopos.IsBound( BasePoints ) )
30 return myPrismTopos.Find( BasePoints );
31 else
32 {
33 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePrismTopology( BasePoints );
34 if( !result.IsNull() )
35 ( ( MeshVS_DataSource3D* )this )->myPrismTopos.Bind( BasePoints, result );
36 return result;
37 }
38}
39
40//================================================================
41// Function : GetPyramidTopology
42// Purpose :
43//================================================================
44Handle( MeshVS_HArray1OfSequenceOfInteger )
45 MeshVS_DataSource3D::GetPyramidTopology( const Standard_Integer BasePoints ) const
46{
47 if( myPyramidTopos.IsBound( BasePoints ) )
48 return myPyramidTopos.Find( BasePoints );
49 else
50 {
51 Handle( MeshVS_HArray1OfSequenceOfInteger ) result = CreatePyramidTopology( BasePoints );
52 if( !result.IsNull() )
53 ( ( MeshVS_DataSource3D* )this )->myPyramidTopos.Bind( BasePoints, result );
54 return result;
55 }
56}
57
58//================================================================
59// Function : CreatePrismTopology
60// Purpose :
61//================================================================
62Handle( MeshVS_HArray1OfSequenceOfInteger )
63 MeshVS_DataSource3D::CreatePrismTopology( const Standard_Integer BasePoints )
64{
65 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
66
67 if( BasePoints>=3 )
68 {
69 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+2 );
70 Standard_Integer i, next;
71
72 for( i=0; i<BasePoints; i++ )
73 {
74 result->ChangeValue( 1 ).Prepend( i );
75 result->ChangeValue( 2 ).Append( i+BasePoints );
76
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 );
82 }
83 }
84
85 return result;
86}
87
88//================================================================
89// Function : CreatePyramidTopology
90// Purpose :
91//================================================================
92Handle( MeshVS_HArray1OfSequenceOfInteger )
93 MeshVS_DataSource3D::CreatePyramidTopology( const Standard_Integer BasePoints )
94{
95 Handle( MeshVS_HArray1OfSequenceOfInteger ) result;
96
97 if( BasePoints>=3 )
98 {
99 result = new MeshVS_HArray1OfSequenceOfInteger( 1, BasePoints+1 );
100
101 for( Standard_Integer i=1; i<=BasePoints; i++ )
102 {
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 );
107 }
108 }
109
110 return result;
111}