summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmviewstructure.cpp
blob: 966df90bcc4530ba52ff0eddbb1b623c09101923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2000-2001 by Andreas Zehender
    email                : zehender@kde.org
**************************************************************************

**************************************************************************
*                                                                        *
*  This program is free software; you can redistribute it and/or modify  *
*  it under the terms of the GNU General Public License as published by  *
*  the Free Software Foundation; either version 2 of the License, or     *
*  (at your option) any later version.                                   *
*                                                                        *
**************************************************************************/


#include "pmviewstructure.h"

/*
void PMViewStructure::render( )
{
   glVertexPointer( 3, GL_DOUBLE, sizeof( PMVector ), points.data( ) );
   glDrawElements( GL_LINES, lines.size( ) * 2,
                   GL_UNSIGNED_INT, lines.data( ) );
}
*/

PMViewStructure::PMViewStructure( )
{
   m_parameterKey = -1;
}

PMViewStructure::PMViewStructure( unsigned int n, unsigned int l, unsigned int f )
{
   m_points.resize( n );
   m_lines.resize( l );
   m_faces.resize( f );
   m_parameterKey = -1;
}

PMViewStructure::PMViewStructure( const PMViewStructure& vs )
{
   m_points = vs.m_points;
   m_lines = vs.m_lines;
   m_faces = vs.m_faces;
   m_parameterKey = vs.m_parameterKey;
}

PMViewStructure::PMViewStructure( const PMViewStructure* vs )
{
   m_points = vs->m_points;
   m_lines = vs->m_lines;
   m_faces = vs->m_faces;
   m_parameterKey = vs->m_parameterKey;
}

PMViewStructure& PMViewStructure::operator = ( const PMViewStructure& vs )
{
   m_lines = vs.m_lines;
   m_points = vs.m_points;
   m_faces = vs.m_faces;

   return *this;
}

bool PMViewStructure::operator == ( const PMViewStructure& vs ) const
{
   return ( ( m_lines.data( ) == vs.m_lines.data( ) )
            && ( m_points.data( ) == vs.m_points.data( ) )
            && ( m_faces == vs.m_faces ) );
}

bool PMViewStructure::operator != ( const PMViewStructure& vs ) const
{
   return ( ( m_lines.data( ) != vs.m_lines.data( ) )
            || ( m_points.data( ) != vs.m_points.data( ) )
            || !( m_faces == vs.m_faces ) );
}


PMBoundingBox::PMBoundingBox( const PMVector& min, const PMVector& max )
{
   m_bValid = true;
   m_min = min;
   m_max = max;
}

PMBoundingBox::PMBoundingBox( )
{
   m_bValid = false;
   m_min = PMVector( 0.0, 0.0, 0.0 );
   m_max = PMVector( 0.0, 0.0, 0.0 );
}

void PMBoundingBox::mergeWith( const PMBoundingBox& box )
{
   if( m_bValid )
   {
      if( box.m_bValid )
      {
         if( box.m_min.x( ) < m_min.x( ) )
            m_min.setX( box.m_min.x( ) );
         if( box.m_min.y( ) < m_min.y( ) )
            m_min.setY( box.m_min.y( ) );
         if( box.m_min.z( ) < m_min.z( ) )
            m_min.setZ( box.m_min.z( ) );

         if( box.m_max.x( ) > m_max.x( ) )
            m_max.setX( box.m_max.x( ) );
         if( box.m_max.y( ) > m_max.y( ) )
            m_max.setY( box.m_max.y( ) );
         if( box.m_max.z( ) > m_max.z( ) )
            m_max.setZ( box.m_max.z( ) );
      }
   }
   else
   {
      if( box.m_bValid )
      {
         m_bValid = true;
         m_max = box.m_max;
         m_min = box.m_min;
      }
   }
}