mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
184 lines
5.5 KiB
Plaintext
Executable File
184 lines
5.5 KiB
Plaintext
Executable File
// Created on: 1992-11-18
|
|
// Created by: Remi LEQUETTE
|
|
// Copyright (c) 1992-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.
|
|
|
|
|
|
// Modified by skv - Thu Jul 13 18:00:34 2006 OCC12627
|
|
// The method Perform is totally rewroted.
|
|
|
|
#include <IntRes2d_IntersectionSegment.hxx>
|
|
#include <IntRes2d_IntersectionPoint.hxx>
|
|
|
|
//=======================================================================
|
|
//function : TopClass_FaceClassifier
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
TopClass_FaceClassifier::TopClass_FaceClassifier()
|
|
{
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : TopClass_FaceClassifier
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
TopClass_FaceClassifier::TopClass_FaceClassifier(TheFaceExplorer& FExp,
|
|
const gp_Pnt2d& P,
|
|
const Standard_Real Tol)
|
|
{
|
|
Perform(FExp,P,Tol);
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Perform
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
void TopClass_FaceClassifier::Perform(TheFaceExplorer& Fexp,
|
|
const gp_Pnt2d& P,
|
|
const Standard_Real Tol)
|
|
{
|
|
// Test for rejection.
|
|
rejected = Fexp.Reject(P);
|
|
|
|
if (rejected)
|
|
return;
|
|
|
|
gp_Lin2d aLine;
|
|
Standard_Real aParam;
|
|
Standard_Boolean IsValidSegment = Fexp.Segment(P, aLine, aParam);
|
|
TheEdge anEdge;
|
|
TopAbs_Orientation anEdgeOri;
|
|
Standard_Integer aClosestInd;
|
|
IntRes2d_IntersectionPoint aPInter;
|
|
TopAbs_State aState;
|
|
Standard_Boolean IsWReject;
|
|
Standard_Boolean IsEReject;
|
|
|
|
nowires = Standard_True;
|
|
|
|
while (IsValidSegment) {
|
|
myClassifier.Reset(aLine, aParam, Tol);
|
|
|
|
for (Fexp.InitWires(); Fexp.MoreWires(); Fexp.NextWire()) {
|
|
nowires = Standard_False;
|
|
IsWReject = Fexp.RejectWire(aLine, myClassifier.Parameter());
|
|
|
|
if (!IsWReject) {
|
|
// test this wire
|
|
for (Fexp.InitEdges(); Fexp.MoreEdges(); Fexp.NextEdge()) {
|
|
IsEReject = Fexp.RejectEdge(aLine, myClassifier.Parameter());
|
|
|
|
if (!IsEReject) {
|
|
// test this edge
|
|
Fexp.CurrentEdge(anEdge, anEdgeOri);
|
|
|
|
if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED) {
|
|
myClassifier.Compare(anEdge, anEdgeOri);
|
|
aClosestInd = myClassifier.ClosestIntersection();
|
|
|
|
if (aClosestInd != 0) {
|
|
// save the closest edge
|
|
TheIntersection2d &anIntersector = myClassifier.Intersector();
|
|
Standard_Integer aNbPnts = anIntersector.NbPoints();
|
|
|
|
myEdge = anEdge;
|
|
|
|
if (aClosestInd <= aNbPnts) {
|
|
aPInter = anIntersector.Point(aClosestInd);
|
|
} else {
|
|
aClosestInd -= aNbPnts;
|
|
|
|
if (aClosestInd&1) {
|
|
aPInter = anIntersector.
|
|
Segment((aClosestInd + 1)/2).FirstPoint();
|
|
} else {
|
|
aPInter = anIntersector.
|
|
Segment((aClosestInd + 1)/2).LastPoint();
|
|
}
|
|
}
|
|
|
|
myPosition = aPInter.
|
|
TransitionOfSecond().PositionOnCurve();
|
|
myEdgeParameter = aPInter.ParamOnSecond();
|
|
}
|
|
// if we are ON, we stop
|
|
aState = myClassifier.State();
|
|
|
|
if (aState == TopAbs_ON)
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
// if we are out of the wire we stop
|
|
aState = myClassifier.State();
|
|
|
|
if (aState == TopAbs_OUT)
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (!myClassifier.IsHeadOrEnd() && aState != TopAbs_UNKNOWN)
|
|
break;
|
|
|
|
// Bad case for classification. Trying to get another segment.
|
|
IsValidSegment = Fexp.OtherSegment(P, aLine, aParam);
|
|
}
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : State
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
TopAbs_State TopClass_FaceClassifier::State() const
|
|
{
|
|
if (rejected) return TopAbs_OUT;
|
|
else if (nowires) return TopAbs_IN;
|
|
else return myClassifier.State();
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Edge
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
const TheEdge& TopClass_FaceClassifier::Edge() const
|
|
{
|
|
Standard_DomainError_Raise_if(rejected,
|
|
"TopClass_FaceClassifier::Edge:rejected");
|
|
return myEdge;
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : EdgeParameter
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Real TopClass_FaceClassifier::EdgeParameter() const
|
|
{
|
|
Standard_DomainError_Raise_if(rejected,
|
|
"TopClass_FaceClassifier::EdgeParameter:rejected");
|
|
return myEdgeParameter;
|
|
}
|
|
|