// Created on: 1995-03-27 // Created by: Robert COUBLANC // Copyright (c) 1995-1999 Matra Datavision // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. //Modif on jun-24-97 : introduction de CSLib_Class2d de LBR // pour teste si on est dedans ou dehors... //Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ... #include #include #include #include #include #include #include #include //================================================== // Function: Hide this constructor to the next version... // Purpose : simply avoid interfering with the version update //================================================== Select3D_SensitiveFace:: Select3D_SensitiveFace(const Handle(SelectBasics_EntityOwner)& OwnerId, const TColgp_Array1OfPnt& ThePoints, const Select3D_TypeOfSensitivity aType): Select3D_SensitivePoly(OwnerId, ThePoints), mytype (aType) { } //================================================== // Function: Creation // Purpose : //================================================== Select3D_SensitiveFace:: Select3D_SensitiveFace(const Handle(SelectBasics_EntityOwner)& OwnerId, const Handle(TColgp_HArray1OfPnt)& ThePoints, const Select3D_TypeOfSensitivity aType): Select3D_SensitivePoly(OwnerId, ThePoints), mytype (aType) { } //================================================== // Function: Matches // Purpose : //================================================== Standard_Boolean Select3D_SensitiveFace::Matches (const SelectBasics_PickArgs& thePickArgs, Standard_Real& theMatchDMin, Standard_Real& theMatchDepth) { Standard_Real DMin2 = 0.; Standard_Real Xmin = 0.,Ymin = 0.,Xmax = 0.,Ymax = 0.; if(!Bnd_Box2d(mybox2d).IsVoid()) { Bnd_Box2d(mybox2d).Get(Xmin,Ymin,Xmax,Ymax); DMin2 = gp_XY(Xmax-Xmin,Ymax-Ymin).SquareModulus(); } // calculation of a criterion of minimum distance... // from start Dmin = size of the bounding box 2D, // then min. distance of the polyhedron or cdg... Standard_Real aTol2 = thePickArgs.Tolerance() * thePickArgs.Tolerance(); Standard_Integer aSize = mypolyg.Size(), anIndex; gp_XY CDG; for(anIndex=0;anIndex1) { CDG/=(aSize-1); } DMin2 = Min (DMin2, gp_XY (CDG.X() - thePickArgs.X(), CDG.Y() - thePickArgs.Y()).SquareModulus()); theMatchDMin = Sqrt(DMin2); Standard_Boolean isplane2d(Standard_True); for(anIndex=1;anIndex thePickArgs.Tolerance()) isplane2d=Standard_False; } if (isplane2d) { theMatchDepth = ComputeDepth (thePickArgs.PickLine(), thePickArgs.DepthMin(), thePickArgs.DepthMax()); return !thePickArgs.IsClipped (theMatchDepth); } //otherwise it is checked if the point is in the face... TColgp_Array1OfPnt2d aArrayOf2dPnt(1, aSize); Points2D(aArrayOf2dPnt); CSLib_Class2d TheInOutTool (aArrayOf2dPnt, thePickArgs.Tolerance(), thePickArgs.Tolerance(), Xmin, Ymin, Xmax, Ymax); Standard_Integer TheStat = TheInOutTool.SiDans (gp_Pnt2d (thePickArgs.X(), thePickArgs.Y())); Standard_Boolean res(Standard_False); switch(TheStat) { case 0: res = Standard_True; case 1: { if(mytype!=Select3D_TOS_BOUNDARY) res = Standard_True; } } if (res) { theMatchDepth = ComputeDepth (thePickArgs.PickLine(), thePickArgs.DepthMin(), thePickArgs.DepthMax()); return !thePickArgs.IsClipped (theMatchDepth); } return Standard_False; } //======================================================================= //function : Matches //purpose : //======================================================================= Standard_Boolean Select3D_SensitiveFace:: Matches (const Standard_Real XMin, const Standard_Real YMin, const Standard_Real XMax, const Standard_Real YMax, const Standard_Real aTol) { Bnd_Box2d BoundBox; BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol); for(Standard_Integer anIndex=0;anIndex theDepthMin) && (aPointDepth < theDepthMax)) { aDepth = aPointDepth; } } return aDepth; } //======================================================================= //function : ComputeDepth //purpose : //======================================================================= void Select3D_SensitiveFace::ComputeDepth(const gp_Lin& /*theEyeLine*/) const { // this method is obsolete. } //======================================================================= //function : GetConnected //purpose : //======================================================================= Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected(const TopLoc_Location &theLocation) { // Create a copy of this Standard_Integer aSize = mypolyg.Size(); TColgp_Array1OfPnt aPoints(1, aSize); for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex) { aPoints.SetValue(anIndex, mypolyg.Pnt(anIndex-1)); } Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveFace(myOwnerId, aPoints, mytype); if (HasLocation()) aNewEntity->SetLocation(Location()); aNewEntity->UpdateLocation(theLocation); return aNewEntity; }