-// File: Select3D_SensitiveCircle.cxx
-// Created: Tue Feb 6 14:15:06 1996
-// Author: Robert COUBLANC
-// <rob@fidox>
-// Modified Tue Apr 14 1998 by rob : fix Bug : Case of Null Radius Circle...
+// Created on: 1996-02-06
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-#include <Select3D_SensitiveCircle.ixx>
-#include <Precision.hxx>
-#include <gp_Lin2d.hxx>
+#include <Geom_Circle.hxx>
-#include <CSLib_Class2d.hxx>
-#include <Select3D_SensitiveTriangle.hxx>
-#include <ElCLib.hxx>
#include <Select3D_Pnt.hxx>
-#include <Select3D_Pnt2d.hxx>
+#include <Select3D_SensitiveTriangle.hxx>
+#include <Precision.hxx>
-//=======================================================================
-//function : Select3D_SensitiveCircle (constructeur)
-//purpose : Definition of a sensitive circle
-//=======================================================================
-static Standard_Integer S3D_GetCircleNBPoints(const Handle(Geom_Circle)& C,
- const Standard_Integer anInputNumber)
-{
- if(C->Radius()>Precision::Confusion())
- return 2*anInputNumber+1;
+#include <Select3D_SensitiveCircle.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (Select3D_SensitiveCircle, Select3D_SensitivePoly)
+IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitivePoly)
+
+static Standard_Integer GetCircleNbPoints (const Handle(Geom_Circle)& theCircle,
+ const Standard_Integer theNbPnts)
+{
+ // Check if number of points is invalid.
+ // In this case myPolyg raises Standard_ConstructionError
+ // exception (look constructor bellow).
+ if (theNbPnts <= 0)
+ return 0;
+
+ if (theCircle->Radius() > Precision::Confusion())
+ return 2 * theNbPnts + 1;
+
+ // The radius is too small and circle degenerates into point
return 1;
}
-static Standard_Integer S3D_GetArcNBPoints(const Handle(Geom_Circle)& C,
- const Standard_Integer anInputNumber)
-{
- if(C->Radius()>Precision::Confusion())
- return 2*anInputNumber-1;
+
+static Standard_Integer GetArcNbPoints (const Handle(Geom_Circle)& theCircle,
+ const Standard_Integer theNbPnts)
+{
+ // There is no need to check number of points here.
+ // In case of invalid number of points this method returns
+ // -1 or smaller value.
+ if (theCircle->Radius() > Precision::Confusion())
+ return 2 * theNbPnts - 1;
+
+ // The radius is too small and circle degenerates into point
return 1;
}
-
-Select3D_SensitiveCircle::
-Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(Geom_Circle)& TheCircle,
- const Standard_Boolean FilledCircle,
- const Standard_Integer NbPoints):
-Select3D_SensitivePoly(OwnerId, S3D_GetCircleNBPoints(TheCircle,NbPoints)),
-myFillStatus(FilledCircle),
-myDetectedIndex(-1)
+
+//=======================================================================
+//function : Select3D_SensitiveCircle (constructor)
+//purpose : Definition of a sensitive circle
+//=======================================================================
+Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& theOwnerId,
+ const Handle(Geom_Circle)& theCircle,
+ const Standard_Boolean theIsFilled,
+ const Standard_Integer theNbPnts)
+: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts)),
+ myCircle (theCircle),
+ myStart (0),
+ myEnd (0)
{
- if(mynbpoints!=1){
- gp_Pnt p1,p2;//,pmid;
- gp_Vec v1;//,v2;
- Standard_Real ustart = TheCircle->FirstParameter(),uend = TheCircle->LastParameter();
- Standard_Real du = (uend-ustart)/NbPoints;
- Standard_Real R = TheCircle->Radius();
- Standard_Integer rank = 1;
- Standard_Real curu =ustart;
- for(Standard_Integer i=1;i<=NbPoints;i++)
+ mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
+ if (myPolyg.Size() != 1)
+ {
+ gp_Pnt aP1, aP2;
+ gp_Vec aV1;
+ Standard_Real anUStart = theCircle->FirstParameter();
+ Standard_Real anUEnd = theCircle->LastParameter();
+ Standard_Real aStep = (anUEnd - anUStart) / theNbPnts;
+ Standard_Real aRadius = theCircle->Radius();
+ Standard_Integer aPntIdx = 1;
+ Standard_Real aCurU = anUStart;
+ for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; anIndex++)
{
- TheCircle->D1(curu,p1,v1);
-
- v1.Normalize();
- ((Select3D_Pnt*)mypolyg3d)[rank-1] = p1;
- rank++;
- p2 = gp_Pnt(p1.X()+v1.X()*tan(du/2.)*R,
- p1.Y()+v1.Y()*tan(du/2.)*R,
- p1.Z()+v1.Z()*tan(du/2.)*R);
- ((Select3D_Pnt*)mypolyg3d)[rank-1] = p2;
- rank++;
- curu+=du;
+ theCircle->D1 (aCurU, aP1, aV1);
+
+ aV1.Normalize();
+ myPolyg.SetPnt (aPntIdx - 1, aP1);
+ aPntIdx++;
+ aP2 = gp_Pnt (aP1.X() + aV1.X() * tan (aStep / 2.0) * aRadius,
+ aP1.Y() + aV1.Y() * tan (aStep / 2.0) * aRadius,
+ aP1.Z() + aV1.Z() * tan (aStep / 2.0) * aRadius);
+ myPolyg.SetPnt (aPntIdx - 1, aP2);
+ aPntIdx++;
+ aCurU += aStep;
}
- ((Select3D_Pnt*)mypolyg3d)[NbPoints*2] = ((Select3D_Pnt*)mypolyg3d)[0];
+
+ // Copy the first point to the last point of myPolyg
+ myPolyg.SetPnt (theNbPnts * 2, myPolyg.Pnt (0));
+ // Get myCenter3D
+ myCenter3D = theCircle->Location();
}
// Radius = 0.0
else
- ((Select3D_Pnt*)mypolyg3d)[0] = TheCircle->Location();
+ {
+ myPolyg.SetPnt (0, theCircle->Location());
+ // Get myCenter3D
+ myCenter3D = myPolyg.Pnt (0);
+ }
+
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ SetSensitivityFactor (6.0);
+ }
}
//=======================================================================
-//function : Select3D_SensitiveCircle (constructeur)
+//function : Select3D_SensitiveCircle (constructor)
//purpose : Definition of a sensitive arc
//=======================================================================
-Select3D_SensitiveCircle::
-Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(Geom_Circle)& TheCircle,
- const Standard_Real u1,
- const Standard_Real u2,
- const Standard_Boolean FilledCircle,
- const Standard_Integer NbPoints):
-Select3D_SensitivePoly(OwnerId, S3D_GetArcNBPoints(TheCircle,NbPoints)),
-myFillStatus(FilledCircle),
-myDetectedIndex(-1)
+Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectBasics_EntityOwner)& theOwnerId,
+ const Handle(Geom_Circle)& theCircle,
+ const Standard_Real theU1,
+ const Standard_Real theU2,
+ const Standard_Boolean theIsFilled,
+ const Standard_Integer theNbPnts)
+: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetArcNbPoints (theCircle, theNbPnts)),
+ myCircle (theCircle),
+ myStart (Min (theU1, theU2)),
+ myEnd (Max (theU1, theU2))
{
+ mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
- if(mynbpoints > 1){
- gp_Pnt p1,p2;//,pmid;
- gp_Vec v1;//,v2;
-
- Standard_Real ustart = u1;
- Standard_Real uend = u2;
-
- if (u1 > u2) {ustart=u1;uend=u2;}
-
- Standard_Real du = (uend-ustart)/(NbPoints-1);
- Standard_Real R = TheCircle->Radius();
- Standard_Integer rank = 1;
- Standard_Real curu =ustart;
-
-
-
- for(Standard_Integer i=1;i<=NbPoints-1;i++)
+ if (myPolyg.Size() != 1)
+ {
+ gp_Pnt aP1, aP2;
+ gp_Vec aV1;
+
+ Standard_Real aStep = (myEnd - myStart) / (theNbPnts - 1);
+ Standard_Real aRadius = theCircle->Radius();
+ Standard_Integer aPntIdx = 1;
+ Standard_Real aCurU = myStart;
+
+ for (Standard_Integer anIndex = 1; anIndex <= theNbPnts - 1; anIndex++)
{
- TheCircle->D1(curu,p1,v1);
- v1.Normalize();
- ((Select3D_Pnt*)mypolyg3d)[rank-1] = p1;
- rank++;
- p2 = gp_Pnt(p1.X()+v1.X()*tan(du/2.)*R,
- p1.Y()+v1.Y()*tan(du/2.)*R,
- p1.Z()+v1.Z()*tan(du/2.)*R);
- ((Select3D_Pnt*)mypolyg3d)[rank-1] = p2;
- rank++;
- curu+=du;
+ theCircle->D1 (aCurU, aP1, aV1);
+ aV1.Normalize();
+ myPolyg.SetPnt (aPntIdx - 1, aP1);
+ aPntIdx++;
+ aP2 = gp_Pnt (aP1.X() + aV1.X() * tan (aStep /2.0) * aRadius,
+ aP1.Y() + aV1.Y() * tan (aStep /2.0) * aRadius,
+ aP1.Z() + aV1.Z() * tan (aStep /2.0) * aRadius);
+ myPolyg.SetPnt (aPntIdx - 1, aP2);
+ aPntIdx++;
+ aCurU += aStep;
}
- TheCircle->D0(uend,p1);
- ((Select3D_Pnt*)mypolyg3d)[NbPoints*2-2] = p1;
+ theCircle->D0 (myEnd, aP1);
+ myPolyg.SetPnt (theNbPnts * 2 - 2, aP1);
+ // Get myCenter3D
+ myCenter3D = theCircle->Location();
}
else
- ((Select3D_Pnt*)mypolyg3d)[0] = TheCircle->Location();
+ {
+ myPolyg.SetPnt (0, theCircle->Location());
+ // Get myCenter3D
+ myCenter3D = myPolyg.Pnt (0);
+ }
+
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ SetSensitivityFactor (6.0);
+ }
}
//=======================================================================
//function : Select3D_SensitiveCircle
-//purpose :
+//purpose :
//=======================================================================
-Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const Handle(TColgp_HArray1OfPnt)& Thepolyg3d,
- const Standard_Boolean FilledCircle):
-Select3D_SensitivePoly(OwnerId, Thepolyg3d),
-myFillStatus(FilledCircle),
-myDetectedIndex(-1)
-{
-
-}
-Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
- const TColgp_Array1OfPnt& Thepolyg3d,
- const Standard_Boolean FilledCircle):
-Select3D_SensitivePoly(OwnerId, Thepolyg3d),
-myFillStatus(FilledCircle),
-myDetectedIndex(-1)
+Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& theOwnerId,
+ const Handle(TColgp_HArray1OfPnt)& thePnts3d,
+ const Standard_Boolean theIsFilled)
+: Select3D_SensitivePoly (theOwnerId, thePnts3d, !theIsFilled),
+ myStart (0),
+ myEnd (0)
{
-}
+ mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
-Standard_Boolean Select3D_SensitiveCircle::
-Matches(const Standard_Real X,
- const Standard_Real Y,
- const Standard_Real aTol,
- Standard_Real& DMin)
-{
-
-
- // in case of Edge (for the face it is only checked if
- // the mouse point X,Y is found inside the triangle
- // pi,pi+1,pi+2 with close tolerance... if yes, finish...
- if(mynbpoints>1){
- Standard_Boolean Found =Standard_False;
- Standard_Integer i = 0;
- //gp_Pnt2d p1,p2,p3,pg;
-
- if(!myFillStatus){
- while(i < mynbpoints-2 && !Found) {
- Standard_Integer TheStat =
- Select3D_SensitiveTriangle::Status(((Select3D_Pnt2d*)mypolyg2d)[i],
- ((Select3D_Pnt2d*)mypolyg2d)[i+1],
- ((Select3D_Pnt2d*)mypolyg2d)[i+2],
- gp_XY(X,Y),aTol,DMin);
- Found = (TheStat!=2);
- if(Found) myDetectedIndex=i;
- i+=2;
-
- }
- }
- else {
- myDetectedIndex =-1;
-#ifndef DEB
- Standard_Real DMin2 = 0.;
-#else
- Standard_Real DMin2;
-#endif
- Standard_Real Xmin,Ymin,Xmax,Ymax;
- Bnd_Box2d(mybox2d).Get(Xmin,Ymin,Xmax,Ymax);
- if(!Bnd_Box2d(mybox2d).IsVoid())
- DMin2 = gp_XY(Xmax-Xmin,Ymax-Ymin).SquareModulus();
- TColgp_Array1OfPnt2d aArrayOf2dPnt(1, mynbpoints);
- Points2D(aArrayOf2dPnt);
- CSLib_Class2d TheInOutTool(aArrayOf2dPnt,aTol,aTol,Xmin,Ymin,Xmax,Ymax);
- Standard_Integer TheStat = TheInOutTool.SiDans(gp_Pnt2d(X,Y));
- Standard_Real aTol2 = aTol*aTol;
- if(TheStat!=1) {
- for(Standard_Integer I=0;i<mynbpoints-1;i+=2){
- gp_XY V1(((Select3D_Pnt2d*)mypolyg2d)[I+1]),V(X,Y);
- V1-=((Select3D_Pnt2d*)mypolyg2d)[I];
- V-=((Select3D_Pnt2d*)mypolyg2d)[I];
- Standard_Real Vector = V1^V;
- Standard_Real V1V1 = V1.SquareModulus();
- DMin2 =
- (V1V1 <=aTol2) ?
- Min(DMin2,V.SquareModulus()): // if the segment is too small...
- Min(DMin2,Vector*Vector/V1V1);
-
- }
- Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
- return Standard_True;
- }
- return Standard_False;
-
- }
- if(!Found)
- myDetectedIndex=-1;
- else
- Select3D_SensitiveEntity::Matches(X,Y,aTol,DMin);
-
- return Found;
- }
- return Standard_True;
+ if (myPolyg.Size() != 1)
+ computeCenter3D();
+ else
+ myCenter3D = myPolyg.Pnt (0);
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ SetSensitivityFactor (6.0);
+ }
}
-Standard_Boolean Select3D_SensitiveCircle::
-Matches(const Standard_Real XMin,
- const Standard_Real YMin,
- const Standard_Real XMax,
- const Standard_Real YMax,
- const Standard_Real aTol)
+
+//=======================================================================
+//function : Select3D_SensitiveCircle
+//purpose :
+//=======================================================================
+
+Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& theOwnerId,
+ const TColgp_Array1OfPnt& thePnts3d,
+ const Standard_Boolean theIsFilled)
+: Select3D_SensitivePoly (theOwnerId, thePnts3d, !theIsFilled),
+ myStart (0),
+ myEnd (0)
{
- myDetectedIndex =-1;
- Bnd_Box2d abox;
- abox.Update(Min(XMin,XMax),Min(YMin,YMax),Max(XMin,XMax),Max(YMin,YMax));
- abox.Enlarge(aTol);
- for(Standard_Integer i=0;i<mynbpoints;i++)
- if(abox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[i])) return Standard_False;
+ mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
- return Standard_True;
+ if (myPolyg.Size() != 1)
+ computeCenter3D();
+ else
+ myCenter3D = myPolyg.Pnt (0);
+
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ SetSensitivityFactor (6.0);
+ }
}
+//=======================================================================
+// function : BVH
+// purpose : Builds BVH tree for a circle's edge segments if needed
+//=======================================================================
+void Select3D_SensitiveCircle::BVH()
+{
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ Select3D_SensitivePoly::BVH();
+ }
+}
//=======================================================================
-//function : Matches
-//purpose :
+// function : Matches
+// purpose : Checks whether the circle overlaps current selecting volume
//=======================================================================
+Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
+ SelectBasics_PickResult& thePickResult)
+{
+ Standard_Real aDepth = RealLast();
+ Standard_Real aDistToCOG = RealLast();
-Standard_Boolean Select3D_SensitiveCircle::
-Matches (const TColgp_Array1OfPnt2d& aPoly,
- const Bnd_Box2d& aBox,
- const Standard_Real aTol)
-{
- Standard_Real Umin,Vmin,Umax,Vmax;
- aBox.Get(Umin,Vmin,Umax,Vmax);
- Standard_Real Tolu,Tolv;
- Tolu = 1e-7;
- Tolv = 1e-7;
- CSLib_Class2d aClassifier2d(aPoly,aTol,aTol,Umin,Vmin,Umax,Vmax);
-
- for(Standard_Integer j=1;j<=mynbpoints;j++){
- Standard_Integer RES = aClassifier2d.SiDans(((Select3D_Pnt2d*)mypolyg2d)[j-1]);
- if(RES!=1) return Standard_False;
+ if (mySensType == Select3D_TOS_BOUNDARY)
+ {
+ if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult))
+ {
+ thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ return Standard_False;
+ }
}
- return Standard_True;
-}
+ else if (mySensType == Select3D_TOS_INTERIOR)
+ {
+ Handle(TColgp_HArray1OfPnt) anArrayOfPnt;
+ Points3D (anArrayOfPnt);
+ if (!theMgr.IsOverlapAllowed())
+ {
+ thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
+ {
+ Standard_Real aDummy;
+ if (!theMgr.Overlaps (anArrayOfPnt->Value (aPntIdx), aDummy))
+ return Standard_False;
+ }
+ return Standard_True;
+ }
+ if (!theMgr.Overlaps (anArrayOfPnt, Select3D_TOS_INTERIOR, aDepth))
+ {
+ thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ return Standard_False;
+ }
+ }
+ aDistToCOG = theMgr.DistToGeometryCenter (myCenter3D);
+ thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
+ return Standard_True;
+}
-void Select3D_SensitiveCircle::
-ArrayBounds(Standard_Integer & Low,
- Standard_Integer & Up) const
+void Select3D_SensitiveCircle::ArrayBounds (Standard_Integer & theLow,
+ Standard_Integer & theUp) const
{
- Low = 0;
- Up = mynbpoints-1;
+ theLow = 0;
+ theUp = myPolyg.Size() - 1;
}
-
-gp_Pnt Select3D_SensitiveCircle::
-GetPoint3d(const Standard_Integer Rank) const
+//=======================================================================
+//function : GetPoint3d
+//purpose :
+//=======================================================================
+gp_Pnt Select3D_SensitiveCircle::GetPoint3d (const Standard_Integer thePntIdx) const
{
- if(Rank>=0&& Rank<mynbpoints)
- return ((Select3D_Pnt*)mypolyg3d)[Rank];
- return ((Select3D_Pnt*)mypolyg3d)[0];
-}
+ if (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
+ return myPolyg.Pnt (thePntIdx);
+ return gp_Pnt();
+}
//=======================================================================
-//function : Dump
-//purpose :
+//function : GetConnected
+//purpose :
//=======================================================================
-void Select3D_SensitiveCircle::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
+Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected()
{
- // Standard_Integer rank(1);
- gp_XYZ CDG(0.,0.,0.);
-
- S<<"\tSensitiveCircle 3D :";
-
- Standard_Boolean isclosed = 1== mynbpoints;
- if(isclosed)
- S<<"(Closed Circle)"<<endl;
+ Standard_Boolean isFilled = mySensType == Select3D_TOS_INTERIOR;
+ // Create a copy of this
+ Handle(Select3D_SensitiveEntity) aNewEntity;
+ // this was constructed using Handle(Geom_Circle)
+ if(!myCircle.IsNull())
+ {
+ if ((myEnd - myStart) > Precision::Confusion())
+ {
+ // Arc
+ aNewEntity = new Select3D_SensitiveCircle (myOwnerId, myCircle, myStart, myEnd, isFilled);
+ }
+ else
+ {
+ // Circle
+ aNewEntity = new Select3D_SensitiveCircle (myOwnerId, myCircle, isFilled);
+ }
+ }
+ // this was constructed using TColgp_Array1OfPnt
else
- S<<"(Arc Of Circle)"<<endl;
-
- if(HasLocation())
- S<<"\t\tExisting Location"<<endl;
-
-
- if(FullDump){
- Standard_Integer EndIndex = isclosed? mynbpoints-2 : mynbpoints-1, nbpt(0);
- for(Standard_Integer i=0;i<EndIndex;i+=2){
- CDG +=((Select3D_Pnt*)mypolyg3d)[i];
- nbpt++;
+ {
+ Standard_Integer aSize = myPolyg.Size();
+ TColgp_Array1OfPnt aPolyg (1, aSize);
+ for(Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
+ {
+ aPolyg.SetValue(anIndex, myPolyg.Pnt (anIndex-1));
}
-
- CDG/=nbpt;
-
- Standard_Real R = (CDG-((Select3D_Pnt*)mypolyg3d)[0]).Modulus();
-
- S<<"\t\t Center : ("<<CDG.X()<<" , "<<CDG.Y()<<" , "<<CDG.Z()<<" )"<<endl;
- S<<"\t\t Radius :"<<R<<endl;
-
+ aNewEntity = new Select3D_SensitiveCircle (myOwnerId, aPolyg, isFilled);
}
+
+ return aNewEntity;
}
-Standard_Real Select3D_SensitiveCircle::ComputeDepth(const gp_Lin& EyeLine) const
+
+//=======================================================================
+//function : computeCenter3D
+//purpose :
+//=======================================================================
+void Select3D_SensitiveCircle::computeCenter3D()
{
- gp_Pnt CDG;
- if(myDetectedIndex==-1){
- gp_XYZ CurCoord(((Select3D_Pnt*)mypolyg3d)[0]);
- Standard_Boolean isclosed = 1==mynbpoints;
- Standard_Integer EndIndex = isclosed ? mynbpoints-2 : mynbpoints-1, nbpt(0);
- for(Standard_Integer i=1;i<EndIndex;i+=2){
- CurCoord +=((Select3D_Pnt*)mypolyg3d)[i];
- nbpt++;
+ gp_XYZ aCenter;
+ Standard_Integer aNbPnts = myPolyg.Size();
+ if (aNbPnts != 1)
+ {
+ // The mass of points system
+ Standard_Integer aMass = aNbPnts - 1;
+ // Find the circle barycenter
+ for (Standard_Integer anIndex = 0; anIndex < aNbPnts - 1; ++anIndex)
+ {
+ aCenter += myPolyg.Pnt(anIndex);
}
- CDG.SetXYZ(CurCoord);
+ myCenter3D = aCenter / aMass;
}
- else{
- gp_XYZ CurCoord(((Select3D_Pnt*)mypolyg3d)[myDetectedIndex]);
- CurCoord+=((Select3D_Pnt*)mypolyg3d)[myDetectedIndex+1];
- CurCoord+=((Select3D_Pnt*)mypolyg3d)[myDetectedIndex+2];
- CDG.SetXYZ(CurCoord);
+ else
+ {
+ myCenter3D = myPolyg.Pnt(0);
}
+}
- return ElCLib::Parameter(EyeLine,CDG);
-
+//=======================================================================
+// function : CenterOfGeometry
+// purpose : Returns center of the circle. If location transformation
+// is set, it will be applied
+//=======================================================================
+gp_Pnt Select3D_SensitiveCircle::CenterOfGeometry() const
+{
+ return myCenter3D;
}