CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
SiExtents.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
38namespace OdSi
39{
40
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 if (extents.minPoint().x == maxPoint().x || extents.minPoint().y == maxPoint().y
81 || minPoint().x == extents.maxPoint().x || minPoint().y == extents.maxPoint().y)
82 return false;//extents not intersect, they has one a border for both
83 return !( extents.minPoint().x > (maxPoint().x + tol.equalPoint())
84 || extents.minPoint().y > (maxPoint().y + tol.equalPoint())
85 || minPoint().x > (extents.maxPoint().x + tol.equalPoint())
86 || minPoint().y > (extents.maxPoint().y + tol.equalPoint()));
87 }
88 }
89
91 {
92 left = 0, // Coordinate is to the *left* of the *extents*.
93 upon = 1, // Coordinate is *upon* the *extents*.
94 right = 2 // Coordinate is to the *right* of the *extents*.
95 };
96
97
98#ifndef SWIG
116 IntersectResult intersects( double coordinate, int dimension, double tol = OdGeContext::gTol.equalPoint() ) const
117 {
118 if ( m_min[dimension] > (coordinate + tol) ) return right;
119 if ( m_max[dimension] < (coordinate - tol) ) return left;
120 return upon;
121 }
122#endif
128 void makeHalf( int dimension, bool moveRight )
129 {
130 if ( moveRight )
131 m_max[dimension] = ( m_min[dimension] + m_max[dimension]) / 2;
132 else
133 m_min[dimension] = ( m_min[dimension] + m_max[dimension]) / 2;
134 }
135
141 void makeDouble( int dimension, bool moveRight )
142 {
143 if ( moveRight )
144 m_max[dimension] += ( m_max[dimension] - m_min[dimension] );
145 else
146 m_min[dimension] -= ( m_max[dimension] - m_min[dimension] );
147 }
152 void makeCube( bool planar )
153 {
154 if ( m_min.isEqualTo( m_max ) ) return;
155 double ext = odmax( m_max.x - m_min.x, m_max.y - m_min.y );
156 if ( !planar ) ext = odmax( m_max.z - m_min.z, ext );
157 m_max.x = m_min.x + ext;
158 m_max.y = m_min.y + ext;
159 if ( !planar ) m_max.z = m_min.z + ext;
160 }
161
166 Extent3d( const OdGePoint3d& min, const OdGePoint3d& max )
167 : OdGeExtents3d( min, max ) {}
170 : OdGeExtents3d( OdGePoint3d( source.minPoint().x, source.minPoint().y, 0 ),
171 OdGePoint3d( source.maxPoint().x, source.maxPoint().y, 0 )) {}
172 };
173}
174#endif
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
tol
Definition: DimVarDefs.h:2287
#define odmax(X, Y)
Definition: OdPlatform.h:35
#define ODSI_API
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:443
bool contains(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
Definition: GeExtents3d.h:521
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:438
double z
Definition: GePoint3d.h:497
double y
Definition: GePoint3d.h:496
double x
Definition: GePoint3d.h:495
Definition: GeTol.h:49
void makeHalf(int dimension, bool moveRight)
Definition: SiExtents.h:128
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:116
Extent3d(const OdGePoint3d &min, const OdGePoint3d &max)
Definition: SiExtents.h:166
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:152
Extent3d(const OdGeExtents2d &source)
Definition: SiExtents.h:169
Extent3d(const OdGeExtents3d &source)
Definition: SiExtents.h:168
void makeDouble(int dimension, bool moveRight)
Definition: SiExtents.h:141
GLsizei GLsizei GLchar * source
Definition: gles2_ext.h:282
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
Definition: SiVolume.h:34
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65