// Created on: 1995-03-22
// Created by: Laurent BUCHARD
// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 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.
+// This file is part of Open CASCADE Technology software library.
//
-// 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.
+// 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.
//
-// 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.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#define AFFICHAGE 0
#define No_Standard_OutOfRange
-#include <BRepTopAdaptor_FClass2d.ixx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TColgp_SequenceOfPnt2d.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <Geom2dInt_Geom2dCurveTool.hxx>
+#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve2d.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
+#include <BRepAdaptor_HSurface.hxx>
#include <BRepClass_FaceClassifier.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
#include <CSLib_Class2d.hxx>
+#include <ElCLib.hxx>
+#include <Geom2dInt_Geom2dCurveTool.hxx>
#include <GeomAbs_SurfaceType.hxx>
-#include <BRepAdaptor_HSurface.hxx>
-#include <TopExp.hxx>
-#include <BRepAdaptor_Curve.hxx>
-
+#include <GCPnts_QuasiUniformDeflection.hxx>
#include <gp_Pnt.hxx>
-#include <ElCLib.hxx>
-
+#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <TColgp_SequenceOfPnt2d.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
-#ifdef WNT
+#ifdef _MSC_VER
#include <stdio.h>
#endif
-#ifdef DEB
+#ifdef OCCT_DEBUG
#define LBRCOMPT 0
#else
#define LBRCOMPT 0
//-- and the last point registered in SeqPnt2d
//-- Try to remote the first point of the current edge
//-- from the last saved point
-#ifdef DEB
- gp_Pnt2d Pnt2dDebutEdgeCourant=
+#ifdef OCCT_DEBUG
+ gp_Pnt2d Pnt2dDebutEdgeCourant = C.Value(u); (void)Pnt2dDebutEdgeCourant;
#endif
- C.Value(u);
//Standard_Real Baillement2dU=0;
//Standard_Real Baillement2dV=0;
if(NbEdges)
{ //-- on compte ++ with a normal explorer and with the Wire Explorer
/*
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << endl;
cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probablement FAUX **" << endl;
PClass(im1)=SeqPnt2d.Value(im1);
PClass(nbpnts)=SeqPnt2d.Value(nbpnts);
-
+ Standard_Real aPer = 0.;
// for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++,im2++)
for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++)
{
// Standard_Real N = A.Magnitude() * B.Magnitude();
square += (PClass(im0).X()-PClass(im1).X())*(PClass(im0).Y()+PClass(im1).Y())*.5;
+ aPer += (PClass(im0).XY() - PClass(im1).XY()).Modulus();
// if(N>1e-16){ Standard_Real a=A.Angle(B); angle+=a; }
}
+ Standard_Real anExpThick = Max(2. * Abs(square) / aPer, 1e-7);
+ Standard_Real aDefl = Max(FlecheU, FlecheV);
+ Standard_Real aDiscrDefl = Min(aDefl*0.1, anExpThick * 10.);
+ while (aDefl > anExpThick && aDiscrDefl > 1e-7)
+ {
+ // Deflection of the polygon is too much for this ratio of area and perimeter,
+ // and this might lead to self-intersections.
+ // Discretize the wire more tightly to eliminate the error.
+ firstpoint = 1;
+ SeqPnt2d.Clear();
+ FlecheU = 0.0;
+ FlecheV = 0.0;
+ for (WireExplorer.Init(TopoDS::Wire(FaceExplorer.Current()), Face);
+ WireExplorer.More(); WireExplorer.Next())
+ {
+ edge = WireExplorer.Current();
+ Or = edge.Orientation();
+ if (Or == TopAbs_FORWARD || Or == TopAbs_REVERSED)
+ {
+ Standard_Real pfbid, plbid;
+ BRep_Tool::Range(edge, Face, pfbid, plbid);
+ if (Abs(plbid - pfbid) < 1.e-9) continue;
+ BRepAdaptor_Curve2d C(edge, Face);
+ GCPnts_QuasiUniformDeflection aDiscr(C, aDiscrDefl);
+ if (!aDiscr.IsDone())
+ break;
+ Standard_Integer nbp = aDiscr.NbPoints();
+ Standard_Integer iStep = 1, i = 1, iEnd = nbp + 1;
+ if (Or == TopAbs_REVERSED)
+ {
+ iStep = -1;
+ i = nbp;
+ iEnd = 0;
+ }
+ if (firstpoint == 2)
+ i += iStep;
+ for (; i != iEnd; i += iStep)
+ {
+ gp_Pnt2d aP2d = C.Value(aDiscr.Parameter(i));
+ SeqPnt2d.Append(aP2d);
+ }
+ if (nbp > 2)
+ {
+ Standard_Integer ii = SeqPnt2d.Length();
+ gp_Lin2d Lin(SeqPnt2d(ii - 2), gp_Dir2d(gp_Vec2d(SeqPnt2d(ii - 2), SeqPnt2d(ii))));
+ Standard_Real ul = ElCLib::Parameter(Lin, SeqPnt2d(ii - 1));
+ gp_Pnt2d Pp = ElCLib::Value(ul, Lin);
+ Standard_Real dU = Abs(Pp.X() - SeqPnt2d(ii - 1).X());
+ Standard_Real dV = Abs(Pp.Y() - SeqPnt2d(ii - 1).Y());
+ if (dU > FlecheU) FlecheU = dU;
+ if (dV > FlecheV) FlecheV = dV;
+ }
+ firstpoint = 2;
+ }
+ }
+ nbpnts = SeqPnt2d.Length();
+ PClass.Resize(1, nbpnts, Standard_False);
+ im1 = nbpnts - 1;
+ im0 = 1;
+ PClass(im1) = SeqPnt2d.Value(im1);
+ PClass(nbpnts) = SeqPnt2d.Value(nbpnts);
+ square = 0.;
+ aPer = 0.;
+ for (Standard_Integer ii = 1; ii<nbpnts; ii++, im0++, im1++)
+ {
+ if (im1 >= nbpnts) im1 = 1;
+ PClass(ii) = SeqPnt2d.Value(ii);
+ square += (PClass(im0).X() - PClass(im1).X())*(PClass(im0).Y() + PClass(im1).Y())*.5;
+ aPer += (PClass(im0).XY() - PClass(im1).XY()).Modulus();
+ }
+
+ anExpThick = Max(2. * Abs(square) / aPer, 1e-7);
+ aDefl = Max(FlecheU, FlecheV);
+ aDiscrDefl = Min(aDiscrDefl * 0.1, anExpThick * 10.);
+ }
//-- FlecheU*=10.0;
//-- FlecheV*=10.0;
// {
// BadWire=1;
// TabOrien.Append(-1);
-//#ifdef DEB
+//#ifdef OCCT_DEBUG
// cout << endl;
// cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probably FALSE **" << endl;
// cout << "*** Total rotation angle of the wire : " << angle << endl;
}//if(nbpoints>3
else
{
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << endl;
cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probably FALSE **" << endl;
cout << "*** The sample wire contains less than 3 points" << endl;
const Standard_Boolean IsVPer = surf->IsVPeriodic();
const Standard_Real uperiod = IsUPer ? surf->UPeriod() : 0.0;
const Standard_Real vperiod = IsVPer ? surf->VPeriod() : 0.0;
- TopAbs_State Status = TopAbs_UNKNOWN;
+ TopAbs_State aStatus = TopAbs_UNKNOWN;
Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
if (RecadreOnPeriodic)
Standard_Real m_Toluv = (Toluv > 4.0) ? 4.0 : Toluv;
//aClassifier.Perform(Face,Puv,Toluv);
aClassifier.Perform(Face,Puv,m_Toluv);
- Status = aClassifier.State();
+ aStatus = aClassifier.State();
}
if(dedans == 1) {
- Status = TopAbs_IN;
+ aStatus = TopAbs_IN;
}
if(dedans == -1) {
- Status = TopAbs_OUT;
+ aStatus = TopAbs_OUT;
}
}
else { //-- TabOrien(1)=-1 False Wire
BRepClass_FaceClassifier aClassifier;
aClassifier.Perform(Face,Puv,Toluv);
- Status = aClassifier.State();
+ aStatus = aClassifier.State();
}
if (!RecadreOnPeriodic || (!IsUPer && !IsVPer))
- return Status;
- if (Status == TopAbs_IN || Status == TopAbs_ON)
- return Status;
+ return aStatus;
+ if (aStatus == TopAbs_IN || aStatus == TopAbs_ON)
+ return aStatus;
if (!urecadre)
{
u = uu;
if (v > Vmax || !IsVPer)
- return Status;
+ return aStatus;
}
} //for (;;)
}
const Standard_Boolean IsVPer = surf->IsVPeriodic();
const Standard_Real uperiod = IsUPer ? surf->UPeriod() : 0.0;
const Standard_Real vperiod = IsVPer ? surf->VPeriod() : 0.0;
- TopAbs_State Status = TopAbs_UNKNOWN;
+ TopAbs_State aStatus = TopAbs_UNKNOWN;
Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
if (RecadreOnPeriodic)
}
}
if(dedans==0) {
- Status = TopAbs_ON;
+ aStatus = TopAbs_ON;
}
if(dedans == 1) {
- Status = TopAbs_IN;
+ aStatus = TopAbs_IN;
}
if(dedans == -1) {
- Status = TopAbs_OUT;
+ aStatus = TopAbs_OUT;
}
}
else { //-- TabOrien(1)=-1 False Wire
BRepClass_FaceClassifier aClassifier;
aClassifier.Perform(Face,Puv,Tol);
- Status = aClassifier.State();
+ aStatus = aClassifier.State();
}
if (!RecadreOnPeriodic || (!IsUPer && !IsVPer))
- return Status;
- if (Status == TopAbs_IN || Status == TopAbs_ON)
- return Status;
+ return aStatus;
+ if (aStatus == TopAbs_IN || aStatus == TopAbs_ON)
+ return aStatus;
if (!urecadre)
{
u = uu;
if (v > Vmax || !IsVPer)
- return Status;
+ return aStatus;
}
} //for (;;)
}
//const BRepTopAdaptor_FClass2d & BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& Other) const {
const BRepTopAdaptor_FClass2d & BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& ) const {
+#ifdef OCCT_DEBUG
cerr<<"Copy not allowed in BRepTopAdaptor_FClass2d"<<endl;
- Standard_ConstructionError::Raise();
- return(*this);
+#endif
+ throw Standard_ConstructionError();
}