File indexing completed on 2026-09-12 09:18:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _SelectMgr_RectangularFrustum_HeaderFile
0017 #define _SelectMgr_RectangularFrustum_HeaderFile
0018
0019 #include <SelectMgr_Frustum.hxx>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class SelectMgr_RectangularFrustum : public SelectMgr_Frustum<4>
0033 {
0034 public:
0035
0036
0037 struct SelectionRectangle
0038 {
0039 SelectionRectangle()
0040 : myMinPnt(gp_Pnt2d(RealLast(), RealLast())),
0041 myMaxPnt(gp_Pnt2d(RealLast(), RealLast()))
0042 {
0043 }
0044
0045 const gp_Pnt2d& MousePos() const { return myMinPnt; }
0046
0047 void SetMousePos(const gp_Pnt2d& thePos)
0048 {
0049 myMinPnt = thePos;
0050 myMaxPnt = thePos;
0051 }
0052
0053 const gp_Pnt2d& MinPnt() const { return myMinPnt; }
0054
0055 void SetMinPnt(const gp_Pnt2d& theMinPnt) { myMinPnt = theMinPnt; }
0056
0057 const gp_Pnt2d& MaxPnt() const { return myMaxPnt; }
0058
0059 void SetMaxPnt(const gp_Pnt2d& theMaxPnt) { myMaxPnt = theMaxPnt; }
0060
0061 private:
0062 gp_Pnt2d myMinPnt;
0063 gp_Pnt2d myMaxPnt;
0064 };
0065
0066
0067 Standard_EXPORT SelectMgr_RectangularFrustum();
0068
0069
0070 Standard_EXPORT void Init(const gp_Pnt2d& thePoint);
0071
0072
0073 Standard_EXPORT void Init(const gp_Pnt2d& theMinPnt, const gp_Pnt2d& theMaxPnt);
0074
0075
0076 Standard_EXPORT bool isIntersectCircle(const double theRadius,
0077 const gp_Pnt& theCenter,
0078 const gp_Trsf& theTrsf,
0079 const NCollection_Array1<gp_Pnt>& theVertices) const;
0080
0081
0082 Standard_EXPORT bool isSegmentsIntersect(const gp_Pnt& thePnt1Seg1,
0083 const gp_Pnt& thePnt2Seg1,
0084 const gp_Pnt& thePnt1Seg2,
0085 const gp_Pnt& thePnt2Seg2) const;
0086
0087
0088
0089 Standard_EXPORT void Build() override;
0090
0091
0092
0093 Standard_EXPORT bool IsScalable() const override;
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 Standard_EXPORT occ::handle<SelectMgr_BaseIntersector> ScaleAndTransform(
0105 const int theScaleFactor,
0106 const gp_GTrsf& theTrsf,
0107 const occ::handle<SelectMgr_FrustumBuilder>& theBuilder) const override;
0108
0109
0110
0111
0112
0113
0114
0115 Standard_EXPORT occ::handle<SelectMgr_BaseIntersector> CopyWithBuilder(
0116 const occ::handle<SelectMgr_FrustumBuilder>& theBuilder) const override;
0117
0118
0119
0120
0121 Standard_EXPORT bool OverlapsBox(const NCollection_Vec3<double>& theBoxMin,
0122 const NCollection_Vec3<double>& theBoxMax,
0123 const SelectMgr_ViewClipRange& theClipRange,
0124 SelectBasics_PickResult& thePickResult) const override;
0125
0126
0127
0128 Standard_EXPORT bool OverlapsBox(const NCollection_Vec3<double>& theBoxMin,
0129 const NCollection_Vec3<double>& theBoxMax,
0130 bool* theInside) const override;
0131
0132
0133 Standard_EXPORT bool OverlapsPoint(const gp_Pnt& thePnt,
0134 const SelectMgr_ViewClipRange& theClipRange,
0135 SelectBasics_PickResult& thePickResult) const override;
0136
0137
0138 Standard_EXPORT bool OverlapsPoint(const gp_Pnt& thePnt) const override;
0139
0140
0141
0142
0143 Standard_EXPORT bool OverlapsPolygon(const NCollection_Array1<gp_Pnt>& theArrayOfPnts,
0144 Select3D_TypeOfSensitivity theSensType,
0145 const SelectMgr_ViewClipRange& theClipRange,
0146 SelectBasics_PickResult& thePickResult) const override;
0147
0148
0149 Standard_EXPORT bool OverlapsSegment(const gp_Pnt& thePnt1,
0150 const gp_Pnt& thePnt2,
0151 const SelectMgr_ViewClipRange& theClipRange,
0152 SelectBasics_PickResult& thePickResult) const override;
0153
0154
0155
0156
0157 Standard_EXPORT bool OverlapsTriangle(const gp_Pnt& thePnt1,
0158 const gp_Pnt& thePnt2,
0159 const gp_Pnt& thePnt3,
0160 Select3D_TypeOfSensitivity theSensType,
0161 const SelectMgr_ViewClipRange& theClipRange,
0162 SelectBasics_PickResult& thePickResult) const override;
0163
0164
0165 Standard_EXPORT bool OverlapsSphere(const gp_Pnt& theCenter,
0166 const double theRadius,
0167 const SelectMgr_ViewClipRange& theClipRange,
0168 SelectBasics_PickResult& thePickResult) const override;
0169
0170
0171 Standard_EXPORT bool OverlapsSphere(const gp_Pnt& theCenter,
0172 const double theRadius,
0173 bool* theInside) const override;
0174
0175
0176
0177 Standard_EXPORT bool OverlapsCylinder(const double theBottomRad,
0178 const double theTopRad,
0179 const double theHeight,
0180 const gp_Trsf& theTrsf,
0181 const bool theIsHollow,
0182 const SelectMgr_ViewClipRange& theClipRange,
0183 SelectBasics_PickResult& thePickResult) const override;
0184
0185
0186
0187 Standard_EXPORT bool OverlapsCylinder(const double theBottomRad,
0188 const double theTopRad,
0189 const double theHeight,
0190 const gp_Trsf& theTrsf,
0191 const bool theIsHollow,
0192 bool* theInside = nullptr) const override;
0193
0194
0195
0196
0197
0198 Standard_EXPORT bool OverlapsCircle(const double theBottomRad,
0199 const gp_Trsf& theTrsf,
0200 const bool theIsFilled,
0201 const SelectMgr_ViewClipRange& theClipRange,
0202 SelectBasics_PickResult& thePickResult) const override;
0203
0204
0205
0206
0207
0208 Standard_EXPORT bool OverlapsCircle(const double theBottomRad,
0209 const gp_Trsf& theTrsf,
0210 const bool theIsFilled,
0211 bool* theInside = nullptr) const override;
0212
0213
0214
0215
0216 Standard_EXPORT double DistToGeometryCenter(const gp_Pnt& theCOG) const override;
0217
0218
0219
0220 Standard_EXPORT gp_Pnt DetectedPoint(const double theDepth) const override;
0221
0222
0223 const gp_Pnt* GetVertices() const { return myVertices; }
0224
0225
0226
0227
0228 const gp_Pnt& GetNearPnt() const override { return myNearPickedPnt; }
0229
0230
0231
0232
0233 const gp_Pnt& GetFarPnt() const override { return myFarPickedPnt; }
0234
0235
0236 const gp_Dir& GetViewRayDirection() const override { return myViewRayDir; }
0237
0238
0239 Standard_EXPORT const gp_Pnt2d& GetMousePosition() const override;
0240
0241
0242
0243 Standard_EXPORT void GetPlanes(
0244 NCollection_DynamicArray<NCollection_Vec4<double>>& thePlaneEquations) const override;
0245
0246
0247 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0248
0249 protected:
0250 Standard_EXPORT void segmentSegmentDistance(const gp_Pnt& theSegPnt1,
0251 const gp_Pnt& theSegPnt2,
0252 SelectBasics_PickResult& thePickResult) const;
0253
0254 Standard_EXPORT bool segmentPlaneIntersection(const gp_Vec& thePlane,
0255 const gp_Pnt& thePntOnPlane,
0256 SelectBasics_PickResult& thePickResult) const;
0257
0258 private:
0259 void cacheVertexProjections(SelectMgr_RectangularFrustum* theFrustum) const;
0260
0261 private:
0262 enum
0263 {
0264 LeftTopNear,
0265 LeftTopFar,
0266 LeftBottomNear,
0267 LeftBottomFar,
0268 RightTopNear,
0269 RightTopFar,
0270 RightBottomNear,
0271 RightBottomFar
0272 };
0273
0274 private:
0275
0276 SelectionRectangle mySelRectangle;
0277 gp_Pnt myNearPickedPnt;
0278 gp_Pnt myFarPickedPnt;
0279 gp_Dir myViewRayDir;
0280 double myScale;
0281
0282 };
0283
0284 #endif