CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
SiShapePlane.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#ifndef _SiShapePlane_h_Included_
25#define _SiShapePlane_h_Included_
26
27#include "Ge/GePlane.h"
28#include "Ge/GeExtents3d.h"
29#include "Ge/GeBoundBlock3d.h"
30#include "Si/SiSpatialIndex.h"
31
32#include "TD_PackPush.h"
33
40struct OdSiShapePlane : public OdSiShape {
43
44 OdSiShapePlane( const OdGePoint3d& pointOnPlane, const OdGeVector3d& planeNormal ) {
45 m_pointOnPlane = pointOnPlane;
46 m_planeNormal = planeNormal;
47 }
48 OdSiShapePlane( const OdGePlane& plane ) {
50 m_planeNormal = plane.normal();
51 }
52 inline double signedDistanceTo( const OdGePoint3d& pt ) const {
54 }
55 bool contains( const OdGeExtents3d& , bool , const OdGeTol& ) const {
56 return false;
57 }
58 bool intersects( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol ) const {
59 const OdGePoint3d& minPt = extents.minPoint();
60 double e = tol.equalPoint();
61 if( OdLess( signedDistanceTo( minPt ), 0.0, e ) ) {
62 const OdGePoint3d& maxPt = extents.maxPoint();
63 if( !OdLess( signedDistanceTo( maxPt ), 0.0, e ) ) {
64 return true;
65 }
66 OdGePoint3d pt( minPt.x, minPt.y, maxPt.z );
67 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
68 return true;
69 }
70 pt.set( minPt.x, maxPt.y, minPt.z );
71 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
72 return true;
73 }
74 pt.set( maxPt.x, minPt.y, minPt.z );
75 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
76 return true;
77 }
78 pt.set( maxPt.x, maxPt.y, minPt.z );
79 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
80 return true;
81 }
82 pt.set( maxPt.x, minPt.y, maxPt.z );
83 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
84 return true;
85 }
86 pt.set( minPt.x, maxPt.y, maxPt.z );
87 if( !OdLess( signedDistanceTo( pt ), 0.0, e ) ) {
88 return true;
89 }
90 return false;
91 }
92 else if( OdGreater( signedDistanceTo( minPt ), 0.0, e ) ) {
93 const OdGePoint3d& maxPt = extents.maxPoint();
94 if( !OdGreater( signedDistanceTo( maxPt ), 0.0, e ) ) {
95 return true;
96 }
97 OdGePoint3d pt( minPt.x, minPt.y, maxPt.z );
98 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
99 return true;
100 }
101 pt.set( minPt.x, maxPt.y, minPt.z );
102 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
103 return true;
104 }
105 pt.set( maxPt.x, minPt.y, minPt.z );
106 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
107 return true;
108 }
109 pt.set( maxPt.x, maxPt.y, minPt.z );
110 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
111 return true;
112 }
113 pt.set( maxPt.x, minPt.y, maxPt.z );
114 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
115 return true;
116 }
117 pt.set( minPt.x, maxPt.y, maxPt.z );
118 if( !OdGreater( signedDistanceTo( pt ), 0.0, e ) ) {
119 return true;
120 }
121 return false;
122 }
123 return true; // point on plane
124 }
125 virtual OdSiShape* clone() const { return new OdSiShapePlane(m_pointOnPlane, m_planeNormal); }
126 virtual void transform(const OdGeMatrix3d& tf)
127 {
131 }
132};
133
138{
139 OdSiHalfSpace( const OdGePoint3d& pointOnPlane, const OdGeVector3d& planeNormal ): OdSiShapePlane(pointOnPlane, planeNormal)
140 {
141 }
142
143 OdSiHalfSpace( const OdGePlane& plane ): OdSiShapePlane(plane){
144 }
145
146 void copyFrom(const OdSiHalfSpace& o)
147 {
148 m_pointOnPlane = o.m_pointOnPlane;
149 m_planeNormal = o.m_planeNormal;
150 }
151
152 virtual bool contains(const OdGeExtents3d& extents, bool planar, const OdGeTol& tol) const
153 {
154 double e = tol.equalPoint();
155 return OdGreaterOrEqual(signedDistanceTo(extents.minPoint()), 0.0, e) &&
156 OdGreaterOrEqual(signedDistanceTo(extents.maxPoint()), 0.0, e) &&
157 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.minPoint().y, extents.maxPoint().z)), 0.0, e) &&
158 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.maxPoint().y, extents.minPoint().z)), 0.0, e) &&
159 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.minPoint().y, extents.minPoint().z)), 0.0, e) &&
160 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.maxPoint().y, extents.minPoint().z)), 0.0, e) &&
161 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.minPoint().y, extents.maxPoint().z)), 0.0, e) &&
162 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.maxPoint().y, extents.maxPoint().z)), 0.0, e);
163 }
164
165 virtual bool intersects( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol ) const
166 {
167 double e = tol.equalPoint();
168 return OdGreaterOrEqual(signedDistanceTo(extents.minPoint()), 0.0, e) ||
169 OdGreaterOrEqual(signedDistanceTo(extents.maxPoint()), 0.0, e) ||
170 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.minPoint().y, extents.maxPoint().z)), 0.0, e) ||
171 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.maxPoint().y, extents.minPoint().z)), 0.0, e) ||
172 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.minPoint().y, extents.minPoint().z)), 0.0, e) ||
173 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.maxPoint().y, extents.minPoint().z)), 0.0, e) ||
174 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.maxPoint().x, extents.minPoint().y, extents.maxPoint().z)), 0.0, e) ||
175 OdGreaterOrEqual(signedDistanceTo(OdGePoint3d(extents.minPoint().x, extents.maxPoint().y, extents.maxPoint().z)), 0.0, e);
176 }
177
178 virtual OdSiShape* clone() const { return new OdSiHalfSpace(m_pointOnPlane, m_planeNormal); }
179
180 bool intersects(const OdGeBoundBlock3d& extents, const OdGeTol& tol, bool& bContains) const;
181};
182
183#include "TD_PackPop.h"
184
185#endif
tol
Definition: DimVarDefs.h:2287
bool OdLess(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:547
bool OdGreater(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:557
bool OdGreaterOrEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:562
#define ODSI_API
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:443
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:438
OdGePoint3d pointOnPlane() const
OdGeVector3d normal() const
double z
Definition: GePoint3d.h:497
OdGePoint3d & transformBy(const OdGeMatrix3d &xfm)
double y
Definition: GePoint3d.h:496
double x
Definition: GePoint3d.h:495
OdGePoint3d & set(double xx, double yy, double zz)
Definition: GePoint3d.h:455
Definition: GeTol.h:49
double dotProduct(const OdGeVector3d &vect) const
Definition: GeVector3d.h:586
OdGeVector3d & normalize(const OdGeTol &tol=OdGeContext::gTol)
OdGeVector3d & transformBy(const OdGeMatrix3d &xfm)
virtual bool contains(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol) const
Definition: SiShapePlane.h:152
OdSiHalfSpace(const OdGePlane &plane)
Definition: SiShapePlane.h:143
virtual bool intersects(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol) const
Definition: SiShapePlane.h:165
virtual OdSiShape * clone() const
Definition: SiShapePlane.h:178
bool intersects(const OdGeBoundBlock3d &extents, const OdGeTol &tol, bool &bContains) const
OdSiHalfSpace(const OdGePoint3d &pointOnPlane, const OdGeVector3d &planeNormal)
Definition: SiShapePlane.h:139
void copyFrom(const OdSiHalfSpace &o)
Definition: SiShapePlane.h:146
double signedDistanceTo(const OdGePoint3d &pt) const
Definition: SiShapePlane.h:52
OdSiShapePlane(const OdGePoint3d &pointOnPlane, const OdGeVector3d &planeNormal)
Definition: SiShapePlane.h:44
bool intersects(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol) const
Definition: SiShapePlane.h:58
virtual void transform(const OdGeMatrix3d &tf)
Definition: SiShapePlane.h:126
OdGeVector3d m_planeNormal
Definition: SiShapePlane.h:42
OdGePoint3d m_pointOnPlane
Definition: SiShapePlane.h:41
bool contains(const OdGeExtents3d &, bool, const OdGeTol &) const
Definition: SiShapePlane.h:55
OdSiShapePlane(const OdGePlane &plane)
Definition: SiShapePlane.h:48
virtual OdSiShape * clone() const
Definition: SiShapePlane.h:125