// Created on: 1999-04-27
// Created by: Andrey BETENEV
// Copyright (c) 1999-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.
// pdn 01.06.99 S4205: handling not-SameRange edges
// abv 22.07.99 implementing patch indices
// svv 10.01.00 porting on DEC
-#include <ShapeFix_ComposeShell.ixx>
-
-#include <Precision.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Lin2d.hxx>
+#include <Bnd_Box2d.hxx>
+#include <BndLib_Add2dCurve.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <Extrema_ExtPC2d.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dInt_GInter.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_Surface.hxx>
#include <gp_Dir2d.hxx>
-
-#include <TColStd_Array1OfInteger.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <IntRes2d_Domain.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <IntRes2d_IntersectionSegment.hxx>
+#include <Precision.hxx>
+#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_Curve.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeAnalysis_Surface.hxx>
+#include <ShapeAnalysis_TransferParameters.hxx>
+#include <ShapeAnalysis_TransferParametersProj.hxx>
+#include <ShapeAnalysis_WireOrder.hxx>
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <ShapeBuild_Vertex.hxx>
+#include <ShapeExtend.hxx>
+#include <ShapeExtend_CompositeSurface.hxx>
+#include <ShapeExtend_WireData.hxx>
+#include <ShapeFix_ComposeShell.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Wire.hxx>
+#include <ShapeFix_WireSegment.hxx>
+#include <Standard_Type.hxx>
+#include <TColgp_SequenceOfPnt2d.hxx>
#include <TColStd_Array1OfBoolean.hxx>
+#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
-#include <TColgp_SequenceOfPnt2d.hxx>
#include <TColStd_SequenceOfReal.hxx>
-
-#include <IntRes2d_IntersectionSegment.hxx>
-#include <IntRes2d_IntersectionPoint.hxx>
-#include <IntRes2d_Domain.hxx>
-
-#include <Geom2dInt_GInter.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom2d_Line.hxx>
-#include <Geom2dAdaptor_Curve.hxx>
-#include <GeomAdaptor_Surface.hxx>
-
+#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
-#include <TopTools_MapOfShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
-#include <BRepTools.hxx>
-#include <Bnd_Box2d.hxx>
-#include <BndLib_Add2dCurve.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-
-#include <ShapeExtend.hxx>
-#include <ShapeExtend_WireData.hxx>
-#include <ShapeBuild_Vertex.hxx>
-#include <ShapeBuild_Edge.hxx>
-#include <ShapeAnalysis.hxx>
-#include <ShapeAnalysis_Edge.hxx>
-#include <ShapeAnalysis_WireOrder.hxx>
-#include <ShapeFix_Wire.hxx>
-#include <ShapeFix_Edge.hxx>
-#include <ShapeFix_WireSegment.hxx>
-#include <ShapeAnalysis_Curve.hxx>
-#include <ShapeBuild_ReShape.hxx>
-#include <ShapeAnalysis_TransferParametersProj.hxx>
-#include <ShapeFix_Face.hxx>
-#include <ShapeAnalysis_Surface.hxx>
-#include <gp_Pnt.hxx>
-#include <Extrema_ExtPC2d.hxx>
-#include <ShapeAnalysis.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_ComposeShell,ShapeFix_Root)
//=======================================================================
//function : ShapeFix_ComposeShell
//purpose :
//=======================================================================
-
ShapeFix_ComposeShell::ShapeFix_ComposeShell () :
myStatus(0), myClosedMode(Standard_False)
{
for ( TopoDS_Iterator it(res); it.More(); it.Next() ) {
TopoDS_Edge E = TopoDS::Edge ( it.Value() );
if ( ! E.IsNull() ) segw->Add ( E );
-#ifdef DEB
+#ifdef OCCT_DEBUG
else cout << "Error: ShapeFix_ComposeShell, ApplyContext: wrong mapping of edge" << endl;
#endif
}
else wire.AddEdge ( index, aE, iumin, iumax, ivmin, ivmax );
}
}
-#ifdef DEB
+#ifdef OCCT_DEBUG
else cout << "Warning: ShapeFix_ComposeShell, ApplyContext: edge is to remove - not implemented" << endl;
#endif
//function : GetPatchIndex
//purpose : auxilary
//=======================================================================
+
// computes index for the patch by given parameter Param
static Standard_Integer GetPatchIndex (const Standard_Real Param,
const Handle(TColStd_HArray1OfReal) &Params,
return i - ishift * ( NP - 1 );
}
-
//=======================================================================
//function : LoadWires
//purpose :
seqw.Clear();
// Init seqw by initial set of wires (with corresponding orientation)
- for ( TopoDS_Iterator iw(myFace,Standard_False); iw.More(); iw.Next() ) {
-//smh#8
+ for ( TopoDS_Iterator iw(myFace,Standard_False); iw.More(); iw.Next() )
+ {
TopoDS_Shape tmpW = Context()->Apply ( iw.Value() ) ;
- if(tmpW.ShapeType() != TopAbs_WIRE) {
- if(tmpW.ShapeType() == TopAbs_VERTEX) {
+ if(tmpW.ShapeType() != TopAbs_WIRE)
+ {
+ if(tmpW.ShapeType() == TopAbs_VERTEX)
+ {
ShapeFix_WireSegment seg; //(( isOuter ? TopAbs_REVERSED : TopAbs_FORWARD ) );
seg.SetVertex(TopoDS::Vertex(tmpW));
seg.Orientation(tmpW.Orientation());
seqw.Append ( seg );
}
+
continue;
}
+
TopoDS_Wire wire = TopoDS::Wire ( tmpW );
Standard_Boolean isNonManifold = ( wire.Orientation() != TopAbs_REVERSED &&
wire.Orientation() != TopAbs_FORWARD );
-
-
// protect against INTERNAL/EXTERNAL wires
-// if ( wire.Orientation() != TopAbs_REVERSED &&
-// wire.Orientation() != TopAbs_FORWARD ) continue;
+ // if ( wire.Orientation() != TopAbs_REVERSED &&
+ // wire.Orientation() != TopAbs_FORWARD ) continue;
// determine orientation of the wire
-// TopoDS_Face face = TopoDS::Face ( myFace.EmptyCopied() );
-// B.Add ( face, wire );
-// Standard_Boolean isOuter = ShapeAnalysis::IsOuterBound ( face );
+ // TopoDS_Face face = TopoDS::Face ( myFace.EmptyCopied() );
+ // B.Add ( face, wire );
+ // Standard_Boolean isOuter = ShapeAnalysis::IsOuterBound ( face );
- if(isNonManifold) {
-
+ if(isNonManifold)
+ {
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData ( wire ,Standard_True,Standard_False);
//pdn protection againts of wires w/o edges
Standard_Integer nbEdges = sbwd->NbEdges();
- if(nbEdges) {
-
+ if(nbEdges)
+ {
//wire segments for non-manifold topology should have INTERNAL orientation
ShapeFix_WireSegment seg ( sbwd, TopAbs_INTERNAL);
seqw.Append ( seg );
}
}
- else {
+ else
+ {
//splitting wires containing manifold and non-manifold parts on a separate
- //wire segment
-
+ //wire segment
Handle(ShapeExtend_WireData) sbwdM = new ShapeExtend_WireData();
Handle(ShapeExtend_WireData) sbwdNM = new ShapeExtend_WireData();
sbwdNM->ManifoldMode() = Standard_False;
TopoDS_Iterator aIt(wire);
- for( ; aIt.More(); aIt.Next()) {
+ for( ; aIt.More(); aIt.Next())
+ {
TopoDS_Edge E = TopoDS::Edge ( aIt.Value() );
if(E.Orientation() == TopAbs_FORWARD || E.Orientation() == TopAbs_REVERSED)
sbwdM->Add(E);
else
sbwdNM->Add(E);
}
+
Standard_Integer nbMEdges = sbwdM->NbEdges();
Standard_Integer nbNMEdges = sbwdNM->NbEdges();
- if(nbNMEdges) {
+
+ if(nbNMEdges)
+ {
ShapeFix_WireSegment seg ( sbwdNM, TopAbs_INTERNAL); //(( isOuter ? TopAbs_REVERSED : TopAbs_FORWARD ) );
seqw.Append ( seg );
}
+
if(nbMEdges) {
// Orientation is set so as to allow the segment to be traversed in only one direction
// skl 01.04.2002
sfw->Load ( sbwdM );
Standard_Integer stat=0;
Handle(Geom_Surface) gs = BRep_Tool::Surface(myFace);
- if( gs->IsUPeriodic() && gs->IsVPeriodic() ) {
+ if( gs->IsUPeriodic() && gs->IsVPeriodic() )
+ {
// For torus-like shapes, first reorder in 2d since reorder is indifferent in 3d
ShapeAnalysis_WireOrder sawo(Standard_False, 0);
ShapeAnalysis_Edge sae;
continue;
sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
}
+
sawo.Perform();
stat = (sawo.Status() < 0 ? -1 : 1);
sfw->FixReorder(sawo);
if (sfw->StatusReorder(ShapeExtend_DONE3))
stat=-1;
- if( stat < 0 ) {
+ if(stat < 0)
+ {
BRep_Builder B;
TopoDS_Shape dummy = myFace.EmptyCopied();
TopoDS_Face face = TopoDS::Face ( dummy );
seqw.Append ( seg );
}
}
-
}
}
}
}
if ( j < np ) { i = 0; break; } // not tangency
- if ( i == endInd )
+ if ( i == endInd ) {
if ( special <=0 ) break;
else special = -1;
+ }
}
if ( myClosedMode ) {
if ( code != IOR_UNDEF && ! begin ) {
else if ( code == IOR_BOTH ) { // parity error in intersector
code = IOR_LEFT;
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
-#ifdef DEB
- cout << "Warning: ShapeFix_ComposeShell::ComputeCode: lost intersection point" << cout;
+#ifdef OCCT_DEBUG
+ cout << "Warning: ShapeFix_ComposeShell::ComputeCode: lost intersection point" << endl;
#endif
}
return code;
}
}
-
-//=======================================================================
-//function : DefinePatchForWire
-//purpose : auxilary
-//=======================================================================
-static void DefinePatchForWire(ShapeFix_WireSegment &wire, const Standard_Integer code,
- const Standard_Boolean isCutByU, const Standard_Integer cutIndex)
-{
- for(Standard_Integer i = 1; i <= wire.NbEdges(); i++)
- DefinePatch(wire,code,isCutByU,cutIndex,i);
-}
-
-
//=======================================================================
//function : GetGridResolution
//purpose : auxilary
if ( nsplit !=1 ) {
DistributeSplitPoints ( wire.WireData(), myFace, i, nsplit, indexes, values );
if ( nsplit <=0 ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Error: ShapeFix_ComposeShell::SplitWire: edge dismissed" << endl;
#endif
i--;
// get bounding box of pcurve
ShapeAnalysis_Curve sac;
Bnd_Box2d box;
- sac.FillBndBox ( c2d, f, l, 11, Standard_True, box );
+ const Standard_Integer aNbPoints = 41;
+ sac.FillBndBox ( c2d, f, l, aNbPoints, Standard_True, box );
Standard_Real umin, vmin, umax, vmax;
box.Get ( umin, vmin, umax, vmax );
if ( IntEdgePar.Length() <1 ) {
//pdn Defining position of wire. There is no intersection, so by any point.
- DefinePatchForWire ( wire, firstCode, isCutByU, cutIndex );
+ //DefinePatchForWire ( wire, firstCode, isCutByU, cutIndex );
return Standard_False; //pdn ??
}
j=i++;
}
}
-
+ //sequence of real codes for each segment
+ TColStd_SequenceOfInteger aNewSegCodes;
// Compute segment codes (left side of line, right or tangential)
for ( i=1; i <= IntEdgePar.Length(); i++ ) {
j = ( i < IntEdgePar.Length() ? i + 1 : 1 );
Standard_Integer code = ComputeCode ( sewd, line, IntEdgeInd(i), IntEdgeInd(j),
- IntEdgePar(i), IntEdgePar(j),isnonmanifold );
+ IntEdgePar(i), IntEdgePar(j),isnonmanifold );
SegmentCodes.Append ( code );
}
-
+
// for EXTERNAL wire, i.e. another joint line, every point is double intersection
if ( wire.Orientation() == TopAbs_EXTERNAL ) {
for ( i=1; i <= IntEdgePar.Length(); i++ )
+ {
IntCode.Append ( ITP_TANG | IOR_BOTH );
+ aNewSegCodes.Append(SegmentCodes(i));
+ }
}
// For real (closed) wire, analyze tangencies
else {
}
//pdn exit if all split points removed
if ( IntEdgePar.Length() <1 ) {
- //DefinePatchForWire ( wire, firstCode, isCutByU, cutIndex );
return Standard_False; //pdn ??
}
// beginning and end of tangential segment.
// Orientation (IOR) tells on which side of line edge crosses it
j = IntEdgePar.Length();
+
for ( i=1; i <= IntEdgePar.Length(); j = i++ ) {
Standard_Integer codej = SegmentCodes(j);
Standard_Integer codei = SegmentCodes(i);
if ( myClosedMode ) {
- if ( ( codej & IOR_BOTH ) == IOR_BOTH ) //IOR_LEFT : IOR_RIGHT
- codej = ( codej & IOR_POS ? IOR_RIGHT : IOR_LEFT );
- if ( ( codei & IOR_BOTH ) == IOR_BOTH ) //IOR_RIGHT : IOR_LEFT
- codei = ( codei & IOR_POS ? IOR_LEFT : IOR_RIGHT );
+ if ( ( codej & IOR_BOTH ) == IOR_BOTH ) //IOR_LEFT : IOR_RIGHT
+ codej = ( codej & IOR_POS ? IOR_RIGHT : IOR_LEFT );
+ if ( ( codei & IOR_BOTH ) == IOR_BOTH ) //IOR_RIGHT : IOR_LEFT
+ codei = ( codei & IOR_POS ? IOR_LEFT : IOR_RIGHT );
+ aNewSegCodes.Append ( codei );
+ if(IntEdgeInd(i) == IntEdgeInd(j))
+ aNewSegCodes.Append ( codej );
+
}
+ else
+ aNewSegCodes.Append ( codei );
Standard_Integer ipcode = ( codej | codei );
if ( codej == IOR_UNDEF ) { // previous segment was tangency
if ( IntLinePar(i) > IntLinePar (j) )
}
//=======================================
+
+
// Split edges in the wire by intersection points and fill vertices array
TopTools_SequenceOfShape IntVertices;
wire = SplitWire ( wire, IntEdgeInd, IntEdgePar, IntVertices,
- SegmentCodes, isCutByU, cutIndex );
+ aNewSegCodes, isCutByU, cutIndex );
// add all data to input arrays
for ( i=1; i <= IntLinePar.Length(); i++ ) {
}
if ( tanglevel <0 ) {
// myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL4 );
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Warning: ShapeFix_ComposeShell::SplitByLine: tangency level <0 !" << endl;
#endif
}
// protection against creating null-length edges
if ( SplitLinePar(i) - SplitLinePar(i-1) < ::Precision::PConfusion() ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Info: ShapeFix_ComposeShell::SplitByLine: Short segment ignored" << endl;
#endif
if ( ! V1.IsSame ( V2 ) ) { // merge coincident vertices
Context()->Replace ( V1, V.Oriented ( V1.Orientation() ) );
Context()->Replace ( V2, V.Oriented ( V2.Orientation() ) );
V1 = V2 = V;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Info: ShapeFix_ComposeShell::SplitByLine: Coincided vertices merged" << endl;
#endif
}
// set patch indices
DefinePatch ( seg, IOR_UNDEF, isCutByU, cutIndex );
if ( ! isCutByU ) {
- seg.DefineIUMin ( 1, GetPatchIndex ( SplitLinePar(i-1)+::Precision::PConfusion(),
- myGrid->UJointValues(), myUClosed ) );
- seg.DefineIUMax ( 1, GetPatchIndex ( SplitLinePar(i)-::Precision::PConfusion(),
+ Standard_Real shiftU =
+ (myClosedMode && myUClosed ? ShapeAnalysis::AdjustToPeriod(SplitLinePar(i-1) -TOLINT, myGrid->UJointValue(1), myGrid->UJointValue(2)) : 0.);
+ Standard_Real aPar = SplitLinePar(i-1) + shiftU;
+
+ seg.DefineIUMin ( 1, GetPatchIndex ( aPar+::Precision::PConfusion(), myGrid->UJointValues(), myUClosed ) );
+ seg.DefineIUMax ( 1, GetPatchIndex ( aPar-::Precision::PConfusion(),
myGrid->UJointValues(), myUClosed ) + 1 );
}
else {
- seg.DefineIVMin ( 1, GetPatchIndex ( SplitLinePar(i-1)+::Precision::PConfusion(),
+ Standard_Real shiftV = (myClosedMode && myVClosed ? ShapeAnalysis::AdjustToPeriod(SplitLinePar(i-1) -TOLINT, myGrid->VJointValue(1), myGrid->VJointValue(2)) : 0.);
+ Standard_Real aPar = SplitLinePar(i-1) + shiftV;
+ seg.DefineIVMin ( 1, GetPatchIndex ( aPar+::Precision::PConfusion(),
myGrid->VJointValues(), myVClosed ) );
- seg.DefineIVMax ( 1, GetPatchIndex ( SplitLinePar(i)-::Precision::PConfusion(),
+ seg.DefineIVMax ( 1, GetPatchIndex ( aPar-::Precision::PConfusion(),
myGrid->VJointValues(), myVClosed ) + 1 );
}
}
if ( parity % 2 ) {
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL4 );
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Error: ShapeFix_ComposeShell::SplitByLine: parity error" << endl;
#endif
}
BRepTools::UVBounds(myFace,Uf,Ul,Vf,Vl);
Standard_Real Umin,Umax,Vmin,Vmax;
myGrid->Bounds(Umin,Umax,Vmin,Vmax);
- Standard_Real pprec = ::Precision::PConfusion();
-
+
+ //value of precision to define number of patch should be the same as used in the definitin position of point realtively to seam edge (TOLINT)
+ Standard_Real pprec = TOLINT;//::Precision::PConfusion();
+ Standard_Integer i = 1;
+ if(myClosedMode)
+ {
+ //for closed mode when only one patch exist and location of the splitting line is coinsident with first joint value
+ //Therefore in this case it is necessary to move all wire segments in the range of the patch between first and last joint
+ //values. Then all wire segments are lie between -period and period in order to have valid split ranges after splitting.
+ //Because for closed mode cut index always equal to 1 and parts of segments after splitting always should have index either (0,1) or (1,2).
+
+ for ( i=1; i <= seqw.Length(); i++ )
+ {
+ ShapeFix_WireSegment &wire = seqw(i);
+
+ TopoDS_Shape atmpF = myFace.EmptyCopied();
+ BRep_Builder aB;
+ atmpF.Orientation(TopAbs_FORWARD);
+ aB.Add(atmpF, wire.WireData()->Wire());
+ Standard_Real Uf1,Ul1,Vf1,Vl1;
+ ShapeAnalysis::GetFaceUVBounds(TopoDS::Face(atmpF),Uf1,Ul1,Vf1,Vl1);
+
+ //for closed mode it is necessary to move wire segment in the interval defined by first and last grid UV values
+ Standard_Real shiftU = (myClosedMode && myUClosed ? ShapeAnalysis::AdjustToPeriod(Ul1 -pprec, myGrid->UJointValue(1), myGrid->UJointValue(2)) : 0.);
+ Standard_Real shiftV = (myClosedMode && myVClosed ? ShapeAnalysis::AdjustToPeriod(Vl1 -pprec, myGrid->VJointValue(1), myGrid->VJointValue(2)) : 0.);
+ Uf1 += shiftU;
+ Ul1 += shiftU;
+ Vf1 += shiftV;
+ Vl1 += shiftV;
+ // limit patch indices to be in range of grid (extended for periodic) (0, 2)
+ //in same cases for example trj4_pm2-ug-203.stp (entity #8024) wire in 2D space has length greater then period
+ Standard_Integer iumin = Max(0,GetPatchIndex ( Uf1+pprec, myGrid->UJointValues(), myUClosed ));
+ Standard_Integer iumax = GetPatchIndex ( Ul1-pprec, myGrid->UJointValues(), myUClosed ) + 1;
+
+
+ for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
+ wire.DefineIUMin ( j, iumin );
+ wire.DefineIUMax ( j, iumax );
+ }
+
+ Standard_Integer ivmin = Max(0,GetPatchIndex ( Vf1+pprec, myGrid->VJointValues(), myVClosed ));
+ Standard_Integer ivmax = GetPatchIndex ( Vl1-pprec, myGrid->VJointValues(), myVClosed ) + 1;
+
+ for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
+ wire.DefineIVMin ( j, ivmin );
+ wire.DefineIVMax ( j, ivmax );
+ }
+ }
+ }
+ else
+ {
+ // limit patch indices to be in range of grid (extended for periodic)
+ Standard_Integer iumin = GetPatchIndex ( Uf+pprec, myGrid->UJointValues(), myUClosed );
+ Standard_Integer iumax = GetPatchIndex ( Ul-pprec, myGrid->UJointValues(), myUClosed ) + 1;
+ for ( i=1; i <= seqw.Length(); i++ ) {
+ ShapeFix_WireSegment &wire = seqw(i);
+ for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
+ wire.DefineIUMin ( j, iumin );
+ wire.DefineIUMax ( j, iumax );
+ }
+ }
+ Standard_Integer ivmin = GetPatchIndex ( Vf+pprec, myGrid->VJointValues(), myVClosed );
+ Standard_Integer ivmax = GetPatchIndex ( Vl-pprec, myGrid->VJointValues(), myVClosed ) + 1;
+ for ( i=1; i <= seqw.Length(); i++ ) {
+ ShapeFix_WireSegment &wire = seqw(i);
+ for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
+ wire.DefineIVMin ( j, ivmin );
+ wire.DefineIVMax ( j, ivmax );
+ }
+ }
+ }
// split by u lines
- Standard_Integer i; // svv #1
+
for ( i = ( myUClosed ? 1 : 2 ); i <= myGrid->NbUPatches(); i++ ) {
gp_Pnt2d pos ( myGrid->UJointValue(i), 0. ); // 0. - for infinite ranges: myGrid->VJointValue(1) ;
gp_Lin2d line ( pos, gp_Dir2d ( 0., 1. ) );
Standard_Real X = pos.X();
Standard_Real sh = ShapeAnalysis::AdjustToPeriod(X,Uf, Uf+period);
for( ; X+sh <= Ul+pprec; sh += period ) {
- gp_Lin2d ln = line.Translated(gp_Vec2d(sh,0));
- Standard_Integer cutIndex = GetPatchIndex ( X+sh+pprec, myGrid->UJointValues(), myUClosed );
- SplitByLine ( seqw, ln, Standard_True, cutIndex );
+ gp_Lin2d ln = line.Translated(gp_Vec2d(sh,0));
+ Standard_Integer cutIndex = GetPatchIndex ( X+sh+pprec, myGrid->UJointValues(), myUClosed );
+ SplitByLine ( seqw, ln, Standard_True, cutIndex );
}
}
else
SplitByLine ( seqw, line, Standard_True, i );
}
-
+
// split by v lines
for ( i = ( myVClosed ? 1 : 2 ); i <= myGrid->NbVPatches(); i++ ) {
gp_Pnt2d pos ( 0., myGrid->VJointValue(i) );
Standard_Real Y = pos.Y();
Standard_Real sh = ShapeAnalysis::AdjustToPeriod(Y,Vf, Vf+period);
for( ; Y+sh <= Vl+pprec; sh += period) {
- gp_Lin2d ln = line.Translated(gp_Vec2d(0,sh));
- Standard_Integer cutIndex = GetPatchIndex ( Y+sh+pprec, myGrid->VJointValues(), myVClosed );
- SplitByLine ( seqw, ln, Standard_False, cutIndex );
+ gp_Lin2d ln = line.Translated(gp_Vec2d(0,sh));
+ Standard_Integer cutIndex = GetPatchIndex ( Y+sh+pprec, myGrid->VJointValues(), myVClosed );
+ SplitByLine ( seqw, ln, Standard_False, cutIndex );
}
}
else
SplitByLine ( seqw, line, Standard_False, i );
}
- // limit patch indices to be in range of grid (extended for periodic)
- Standard_Integer iumin = GetPatchIndex ( Uf+pprec, myGrid->UJointValues(), myUClosed );
- Standard_Integer iumax = GetPatchIndex ( Ul-pprec, myGrid->UJointValues(), myUClosed ) + 1;
- for ( i=1; i <= seqw.Length(); i++ ) {
- ShapeFix_WireSegment &wire = seqw(i);
- for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
- wire.DefineIUMin ( j, iumin );
- wire.DefineIUMax ( j, iumax );
- }
- }
- Standard_Integer ivmin = GetPatchIndex ( Vf+pprec, myGrid->VJointValues(), myVClosed );
- Standard_Integer ivmax = GetPatchIndex ( Vl-pprec, myGrid->VJointValues(), myVClosed ) + 1;
- for ( i=1; i <= seqw.Length(); i++ ) {
- ShapeFix_WireSegment &wire = seqw(i);
- for ( Standard_Integer j=1; j <= wire.NbEdges(); j++ ) {
- wire.DefineIVMin ( j, ivmin );
- wire.DefineIVMax ( j, ivmax );
- }
- }
}
i--;
continue;
}
-#ifdef DEB
+#ifdef OCCT_DEBUG
for ( Standard_Integer k=1; ! myClosedMode && k <= seqw(i).NbEdges(); k++ )
- if ( ! seqw(i).CheckPatchIndex ( k ) ) {;} //break;
-// cout << "Warning: ShapeFix_ComposeShell::CollectWires: Wrong patch indices" << endl;
+ if ( ! seqw(i).CheckPatchIndex ( k ) ) {
+ cout << "Warning: ShapeFix_ComposeShell::CollectWires: Wrong patch indices" << endl;
+ break;
+ }
#endif
Standard_Integer isshort = IsShortSegment ( seqw(i), myFace, myGrid, myLoc,
myUResolution, myVResolution );
( seqw(i).Orientation() == TopAbs_EXTERNAL ||
( seqw(i).NbEdges() == 1 && //:abv 13.05.02: OCC320 - remove if degenerated
BRep_Tool::Degenerated ( seqw(i).Edge(1) ) ) ) ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Info: ShapeFix_ComposeShell::CollectWires: Short segment ignored" << endl;
#endif
seqw(i).Orientation ( TopAbs_INTERNAL );
TopoDS_Vertex firstV, endV;
TopoDS_Edge firstEdge, lastEdge;
Standard_Real tol = 0;
- Standard_Integer iumin, iumax, ivmin, ivmax;
+ Standard_Integer iumin = 0, iumax = 0, ivmin = 0, ivmax = 0;
Standard_Real dsu=0., dsv=0.;
Standard_Boolean canBeClosed = Standard_False;
for(;;) {
if ( anOr == TopAbs_FORWARD ) reverse = Standard_True;
index = i;
seg.GetPatchIndex ( 1, iumin, iumax, ivmin, ivmax );
+
misoriented = Standard_False;
dsu = dsv = 0.;
break;
}
// check whether current segment is on the same patch with previous
- Standard_Integer sp = ( myClosedMode || // no indexation in closed mode
- IsSamePatch ( seg, myGrid->NbUPatches(), myGrid->NbVPatches(),
- iumin, iumax, ivmin, ivmax ) );
+ Standard_Integer sp = IsSamePatch ( seg, myGrid->NbUPatches(), myGrid->NbVPatches(),
+ iumin, iumax, ivmin, ivmax );
// not same patch has lowest priority
if ( ! sp && ( canBeClosed || ( index && samepatch ) ) ) continue;
else if ( samepatch ) { // extend patch indices
IsSamePatch ( seg, myGrid->NbUPatches(), myGrid->NbVPatches(),
iumin, iumax, ivmin, ivmax, Standard_True );
- }
+ }
+
+ //for closed mode in case if current segment is seam segment it is necessary to detect crossing seam edge
+ //in order to have possibility to take candidate from other patch
+ if(myClosedMode )
+ seg.GetPatchIndex ( 1, iumin, iumax, ivmin, ivmax );
+
// TopAbs_Orientation or = seg.Orientation();
if ( ! reverse ) sbwd->Add ( seg.WireData() );
else {
IsCoincided ( endPnt, firstPnt, myUResolution, myVResolution, 2.* tol ) ) ) {
if ( ! endV.IsSame ( sae.FirstVertex ( firstEdge ) ) ) {
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL5 );
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Warning: ShapeFix_ComposeShell::CollectWires: can't close wire" << endl;
#endif
}
//pdn add into resulting sequence!
ShapeFix_WireSegment s ( wd, TopAbs_FORWARD );
wires.Append ( s );
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout <<"Warning: Short segment processed as separate wire"<<endl;
#endif
continue;
TopAbs_State stPoint = clas.Perform (unp,Standard_False);
if(stPoint == TopAbs_ON || stPoint == TopAbs_UNKNOWN) {
- TopoDS_Edge ed = TopoDS::Edge ( ew.Value() );
- Standard_Real cf, cl;
- Handle(Geom2d_Curve) cw = BRep_Tool::CurveOnSurface ( ed, pf, cf, cl );
+ TopoDS_Edge anEdge = TopoDS::Edge ( ew.Value() );
+ Standard_Real aCF, aCL;
+ Handle(Geom2d_Curve) aCW = BRep_Tool::CurveOnSurface ( anEdge, pf, aCF, aCL);
// handle tangential case (ON)
while ( stPoint == TopAbs_ON || stPoint == TopAbs_UNKNOWN ) {
- stPoint = clas.Perform ( cw->Value(cl), Standard_False );
+ stPoint = clas.Perform (aCW->Value(aCL), Standard_False );
if ( ! ew.More() ) break;
ew.Next();
if ( ! ew.More() ) break;
if(edge.Orientation() !=TopAbs_FORWARD &&
edge.Orientation() !=TopAbs_REVERSED)
continue;
- Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface ( edge, pf, cf, cl );
- if ( ! c2d.IsNull() ) cw = c2d;
+ Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface ( edge, pf, aCF, aCL );
+ if ( ! c2d.IsNull() ) aCW = c2d;
}
}
TopAbs_State stInfin = clas.PerformInfinitePoint();
// check for lost wires, and if they are, make them roots
if ( roots.Length() <=0 && loops.Length() >0 ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Error: ShapeFix_ComposeShell::MakeFacesOnPatch: can't dispatch wires" << endl;
#endif
for ( Standard_Integer j=1; j <= loops.Length(); j++ ) {
BRepTopAdaptor_FClass2d clas ( fc, ::Precision::PConfusion() );
if ( clas.PerformInfinitePoint() == TopAbs_IN ) {
reverse = Standard_True;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Warning: ShapeFix_ComposeShell::MakeFacesOnPatch: badly oriented wire" << endl;
#endif
}
// check for lost wires, and if they are, make them roots
if ( i == roots.Length() && loops.Length() >0 ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Error: ShapeFix_ComposeShell::MakeFacesOnPatch: can't dispatch wires" << endl;
#endif
for ( j=1; j <= loops.Length(); j++ ) {