mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
HOMAG patch for OCCT 6.7.0
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
//
|
||||
// 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 version 2.1 as published
|
||||
// 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.
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <GeomAPI.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_OffsetCurve.hxx>
|
||||
#include <MAT_Arc.hxx>
|
||||
#include <MAT_Node.hxx>
|
||||
@@ -105,9 +106,6 @@
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <DrawTrSurf_Curve2d.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#endif
|
||||
|
||||
#ifdef DEB
|
||||
static Standard_Boolean AffichGeom = Standard_False;
|
||||
static Standard_Boolean Affich2d = Standard_False;
|
||||
static Standard_Boolean AffichEdge = Standard_False;
|
||||
@@ -115,10 +113,6 @@ static Standard_Integer NbTRIMEDGES = 0;
|
||||
static Standard_Integer NbOFFSET = 0;
|
||||
static Standard_Integer NbEDGES = 0;
|
||||
static Standard_Integer NbBISSEC = 0;
|
||||
#ifndef WNT
|
||||
static char tname[100];
|
||||
static Standard_CString name = tname ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Modified by Sergey KHROMOV - Thu Nov 16 17:24:39 2000 Begin
|
||||
@@ -174,15 +168,6 @@ static void EdgeVertices (const TopoDS_Edge& E,
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateDetromp (TopTools_ListOfShape& Detromp1,
|
||||
TopTools_ListOfShape& Detromp2,
|
||||
const TopTools_SequenceOfShape& Vertices,
|
||||
const TColgp_SequenceOfPnt& Params,
|
||||
const Bisector_Bisec& Bisec,
|
||||
const Standard_Boolean SOnE,
|
||||
const Standard_Boolean EOnE,
|
||||
const BRepFill_TrimEdgeTool& Trim);
|
||||
|
||||
static Standard_Boolean VertexFromNode
|
||||
(const Handle(MAT_Node)& aNode,
|
||||
const Standard_Real Offset,
|
||||
@@ -196,10 +181,11 @@ static void StoreInMap (const TopoDS_Shape& V1,
|
||||
|
||||
static void TrimEdge (const TopoDS_Edge& CurrentEdge,
|
||||
const TopTools_ListOfShape& D,
|
||||
TopTools_SequenceOfShape& Sv,
|
||||
TColStd_SequenceOfReal& MapverPar,
|
||||
TopTools_SequenceOfShape& S,
|
||||
TopTools_IndexedDataMapOfShapeShape& MapVV);
|
||||
TopTools_SequenceOfShape& Sv,
|
||||
TColStd_SequenceOfReal& MapverPar,
|
||||
TopTools_SequenceOfShape& S,
|
||||
TopTools_IndexedDataMapOfShapeShape& MapVV,
|
||||
const Standard_Integer IndOfE);
|
||||
|
||||
static Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& EC,
|
||||
const TopoDS_Vertex& V);
|
||||
@@ -220,7 +206,9 @@ static void MakeOffset
|
||||
const TopoDS_Face& F,
|
||||
const Standard_Real Offset,
|
||||
BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
|
||||
const Handle(Geom_Plane)& RefPlane);
|
||||
const Handle(Geom_Plane)& RefPlane,
|
||||
const Standard_Boolean IsOpenResult,
|
||||
const TopoDS_Vertex * Ends);
|
||||
|
||||
|
||||
|
||||
@@ -265,9 +253,6 @@ static Standard_Boolean KPartCircle
|
||||
E = TopoDS::Edge(exp.Current());
|
||||
if (NbEdges > 1) return Standard_False;
|
||||
}
|
||||
TopoDS_Vertex V1,V2;
|
||||
TopExp::Vertices(E,V1,V2);
|
||||
if (!V1.IsSame(V2)) return Standard_False;
|
||||
|
||||
Standard_Real f,l;
|
||||
TopLoc_Location L;
|
||||
@@ -278,15 +263,43 @@ static Standard_Boolean KPartCircle
|
||||
C = Ct->BasisCurve();
|
||||
}
|
||||
|
||||
if (!C->IsKind(STANDARD_TYPE(Geom_Circle))) return Standard_False;
|
||||
Handle(Geom_Circle) CE = Handle(Geom_Circle)::DownCast(C);
|
||||
Standard_Real anOffset = myOffset;
|
||||
if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
|
||||
|
||||
if (anOffset < 0. || Abs(anOffset) < CE->Radius()) {
|
||||
Handle(Geom_Circle) OC = new Geom_Circle (CE->Position(),CE->Radius() - anOffset);
|
||||
myShape = BRepLib_MakeEdge(OC,f,l);
|
||||
|
||||
TopoDS_Vertex V1,V2;
|
||||
TopExp::Vertices(E,V1,V2);
|
||||
if (!V1.IsSame(V2) || //open result or closed circle
|
||||
C->IsKind(STANDARD_TYPE(Geom_Circle)))
|
||||
{
|
||||
Standard_Real anOffset = myOffset;
|
||||
|
||||
Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface(E, mySpine, f, l);
|
||||
Handle(Geom2dAdaptor_HCurve) AHC = new Geom2dAdaptor_HCurve(aPCurve, f, l);
|
||||
Handle(Geom2d_Curve) OC;
|
||||
if (AHC->GetType() == GeomAbs_Line)
|
||||
{
|
||||
if (E.Orientation() == TopAbs_REVERSED)
|
||||
anOffset *= -1;
|
||||
Adaptor3d_OffsetCurve Off(AHC,anOffset);
|
||||
OC = new Geom2d_Line(Off.Line());
|
||||
}
|
||||
else if (AHC->GetType() == GeomAbs_Circle)
|
||||
{
|
||||
if (E.Orientation() == TopAbs_FORWARD)
|
||||
anOffset *= -1;
|
||||
gp_Circ2d theCirc = AHC->Circle();
|
||||
if (anOffset < 0. || Abs(anOffset) < theCirc.Radius())
|
||||
OC = new Geom2d_Circle (theCirc.Position(), theCirc.Radius() - anOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (E.Orientation() == TopAbs_FORWARD)
|
||||
anOffset *= -1;
|
||||
Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l);
|
||||
OC = new Geom2d_OffsetCurve( G2dT, anOffset);
|
||||
}
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine);
|
||||
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
|
||||
myShape = BRepLib_MakeEdge(OC, aPlane, f, l);
|
||||
BRepLib::BuildCurve3d(TopoDS::Edge(myShape));
|
||||
|
||||
myShape.Orientation(E.Orientation());
|
||||
myShape.Location(L);
|
||||
if (Alt != 0.) {
|
||||
@@ -298,13 +311,19 @@ static Standard_Boolean KPartCircle
|
||||
T.SetTranslation(Trans);
|
||||
myShape.Move(TopLoc_Location(T));
|
||||
}
|
||||
|
||||
|
||||
TopTools_ListOfShape LL;
|
||||
LL.Append(myShape);
|
||||
myMap.Add(E,LL);
|
||||
|
||||
TopoDS_Edge myEdge = TopoDS::Edge(myShape);
|
||||
myShape = BRepLib_MakeWire(myEdge);
|
||||
|
||||
myIsDone = Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
myIsDone = Standard_True;
|
||||
return Standard_True;
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -313,7 +332,8 @@ static Standard_Boolean KPartCircle
|
||||
//=======================================================================
|
||||
|
||||
BRepFill_OffsetWire::BRepFill_OffsetWire()
|
||||
:myIsDone(Standard_False)
|
||||
: myIsOpenResult(Standard_False),
|
||||
myIsDone(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -324,9 +344,10 @@ BRepFill_OffsetWire::BRepFill_OffsetWire()
|
||||
//=======================================================================
|
||||
|
||||
BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face& Spine,
|
||||
const GeomAbs_JoinType Join )
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean IsOpenResult)
|
||||
{
|
||||
Init(Spine,Join);
|
||||
Init(Spine,Join,IsOpenResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -335,16 +356,15 @@ BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face& Spine,
|
||||
//=======================================================================
|
||||
|
||||
void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine,
|
||||
const GeomAbs_JoinType Join )
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Boolean IsOpenResult)
|
||||
{
|
||||
Standard_NotImplemented_Raise_if(Join > GeomAbs_Arc,
|
||||
"Only GeomAbs_Arc is implemented");
|
||||
|
||||
myIsDone = Standard_False;
|
||||
TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
|
||||
mySpine = TopoDS::Face(aLocalShape);
|
||||
// mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
|
||||
myJoinType = Join;
|
||||
myIsOpenResult = IsOpenResult;
|
||||
|
||||
CheckFace(mySpine);
|
||||
|
||||
@@ -379,8 +399,8 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine,
|
||||
// static BRepMAT2d_Explorer Exp;
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
|
||||
Exp.Perform(myWorkSpine);
|
||||
myBilo.Compute(Exp,1,MAT_Left);
|
||||
myLink.Perform(Exp,myBilo);
|
||||
myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult);
|
||||
myLink.Perform(Exp, myBilo);
|
||||
}
|
||||
|
||||
|
||||
@@ -500,7 +520,7 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
myCallGen = Standard_False;
|
||||
if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return;
|
||||
if (KPartCircle(myWorkSpine,Offset,Alt,myShape,myMap,myIsDone)) return;
|
||||
|
||||
TopoDS_Face oldWorkSpain = myWorkSpine;
|
||||
|
||||
@@ -602,14 +622,12 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
|
||||
|
||||
if(aSubst.IsCopied(myWorkSpine)) {
|
||||
myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First());
|
||||
//sprintf(name,"WS1");
|
||||
//DBRep::Set(name,myWorkSpine);
|
||||
|
||||
BRepMAT2d_Explorer newExp;
|
||||
newExp.Perform(myWorkSpine);
|
||||
BRepMAT2d_BisectingLocus newBilo;
|
||||
BRepMAT2d_LinkTopoBilo newLink;
|
||||
newBilo.Compute(newExp,1,MAT_Left);
|
||||
newBilo.Compute(newExp, 1, MAT_Left, myJoinType, myIsOpenResult);
|
||||
|
||||
if(!newBilo.IsDone())
|
||||
{
|
||||
@@ -635,24 +653,29 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
|
||||
{
|
||||
myShape.Nullify();
|
||||
myIsDone = Standard_False;
|
||||
#ifdef BREPFILL_DEB
|
||||
cout<<"An exception was caught in BRepFill_OffsetWire::Perform : ";
|
||||
Standard_Failure::Caught()->Print(cout);
|
||||
cout<<endl;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145 End
|
||||
// Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin
|
||||
TopExp_Explorer anExp(myShape, TopAbs_WIRE);
|
||||
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Shape &aWire = anExp.Current();
|
||||
|
||||
if (!aWire.Closed()) {
|
||||
myShape.Nullify();
|
||||
myIsDone = Standard_False;
|
||||
Standard_ConstructionError::Raise("Offset wire is not closed.");
|
||||
if (!myIsOpenResult)
|
||||
{
|
||||
TopExp_Explorer anExp(myShape, TopAbs_WIRE);
|
||||
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Shape &aWire = anExp.Current();
|
||||
|
||||
if (!aWire.Closed()) {
|
||||
myShape.Nullify();
|
||||
myIsDone = Standard_False;
|
||||
Standard_ConstructionError::Raise("Offset wire is not closed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End
|
||||
@@ -706,9 +729,6 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
const GeomAbs_JoinType Join,
|
||||
const Standard_Real Alt)
|
||||
{
|
||||
Standard_NotImplemented_Raise_if (Join > GeomAbs_Arc,
|
||||
"Only GeomAbs_Arc is implemented");
|
||||
|
||||
myIsDone = Standard_False;
|
||||
TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
|
||||
myWorkSpine = TopoDS::Face(aLocalShape);
|
||||
@@ -734,7 +754,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
//********************************
|
||||
// Calculate for a non null offset
|
||||
//********************************
|
||||
if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone))
|
||||
if (KPartCircle(myWorkSpine,Offset,Alt,myShape,myMap,myIsDone))
|
||||
return;
|
||||
|
||||
BRep_Builder myBuilder;
|
||||
@@ -770,25 +790,36 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
//---------------------------------------------------------------
|
||||
// Construction of Circles and OffsetCurves
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
TopoDS_Vertex Ends [2];
|
||||
if (myIsOpenResult)
|
||||
{
|
||||
TopoDS_Wire theWire;
|
||||
TopoDS_Iterator iter(mySpine);
|
||||
theWire = TopoDS::Wire(iter.Value());
|
||||
TopExp::Vertices(theWire, Ends[0], Ends[1]);
|
||||
}
|
||||
|
||||
for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) {
|
||||
TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic)));
|
||||
TopoDS_Shape& PE = PEE ;
|
||||
for (Standard_Integer ie = 1; ie <= Locus.NumberOfElts(ic); ie++) {
|
||||
const TopoDS_Shape& SE = Link.GeneratingShape(Locus.BasicElt(ic,ie));
|
||||
if (SE.ShapeType() == TopAbs_VERTEX) {
|
||||
MakeCircle (TopoDS::Edge(PE),TopoDS::Vertex(SE),
|
||||
myWorkSpine,myOffset,myMap,RefPlane);
|
||||
if (!SE.IsSame(Ends[0]) && !SE.IsSame(Ends[1]))
|
||||
MakeCircle (TopoDS::Edge(PE),TopoDS::Vertex(SE),
|
||||
myWorkSpine,myOffset,myMap,RefPlane);
|
||||
}
|
||||
else {
|
||||
MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane);
|
||||
MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane,
|
||||
myIsOpenResult, Ends);
|
||||
PE = SE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEB
|
||||
#ifdef DRAW
|
||||
if (AffichEdge) {
|
||||
cout << " End Construction of geometric primitives "<<endl;
|
||||
}
|
||||
@@ -816,6 +847,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
|
||||
#ifdef DRAW
|
||||
if ( AffichGeom) {
|
||||
char name[256];
|
||||
sprintf(name,"BISSEC_%d",NbBISSEC++);
|
||||
DrawTrSurf::Set(name,Bisec.Value());
|
||||
}
|
||||
@@ -930,7 +962,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
if (!Detromp.IsBound(S[1])) Detromp.Bind(S[1],EmptyList);
|
||||
|
||||
|
||||
UpdateDetromp (Detromp(S[0]), Detromp(S[1]), Vertices, Params,
|
||||
UpdateDetromp (Detromp, S[0], S[1], Vertices, Params,
|
||||
Bisec, StartOnEdge, EndOnEdge, Trim);
|
||||
//----------------------------------------------
|
||||
// Storage of vertices on parallel edges.
|
||||
@@ -967,7 +999,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEB
|
||||
#ifdef DRAW
|
||||
if (AffichEdge) {
|
||||
cout << " End Construction of vertices on offsets"<<endl;
|
||||
}
|
||||
@@ -990,11 +1022,19 @@ void BRepFill_OffsetWire::PerformWithBiLo
|
||||
if (MapBis.IsBound(CurrentEdge)) {
|
||||
TopTools_SequenceOfShape S;
|
||||
if (!MapBis(CurrentEdge).IsEmpty()) {
|
||||
Standard_Integer IndOfE = 0;
|
||||
if (myIsOpenResult)
|
||||
{
|
||||
if (j == 1)
|
||||
IndOfE = 1;
|
||||
else if (j == myMap.Extent())
|
||||
IndOfE = -1;
|
||||
}
|
||||
TrimEdge (CurrentEdge,
|
||||
Detromp (CurrentSpine),
|
||||
MapBis (CurrentEdge) ,
|
||||
MapVerPar(CurrentEdge) ,
|
||||
S, MapVV);
|
||||
S, MapVV, IndOfE);
|
||||
for ( k = 1; k <= S.Length(); k++) {
|
||||
myMap(j).Append(S.Value(k));
|
||||
}
|
||||
@@ -1143,7 +1183,7 @@ void BRepFill_OffsetWire::PrepareSpine()
|
||||
TopExp::MapShapes(IteF.Value(), TopAbs_EDGE, EdgeMap);
|
||||
Standard_Integer nbEdges = EdgeMap.Extent();
|
||||
|
||||
if (nbEdges == 1)
|
||||
if (nbEdges == 1 && !myIsOpenResult) //in case of open wire there's no need to do it
|
||||
ForcedCut = 2;
|
||||
// Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End
|
||||
|
||||
@@ -1192,13 +1232,108 @@ void BRepFill_OffsetWire::PrepareSpine()
|
||||
|
||||
#ifdef DRAW
|
||||
if ( AffichEdge) {
|
||||
sprintf(name,"WS");
|
||||
DBRep::Set(name,myWorkSpine);
|
||||
DBRep::Set("WS",myWorkSpine);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateDetromp
|
||||
//purpose : For each interval on bissectrice defined by parameters
|
||||
// test if the medium point is at a distance > offset
|
||||
// in this case vertices corresponding to the extremities of the interval
|
||||
// are ranked in the proofing.
|
||||
// => If the same vertex appears in the proofing, the
|
||||
// border of the zone of proximity is tangent to the offset .
|
||||
//=======================================================================
|
||||
|
||||
void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfShape& Detromp,
|
||||
const TopoDS_Shape& Shape1,
|
||||
const TopoDS_Shape& Shape2,
|
||||
const TopTools_SequenceOfShape& Vertices,
|
||||
const TColgp_SequenceOfPnt& Params,
|
||||
const Bisector_Bisec& Bisec,
|
||||
const Standard_Boolean SOnE,
|
||||
const Standard_Boolean EOnE,
|
||||
const BRepFill_TrimEdgeTool& Trim) const
|
||||
{
|
||||
if (myJoinType == GeomAbs_Intersection &&
|
||||
Vertices.Length() == 1 &&
|
||||
!EOnE)
|
||||
{
|
||||
TopTools_IndexedMapOfShape Vmap1, Vmap2;
|
||||
TopExp::MapShapes(Shape1, TopAbs_VERTEX, Vmap1);
|
||||
TopExp::MapShapes(Shape2, TopAbs_VERTEX, Vmap2);
|
||||
Standard_Boolean Adjacent = Standard_False;
|
||||
for (Standard_Integer i = 1; i <= Vmap1.Extent(); i++)
|
||||
for (Standard_Integer j = 1; j <= Vmap2.Extent(); j++)
|
||||
if (Vmap1(i).IsSame(Vmap2(j)))
|
||||
{
|
||||
Adjacent = Standard_True;
|
||||
break;
|
||||
}
|
||||
if (Adjacent)
|
||||
{
|
||||
Detromp(Shape1).Append(Vertices.First());
|
||||
Detromp(Shape2).Append(Vertices.First());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer ii = 1;
|
||||
Standard_Real U1,U2;
|
||||
TopoDS_Vertex V1,V2;
|
||||
|
||||
Handle(Geom2d_Curve) Bis = Bisec.Value();
|
||||
|
||||
U1 = Bis->FirstParameter();
|
||||
|
||||
if (SOnE) {
|
||||
// the first point of the bissectrice is on the offset
|
||||
V1 = TopoDS::Vertex(Vertices.Value(ii));
|
||||
ii++;
|
||||
}
|
||||
|
||||
while (ii <= Vertices.Length()) {
|
||||
U2 = Params.Value(ii).X();
|
||||
V2 = TopoDS::Vertex(Vertices.Value(ii));
|
||||
|
||||
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
|
||||
if (!Trim.IsInside(P)) {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp(Shape1).Append(V1);
|
||||
Detromp(Shape2).Append(V1);
|
||||
}
|
||||
Detromp(Shape1).Append(V2);
|
||||
Detromp(Shape2).Append(V2);
|
||||
}
|
||||
U1 = U2;
|
||||
V1 = V2;
|
||||
ii ++;
|
||||
}
|
||||
|
||||
// test medium point between the last parameter and the end of the bissectrice.
|
||||
U2 = Bis->LastParameter();
|
||||
if (!EOnE) {
|
||||
if (!Precision::IsInfinite(U2)) {
|
||||
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
|
||||
if (!Trim.IsInside(P)) {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp(Shape1).Append(V1);
|
||||
Detromp(Shape2).Append(V1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp(Shape1).Append(V1);
|
||||
Detromp(Shape2).Append(V1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeWires
|
||||
//purpose :
|
||||
@@ -1825,6 +1960,7 @@ void MakeCircle (const TopoDS_Edge& E,
|
||||
|
||||
#ifdef DRAW
|
||||
if ( AffichGeom && !OE.IsNull()) {
|
||||
char name[256];
|
||||
sprintf(name,"OFFSET_%d",++NbOFFSET);
|
||||
DBRep::Set(name,OE);
|
||||
}
|
||||
@@ -1840,7 +1976,9 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const Standard_Real Offset,
|
||||
BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
|
||||
const Handle(Geom_Plane)& RefPlane)
|
||||
const Handle(Geom_Plane)& RefPlane,
|
||||
const Standard_Boolean IsOpenResult,
|
||||
const TopoDS_Vertex * Ends)
|
||||
{
|
||||
Standard_Real f,l;
|
||||
Standard_Real anOffset = Offset;
|
||||
@@ -1850,6 +1988,20 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
Handle(Geom2d_Curve) G2dOC;
|
||||
|
||||
Standard_Boolean ToExtendFirstPar = Standard_True;
|
||||
Standard_Boolean ToExtendLastPar = Standard_True;
|
||||
if (IsOpenResult)
|
||||
{
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(E, V1, V2);
|
||||
if (V1.IsSame(Ends[0]) ||
|
||||
V1.IsSame(Ends[1]))
|
||||
ToExtendFirstPar = Standard_False;
|
||||
if (V2.IsSame(Ends[0]) ||
|
||||
V2.IsSame(Ends[1]))
|
||||
ToExtendLastPar = Standard_False;
|
||||
}
|
||||
|
||||
Geom2dAdaptor_Curve AC(G2d,f,l);
|
||||
if ( AC.GetType() == GeomAbs_Circle) {
|
||||
// if the offset is greater otr equal to the radius and the side of the
|
||||
@@ -1861,7 +2013,7 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X();
|
||||
Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.;
|
||||
|
||||
if (anOffset*Signe < AC.Circle().Radius()) {
|
||||
if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) {
|
||||
|
||||
Handle(Geom2dAdaptor_HCurve) AHC =
|
||||
new Geom2dAdaptor_HCurve(G2d);
|
||||
@@ -1869,7 +2021,10 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());
|
||||
|
||||
Standard_Real Delta = 2*M_PI - l + f;
|
||||
f -= 0.2*Delta; l += 0.2*Delta;
|
||||
if (ToExtendFirstPar)
|
||||
f -= 0.2*Delta;
|
||||
if (ToExtendLastPar)
|
||||
l += 0.2*Delta;
|
||||
|
||||
G2dOC = new Geom2d_TrimmedCurve(CC,f,l);
|
||||
}
|
||||
@@ -1880,7 +2035,10 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
Adaptor3d_OffsetCurve Off(AHC,anOffset);
|
||||
Handle(Geom2d_Line) CC = new Geom2d_Line(Off.Line());
|
||||
Standard_Real Delta = (l - f);
|
||||
f -= Delta; l += Delta;
|
||||
if (ToExtendFirstPar)
|
||||
f -= Delta;
|
||||
if (ToExtendLastPar)
|
||||
l += Delta;
|
||||
G2dOC = new Geom2d_TrimmedCurve(CC,f,l);
|
||||
}
|
||||
else {
|
||||
@@ -1901,6 +2059,7 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
|
||||
#ifdef DRAW
|
||||
if (AffichGeom && !OE.IsNull()) {
|
||||
char name[256];
|
||||
sprintf(name,"OFFSET_%d",++NbOFFSET);
|
||||
DBRep::Set(name,OE);
|
||||
Standard_Real ii = 0;
|
||||
@@ -1910,77 +2069,6 @@ void MakeOffset (const TopoDS_Edge& E,
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateDetromp
|
||||
//purpose : For each interval on bissectrice defined by parameters
|
||||
// test if the medium point is at a distance > offset
|
||||
// in this case vertices corresponding to the extremities of the interval
|
||||
// are ranked in the proofing.
|
||||
// => If the same vertex appears in the proofing, the
|
||||
// border of the zone of proximity is tangent to the offset .
|
||||
//=======================================================================
|
||||
|
||||
void UpdateDetromp (TopTools_ListOfShape& Detromp1,
|
||||
TopTools_ListOfShape& Detromp2,
|
||||
const TopTools_SequenceOfShape& Vertices,
|
||||
const TColgp_SequenceOfPnt& Params,
|
||||
const Bisector_Bisec& Bisec,
|
||||
const Standard_Boolean SOnE,
|
||||
const Standard_Boolean EOnE,
|
||||
const BRepFill_TrimEdgeTool& Trim)
|
||||
{
|
||||
Standard_Integer ii = 1;
|
||||
Standard_Real U1,U2;
|
||||
TopoDS_Vertex V1,V2;
|
||||
|
||||
Handle(Geom2d_Curve) Bis = Bisec.Value();
|
||||
|
||||
U1 = Bis->FirstParameter();
|
||||
|
||||
if (SOnE) {
|
||||
// the first point of the bissectrice is on the offset
|
||||
V1 = TopoDS::Vertex(Vertices.Value(ii));
|
||||
ii++;
|
||||
}
|
||||
|
||||
while (ii <= Vertices.Length()) {
|
||||
U2 = Params.Value(ii).X();
|
||||
V2 = TopoDS::Vertex(Vertices.Value(ii));
|
||||
|
||||
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
|
||||
if (!Trim.IsInside(P)) {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp1.Append(V1);
|
||||
Detromp2.Append(V1);
|
||||
}
|
||||
Detromp1.Append(V2);
|
||||
Detromp2.Append(V2);
|
||||
}
|
||||
U1 = U2;
|
||||
V1 = V2;
|
||||
ii ++;
|
||||
}
|
||||
|
||||
// test medium point between the last parameter and the end of the bissectrice.
|
||||
U2 = Bis->LastParameter();
|
||||
if (!EOnE) {
|
||||
if (!Precision::IsInfinite(U2)) {
|
||||
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
|
||||
if (!Trim.IsInside(P)) {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp1.Append(V1);
|
||||
Detromp2.Append(V1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!V1.IsNull()) {
|
||||
Detromp1.Append(V1);
|
||||
Detromp2.Append(V1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VertexFromNode
|
||||
@@ -2050,10 +2138,11 @@ void StoreInMap (const TopoDS_Shape& V1,
|
||||
|
||||
void TrimEdge (const TopoDS_Edge& E,
|
||||
const TopTools_ListOfShape& Detromp,
|
||||
TopTools_SequenceOfShape& TheVer,
|
||||
TColStd_SequenceOfReal& ThePar,
|
||||
TopTools_SequenceOfShape& S,
|
||||
TopTools_IndexedDataMapOfShapeShape& MapVV)
|
||||
TopTools_SequenceOfShape& TheVer,
|
||||
TColStd_SequenceOfReal& ThePar,
|
||||
TopTools_SequenceOfShape& S,
|
||||
TopTools_IndexedDataMapOfShapeShape& MapVV,
|
||||
const Standard_Integer IndOfE)
|
||||
{
|
||||
Standard_Boolean Change = Standard_True;
|
||||
BRep_Builder TheBuilder;
|
||||
@@ -2124,45 +2213,94 @@ void TrimEdge (const TopoDS_Edge& E,
|
||||
// the number of vertices should be even. The created edges
|
||||
// go from a vertex with uneven index i to vertex i+1;
|
||||
//-----------------------------------------------------------
|
||||
for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
|
||||
if (IndOfE == 1 || IndOfE == -1) //open result and extreme edges of result
|
||||
{
|
||||
TopoDS_Shape aLocalShape = E.EmptyCopied();
|
||||
TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
|
||||
// TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied());
|
||||
|
||||
if (NewEdge.Orientation() == TopAbs_REVERSED) {
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(E, V1, V2);
|
||||
Standard_Real fpar, lpar;
|
||||
BRep_Tool::Range(E, fpar, lpar);
|
||||
if (IndOfE == 1) //first edge of open wire
|
||||
{
|
||||
if (NewEdge.Orientation() == TopAbs_FORWARD)
|
||||
{
|
||||
TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Range(NewEdge, fpar, ThePar.First());
|
||||
}
|
||||
else
|
||||
{
|
||||
//TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED));
|
||||
//TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Range(NewEdge, ThePar.First(), lpar);
|
||||
}
|
||||
}
|
||||
else {
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
|
||||
else //last edge of open wire
|
||||
{
|
||||
if (NewEdge.Orientation() == TopAbs_FORWARD)
|
||||
{
|
||||
TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Range(NewEdge, ThePar.First(), lpar);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
|
||||
//TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Range(NewEdge, fpar, ThePar.First());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
|
||||
|
||||
#ifdef DRAW
|
||||
if ( AffichEdge) {
|
||||
sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES);
|
||||
DBRep::Set(name,NewEdge);
|
||||
}
|
||||
if (Affich2d) {
|
||||
TopLoc_Location L;
|
||||
Standard_Real f,l;
|
||||
Handle(Geom_Surface) Surf;
|
||||
Handle(Geom2d_Curve) C;
|
||||
BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l);
|
||||
sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++);
|
||||
Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l);
|
||||
Handle(DrawTrSurf_Curve2d) dr =
|
||||
new DrawTrSurf_Curve2d(C2d,Standard_False);
|
||||
dr->SetColor(Draw_bleu);
|
||||
Draw::Set(name,dr);
|
||||
}
|
||||
#endif
|
||||
|
||||
S.Append(NewEdge);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
|
||||
TopoDS_Shape aLocalShape = E.EmptyCopied();
|
||||
TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
|
||||
// TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied());
|
||||
|
||||
if (NewEdge.Orientation() == TopAbs_REVERSED) {
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_REVERSED));
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
|
||||
}
|
||||
else {
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k) .Oriented(TopAbs_FORWARD));
|
||||
TheBuilder.Add (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
|
||||
}
|
||||
|
||||
|
||||
TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
|
||||
|
||||
#ifdef DRAW
|
||||
if ( AffichEdge) {
|
||||
char name[256];
|
||||
sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES);
|
||||
DBRep::Set(name,NewEdge);
|
||||
}
|
||||
if (Affich2d) {
|
||||
TopLoc_Location L;
|
||||
Standard_Real f,l;
|
||||
Handle(Geom_Surface) Surf;
|
||||
Handle(Geom2d_Curve) C;
|
||||
BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l);
|
||||
char name[256];
|
||||
sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++);
|
||||
Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l);
|
||||
Handle(DrawTrSurf_Curve2d) dr =
|
||||
new DrawTrSurf_Curve2d(C2d,Standard_False);
|
||||
dr->SetColor(Draw_bleu);
|
||||
Draw::Set(name,dr);
|
||||
}
|
||||
#endif
|
||||
|
||||
S.Append(NewEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user