CFx SDK Documentation  2023 SP0
SiExtents.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 #ifndef _SpExtents_h_Included_
26 #define _SpExtents_h_Included_
27 
28 #if _MSC_VER >= 1000
29 #pragma once
30 #endif
31 
32 #include "Si/SiSpatialIndex.h"
33 
38 namespace OdSi
39 {
40 
46  class ODSI_API Extent3d : public OdGeExtents3d, public OdSiShape
47  {
48  public:
49  virtual bool contains( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol) const
50  {
51  if ( planar )
52  {
53  ODA_ASSERT ( extents.minPoint().z == 0 && extents.maxPoint().z == 0 );
54  }
55  return OdGeExtents3d::contains( extents, tol );
56  }
57 
74  virtual bool intersects( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol) const
75  {
76  if ( planar == false )
77  return !isDisjoint( extents, tol );
78  else
79  {
80  return !( extents.minPoint().x > (maxPoint().x + tol.equalPoint())
81  || extents.minPoint().y > (maxPoint().y + tol.equalPoint())
82  || minPoint().x > (extents.maxPoint().x + tol.equalPoint())
83  || minPoint().y > (extents.maxPoint().y + tol.equalPoint()));
84  }
85  }
86 
88  {
89  left = 0, // Coordinate is to the *left* of the *extents*.
90  upon = 1, // Coordinate is *upon* the *extents*.
91  right = 2 // Coordinate is to the *right* of the *extents*.
92  };
93 
94 
95 #ifndef SWIG
113  IntersectResult intersects( double coordinate, int dimension, double tol = OdGeContext::gTol.equalPoint() ) const
114  {
115  if ( m_min[dimension] > (coordinate + tol) ) return right;
116  if ( m_max[dimension] < (coordinate - tol) ) return left;
117  return upon;
118  }
119 #endif
125  void makeHalf( int dimension, bool moveRight )
126  {
127  if ( moveRight )
128  m_max[dimension] = ( m_min[dimension] + m_max[dimension]) / 2;
129  else
130  m_min[dimension] = ( m_min[dimension] + m_max[dimension]) / 2;
131  }
132 
138  void makeDouble( int dimension, bool moveRight )
139  {
140  if ( moveRight )
141  m_max[dimension] += ( m_max[dimension] - m_min[dimension] );
142  else
143  m_min[dimension] -= ( m_max[dimension] - m_min[dimension] );
144  }
149  void makeCube( bool planar )
150  {
151  if ( m_min.isEqualTo( m_max ) ) return;
152  double ext = odmax( m_max.x - m_min.x, m_max.y - m_min.y );
153  if ( !planar ) ext = odmax( m_max.z - m_min.z, ext );
154  m_max.x = m_min.x + ext;
155  m_max.y = m_min.y + ext;
156  if ( !planar ) m_max.z = m_min.z + ext;
157  }
158 
159  Extent3d() {}
164  : OdGeExtents3d( min, max ) {}
167  : OdGeExtents3d( OdGePoint3d( source.minPoint().x, source.minPoint().y, 0 ),
168  OdGePoint3d( source.maxPoint().x, source.maxPoint().y, 0 )) {}
169  };
170 }
171 #endif
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
tol
Definition: DimVarDefs.h:2287
#define odmax(X, Y)
Definition: OdPlatform.h:35
#define ODSI_API
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:259
bool contains(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
Definition: GeExtents3d.h:375
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:254
double z
Definition: GePoint3d.h:369
double y
Definition: GePoint3d.h:368
double x
Definition: GePoint3d.h:367
Definition: GeTol.h:49
void makeHalf(int dimension, bool moveRight)
Definition: SiExtents.h:125
virtual bool intersects(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition: SiExtents.h:74
IntersectResult intersects(double coordinate, int dimension, double tol=OdGeContext::gTol.equalPoint()) const
Definition: SiExtents.h:113
Extent3d(const OdGePoint3d &min, const OdGePoint3d &max)
Definition: SiExtents.h:163
virtual bool contains(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition: SiExtents.h:49
void makeCube(bool planar)
Definition: SiExtents.h:149
Extent3d(const OdGeExtents2d &source)
Definition: SiExtents.h:166
Extent3d(const OdGeExtents3d &source)
Definition: SiExtents.h:165
void makeDouble(int dimension, bool moveRight)
Definition: SiExtents.h:138
GLsizei GLsizei GLchar * source
Definition: gles2_ext.h:282
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
const T & min(const T &x, const T &y)
const T & max(const T &x, const T &y)
Definition: SiVolume.h:34
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:60