1) Generic class "Intf_InterferencePolyhedron" from "Intf" package converted to the non-generic class and moved to the "IntPatch" package. Name of this class was changed to "IntPatch_InterferencePolyhedron".
2) Generic class "MoniTool_Elem" from "MoniTool" package converted to the non-generic class "MoniTool_TransientElem".
3) Generic class "IntWalk_PWalking" from "IntWalk" package converted to the non-generic class. And internal class "TheInt2S" of "IntWalk_PWalking" moved from IntWalk_PWalking.cdl to IntWalk.cdl for correct building. Also several "*.cxx" files of this class merged to one ".cxx".
4) Generic class "Transfer_SimpleBinder" from "Transfer" package converted to the non-generic class and moved to the "TransferBRep" package. Name of this class was changed to "TransferBRep_BinderOfShape".
5) Generic class "Geom2dInt_CurveTool" from "Geom2dInt" package converted to the non-generic class "Geom2dInt_Geom2dCurveTool".
6) Generic class "MAT2d_BisectingLocus" from "MAT2d" package converted to the non-generic class and moved to the "BRepMAT2d" package. Name of this class was changed to "BRepMAT2d_BisectingLocus".
7) Generic class "MAT_Mat" from "MAT" package converted to the non-generic class and moved to the "MAT2d" package. Name of this class was changed to "MAT2d_Mat2d".
Geom2d,
gp,
TopoDS,
- TopTools
+ TopTools,
+ Bisector
is
class Explorer;
-- bisecting locus from a Wire, a Face, or a set of
-- curves from Geom2d.
- class BisectingLocus instantiates BisectingLocus from MAT2d
- (Explorer from BRepMAT2d);
+ class BisectingLocus;
+ ---Purpose: Constuction of the map of the bisector locus on a
+ -- set of geometrys from Geom2d.
+
---Purpose: the map of bisecting locus.
class LinkTopoBilo;
--- /dev/null
+-- Created on: 1993-07-06
+-- Created by: Yves FRICAUD
+-- Copyright (c) 1993-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.
+
+class BisectingLocus from BRepMAT2d
+
+ ---Purpose : BisectingLocus generates and contains the Bisecting_Locus
+ -- of a set of lines from Geom2d, defined by <ExploSet>.
+ --
+ -- If the set of lines contains closed lines:
+ -- ------------------------------------------
+ -- These lines cut the plane in areas.
+ -- One map can be computed for each area.
+ --
+ -- Bisecting locus computes a map in an area.
+ -- The area is defined by a side (MAT_Left,MAT_Right)
+ -- on one of the closed lines.
+ --
+ -- If the set of lines contains only open lines:
+ -- --------------------------------------------
+ -- the map recovers all the plane.
+ --
+ -- Warning: Assume the orientation of the closed lines are
+ -- compatible.
+ --
+ -- Assume the explo contains only lines located in the
+ -- area where the bisecting locus will be computed.
+ --
+ -- Assume a line don't cross itself or an other line.
+ --
+ -- Remark:
+ -- the curves coming from the explorer can be
+ -- decomposed in different parts. It the case for the
+ -- curves other than circles or lines.
+ --
+ -- The map of bisecting locus is described by a graph.
+ -- - The BasicsElements correspond to elements on
+ -- the figure described by the Explorer from BRepMAT2d.
+ -- - The Arcs correspond to the bisectors.
+ -- - The Nodes are the extremities of the arcs.
+
+uses
+ Graph from MAT,
+ Arc from MAT,
+ BasicElt from MAT,
+ Node from MAT,
+ Side from MAT,
+ DataMapOfIntegerBasicElt from MAT,
+ DataMapOfBiIntInteger from MAT2d,
+ Bisec from Bisector,
+ Geometry from Geom2d,
+ Pnt2d from gp,
+ Tool2d from MAT2d,
+ Explorer from BRepMAT2d
+
+is
+ Create returns BisectingLocus from BRepMAT2d;
+
+---Category: Construction.
+
+ Compute (me : in out ;
+ anExplo : in out Explorer from BRepMAT2d;
+ LineIndex : Integer = 1;
+ aSide : Side from MAT = MAT_Left )
+ --- Purpose : Computation of the Bisector_Locus in a set of Lines
+ -- defined in <anExplo>.
+ -- The bisecting locus are computed on the side <aSide>
+ -- from the line <LineIndex> in <anExplo>.
+ is static;
+
+---Category: Querying.
+
+ IsDone (me) returns Boolean from Standard
+ ---Purpose: Returns True if Compute has succeeded.
+ is static;
+
+ Graph(me) returns Graph from MAT
+ --- Purpose : Returns <theGraph> of <me>.
+ is static;
+
+ NumberOfContours (me)
+ ---Purpose: Returns the number of contours.
+ returns Integer from Standard
+ is static;
+
+ NumberOfElts( me ; IndLine : Integer)
+ ---Purpose: Returns the number of BasicElts on the line
+ -- <IndLine>.
+ returns Integer from Standard
+ is static;
+
+ NumberOfSections (me; IndLine : Integer; Index : Integer)
+ ---Purpose: Returns the number of sections of a curve.
+ -- this curve is the Indexth curve in the IndLineth contour
+ -- given by anExplo.
+ --
+ returns Integer from Standard
+ is static;
+
+ BasicElt ( me ; IndLine : Integer ; Index : Integer)
+ ---Purpose: Returns the BasicElts located at the position
+ -- <Index> on the contour designed by <IndLine>.
+ -- Remark: the BasicElts on a contour are sorted.
+ --
+ returns BasicElt from MAT
+ is static;
+
+ GeomElt(me ; aBasicElt : BasicElt from MAT)
+ --- Purpose : Returns the geometry linked to the <BasicElt>.
+ returns Geometry from Geom2d
+ is static;
+
+ GeomElt(me ; aNode : Node from MAT)
+ --- Purpose : Returns the geometry of type <gp> linked to
+ -- the <Node>.
+ returns Pnt2d from gp
+ is static;
+
+ GeomBis(me ; anArc : Arc from MAT ; Reverse :in out Boolean from Standard)
+ --- Purpose : Returns the geometry of type <Bissec>
+ -- linked to the arc <ARC>.
+ -- <Reverse> is False when the FirstNode of <anArc>
+ -- correspond to the first point of geometry.
+ --
+ returns Bisec from Bisector
+ is static;
+
+---Category: private methods.
+
+ Fusion(me : in out)
+ is static private;
+
+ RenumerationAndFusion
+ (me : in out;
+ IndexLine : Integer;
+ LengthLine : Integer;
+ IndexLast : in out Integer;
+ NewMap : in out DataMapOfIntegerBasicElt from MAT)
+ is static private;
+
+fields
+
+ theGraph : Graph from MAT;
+ theTool : Tool2d from MAT2d;
+ isDone : Boolean from Standard;
+ nbSect : DataMapOfBiIntInteger from MAT2d;
+ nbContours : Integer from Standard;
+
+end BisectingLocus;
+
+
--- /dev/null
+// Created on: 1993-07-13
+// Created by: Yves FRICAUD
+// Copyright (c) 1993-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 <BRepMAT2d_BisectingLocus.ixx>
+
+# include <MAT2d_Mat2d.hxx>
+# include <MAT2d_Tool2d.hxx>
+# include <MAT2d_Circuit.hxx>
+# include <MAT2d_CutCurve.hxx>
+# include <MAT2d_BiInt.hxx>
+# include <MAT2d_SequenceOfSequenceOfGeometry.hxx>
+# include <MAT_Graph.hxx>
+# include <MAT_Arc.hxx>
+# include <MAT_BasicElt.hxx>
+# include <MAT_Node.hxx>
+# include <MAT_Bisector.hxx>
+# include <MAT_ListOfBisector.hxx>
+# include <MAT_DataMapOfIntegerBasicElt.hxx>
+# include <MAT_DataMapIteratorOfDataMapOfIntegerBasicElt.hxx>
+# include <Geom2d_Curve.hxx>
+# include <gp_Pnt2d.hxx>
+# include <TColGeom2d_SequenceOfGeometry.hxx>
+# include <Precision.hxx>
+
+#include <Standard_OutOfRange.hxx>
+
+static void CutSketch (MAT2d_SequenceOfSequenceOfGeometry& Figure,
+ MAT2d_DataMapOfBiIntInteger& NbSect);
+
+
+//=============================================================================
+//function : BRepMAT2d_BisectingLocus
+//purpose : Constructeur vide.
+//=============================================================================
+BRepMAT2d_BisectingLocus::BRepMAT2d_BisectingLocus()
+{
+}
+
+
+//=============================================================================
+//function : Compute
+//purpose : Calcul de la carte des lieux bisecteurs sur le contour defini par
+// <anExplo>.
+//=============================================================================
+void BRepMAT2d_BisectingLocus::Compute( BRepMAT2d_Explorer& anExplo,
+ const Standard_Integer IndexLine,
+ const MAT_Side aSide )
+{
+ MAT2d_Mat2d TheMAT;
+ Handle(MAT_ListOfBisector) TheRoots = new MAT_ListOfBisector();
+ MAT2d_SequenceOfSequenceOfGeometry Figure;
+ Standard_Integer i;
+
+ nbSect.Clear();
+ nbContours = anExplo.NumberOfContours();
+
+ //---------------------------------
+ // Lecture des donnees de anExplo.
+ //---------------------------------
+ for (i = 1; i <= anExplo.NumberOfContours(); i++) {
+ TColGeom2d_SequenceOfGeometry Line;
+ Figure.Append(Line);
+ for (anExplo.Init(i); anExplo.More(); anExplo.Next()) {
+ Figure.ChangeValue(i).Append(anExplo.Value());
+ }
+ }
+
+ //-----------------------
+ // Decoupage des courbes.
+ //-----------------------
+ CutSketch(Figure,nbSect);
+
+ //----------------------------------------------------------
+ // Construction du circuit sur lequel est calcule la carte.
+ //----------------------------------------------------------
+ Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit();
+// Modified by Sergey KHROMOV - Wed Mar 6 17:43:47 2002 Begin
+// ACircuit->Perform(Figure,IndexLine,(aSide == MAT_Left));
+ ACircuit->Perform(Figure,anExplo.GetIsClosed(), IndexLine,(aSide == MAT_Left));
+// Modified by Sergey KHROMOV - Wed Mar 6 17:43:48 2002 End
+
+ // -----------------------
+ // Initialistion du Tool.
+ // -----------------------
+ theTool.Sense(aSide);
+ theTool.InitItems(ACircuit);
+
+ // --------------------------------------------
+ // Initialisation et execution de l algorithme.
+ // --------------------------------------------
+ TheMAT.CreateMat(theTool);
+
+ isDone = TheMAT.IsDone(); if (!isDone) return;
+
+ // ----------------------------------------------------------------
+ // Recuperation du resultat de l algorithme et creation du graphe.
+ // ----------------------------------------------------------------
+ for (TheMAT.Init(); TheMAT.More(); TheMAT.Next()) {
+ TheRoots->BackAdd(TheMAT.Bisector());
+ }
+
+ theGraph = new MAT_Graph();
+ theGraph->Perform(TheMAT.SemiInfinite(),
+ TheRoots,
+ theTool.NumberOfItems(),
+ TheMAT.NumberOfBisectors());
+
+ //-----------------------------------------------------------------------
+ // Fusion des elements de base doubles si plusieurs lignes dans Exploset.
+ //-----------------------------------------------------------------------
+ if (anExplo.NumberOfContours() > 1) {
+ MAT_DataMapOfIntegerBasicElt NewMap;
+ Standard_Integer IndexLast = 1;
+
+ //-----------------------------------------------------------------------
+ // Construction de NewMap dont les elements sont ordonnes suivant les
+ // lignes du contour et qui ne contient pas d element dupliques.
+ // em meme temps fusion des arcs dupliques et mise a jour des noeuds.
+ //-----------------------------------------------------------------------
+ for ( i = 1; i <= anExplo.NumberOfContours(); i++) {
+ RenumerationAndFusion(i,
+ theTool.Circuit()->LineLength(i),
+ IndexLast,
+ NewMap);
+ }
+
+ //-----------------------------------------------------------------------
+ // Chargement dans le graph de la nouvelle map.
+ // et compactage de la map des Arcs (ie Elimination des trous du a la
+ // fusion d arcs ).et de celle des Nodes.
+ //-----------------------------------------------------------------------
+ theGraph->ChangeBasicElts(NewMap);
+ theGraph->CompactArcs();
+ theGraph->CompactNodes();
+ }
+}
+
+//=============================================================================
+//function : RenumerationAndFusion
+//purpose :
+//=============================================================================
+void BRepMAT2d_BisectingLocus::RenumerationAndFusion
+ (const Standard_Integer ILine,
+ const Standard_Integer LengthLine,
+ Standard_Integer& IndexLast,
+ MAT_DataMapOfIntegerBasicElt& NewMap)
+{
+ Standard_Integer IndFirst;
+ Standard_Integer i,j;
+ Standard_Integer GeomIndexArc1,GeomIndexArc2,GeomIndexArc3,GeomIndexArc4;
+ Standard_Boolean MergeArc1,MergeArc2;
+
+ for ( i = 1; i <= LengthLine; i++) {
+ const TColStd_SequenceOfInteger& S = theTool.Circuit()->RefToEqui(ILine,i);
+
+ IndFirst = S.Value(1);
+ NewMap.Bind(IndexLast,theGraph->ChangeBasicElt(IndFirst));
+ IndexLast++;
+
+ for(j = 2; j <= S.Length(); j++){
+ theGraph->FusionOfBasicElts(IndFirst,
+ S.Value(j),
+ MergeArc1,
+ GeomIndexArc1,
+ GeomIndexArc2,
+ MergeArc2,
+ GeomIndexArc3,
+ GeomIndexArc4);
+ if(MergeArc1) {
+ theTool.BisecFusion(GeomIndexArc1,GeomIndexArc2);
+ }
+ if(MergeArc2) {
+ theTool.BisecFusion(GeomIndexArc3,GeomIndexArc4);
+ }
+ }
+ }
+}
+
+//=============================================================================
+//function : IsDone
+//Purpose :
+//=============================================================================
+Standard_Boolean BRepMAT2d_BisectingLocus::IsDone() const
+{
+ return isDone;
+}
+
+//=============================================================================
+//function : Graph
+//
+//=============================================================================
+Handle(MAT_Graph) BRepMAT2d_BisectingLocus::Graph() const
+{
+ return theGraph;
+}
+
+//=============================================================================
+//function : NumberOfContours
+//
+//=============================================================================
+Standard_Integer BRepMAT2d_BisectingLocus::NumberOfContours () const
+{
+ return nbContours;
+}
+
+//=============================================================================
+//function : NumberOfElts
+//
+//=============================================================================
+Standard_Integer BRepMAT2d_BisectingLocus::NumberOfElts
+ (const Standard_Integer IndLine) const
+{
+ return theTool.Circuit()->LineLength(IndLine);
+}
+
+//=============================================================================
+//function : NumberOfSect
+//
+//=============================================================================
+Standard_Integer BRepMAT2d_BisectingLocus::NumberOfSections
+(const Standard_Integer IndLine,
+ const Standard_Integer Index )
+ const
+{
+ MAT2d_BiInt B(IndLine,Index);
+ return nbSect(B);
+}
+
+//=============================================================================
+//function : BasicElt
+//
+//=============================================================================
+Handle(MAT_BasicElt) BRepMAT2d_BisectingLocus::BasicElt
+ (const Standard_Integer IndLine,
+ const Standard_Integer Index )
+ const
+{
+ Standard_Integer i;
+ Standard_Integer Ind = Index;
+
+ for (i = 1 ; i < IndLine ; i++){
+ Ind = Ind + theTool.Circuit()->LineLength(i);
+ }
+ return theGraph->BasicElt(Ind);
+}
+
+
+//=============================================================================
+//function : GeomBis
+//
+//=============================================================================
+Bisector_Bisec BRepMAT2d_BisectingLocus::GeomBis (const Handle(MAT_Arc)& anArc,
+ Standard_Boolean& Reverse)
+const
+{
+ Reverse = Standard_False;
+
+ Handle(Geom2d_Curve) Bis = theTool.GeomBis(anArc->GeomIndex()).Value();
+
+ if (Bis->FirstParameter() <= -Precision::Infinite()) {
+ Reverse = Standard_True;
+ }
+ else if (Bis->LastParameter() < Precision::Infinite()) {
+ gp_Pnt2d PF = Bis->Value(Bis->FirstParameter());
+ gp_Pnt2d PL = Bis->Value(Bis->LastParameter());
+ gp_Pnt2d PNode = GeomElt(anArc->FirstNode());
+ if (PNode.SquareDistance(PF) > PNode.SquareDistance(PL))
+ Reverse = Standard_True;
+ }
+ return theTool.GeomBis(anArc->GeomIndex());
+}
+
+//=============================================================================
+//function : GeomElt
+//
+//=============================================================================
+Handle(Geom2d_Geometry) BRepMAT2d_BisectingLocus::GeomElt
+ (const Handle(MAT_BasicElt)& aBasicElt) const
+{
+ return theTool.GeomElt(aBasicElt->GeomIndex());
+}
+
+
+//=============================================================================
+//function : GeomElt
+//
+//=============================================================================
+gp_Pnt2d BRepMAT2d_BisectingLocus::GeomElt(const Handle(MAT_Node)& aNode) const
+{
+ return theTool.GeomPnt(aNode->GeomIndex());
+}
+
+
+//=============================================================================
+//function : CutSketch
+//
+//=============================================================================
+static void CutSketch (MAT2d_SequenceOfSequenceOfGeometry& Figure,
+ MAT2d_DataMapOfBiIntInteger& NbSect)
+{
+ MAT2d_CutCurve Cuter;
+ Standard_Integer i,j,k,ico;
+ Standard_Integer ICurveInit;
+ Standard_Integer NbSection;
+
+ for ( i = 1; i <= Figure.Length(); i++) {
+ TColGeom2d_SequenceOfGeometry& Contour = Figure.ChangeValue(i);
+ ICurveInit = 0;
+
+ for ( j = 1; j <= Contour.Length(); j++) {
+ ICurveInit++;
+ Cuter.Perform(Handle(Geom2d_Curve)::DownCast(Contour.ChangeValue(j)));
+ NbSection = 1;
+ if (!Cuter.UnModified()) {
+ ico = j;
+ NbSection = Cuter.NbCurves();
+ for ( k = 1; k <= NbSection; k++) {
+ Contour.InsertAfter(j,Cuter.Value(k));
+ j++;
+ }
+ Contour.Remove(ico);
+ j--;
+ }
+ MAT2d_BiInt B(i,ICurveInit);
+ NbSect.Bind(B,NbSection);
+ }
+ }
+}
+
#include <IntAna_QuadQuadGeo.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
-#include <IntPatch_ThePWalkingInter.hxx>
+#include <IntWalk_PWalking.hxx>
#include <IntPatch_WLine.hxx>
#include <Geom2dInt_GInter.hxx>
#include <GeomInt_WLApprox.hxx>
//Builder, so they are reestimated as much as possible.
Standard_Real fleche = 1.e-3 * pdeb.Distance(pfin);
Standard_Real tolap = 1.e-7;
- IntPatch_ThePWalkingInter
+ IntWalk_PWalking
IntKK(S1,S2,tol3d,tol3d,fleche,Step);
//The extremities of the intersection (Pardeb,Parfin) are known,
--
-uses Standard, gp, TColStd, GeomAbs, Geom2d, Adaptor3d,Adaptor2d, IntCurve
+uses Standard, gp, TColStd, GeomAbs, Geom2d, Adaptor3d, Adaptor2d, IntCurve
is
- generic class CurveTool;
-
- class Geom2dCurveTool instantiates CurveTool from Geom2dInt
- (Curve2d from Adaptor2d);
+ class Geom2dCurveTool;
class GInter instantiates IntCurveCurveGen from IntCurve
(Curve2d from Adaptor2d,
+++ /dev/null
--- Created on: 1992-10-22
--- Created by: Laurent BUCHARD
--- Copyright (c) 1992-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.
-
-generic class CurveTool from Geom2dInt (
- IntCurveCurve as any)
-
-
- ---Purpose: This class provides a CurveTool as < CurveTool from IntCurve >
- -- from a Tool as < CurveTool from Adaptor3d > .
-
-uses
-
- Pnt2d from gp,
- Vec2d from gp,
- Lin2d from gp,
- Circ2d from gp,
- Elips2d from gp,
- Parab2d from gp,
- Hypr2d from gp,
- Array1OfReal from TColStd,
- CurveType from GeomAbs
-
-
-is
-
-
- GetType(myclass; C: IntCurveCurve)
- ---C++: inline
- returns CurveType from GeomAbs;
-
- IsComposite(myclass; C: IntCurveCurve)
- ---C++: inline
- returns Boolean from Standard;
-
- Line(myclass; C: IntCurveCurve)
-
- ---Purpose: Returns the Lin2d from gp corresponding to the curve C.
- -- This method is called only when TheType returns
- -- GeomAbs_Line.
- ---C++: inline
- returns Lin2d from gp;
-
-
- Circle(myclass; C: IntCurveCurve)
-
- ---Purpose: Returns the Circ2d from gp corresponding to the curve C.
- -- This method is called only when TheType returns
- -- GeomAbs_Circle.
- ---C++: inline
- returns Circ2d from gp;
-
-
- Ellipse(myclass; C: IntCurveCurve)
-
- ---Purpose: Returns the Elips2d from gp corresponding to the curve C.
- -- This method is called only when TheType returns
- -- GeomAbs_Ellipse.
- ---C++: inline
- returns Elips2d from gp;
-
-
- Parabola(myclass; C: IntCurveCurve)
-
- ---Purpose: Returns the Parab2d from gp corresponding to the curve C.
- -- This method is called only when TheType returns
- -- GeomAbs_Parabola.
- ---C++: inline
- returns Parab2d from gp;
-
-
- Hyperbola(myclass; C: IntCurveCurve)
-
- ---Purpose: Returns the Hypr2d from gp corresponding to the curve C.
- -- This method is called only when TheType returns
- -- GeomAbs_Hyperbola.
- ---C++: inline
- returns Hypr2d from gp;
-
-
--- The following method are used only when TheType returns IntCurve_Other.
-
-
- EpsX (myclass; C: IntCurveCurve)
- ---C++: inline
- returns Real;
-
- EpsX (myclass; C: IntCurveCurve;
- Eps_XYZ : Real from Standard)
- ---C++: inline
- returns Real;
-
-
- NbSamples(myclass; C: IntCurveCurve)
-
- returns Integer;
-
- NbSamples(myclass; C: IntCurveCurve; U0,U1: Real from Standard)
-
- returns Integer;
-
-
- FirstParameter(myclass; C:IntCurveCurve)
- ---C++: inline
- returns Real;
-
-
- LastParameter(myclass; C:IntCurveCurve)
- ---C++: inline
- returns Real;
-
-
- Value (myclass; C: IntCurveCurve; X: Real)
- ---C++: inline
- returns Pnt2d from gp;
-
-
- D0 (myclass; C: IntCurveCurve; U: Real ;
- P: out Pnt2d);
- ---C++: inline
-
- D1 (myclass; C: IntCurveCurve; U: Real ;
- P: out Pnt2d; T: out Vec2d);
- ---C++: inline
-
- D2 (myclass; C: IntCurveCurve; U: Real ;
- P: out Pnt2d; T,N: out Vec2d);
- ---C++: inline
-
- D3 (myclass; C: IntCurveCurve; U: Real ;
- P: out Pnt2d; T,N,V: out Vec2d);
- ---C++: inline
-
- DN(myclass; C: IntCurveCurve; U: Real ;
- N: Integer from Standard)
- returns Vec2d;
- ---C++: inline
-
- NbIntervals(myclass ; C: IntCurveCurve)
- ---Purpose : output the number of interval of continuity C2 of
- -- the curve
- ---C++: inline
- returns Integer from Standard;
-
- Intervals (myclass; C: IntCurveCurve
- ; Tab : out Array1OfReal from TColStd);
- ---Purpose: compute Tab.
- ---C++: inline
-
- GetInterval (myclass; C: IntCurveCurve
- ; Index : Integer from Standard
- ; Tab : Array1OfReal from TColStd
- ; U1, U2 : out Real from Standard);
- ---Purpose : output the bounds of interval of index <Index>
- -- used if Type == Composite.
- ---C++: inline
-
- Degree(myclass; C : IntCurveCurve) returns Integer from Standard;
- ---C++: inline
-
-
-end CurveTool;
-
-
-
-
+++ /dev/null
-// Created on: 1992-10-22
-// Created by: Laurent BUCHARD
-// Copyright (c) 1992-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 <GeomAbs_CurveType.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-
-//============================================================
-Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C,
- const Standard_Real U0,
- const Standard_Real U1) {
- GeomAbs_CurveType typC = C.GetType();
- static Standard_Real nbsOther = 10.0;
- Standard_Real nbs = nbsOther;
-
- if(typC == GeomAbs_Line)
- nbs = 2;
- else if(typC == GeomAbs_BezierCurve)
- nbs = 3 + C.NbPoles();
- else if(typC == GeomAbs_BSplineCurve) {
- Standard_Real t=C.LastParameter()-C.FirstParameter();
- Standard_Real t1=U1-U0;
- if(t1<0.0) t1=-t1;
- nbs = C.NbKnots();
- nbs*= C.Degree();
- nbs*= (t1/t);
- if(nbs < 4.0) nbs=4;
- }
- //// modified by jgv, 20.02.02 for bug OCC165 ////
- else if (typC == GeomAbs_OtherCurve)
- nbs = 20;
- //////////////////////////////////////////////////
-
- if(nbs>300)
- nbs = 300;
- return((Standard_Integer)nbs);
-}
-//============================================================
-Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C) {
- GeomAbs_CurveType typC = C.GetType();
- static Standard_Real nbsOther = 10.0;
- Standard_Real nbs = nbsOther;
-
- if(typC == GeomAbs_Line)
- nbs = 2;
- else if(typC == GeomAbs_BezierCurve)
- nbs = 3 + C.NbPoles();
- else if(typC == GeomAbs_BSplineCurve) {
- nbs = C.NbKnots();
- nbs*= C.Degree();
- if(nbs < 2.0) nbs=2;
- }
- //// modified by jgv, 20.02.02 for bug OCC165 ////
- else if (typC == GeomAbs_OtherCurve)
- nbs = 20;
- //////////////////////////////////////////////////
-
- if(nbs>300)
- nbs = 300;
- return((Standard_Integer)nbs);
-}
-
-
-
-
+++ /dev/null
-// Created on: 1992-10-22
-// Created by: Laurent BUCHARD
-// Copyright (c) 1992-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 IntCurveCurve_hxx
-
-#include <GeomAbs_CurveType.hxx>
-#include <GeomAbs_Shape.hxx>
-
-#include <gp_Lin2d.hxx>
-#include <gp_Circ2d.hxx>
-#include <gp_Elips2d.hxx>
-#include <gp_Parab2d.hxx>
-#include <gp_Hypr2d.hxx>
-
-#include <TColStd_Array1OfReal.hxx>
-
-#define IS_C2_COMPOSITE 0
-//============================================================
-inline GeomAbs_CurveType Geom2dInt_CurveTool::GetType(const IntCurveCurve& C) {
- return(C.GetType());
-}
-//============================================================
-inline gp_Lin2d Geom2dInt_CurveTool::Line (const IntCurveCurve& C) {
- return(C.Line());
-}
-//============================================================
-inline gp_Circ2d Geom2dInt_CurveTool::Circle (const IntCurveCurve& C) {
- return(C.Circle());
-}
-//============================================================
-inline gp_Elips2d Geom2dInt_CurveTool::Ellipse (const IntCurveCurve& C) {
- return(C.Ellipse());
-}
-//============================================================
-inline gp_Parab2d Geom2dInt_CurveTool::Parabola (const IntCurveCurve& C) {
- return(C.Parabola());
-}
-//============================================================
-inline gp_Hypr2d Geom2dInt_CurveTool::Hyperbola (const IntCurveCurve& C) {
- return(C.Hyperbola());
-}
-//============================================================
-inline gp_Pnt2d Geom2dInt_CurveTool::Value (const IntCurveCurve& C,
- const Standard_Real U) {
- return(C.Value(U));
-}
-//============================================================
-inline void Geom2dInt_CurveTool::D0(const IntCurveCurve& C,
- const Standard_Real U,
- gp_Pnt2d& P) {
- C.D0(U,P);
-}
-//============================================================
-inline void Geom2dInt_CurveTool::D1 (const IntCurveCurve& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& T) {
- C.D1(U,P,T);
-}
-//============================================================
-inline void Geom2dInt_CurveTool::D2 (const IntCurveCurve& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& T,
- gp_Vec2d& N) {
-
- C.D2(U,P,T,N);
-}
-
-//============================================================
-inline void Geom2dInt_CurveTool::D3 (const IntCurveCurve& C,
- const Standard_Real U,
- gp_Pnt2d& P,
- gp_Vec2d& T,
- gp_Vec2d& N,
- gp_Vec2d& V) {
-
- C.D3(U,P,T,N,V);
-}
-//============================================================
-inline gp_Vec2d Geom2dInt_CurveTool::DN(const Adaptor2d_Curve2d& C,
- const Standard_Real U,
- const Standard_Integer N)
- {
- return C.DN(U,N);
- }
-
-//============================================================
-inline Standard_Real Geom2dInt_CurveTool::FirstParameter (const IntCurveCurve& C) {
- return(C.FirstParameter());
-}
-//============================================================
-inline Standard_Real Geom2dInt_CurveTool::LastParameter (const IntCurveCurve& C) {
- return(C.LastParameter());
-}
-//============================================================
-//== tolerance used by mathemetical algorithms
-//==
-inline Standard_Real Geom2dInt_CurveTool::EpsX (const IntCurveCurve& ) {
- return(1.0e-10);
-}
-//------------------------------------------------------------
-inline Standard_Real Geom2dInt_CurveTool::EpsX (const IntCurveCurve& C,const Standard_Real Eps_XYZ) {
- return(C.Resolution(Eps_XYZ));
-}
-//============================================================
-inline void Geom2dInt_CurveTool::Intervals(const IntCurveCurve& C,
- TColStd_Array1OfReal& Tab) {
-#if IS_C2_COMPOSITE
- C.Intervals(Tab,GeomAbs_C2);
-#else
- C.Intervals(Tab,GeomAbs_C1);
-#endif
-}
-//============================================================
-//inline void Geom2dInt_CurveTool::GetInterval(const IntCurveCurve& C,
-inline void Geom2dInt_CurveTool::GetInterval(const IntCurveCurve& ,
- const Standard_Integer i,
- const TColStd_Array1OfReal& Tab,
- Standard_Real& a,
- Standard_Real& b) {
- a = Tab.Value(i);
- b = Tab.Value(i+1);
-}
-//============================================================
-inline Standard_Integer Geom2dInt_CurveTool::NbIntervals(const IntCurveCurve& C) {
- Standard_Integer N=1;
-#if IS_C2_COMPOSITE
- N = C.NbIntervals(GeomAbs_C2);
-#else
- N = C.NbIntervals(GeomAbs_C1);
-#endif
- return(N);
-}
-//============================================================
-
- inline Standard_Integer Geom2dInt_CurveTool::Degree(const IntCurveCurve& C)
-{
- return C.Degree();
-}
--- /dev/null
+-- Created on: 1992-10-22
+-- Created by: Laurent BUCHARD
+-- Copyright (c) 1992-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.
+
+class Geom2dCurveTool from Geom2dInt
+
+
+ ---Purpose: This class provides a Geom2dCurveTool as < Geom2dCurveTool from IntCurve >
+ -- from a Tool as < Geom2dCurveTool from Adaptor3d > .
+
+uses
+
+ Pnt2d from gp,
+ Vec2d from gp,
+ Lin2d from gp,
+ Circ2d from gp,
+ Elips2d from gp,
+ Parab2d from gp,
+ Hypr2d from gp,
+ Array1OfReal from TColStd,
+ CurveType from GeomAbs,
+ Curve2d from Adaptor2d
+
+
+is
+
+
+ GetType(myclass; C: Curve2d from Adaptor2d)
+ ---C++: inline
+ returns CurveType from GeomAbs;
+
+ IsComposite(myclass; C: Curve2d from Adaptor2d)
+ ---C++: inline
+ returns Boolean from Standard;
+
+ Line(myclass; C: Curve2d from Adaptor2d)
+
+ ---Purpose: Returns the Lin2d from gp corresponding to the curve C.
+ -- This method is called only when TheType returns
+ -- GeomAbs_Line.
+ ---C++: inline
+ returns Lin2d from gp;
+
+
+ Circle(myclass; C: Curve2d from Adaptor2d)
+
+ ---Purpose: Returns the Circ2d from gp corresponding to the curve C.
+ -- This method is called only when TheType returns
+ -- GeomAbs_Circle.
+ ---C++: inline
+ returns Circ2d from gp;
+
+
+ Ellipse(myclass; C: Curve2d from Adaptor2d)
+
+ ---Purpose: Returns the Elips2d from gp corresponding to the curve C.
+ -- This method is called only when TheType returns
+ -- GeomAbs_Ellipse.
+ ---C++: inline
+ returns Elips2d from gp;
+
+
+ Parabola(myclass; C: Curve2d from Adaptor2d)
+
+ ---Purpose: Returns the Parab2d from gp corresponding to the curve C.
+ -- This method is called only when TheType returns
+ -- GeomAbs_Parabola.
+ ---C++: inline
+ returns Parab2d from gp;
+
+
+ Hyperbola(myclass; C: Curve2d from Adaptor2d)
+
+ ---Purpose: Returns the Hypr2d from gp corresponding to the curve C.
+ -- This method is called only when TheType returns
+ -- GeomAbs_Hyperbola.
+ ---C++: inline
+ returns Hypr2d from gp;
+
+
+-- The following method are used only when TheType returns IntCurve_Other.
+
+
+ EpsX (myclass; C: Curve2d from Adaptor2d)
+ ---C++: inline
+ returns Real;
+
+ EpsX (myclass; C: Curve2d from Adaptor2d;
+ Eps_XYZ : Real from Standard)
+ ---C++: inline
+ returns Real;
+
+
+ NbSamples(myclass; C: Curve2d from Adaptor2d)
+
+ returns Integer;
+
+ NbSamples(myclass; C: Curve2d from Adaptor2d; U0,U1: Real from Standard)
+
+ returns Integer;
+
+
+ FirstParameter(myclass; C:Curve2d from Adaptor2d)
+ ---C++: inline
+ returns Real;
+
+
+ LastParameter(myclass; C:Curve2d from Adaptor2d)
+ ---C++: inline
+ returns Real;
+
+
+ Value (myclass; C: Curve2d from Adaptor2d; X: Real)
+ ---C++: inline
+ returns Pnt2d from gp;
+
+
+ D0 (myclass; C: Curve2d from Adaptor2d; U: Real ;
+ P: out Pnt2d);
+ ---C++: inline
+
+ D1 (myclass; C: Curve2d from Adaptor2d; U: Real ;
+ P: out Pnt2d; T: out Vec2d);
+ ---C++: inline
+
+ D2 (myclass; C: Curve2d from Adaptor2d; U: Real ;
+ P: out Pnt2d; T,N: out Vec2d);
+ ---C++: inline
+
+ D3 (myclass; C: Curve2d from Adaptor2d; U: Real ;
+ P: out Pnt2d; T,N,V: out Vec2d);
+ ---C++: inline
+
+ DN(myclass; C: Curve2d from Adaptor2d; U: Real ;
+ N: Integer from Standard)
+ returns Vec2d;
+ ---C++: inline
+
+ NbIntervals(myclass ; C: Curve2d from Adaptor2d)
+ ---Purpose : output the number of interval of continuity C2 of
+ -- the curve
+ ---C++: inline
+ returns Integer from Standard;
+
+ Intervals (myclass; C: Curve2d from Adaptor2d
+ ; Tab : out Array1OfReal from TColStd);
+ ---Purpose: compute Tab.
+ ---C++: inline
+
+ GetInterval (myclass; C: Curve2d from Adaptor2d
+ ; Index : Integer from Standard
+ ; Tab : Array1OfReal from TColStd
+ ; U1, U2 : out Real from Standard);
+ ---Purpose : output the bounds of interval of index <Index>
+ -- used if Type == Composite.
+ ---C++: inline
+
+ Degree(myclass; C : Curve2d from Adaptor2d) returns Integer from Standard;
+ ---C++: inline
+
+
+end Geom2dCurveTool;
+
+
+
+
--- /dev/null
+// Created on: 1992-10-22
+// Created by: Laurent BUCHARD
+// Copyright (c) 1992-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 <Geom2dInt_Geom2dCurveTool.ixx>
+
+#include <GeomAbs_CurveType.hxx>
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+
+#include <Adaptor2d_Curve2d.hxx>
+
+//============================================================
+Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C,
+ const Standard_Real U0,
+ const Standard_Real U1) {
+ GeomAbs_CurveType typC = C.GetType();
+ static Standard_Real nbsOther = 10.0;
+ Standard_Real nbs = nbsOther;
+
+ if(typC == GeomAbs_Line)
+ nbs = 2;
+ else if(typC == GeomAbs_BezierCurve)
+ nbs = 3 + C.NbPoles();
+ else if(typC == GeomAbs_BSplineCurve) {
+ Standard_Real t=C.LastParameter()-C.FirstParameter();
+ Standard_Real t1=U1-U0;
+ if(t1<0.0) t1=-t1;
+ nbs = C.NbKnots();
+ nbs*= C.Degree();
+ nbs*= (t1/t);
+ if(nbs < 4.0) nbs=4;
+ }
+ //// modified by jgv, 20.02.02 for bug OCC165 ////
+ else if (typC == GeomAbs_OtherCurve)
+ nbs = 20;
+ //////////////////////////////////////////////////
+
+ if(nbs>300)
+ nbs = 300;
+ return((Standard_Integer)nbs);
+}
+//============================================================
+Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C) {
+ GeomAbs_CurveType typC = C.GetType();
+ static Standard_Real nbsOther = 10.0;
+ Standard_Real nbs = nbsOther;
+
+ if(typC == GeomAbs_Line)
+ nbs = 2;
+ else if(typC == GeomAbs_BezierCurve)
+ nbs = 3 + C.NbPoles();
+ else if(typC == GeomAbs_BSplineCurve) {
+ nbs = C.NbKnots();
+ nbs*= C.Degree();
+ if(nbs < 2.0) nbs=2;
+ }
+ //// modified by jgv, 20.02.02 for bug OCC165 ////
+ else if (typC == GeomAbs_OtherCurve)
+ nbs = 20;
+ //////////////////////////////////////////////////
+
+ if(nbs>300)
+ nbs = 300;
+ return((Standard_Integer)nbs);
+}
+
+
+
+
--- /dev/null
+// Created on: 1992-10-22
+// Created by: Laurent BUCHARD
+// Copyright (c) 1992-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 <GeomAbs_CurveType.hxx>
+#include <GeomAbs_Shape.hxx>
+
+#include <gp_Lin2d.hxx>
+#include <gp_Circ2d.hxx>
+#include <gp_Elips2d.hxx>
+#include <gp_Parab2d.hxx>
+#include <gp_Hypr2d.hxx>
+
+#include <TColStd_Array1OfReal.hxx>
+#include <Adaptor2d_Curve2d.hxx>
+
+#define IS_C2_COMPOSITE 0
+//============================================================
+inline GeomAbs_CurveType Geom2dInt_Geom2dCurveTool::GetType(const Adaptor2d_Curve2d& C) {
+ return(C.GetType());
+}
+//============================================================
+inline gp_Lin2d Geom2dInt_Geom2dCurveTool::Line (const Adaptor2d_Curve2d& C) {
+ return(C.Line());
+}
+//============================================================
+inline gp_Circ2d Geom2dInt_Geom2dCurveTool::Circle (const Adaptor2d_Curve2d& C) {
+ return(C.Circle());
+}
+//============================================================
+inline gp_Elips2d Geom2dInt_Geom2dCurveTool::Ellipse (const Adaptor2d_Curve2d& C) {
+ return(C.Ellipse());
+}
+//============================================================
+inline gp_Parab2d Geom2dInt_Geom2dCurveTool::Parabola (const Adaptor2d_Curve2d& C) {
+ return(C.Parabola());
+}
+//============================================================
+inline gp_Hypr2d Geom2dInt_Geom2dCurveTool::Hyperbola (const Adaptor2d_Curve2d& C) {
+ return(C.Hyperbola());
+}
+//============================================================
+inline gp_Pnt2d Geom2dInt_Geom2dCurveTool::Value (const Adaptor2d_Curve2d& C,
+ const Standard_Real U) {
+ return(C.Value(U));
+}
+//============================================================
+inline void Geom2dInt_Geom2dCurveTool::D0(const Adaptor2d_Curve2d& C,
+ const Standard_Real U,
+ gp_Pnt2d& P) {
+ C.D0(U,P);
+}
+//============================================================
+inline void Geom2dInt_Geom2dCurveTool::D1 (const Adaptor2d_Curve2d& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& T) {
+ C.D1(U,P,T);
+}
+//============================================================
+inline void Geom2dInt_Geom2dCurveTool::D2 (const Adaptor2d_Curve2d& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& T,
+ gp_Vec2d& N) {
+
+ C.D2(U,P,T,N);
+}
+
+//============================================================
+inline void Geom2dInt_Geom2dCurveTool::D3 (const Adaptor2d_Curve2d& C,
+ const Standard_Real U,
+ gp_Pnt2d& P,
+ gp_Vec2d& T,
+ gp_Vec2d& N,
+ gp_Vec2d& V) {
+
+ C.D3(U,P,T,N,V);
+}
+//============================================================
+inline gp_Vec2d Geom2dInt_Geom2dCurveTool::DN(const Adaptor2d_Curve2d& C,
+ const Standard_Real U,
+ const Standard_Integer N)
+ {
+ return C.DN(U,N);
+ }
+
+//============================================================
+inline Standard_Real Geom2dInt_Geom2dCurveTool::FirstParameter (const Adaptor2d_Curve2d& C) {
+ return(C.FirstParameter());
+}
+//============================================================
+inline Standard_Real Geom2dInt_Geom2dCurveTool::LastParameter (const Adaptor2d_Curve2d& C) {
+ return(C.LastParameter());
+}
+//============================================================
+//== tolerance used by mathemetical algorithms
+//==
+inline Standard_Real Geom2dInt_Geom2dCurveTool::EpsX (const Adaptor2d_Curve2d& ) {
+ return(1.0e-10);
+}
+//------------------------------------------------------------
+inline Standard_Real Geom2dInt_Geom2dCurveTool::EpsX (const Adaptor2d_Curve2d& C,const Standard_Real Eps_XYZ) {
+ return(C.Resolution(Eps_XYZ));
+}
+//============================================================
+inline void Geom2dInt_Geom2dCurveTool::Intervals(const Adaptor2d_Curve2d& C,
+ TColStd_Array1OfReal& Tab) {
+#if IS_C2_COMPOSITE
+ C.Intervals(Tab,GeomAbs_C2);
+#else
+ C.Intervals(Tab,GeomAbs_C1);
+#endif
+}
+//============================================================
+//inline void Geom2dInt_Geom2dCurveTool::GetInterval(const Adaptor2d_Curve2d& C,
+inline void Geom2dInt_Geom2dCurveTool::GetInterval(const Adaptor2d_Curve2d& ,
+ const Standard_Integer i,
+ const TColStd_Array1OfReal& Tab,
+ Standard_Real& a,
+ Standard_Real& b) {
+ a = Tab.Value(i);
+ b = Tab.Value(i+1);
+}
+//============================================================
+inline Standard_Integer Geom2dInt_Geom2dCurveTool::NbIntervals(const Adaptor2d_Curve2d& C) {
+ Standard_Integer N=1;
+#if IS_C2_COMPOSITE
+ N = C.NbIntervals(GeomAbs_C2);
+#else
+ N = C.NbIntervals(GeomAbs_C1);
+#endif
+ return(N);
+}
+//============================================================
+
+ inline Standard_Integer Geom2dInt_Geom2dCurveTool::Degree(const Adaptor2d_Curve2d& C)
+{
+ return C.Degree();
+}
class RLine; -- inherits Line from IntPatch
class ArcFunction;
+
+ class InterferencePolyhedron;
+ ---Purpose: Compute the interference between two polyhedron. Points
+ -- of intersection , polylines of intersection and zones of
+ -- tangence.
-- implicite/implicite
TopolTool from Adaptor3d,
ArcFunction from IntPatch);
- class TheInterfPolyhedron instantiates InterferencePolyhedron from Intf(
- Polyhedron from IntPatch,
- PolyhedronTool from IntPatch,
- Polyhedron from IntPatch,
- PolyhedronTool from IntPatch);
-
- class ThePWalkingInter instantiates PWalking from IntWalk(
- HSurface from Adaptor3d,
- HSurfaceTool from Adaptor3d);
-
alias SearchPnt is InterferencePolygon2d from Intf;
class CSFunction instantiates ZerCOnSSParFunc from IntImp
--- /dev/null
+-- Created on: 1992-09-29
+-- Created by: Didier PIFFAULT
+-- Copyright (c) 1992-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.
+
+class InterferencePolyhedron from IntPatch inherits Interference from Intf
+
+ ---Purpose: Computes the interference between two polyhedra or the
+ -- self interference of a polyhedron.
+
+uses Pnt from gp,
+ XYZ from gp,
+ Box from Bnd,
+ SectionPoint from Intf,
+ SeqOfSectionPoint from Intf,
+ SectionLine from Intf,
+ SeqOfSectionLine from Intf,
+ TangentZone from Intf,
+ SeqOfTangentZone from Intf,
+ Polyhedron from IntPatch,
+ PolyhedronTool from IntPatch
+
+is
+
+-- Interface :
+
+ Create returns InterferencePolyhedron from IntPatch;
+ ---Purpose: Constructs an empty interference of Polyhedron.
+
+ Create (Obje1 : in Polyhedron from IntPatch;
+ Obje2 : in Polyhedron from IntPatch)
+ returns InterferencePolyhedron from IntPatch;
+ ---Purpose: Constructs and computes an interference between the two
+ -- Polyhedra.
+
+ Create (Obje : in Polyhedron from IntPatch)
+ returns InterferencePolyhedron from IntPatch;
+ ---Purpose: Constructs and computes the self interference of a
+ -- Polyhedron.
+
+ Perform (me : in out;
+ Obje1 : in Polyhedron from IntPatch;
+ Obje2 : in Polyhedron from IntPatch);
+ ---Purpose: Computes the interference between the two Polyhedra.
+
+ Perform (me : in out;
+ Obje : in Polyhedron from IntPatch);
+ ---Purpose: Computes the self interference of a Polyhedron.
+
+-- Implementation :
+
+ Interference (me : in out;
+ Obje1 : in Polyhedron from IntPatch)
+ is private;
+ Interference (me : in out;
+ Obje1 : in Polyhedron from IntPatch;
+ Obje2 : in Polyhedron from IntPatch)
+ is private;
+ ---Purpose: Compares the bounding volumes between the facets of <Obje1>
+ -- and the facets of <Obje2> and intersects the facets when the
+ -- bounding volumes have a common part.
+
+ Intersect (me : in out;
+ TriF : in Integer from Standard;
+ Obje1 : in Polyhedron from IntPatch;
+ TriS : in Integer from Standard;
+ Obje2 : in Polyhedron from IntPatch)
+ is private;
+ ---Purpose: Computes the intersection between the facet <Tri1> of
+ -- <FirstPol> and the facet <Tri2> of <SecondPol>.
+
+ TangentZoneValue
+ (me;
+ TheTZ : in out TangentZone from Intf;
+ Obje1 : Polyhedron from IntPatch;
+ Tri1 : Integer from Standard;
+ Obje2 : Polyhedron from IntPatch;
+ Tri2 : Integer from Standard)
+ returns Boolean from Standard
+ is private;
+ ---Purpose: Computes the zone of tangence between the facet <Tri1> of
+ -- <FirstPol> and the facet <Tri2> of <SecondPol>.
+
+ CoupleCharacteristics (me: in out;
+ FirstPol: Polyhedron from IntPatch;
+ SeconPol: Polyhedron from IntPatch) is private;
+fields
+ OI : Integer from Standard[3]; -- index des sommets de l objet
+ TI : Integer from Standard[3]; -- index des sommets du tool
+ dpOpT : Real from Standard[3, 3]; -- distance point Objet - point Tool
+ dpOeT : Real from Standard[3, 3]; -- distance point Objet - edge Tool
+ deOpT : Real from Standard[3, 3]; -- distance edge Objet - point Tool
+ voo : XYZ from gp[3]; -- vecteur point point Obje
+ vtt : XYZ from gp[3]; -- vecteur point point Tool
+ Incidence: Real from Standard; -- angle entre les deux plans
+
+end InterferencePolyhedron;
--- /dev/null
+// Created on: 1992-11-09
+// Created by: Didier PIFFAULT
+// Copyright (c) 1992-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 <IntPatch_InterferencePolyhedron.ixx>
+
+#include <IntPatch_Polyhedron.hxx>
+#include <IntPatch_PolyhedronTool.hxx>
+
+#include <gp_XYZ.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <Intf_SectionPoint.hxx>
+#include <Intf_SeqOfSectionPoint.hxx>
+#include <Intf_SectionLine.hxx>
+#include <Intf_SeqOfSectionLine.hxx>
+#include <Intf_TangentZone.hxx>
+#include <Intf_SeqOfTangentZone.hxx>
+#include <Intf.hxx>
+#include <Bnd_HArray1OfBox.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <Bnd_BoundSortBox.hxx>
+
+static const int Pourcent3[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};
+
+//=======================================================================
+//function : IntPatch_InterferencePolyhedron
+//purpose : Empty constructor.
+//=======================================================================
+
+IntPatch_InterferencePolyhedron::IntPatch_InterferencePolyhedron ()
+: Intf_Interference(Standard_False)
+{}
+
+//=======================================================================
+//function : IntPatch_InterferencePolyhedron
+//purpose :
+//=======================================================================
+
+IntPatch_InterferencePolyhedron::IntPatch_InterferencePolyhedron
+ (const IntPatch_Polyhedron& FirstPol, const IntPatch_Polyhedron& SeconPol)
+: Intf_Interference(Standard_False)
+{
+ if (!IntPatch_PolyhedronTool::Bounding(FirstPol).IsOut
+ (IntPatch_PolyhedronTool::Bounding(SeconPol))) {
+ Tolerance=IntPatch_PolyhedronTool::DeflectionOverEstimation(FirstPol)+
+ IntPatch_PolyhedronTool::DeflectionOverEstimation(SeconPol);
+ if (Tolerance==0.)
+ Tolerance=Epsilon(1000.);
+ Interference(FirstPol, SeconPol);
+ }
+}
+
+//=======================================================================
+//function : IntPatch_InterferencePolyhedron
+//purpose :
+//=======================================================================
+
+IntPatch_InterferencePolyhedron::IntPatch_InterferencePolyhedron
+ (const IntPatch_Polyhedron& Objet)
+: Intf_Interference(Standard_True)
+{
+ Tolerance=IntPatch_PolyhedronTool::DeflectionOverEstimation(Objet)*2;
+ if (Tolerance==0.)
+ Tolerance=Epsilon(1000.);
+ Interference(Objet,Objet); //-- lbr le 5 juillet 96
+ }
+
+
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+
+void IntPatch_InterferencePolyhedron::Perform
+ (const IntPatch_Polyhedron& FirstPol, const IntPatch_Polyhedron& SeconPol)
+{
+ SelfInterference(Standard_False);
+ if (!IntPatch_PolyhedronTool::Bounding(FirstPol).IsOut
+ (IntPatch_PolyhedronTool::Bounding(SeconPol))) {
+ Tolerance=IntPatch_PolyhedronTool::DeflectionOverEstimation(FirstPol)+
+ IntPatch_PolyhedronTool::DeflectionOverEstimation(SeconPol);
+ if (Tolerance==0.)
+ Tolerance=Epsilon(1000.);
+ Interference(FirstPol, SeconPol);
+ }
+}
+
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+
+void IntPatch_InterferencePolyhedron::Perform
+ (const IntPatch_Polyhedron& Objet)
+{
+ SelfInterference(Standard_True);
+ Tolerance=IntPatch_PolyhedronTool::DeflectionOverEstimation(Objet)*2;
+ if (Tolerance==0.)
+ Tolerance=Epsilon(1000.);
+ Interference(Objet);
+}
+
+
+//=======================================================================
+//function : Interference
+//purpose :
+//=======================================================================
+
+void IntPatch_InterferencePolyhedron::Interference
+ (const IntPatch_Polyhedron&)
+{}
+
+void IntPatch_InterferencePolyhedron::Interference
+ (const IntPatch_Polyhedron& FirstPol, const IntPatch_Polyhedron& SeconPol)
+{
+ Standard_Boolean gridOnFirst=Standard_True;
+ Standard_Integer NbTrianglesFirstPol = IntPatch_PolyhedronTool::NbTriangles(FirstPol);
+ Standard_Integer NbTrianglesSecondPol = IntPatch_PolyhedronTool::NbTriangles(SeconPol);
+ Standard_Integer iFirst, iSecon;
+
+ //------------------------------------------------------------------------------------------
+ //-- the same number of triangles it is necessary to test better on
+ //-- the size of boxes.
+ //--
+ //-- the second is chosen if nbTri1 > 2*nbTri2 or if VolBoit1 > 2*VolBoit2
+ //--
+ //--if (!SelfIntf && NbTrianglesFirstPol>NbTrianglesSecondPol)
+ //-- gridOnFirst=Standard_False;
+
+ if(!SelfIntf) {
+ if(NbTrianglesFirstPol > NbTrianglesSecondPol+NbTrianglesSecondPol) gridOnFirst=Standard_False;
+
+ Standard_Real vol1,vol2,Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
+ IntPatch_PolyhedronTool::Bounding(FirstPol).Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+ vol1 = (Xmax-Xmin)*(Ymax-Ymin)*(Zmax-Zmin);
+
+ IntPatch_PolyhedronTool::Bounding(SeconPol).Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+ vol2 = (Xmax-Xmin)*(Ymax-Ymin)*(Zmax-Zmin);
+
+ if(vol1> 8.0*vol2) gridOnFirst=Standard_False;
+ }
+
+
+ if (gridOnFirst) {
+ Bnd_BoundSortBox TheGridFirst;
+ TheGridFirst.Initialize(IntPatch_PolyhedronTool::Bounding(FirstPol),
+ IntPatch_PolyhedronTool::ComponentsBounding(FirstPol));
+
+ for (iSecon=1; iSecon<=NbTrianglesSecondPol; iSecon++) {
+
+ TColStd_ListIteratorOfListOfInteger iLoI(TheGridFirst.Compare
+ (IntPatch_PolyhedronTool::ComponentsBounding(SeconPol)->Value(iSecon)));
+ while (iLoI.More()) {
+ iFirst=iLoI.Value();
+ if (SelfIntf) {
+ if (iFirst<iSecon)
+ Intersect(iFirst, FirstPol, iSecon, SeconPol);
+ }
+ else
+ Intersect(iFirst, FirstPol, iSecon, SeconPol);
+ iLoI.Next();
+ }
+ }
+ }
+
+ else {
+ Bnd_BoundSortBox TheGridSecond;
+ TheGridSecond.Initialize(IntPatch_PolyhedronTool::Bounding(SeconPol),
+ IntPatch_PolyhedronTool::ComponentsBounding(SeconPol));
+
+ for (iFirst=1; iFirst<=NbTrianglesFirstPol; iFirst++) {
+ TColStd_ListIteratorOfListOfInteger
+ iLoI(TheGridSecond.Compare
+ (IntPatch_PolyhedronTool::ComponentsBounding(FirstPol)->Value(iFirst)));
+
+ while (iLoI.More()) {
+ iSecon=iLoI.Value();
+ if (SelfIntf) {
+ if (iFirst<iSecon)
+ Intersect(iFirst, FirstPol, iSecon, SeconPol);
+ }
+ else
+ Intersect(iFirst, FirstPol, iSecon, SeconPol);
+ iLoI.Next();
+ }
+ }
+ }
+}
+
+
+//=======================================================================
+//function : Intersect
+//purpose : Intersection of two triangles issue from two Polyhedron.
+//=======================================================================
+
+void IntPatch_InterferencePolyhedron::Intersect
+(const Standard_Integer Tri1, const IntPatch_Polyhedron& FirstPol,
+ const Standard_Integer Tri2, const IntPatch_Polyhedron& SeconPol)
+{
+ IntPatch_PolyhedronTool::Triangle(FirstPol, Tri1,OI[0],OI[1],OI[2]);
+ IntPatch_PolyhedronTool::Triangle(SeconPol, Tri2,TI[0],TI[1],TI[2]);
+
+ // If there is an intersection of a polyhedron with itself, the
+ // intersections are excluded
+ // from a triangle with connected triangles :
+
+ if (SelfIntf) {
+ if (OI[0]==TI[0] || OI[0]==TI[1] || OI[0]==TI[2] ||
+ OI[1]==TI[0] || OI[1]==TI[1] || OI[1]==TI[2] ||
+ OI[2]==TI[0] || OI[2]==TI[1] || OI[2]==TI[2] ) return;
+ }
+
+ // The precision of intersections includes two values ;
+
+ // - Tolerance :This value allows detecting potential
+ // intersections in all cases. The value should be the
+ // sum of upper bounds of tops pof two polyhedrons.
+
+ // - floatGap : This value is the actual precision of calculation
+ // of line of section.Its value is very small, it
+ // allows having the same behaviour for
+ // geometry tests as for the values used.
+
+ Standard_Real floatGap=1e-13 ; //-- Epsilon(1000.);
+
+
+ // Equation of the triangle plane of the objet
+ gp_XYZ ONor; // Normal vector.
+ Standard_Real Odp; // Polar Distance.
+ Intf::PlaneEquation(IntPatch_PolyhedronTool::Point(FirstPol, OI[0]),
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[1]),
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[2]),
+ ONor, Odp);
+
+
+// Equation of the triangle plane of the tool
+ gp_XYZ TNor; // Normal vector.
+ Standard_Real Tdp; // Polar distance.
+ Intf::PlaneEquation(IntPatch_PolyhedronTool::Point(SeconPol, TI[0]),
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[1]),
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[2]),
+ TNor, Tdp);
+
+
+// Scalar product of two normalized vectors -> cosinus of the angle
+ Incidence= Abs(TNor*ONor);
+
+// Distance of the plane of the triangle from the object by three points of SeconPol
+ Standard_Real dfOpT[3];
+ dfOpT[0]=ONor*(IntPatch_PolyhedronTool::Point(SeconPol, TI[0]).XYZ())-Odp;
+ dfOpT[1]=ONor*(IntPatch_PolyhedronTool::Point(SeconPol, TI[1]).XYZ())-Odp;
+ dfOpT[2]=ONor*(IntPatch_PolyhedronTool::Point(SeconPol, TI[2]).XYZ())-Odp;
+
+// Distance of the plane of the triangle from the tool by three points of FirstPol
+ Standard_Real dpOfT[3];
+ dpOfT[0]=TNor*(IntPatch_PolyhedronTool::Point(FirstPol, OI[0]).XYZ())-Tdp;
+ dpOfT[1]=TNor*(IntPatch_PolyhedronTool::Point(FirstPol, OI[1]).XYZ())-Tdp;
+ dpOfT[2]=TNor*(IntPatch_PolyhedronTool::Point(FirstPol, OI[2]).XYZ())-Tdp;
+
+// Values defining the couple of triangle dpOpT, dpOeT, deOpT
+ CoupleCharacteristics(FirstPol, SeconPol);
+
+// If three points of the triangle of <SeconPol> are in the plane of the
+// triangle of <Obje> within <Tolerance> the eventual tangency zone is found.
+
+ Intf_TangentZone TheTZ;
+ if ((Abs(dfOpT[0])<=Tolerance &&
+ Abs(dfOpT[1])<=Tolerance &&
+ Abs(dfOpT[2])<=Tolerance) &&
+ (Abs(dpOfT[0])<=Tolerance &&
+ Abs(dpOfT[1])<=Tolerance &&
+ Abs(dpOfT[2])<=Tolerance) &&
+ (Abs(dfOpT[0]+dfOpT[1]+dfOpT[2])!=
+ Abs(dfOpT[0])+Abs(dfOpT[1])+Abs(dfOpT[2])) &&
+ (Abs(dpOfT[0]+dpOfT[1]+dpOfT[2])!=
+ Abs(dpOfT[0])+Abs(dpOfT[1])+Abs(dpOfT[2]))){
+
+ if (TangentZoneValue(TheTZ, FirstPol, Tri1, SeconPol, Tri2))
+ {
+ if (!Insert(TheTZ)) myTZones.Append(TheTZ);
+ }
+ }
+
+// Otherwise line of section is calculated:
+ else {
+ Standard_Integer iObj, iToo;
+
+ // Zone de stockage des resultats :
+ Standard_Integer nbpiOT=0;
+ Standard_Integer nbpiO=0;
+ Standard_Integer nbpiT=0;
+ Intf_SeqOfSectionPoint piOT;
+ Standard_Real parO[3];
+ Standard_Real parT[3];
+
+ // Indicateurs d arete touchee
+ Standard_Integer edOT[3];
+ Standard_Integer edTT[3];
+
+ // Initializations
+ //--for (iObj=0; iObj<3; iObj++) {
+ // parO[iObj]=parT[iObj]=-1.;
+ // edOT[iObj]=edTT[iObj]=1;
+ //--}
+ parO[0]=parT[0]=parO[1]=parT[1]=parO[2]=parT[2]=-1.0;
+ edOT[0]=edTT[0]=edOT[1]=edTT[1]=edOT[2]=edTT[2]= 1;
+
+ // Singularite VERTEX VERTEX
+ //for (iObj=0; iObj<3; iObj++) {
+ // for (iToo=0; iToo<3; iToo++) {
+ // if (dpOpT[iObj][iToo] <= floatGap) {
+ // piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]),
+ // Intf_VERTEX, OI[iObj], 0, 0.,
+ // Intf_VERTEX, TI[iToo], 0, 0.,
+ // Incidence));
+ // parO[iObj]=0.;
+ // parT[iToo]=0.;
+ // edOT[Pourcent3[iObj+2]]=0; edOT[iObj]=0;
+ // edTT[Pourcent3[iToo+2]]=0; edTT[iToo]=0;
+ // nbpiOT++; nbpiO++; nbpiT++;
+ // }
+ // }
+ //}
+ //---------------------------->
+ for (iObj=0; iObj<3; iObj++) {
+ for (iToo=0; iToo<3; iToo++) {
+ if (dpOpT[iObj][iToo] <= floatGap) {
+ piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]),
+ Intf_VERTEX, OI[iObj], 0, 0.,
+ Intf_VERTEX, TI[iToo], 0, 0.,
+ Incidence));
+ parO[iObj]=parT[iToo]=0.0;
+ edOT[Pourcent3[iObj+2]]=edOT[iObj]=edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
+ nbpiOT++; nbpiO++; nbpiT++;
+ }
+ }
+ }
+
+
+ // Singularite VERTEX EDGE
+ Standard_Integer inext, jnext;
+ for (iObj=0; iObj<3; iObj++) {
+ if (parO[iObj]==-1.) {
+ for (iToo=0; iToo<3; iToo++) {
+ inext=Pourcent3[iToo+1];
+ if (edTT[iToo]==1) {
+ if (dpOeT[iObj][iToo] <= floatGap && dpOeT[iObj][iToo]>=-floatGap ) {
+ if ((dpOpT[iObj][iToo]+dpOpT[iObj][inext])<vtt[iToo].Modulus()) {
+ parT[iToo]=dpOpT[iObj][iToo]/(dpOpT[iObj][iToo]+
+ dpOpT[iObj][inext]);
+ if (TI[iToo]>TI[inext]) parT[iToo]=1.-parT[iToo];
+ piOT.Append(Intf_SectionPoint
+ (IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]),
+ Intf_VERTEX, OI[iObj], 0, 0.,
+ Intf_EDGE, Min(TI[iToo],TI[inext]),
+ Max(TI[iToo],TI[inext]), parT[iToo],
+ Incidence));
+ parO[iObj]=0.;
+ edOT[Pourcent3[iObj+2]]=0; edOT[iObj]=0;
+ edTT[iToo]=0;
+ nbpiOT++; nbpiO++; nbpiT++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Singularite EDGE VERTEX
+ for (iToo=0; iToo<3; iToo++) {
+ if (parT[iToo]==-1.) {
+ for (iObj=0; iObj<3; iObj++) {
+ inext=Pourcent3[iObj+1];
+ if (edOT[iObj]==1) {
+ if (Abs(deOpT[iObj][iToo]) <= floatGap) {
+ if ((dpOpT[iObj][iToo]+dpOpT[inext][iToo])<voo[iObj].Modulus()){
+ parO[iObj]=dpOpT[iObj][iToo]/(dpOpT[iObj][iToo]+
+ dpOpT[inext][iToo]);
+ if (OI[iObj]>OI[inext]) parO[iObj]=1.-parO[iObj];
+ piOT.Append(Intf_SectionPoint
+ (IntPatch_PolyhedronTool::Point(SeconPol, TI[iToo]),
+ Intf_EDGE, Min(OI[iObj],OI[inext]),
+ Max(OI[iObj],OI[inext]), parO[iObj],
+ Intf_VERTEX, TI[iToo], 0, 0.,
+ Incidence));
+ parT[iToo]=0.;
+ edOT[iObj]=edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
+ nbpiOT++; nbpiO++; nbpiT++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Singularite FACE VERTEX
+ for (iToo=0; iToo<3; iToo++) {
+ if (parT[iToo]!=0.) {
+ if (Abs(dfOpT[iToo]) <= floatGap) {
+ piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(SeconPol, TI[iToo]),
+ Intf_FACE, Tri1, 0, 0.,
+ Intf_VERTEX, TI[iToo], 0, 0.,
+ Incidence));
+ parT[iToo]=0.;
+ edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
+ nbpiOT++; nbpiT++;
+ }
+ }
+ }
+
+ // Singularite VERTEX FACE
+ for (iObj=0; iObj<3; iObj++) {
+ if (parO[iObj]!=0.) {
+ if (Abs(dpOfT[iObj]) <= floatGap) {
+ piOT.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]),
+ Intf_VERTEX, OI[iObj], 0, 0.,
+ Intf_FACE, Tri2, 0, 0.,
+ Incidence));
+ parO[iObj]=0.;
+ edOT[Pourcent3[iObj+2]]=edOT[iObj]=0;
+ nbpiOT++; nbpiO++;
+ }
+ }
+ }
+
+ // Singularite EDGE EDGE
+ gp_Pnt piO;
+ gp_XYZ piT;
+ Standard_Real lg;
+ for (iObj=0; iObj<3; iObj++) {
+ inext=Pourcent3[iObj+1];
+ if (edOT[iObj]==1 && (dpOfT[iObj]*dpOfT[inext])<0.) {
+ lg=dpOfT[iObj]/(dpOfT[iObj]-dpOfT[inext]);
+ if (lg>0. && lg<1.) {
+ for (iToo=0; iToo<3; iToo++) {
+ jnext=Pourcent3[iToo+1];
+ if (edTT[iToo]==1 && (dfOpT[iToo]*dfOpT[jnext])<0.) {
+ lg=dfOpT[iToo]/(dfOpT[iToo]-dfOpT[jnext]);
+ if (lg>0. && lg<1.) {
+ Standard_Boolean Pb=Standard_False;
+ if (OI[iObj]>OI[inext]) {
+ Standard_Real div=(dpOeT[inext][iToo]-dpOeT[iObj][iToo]);
+ if(div>floatGap || div<-floatGap) {
+ parO[iObj]=dpOeT[inext][iToo]/div;
+ piO=(IntPatch_PolyhedronTool::Point(FirstPol,OI[inext]).XYZ()) +
+ (voo[iObj].Reversed()*parO[iObj]);
+ }
+ else
+ Pb=Standard_True;
+ }
+ else {
+ Standard_Real div = dpOeT[iObj][iToo]-dpOeT[inext][iToo];
+ if(div>floatGap || div<-floatGap) {
+ parO[iObj]=dpOeT[iObj][iToo]/
+ (dpOeT[iObj][iToo]-dpOeT[inext][iToo]);;
+ piO=(IntPatch_PolyhedronTool::Point(FirstPol,OI[iObj]).XYZ()) +
+ (voo[iObj]*parO[iObj]);
+ }
+ else
+ Pb=Standard_True;
+ }
+ if (TI[iToo]>TI[jnext]) {
+ Standard_Real div=(deOpT[iObj][jnext]-deOpT[iObj][iToo]);
+ if(div>floatGap || div<-floatGap) {
+ parT[iToo]=deOpT[iObj][jnext]/div;
+ piT=(IntPatch_PolyhedronTool::Point(SeconPol,TI[jnext]).XYZ()) +
+ (vtt[iToo].Reversed()*parT[iToo]);
+ }
+ else
+ Pb=Standard_True;
+ }
+ else {
+ Standard_Real div=(deOpT[iObj][iToo]-deOpT[iObj][jnext]);
+ if(div>floatGap || div<-floatGap) {
+ parT[iToo]=deOpT[iObj][iToo]/div;
+ piT=(IntPatch_PolyhedronTool::Point(SeconPol,TI[iToo]).XYZ()) +
+ (vtt[iToo]*parT[iToo]);
+ }
+ else
+ Pb=Standard_True;
+ }
+ if(Pb==Standard_False) {
+ piT-=piO.XYZ();
+ lg=piT.Modulus();
+ if (lg <= floatGap){
+ piOT.Append(Intf_SectionPoint
+ (piO,
+ Intf_EDGE, Min(OI[iObj],OI[inext]),
+ Max(OI[iObj],OI[inext]), parO[iObj],
+ Intf_EDGE, Min(TI[iToo],TI[jnext]),
+ Max(TI[iToo],TI[jnext]), parT[iToo],
+ Incidence));
+ edOT[iObj]=edTT[iToo]=0;
+ nbpiOT++; nbpiO++; nbpiT++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Intersection EDGE FACE
+ for (iObj=0; iObj<3; iObj++) {
+ inext=Pourcent3[iObj+1];
+ if (edOT[iObj]==1 && (dpOfT[iObj]*dpOfT[inext])<0.) {
+ lg=dpOfT[iObj]/(dpOfT[iObj]-dpOfT[inext]);
+ if (lg>0. && lg<1.) {
+ parO[iObj]=lg;
+ piO=(IntPatch_PolyhedronTool::Point(FirstPol, OI[iObj]).XYZ())+
+ (voo[iObj]*parO[iObj]);
+ if (OI[iObj]>OI[inext]) parO[iObj]=1.-parO[iObj];
+ piOT.Append(
+ Intf_SectionPoint (piO,
+ Intf_EDGE, Min(OI[iObj],OI[inext]),
+ Max(OI[iObj],OI[inext]), parO[iObj],
+ Intf_FACE, Tri2, 0, 0., Incidence));
+ nbpiOT++; nbpiO++;
+ }
+ }
+ }
+
+ // Intersection FACE EDGE
+ for (iToo=0; iToo<3; iToo++) {
+ jnext=Pourcent3[iToo+1];
+ if (edTT[iToo]==1 && (dfOpT[iToo]*dfOpT[jnext])<0.) {
+ lg=dfOpT[iToo]/(dfOpT[iToo]-dfOpT[jnext]);
+ if (lg>0. && lg<1.) {
+ parT[iToo]=lg;
+ piO=(IntPatch_PolyhedronTool::Point(SeconPol, TI[iToo]).XYZ())+
+ (vtt[iToo]*parT[iToo]);
+ if (TI[iToo]>TI[jnext]) parT[iToo]=1.-parT[iToo];
+ piOT.Append(Intf_SectionPoint
+ (piO,
+ Intf_FACE, Tri1, 0, 0.,
+ Intf_EDGE, Min(TI[iToo],TI[jnext]),
+ Max(TI[iToo],TI[jnext]), parT[iToo],
+ Incidence));
+ nbpiOT++; nbpiT++;
+ }
+ }
+ }
+
+
+ Standard_Integer id[4];
+ Standard_Integer ideb=-1;
+ Standard_Integer ifin=-2;
+
+ if (nbpiOT>1) {
+
+// Sort the <nbpiOT> sections points along the intersection beetween the
+// two triangles :
+
+ gp_XYZ dir=ONor^TNor;
+ Standard_Real d[4];
+ Standard_Integer iPi, iPs;
+ for (iPi=0; iPi<nbpiOT; iPi++) {
+ d[iPi]=dir*piOT(iPi+1).Pnt().XYZ();
+ }
+
+ Standard_Integer di;
+ id[0]=0;
+ for (iPi=1; iPi<nbpiOT; iPi++) {
+ id[iPi]=iPi;
+ for (iPs=iPi-1; iPs>=0; iPs--) {
+ if (d[id[iPs]] > d[id[iPs+1]]) {
+ di=id[iPs+1];
+ id[iPs+1]=id[iPs];
+ id[iPs]=di;
+ }
+ else break;
+ }
+ }
+ }
+
+// Possibility of line of section :
+
+ if (nbpiO==2 && nbpiT==2) {
+
+ // In the case when an edge is in the plane of the other triangle
+ // it is necessary to check if it has not been already processed
+ // on a connected triangle :
+
+ // Pour l objet :
+ Standard_Integer pivo=-1;
+ Standard_Integer pedg=-1;
+ if (parO[0]==0.) {
+ pivo=0;
+ if (parO[1]==0.) pedg=1;
+ else if (parO[2]==0.) pedg=2;
+ }
+ else if (parO[1]==0.) {
+ pivo=1;
+ if (parO[2]==0.) pedg=2;
+ }
+ if (pivo>=0 && pedg>=0) {
+ IntPatch_PolyhedronTool::TriConnex(FirstPol, Tri1,OI[pivo],OI[pedg],pivo,pedg);
+ if (pivo > Tri1) {
+ nbpiOT=0;
+ ideb=-1; // On a deja trouve celle ci
+ ifin=-2;
+ }
+ }
+
+ // For the tool :
+ pivo=-1;
+ pedg=-1;
+ if (parT[0]==0.) {
+ pivo=0;
+ if (parT[1]==0.) pedg=1;
+ else if (parT[2]==0.) pedg=2;
+ }
+ else if (parT[1]==0.) {
+ pivo=1;
+ if (parT[2]==0.) pedg=2;
+ }
+ if (pivo>=0 && pedg>=0) {
+ IntPatch_PolyhedronTool::TriConnex(SeconPol, Tri2,TI[pivo],TI[pedg],pivo,pedg);
+ if (pivo > Tri2) {
+ nbpiOT=0;
+ ideb=-1; // It has been already found
+ ifin=-2;
+ }
+ }
+
+ if (nbpiOT>0) {
+
+// If there is a covering up : insert the section line in the existent
+// list or create a new section line :
+
+ if (piOT(id[0]+1).TypeOnFirst()==Intf_FACE) {
+ if (piOT(id[1]+1).TypeOnFirst()==Intf_FACE) {
+ ideb=-id[0]-1; // No line of section possible
+ ifin=-id[1]-1; //
+ }
+ else if (piOT(id[1]+1).TypeOnSecond()!=Intf_FACE) {
+ ideb=id[1]; // No line of section possible
+ ifin=id[1]; // only a pointersec
+ }
+ else if (nbpiOT>=3) {
+ ideb=id[1]; // Retrieve 2 segments of section
+ ifin=id[2]; //
+ }
+ else {
+ ideb=-999; // No line of section possible
+ ifin=-999;
+ }
+ }
+ else if (piOT(id[0]+1).TypeOnSecond()==Intf_FACE) {
+ if (piOT(id[1]+1).TypeOnSecond()==Intf_FACE) {
+ ideb=-id[0]-1; // No line of section possible
+ ifin=-id[1]-1; //
+ }
+ else if (piOT(id[1]+1).TypeOnFirst()!=Intf_FACE) {
+ ideb=id[1]; // No line of section possible
+ ifin=id[1]; // only a pointersec
+ }
+ else if (nbpiOT>=3) {
+ ideb=id[1]; // Recouvrement des 2 segments de section
+ ifin=id[2]; //
+ }
+ else {
+ ideb=-999; // No line of section possible
+ ifin=-999;
+ }
+ }
+
+ else { // Singularity on the first point there is only two or
+ ideb=id[0]; // three pointersec, so the first is a solution
+ ifin=id[1]; // and the second too.
+ }
+ }
+
+
+// Insertion of the segment found in the existing section lines :
+
+ if(ideb<0) {
+ if(ifin<0) {
+ if(ideb!=-999) {
+ //static unsigned nisp=0;
+ Standard_Real d=piOT(-ideb).Pnt().Distance(piOT(-ifin).Pnt());
+ if(d<Tolerance) {
+ Insert(piOT(-ideb), piOT(-ifin));
+ //-- cout<<"Insertion Point IntPatch_InterferencePolyhedron 1,2 d="<<d<<" Tol="<<Tolerance<<" num:"<<++nisp<<endl;
+ //-- piOT(-ideb).Dump(1); piOT(-ifin).Dump(0);
+ //-- cout<<"point p"<<++nisp<<" "<<piOT(-ideb).Pnt().X()<<" "<<piOT(-ideb).Pnt().Y()<<" "<<piOT(-ideb).Pnt().Z()<<endl;
+ }
+ else {
+ //-- cout<<"Insertion Point IntPatch_InterferencePolyhedron 1,2 d="<<d<<" Tol="<<Tolerance<<" NON INSERE "<<endl;
+ }
+ }
+ }
+ }
+ else if (ideb>=0) {
+ if (ideb!=ifin) {
+ Insert(piOT(ideb+1), piOT(ifin+1));
+
+ // else
+ // un pointersec : It is necessary to check if it has not been already found
+ // and if not insert it in the list.
+ // Attention! It is necessary to check
+ // for each new segment if a point is in the list
+ // and in this case remove it from the list.
+ }
+ }
+ }
+ }
+}
+
+
+//=======================================================================
+//function : TangentZoneValue
+//purpose :
+//=======================================================================
+
+Standard_Boolean IntPatch_InterferencePolyhedron::TangentZoneValue
+ (Intf_TangentZone& TheTZ,
+ const IntPatch_Polyhedron& FirstPol,
+ const Standard_Integer Tri1,
+ const IntPatch_Polyhedron& SeconPol,
+ const Standard_Integer Tri2) const
+{
+ // Potential tangent Zone !
+ // ------------------------
+
+ Standard_Boolean finished=Standard_False;
+ Standard_Integer nob, nou, nob2, nou2;
+ Standard_Real par;
+
+ Intf_PIType tOP[3];
+ Intf_PIType tTP[3];
+ for (nou=0; nou<3; nou++) {
+ tOP[nou]= Intf_EXTERNAL;
+ tTP[nou]= Intf_EXTERNAL;
+ }
+
+ Standard_Integer nbpInt=0;
+ Intf_SeqOfSectionPoint Tpi;
+
+ // Compute the positions of the points of <Tri1> in the triangle <Tri2>.
+ for (nob=0; nob<=2; nob++) {
+ nob2=Pourcent3[nob+1];
+ for (nou=0; nou<=2; nou++) {
+ nou2=Pourcent3[nou+1];
+ if (dpOpT[nob][nou]<=Tolerance) {
+ Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[nob]),
+ Intf_VERTEX, OI[nob], 0, 0.,
+ Intf_VERTEX, TI[nou], 0, 0.,
+ 1.));
+ tOP[nob]=Intf_VERTEX;
+ tTP[nou]=Intf_VERTEX;
+ nbpInt++;
+ break;
+ }
+ else if (Abs(dpOeT[nob][nou])<=Tolerance) {
+ if (dpOpT[nob][nou]+dpOpT[nob][nou2]<vtt[nou].Modulus()) {
+ par=dpOpT[nob][nou]/(dpOpT[nob][nou]+dpOpT[nob][nou2]);
+ if (TI[nou]>TI[nou2]) par=1.-par;
+ Tpi.Append(Intf_SectionPoint (IntPatch_PolyhedronTool::Point(FirstPol, OI[nob]),
+ Intf_VERTEX, OI[nob], 0, 0.,
+ Intf_EDGE, Min(TI[nou], TI[nou2]),
+ Max(TI[nou], TI[nou2]), par,
+ 1.));
+ tOP[nob]=Intf_EDGE;
+ nbpInt++;
+ break;
+ }
+ }
+ }
+ if (tOP[nob]==Intf_EXTERNAL) {
+ if (Intf::Contain(IntPatch_PolyhedronTool::Point(SeconPol, TI[0]),
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[1]),
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[2]),
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[nob]))) {
+ Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(FirstPol, OI[nob]),
+ Intf_VERTEX, OI[nob], 0, 0.,
+ Intf_FACE, Tri2, 0, 0.,
+ 1.));
+ tOP[nob]=Intf_FACE;
+ nbpInt++;
+ }
+ }
+ }
+
+ // If the three points of <Tri1> are in <Tri2> the triangle Tri1 is
+ // itself the tangent zone else compute the positions of the points
+ // of <Tri2> in <Tri1>.
+ if (nbpInt < 3) {
+ for (nou=0; nou<=2; nou++) {
+ nou2=Pourcent3[nou+1];
+ if (tTP[nou]==Intf_EXTERNAL) {
+ for (nob=0; nob<=2; nob++) {
+ nob2=Pourcent3[nob+1];
+ if (Abs(deOpT[nob][nou])<=Tolerance) {
+ if (dpOpT[nob][nou]+dpOpT[nob2][nou]<voo[nob].Modulus()) {
+ par=dpOpT[nob][nou]/(dpOpT[nob][nou]+dpOpT[nob2][nou]);
+ if (OI[nob]>OI[nob2]) par=1.-par;
+ Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(SeconPol,TI[nou]),
+ Intf_EDGE, Min(OI[nob], OI[nob2]),
+ Max(OI[nob], OI[nob2]), par,
+ Intf_VERTEX, TI[nou], 0, 0., 1.));
+ tTP[nou]=Intf_EDGE;
+ nbpInt++;
+ break;
+ }
+ }
+ }
+ if (tTP[nou]==Intf_EXTERNAL) {
+ if (Intf::Contain(IntPatch_PolyhedronTool::Point(FirstPol, OI[0]),
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[1]),
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[2]),
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[nou]))) {
+ Tpi.Append(Intf_SectionPoint(IntPatch_PolyhedronTool::Point(SeconPol, TI[nou]),
+ Intf_FACE, Tri1, 0, 0.,
+ Intf_VERTEX, TI[nou], 0, 0.,
+ 1.));
+ tTP[nou]=Intf_FACE;
+ nbpInt++;
+ }
+ }
+ }
+ }
+ if (tTP[0]!=Intf_EXTERNAL &&
+ tTP[1]!=Intf_EXTERNAL &&
+ tTP[2]!=Intf_EXTERNAL)
+ finished=Standard_True;
+ }
+ else
+ finished=Standard_True;
+
+ // Insertion of the points of intersection in the zone of tangency :
+ for (nob=1; nob<=nbpInt; nob++)
+ TheTZ.Append(Tpi(nob));
+
+ if (!finished) {
+ // If one of the triangles is not in the zone of tangency, it is necessary to find
+ // the points of intersection edge/edge :
+
+ Standard_Real parO[6], parT[6];
+ Standard_Integer nbNoInserted=0;
+ Standard_Integer piToInsert[6];
+
+ for (nob=0; nob<3; nob++) {
+ //processing of the object segment P[nob], P[nob+1]
+ nob2=Pourcent3[nob+1];
+
+ for (nou=0; nou<3; nou++) {
+ //processing of the segment of the tool P[nou], P[nou+1]
+ nou2=Pourcent3[nou+1];
+
+ if (dpOeT[nob][nou]*dpOeT[nob2][nou]<0. &&
+ deOpT[nob][nou]*deOpT[nob][nou2]<0.) {
+
+ if (nbpInt>=6) {
+ break;
+ }
+ else {
+ parO[nbpInt]=dpOeT[nob][nou]/(dpOeT[nob][nou]-dpOeT[nob2][nou]);
+ parT[nbpInt]=deOpT[nob][nou]/(deOpT[nob][nou]-deOpT[nob][nou2]);
+ gp_Pnt lepi=IntPatch_PolyhedronTool::Point(SeconPol, TI[nou]).Translated
+ (gp_Vec(vtt[nou]*parT[nbpInt]));
+ if (OI[nob]>OI[nob2]) parO[nbpInt]=1.-parO[nbpInt];
+ if (TI[nou]>TI[nou2]) parT[nbpInt]=1.-parT[nbpInt];
+ Tpi.Append(Intf_SectionPoint(lepi,
+ Intf_EDGE, Min(OI[nob],OI[nob2]),
+ Max(OI[nob],OI[nob2]), parO[nbpInt],
+ Intf_EDGE, Min(TI[nou],TI[nou2]),
+ Max(TI[nou],TI[nou2]), parT[nbpInt],
+ Incidence));
+ nbpInt++;
+ if (!TheTZ.Insert(Tpi(nbpInt))) {
+ piToInsert[nbNoInserted]=nbpInt;
+ nbNoInserted++;
+ }
+ }
+ }
+ }
+ if (nbpInt>=6) break; // Number of pi passed in TZ !
+ }
+ nob=nbNoInserted-1;
+ while (nob>=0) {
+ while (!TheTZ.Insert(Tpi(piToInsert[nob]))) {
+ nob--;
+ if (nob<0) break;
+ }
+ if (nob>=0) {
+ while (nob<nbNoInserted) {
+ piToInsert[nob]=piToInsert[nob+1];
+ nob++;
+ }
+ nbNoInserted--;
+ nob=nbNoInserted-1;
+ }
+ }
+ if (nbNoInserted>0) {
+ nob=nbNoInserted-1;
+ while (nob>=0) {
+ Tpi(piToInsert[nob--]).Dump(4);
+ }
+ }
+ }
+ if (nbpInt<3) nbpInt=0;
+ return nbpInt>0;
+}
+
+
+//=======================================================================
+//function : CoupleCharacteristics
+//purpose :
+//=======================================================================
+
+void IntPatch_InterferencePolyhedron::CoupleCharacteristics (const IntPatch_Polyhedron& FirstPol,
+ const IntPatch_Polyhedron& SeconPol)
+{
+ Standard_Integer n1, n2;
+ Standard_Real lg;
+
+ for (n1=0; n1<3; n1++) {
+ n2=Pourcent3[n1+1];
+ voo[n1]=IntPatch_PolyhedronTool::Point(FirstPol, OI[n2]).XYZ()-
+ IntPatch_PolyhedronTool::Point(FirstPol, OI[n1]).XYZ();
+ vtt[n1]=IntPatch_PolyhedronTool::Point(SeconPol, TI[n2]).XYZ()-
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[n1]).XYZ();
+ }
+
+ gp_XYZ vvec=(voo[0]^voo[1])+(voo[1]^voo[2])+(voo[2]^voo[0]);
+ gp_XYZ vnorT=(vtt[0]^vtt[1])+(vtt[1]^vtt[2])+(vtt[2]^vtt[0]);
+ if (vnorT.Modulus()>vvec.Modulus())
+ vvec=vnorT;
+
+ for (n1=0; n1<3; n1++) {
+
+ for (n2=0; n2<3; n2++) {
+
+ gp_XYZ vto=IntPatch_PolyhedronTool::Point(FirstPol, OI[n1]).XYZ()-
+ IntPatch_PolyhedronTool::Point(SeconPol, TI[n2]).XYZ();
+ dpOpT[n1][n2]=vto.Modulus();
+
+ lg=vtt[n2].Modulus();
+ if (lg > 1e-16) { //-- RealEpsilon()
+ gp_XYZ vv=vto^vtt[n2];
+ lg=(vvec*vv)>0.0 ? lg : -lg;
+ dpOeT[n1][n2]=vv.Modulus()/lg;
+ }
+ else
+ dpOeT[n1][n2]=dpOpT[n1][n2];
+
+ lg=voo[n1].Modulus();
+ if (lg > 1e-16) { //-- RealEpsilon())
+ gp_XYZ vv=vto^voo[n1];
+ lg=(vvec*vv)>0.0 ? -lg : lg;
+ deOpT[n1][n2]=vv.Modulus()/lg;
+ }
+ else
+ deOpT[n1][n2]=dpOpT[n1][n2];
+ }
+ }
+}
#include <IntPatch_PrmPrmIntersection.ixx>
-#include <IntPatch_TheInterfPolyhedron.hxx>
-#include <IntPatch_ThePWalkingInter.hxx>
+#include <IntPatch_InterferencePolyhedron.hxx>
+#include <IntWalk_PWalking.hxx>
#include <IntPatch_WLine.hxx>
#include <IntPatch_RstInt.hxx>
const Standard_Real Deflection,
const Standard_Real Increment)
{
- IntPatch_TheInterfPolyhedron Interference(Poly1,Poly2);
+ IntPatch_InterferencePolyhedron Interference(Poly1,Poly2);
empt = Standard_True;
done = Standard_True;
SLin.Clear();
TColStd_Array1OfReal StartParams(1,4);
- IntPatch_ThePWalkingInter PW( Surf1, Surf2, TolTangency, Epsilon, Deflection, Increment );
+ IntWalk_PWalking PW( Surf1, Surf2, TolTangency, Epsilon, Deflection, Increment );
Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
Standard_Real incidence;
const Standard_Real Deflection,
const Standard_Real Increment)
{
- IntPatch_TheInterfPolyhedron Interference(Poly1);
+ IntPatch_InterferencePolyhedron Interference(Poly1);
empt = Standard_True;
done = Standard_True;
SLin.Clear();
Standard_Real pu1,pu2,pv1,pv2;
TColStd_Array1OfReal StartParams(1,4);
- IntPatch_ThePWalkingInter PW(Surf1,Surf1,TolTangency,Epsilon,Deflection,Increment);
+ IntWalk_PWalking PW(Surf1,Surf1,TolTangency,Epsilon,Deflection,Increment);
Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
Standard_Real incidence;
V2(Low) = v2;
AC(Low) =0.0;
- IntPatch_ThePWalkingInter PW(Surf1,Surf2,0.000001,0.000001,0.001,0.001);
+ IntWalk_PWalking PW(Surf1,Surf2,0.000001,0.000001,0.001,0.001);
Standard_Integer i;
for(i=Low+1; i<=High; i++)
gp_Pnt Point3dDebut,Point3dFin;
TColStd_Array1OfReal StartParams(1,4);
- IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
+ IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts);
for(; IterLOP2.More(); IterLOP2.Next() ){
// nIncrement/=0.5*MaxOscill;
// }
- IntPatch_ThePWalkingInter PW(Surf1,Surf2,
+ IntWalk_PWalking PW(Surf1,Surf2,
TolTangency,
Epsilon,
Deflection,
gp_Pnt Point3dDebut,Point3dFin;
TColStd_Array1OfReal StartParams(1,4);
- IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
+ IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
if(nbLigSec>=1)
{
//if(MaxOscill>10)
//nIncrement/=0.5*MaxOscill;
- IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
+ IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
Standard_Real dminiPointLigne;
Standard_Boolean HasStartPoint,RejetLigne;
IntWalk_IWalking_4.gxx
IntWalk_IWalking_5.gxx
IntWalk_IWalking_6.gxx
-IntWalk_PWalking_1.gxx
-IntWalk_PWalking_2.gxx
-IntWalk_PWalking_3.gxx
-IntWalk_PWalking_4.gxx
IntWalk_VectorOfInteger.hxx
IntWalk_VectorOfWalkingData.hxx
-- All the methods of the classes of this package are Internal.
--
uses
- Standard, MMgt, TCollection, TColStd, gp, math, StdFail, IntSurf, IntImp
+ Standard, MMgt, TCollection, TColStd, gp, math, StdFail, IntSurf, IntImp, Adaptor3d
is
--algorithm/solution for a marching on intersection between
-- 2 biparametric surfaces
- generic class PWalking, TheInt2S;
+ class PWalking;
+
+ --internal of PWalking
+ class TheInt2S instantiates Int2S from IntImp
+ (HSurface from Adaptor3d, HSurfaceTool from Adaptor3d);
end IntWalk;
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-generic class PWalking from IntWalk (
- ThePSurface as any;
- ThePSurfaceTool as any)
-
+class PWalking from IntWalk
---Purpose: This class implements an algorithm to determine the
-- intersection between 2 parametrized surfaces, marching from
LineOn2S from IntSurf,
Dir from gp,
Dir2d from gp,
- Pnt from gp
+ Pnt from gp,
+ TheInt2S from IntWalk,
+ HSurface from Adaptor3d,
+ HSurfaceTool from Adaptor3d
raises OutOfRange from Standard,
NotDone from StdFail
- class TheInt2S instantiates Int2S from IntImp
- (ThePSurface, ThePSurfaceTool);
-
is
Create ( Caro1 ,
- Caro2 : ThePSurface ;
+ Caro2 : HSurface from Adaptor3d ;
TolTangency,
Epsilon,
Deflection,
Create ( Caro1 ,
- Caro2 : ThePSurface ;
+ Caro2 : HSurface from Adaptor3d ;
TolTangency,
Epsilon,
Deflection,
is private;
DistanceMinimizeByGradient( me : in out;
- theASurf1 , theASurf2 : ThePSurface ;
+ theASurf1 , theASurf2 : HSurface from Adaptor3d ;
theU1, theV1, theU2, theV2: out Real from Standard;
theStep0U1V1: Real from Standard = 1.0e-6;
theStep0U2V2: Real from Standard = 1.0e-6)
-- initial point.
DistanceMinimizeByExtrema(me : in out;
- theASurf1 : ThePSurface ;
+ theASurf1 : HSurface from Adaptor3d ;
theP0 : Pnt from gp;
theU0, theV0: out Real from Standard;
theStep0U: Real from Standard = 1.0;
-- initial point.
SeekPointOnBoundary(me : in out;
- theASurf1 , theASurf2 : ThePSurface ;
+ theASurf1 , theASurf2 : HSurface from Adaptor3d ;
theU1, theV1, theU2, theV2: Real from Standard;
isTheFirst : Boolean from Standard)
returns Boolean from Standard
PutToBoundary( me : in out;
- theASurf1 , theASurf2 : ThePSurface)
+ theASurf1 , theASurf2 : HSurface from Adaptor3d)
-- Tries to extend existing intersection line
-- (as set of points) to surface's boundaries,
-- if it is possibly.
SeekAdditionalPoints( me : in out;
- theASurf1 , theASurf2 : ThePSurface;
+ theASurf1 , theASurf2 : HSurface from Adaptor3d;
theMinNbPoints : Integer from Standard)
returns Boolean from Standard;
-- Unites and correctly coordinates of work of
firstd1 : Dir2d from gp;
firstd2 : Dir2d from gp;
- myIntersectionOn2S : TheInt2S ;
+ myIntersectionOn2S : TheInt2S from IntWalk;
STATIC_BLOCAGE_SUR_PAS_TROP_GRAND : Integer from Standard;
STATIC_PRECEDENT_INFLEXION : Integer from Standard;
end PWalking;
--- /dev/null
+// Copyright (c) 1995-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 <IntWalk_PWalking.ixx>
+
+#include <IntWalk_StatusDeflection.hxx>
+
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColStd_Array1OfReal.hxx>
+
+#include <IntImp_ComputeTangence.hxx>
+
+#include <Adaptor3d_HSurface.hxx>
+#include <Adaptor3d_HSurfaceTool.hxx>
+
+#include <Precision.hxx>
+
+#include <math_FunctionSetRoot.hxx>
+#include <Geom_Surface.hxx>
+
+#include <Standard_Failure.hxx>
+#include <gp_Pnt2d.hxx>
+
+//==================================================================================
+// function : IntWalk_PWalking::IntWalk_PWalking
+// purpose :
+// estimate of max step : To avoid abrupt changes
+// during change of isos
+//==================================================================================
+void ComputePasInit(Standard_Real *pasuv,
+ Standard_Real Um1,Standard_Real UM1,
+ Standard_Real Vm1,Standard_Real VM1,
+ Standard_Real Um2,Standard_Real UM2,
+ Standard_Real Vm2,Standard_Real VM2,
+ Standard_Real _Um1,Standard_Real _UM1,
+ Standard_Real _Vm1,Standard_Real _VM1,
+ Standard_Real _Um2,Standard_Real _UM2,
+ Standard_Real _Vm2,Standard_Real _VM2,
+ const Handle(Adaptor3d_HSurface)& ,
+ const Handle(Adaptor3d_HSurface)& ,
+ const Standard_Real Increment)
+{
+ Standard_Real du1=Abs(UM1-Um1);
+ Standard_Real dv1=Abs(VM1-Vm1);
+ Standard_Real du2=Abs(UM2-Um2);
+ Standard_Real dv2=Abs(VM2-Vm2);
+
+ Standard_Real _du1=Abs(_UM1-_Um1);
+ Standard_Real _dv1=Abs(_VM1-_Vm1);
+ Standard_Real _du2=Abs(_UM2-_Um2);
+ Standard_Real _dv2=Abs(_VM2-_Vm2);
+
+ //-- limit the reduction of uv box estimate to 0.01 natural box
+ //-- du1 : On box of Inter
+ //-- _du1 : On parametric space
+ if(_du1<1e50 && du1<0.01*_du1) du1=0.01*_du1;
+ if(_dv1<1e50 && dv1<0.01*_dv1) dv1=0.01*_dv1;
+ if(_du2<1e50 && du2<0.01*_du2) du2=0.01*_du2;
+ if(_dv2<1e50 && dv2<0.01*_dv2) dv2=0.01*_dv2;
+
+ pasuv[0]=Increment*du1;
+ pasuv[1]=Increment*dv1;
+ pasuv[2]=Increment*du2;
+ pasuv[3]=Increment*dv2;
+}
+
+//=======================================================================
+//function : IsParallel
+//purpose : Checks if theLine is parallel of some boundary of given
+// surface (it is determined by theCheckSurf1 flag).
+// Parallelism assumes small oscillations (swing is less or
+// equal than theToler).
+// Small lines (if first and last parameters in the Surface
+// are almost equal) are classified as parallel (as same as
+// any point can be considered as parallel of any line).
+//=======================================================================
+static void IsParallel(const Handle(IntSurf_LineOn2S)& theLine,
+ const Standard_Boolean theCheckSurf1,
+ const Standard_Real theToler,
+ Standard_Boolean& theIsUparallel,
+ Standard_Boolean& theIsVparallel)
+{
+ const Standard_Integer aNbPointsMAX = 23;
+
+ theIsUparallel = theIsVparallel = Standard_True;
+
+ Standard_Integer aNbPoints = theLine->NbPoints();
+ if(aNbPoints > aNbPointsMAX)
+ {
+ aNbPoints = aNbPointsMAX;
+ }
+ else if(aNbPoints < 3)
+ {
+ //Here we cannot estimate parallelism.
+ //Do all same as for small lines
+ return;
+ }
+
+ Standard_Real aStep = IntToReal(theLine->NbPoints()) / aNbPoints;
+ Standard_Real aNPoint = 1.0;
+
+ Standard_Real aUmin = RealLast(), aUmax = RealFirst(), aVmin = RealLast(), aVmax = RealFirst();
+ for(Standard_Integer aNum = 1; aNum <= aNbPoints; aNum++, aNPoint += aStep)
+ {
+ if(aNPoint > aNbPoints)
+ {
+ aNPoint = aNbPoints;
+ }
+
+ Standard_Real u, v;
+ if(theCheckSurf1)
+ theLine->Value(RealToInt(aNPoint)).ParametersOnS1(u, v);
+ else
+ theLine->Value(RealToInt(aNPoint)).ParametersOnS2(u, v);
+
+ if(u < aUmin)
+ aUmin = u;
+
+ if(u > aUmax)
+ aUmax = u;
+
+ if(v < aVmin)
+ aVmin = v;
+
+ if(v > aVmax)
+ aVmax = v;
+ }
+
+ theIsVparallel = ((aUmax - aUmin) < theToler);
+ theIsUparallel = ((aVmax - aVmin) < theToler);
+}
+
+//=======================================================================
+//function : Checking
+//purpose : Check, if given point is in surface's boundaries.
+// If "yes" then theFactTol = 0.0, else theFactTol is
+// equal maximal deviation.
+//=======================================================================
+static Standard_Boolean Checking( const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ Standard_Real& theU1,
+ Standard_Real& theV1,
+ Standard_Real& theU2,
+ Standard_Real& theV2,
+ Standard_Real& theFactTol)
+{
+ const Standard_Real aTol = Precision::PConfusion();
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+ Standard_Boolean isOnOrIn = Standard_True;
+ theFactTol = 0.0;
+
+ Standard_Real aDelta = aU1bFirst - theU1;
+ if(aDelta > aTol)
+ {
+ theU1 = aU1bFirst;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = theU1 - aU1bLast;
+ if(aDelta > aTol)
+ {
+ theU1 = aU1bLast;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = aV1bFirst - theV1;
+ if(aDelta > aTol)
+ {
+ theV1 = aV1bFirst;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = theV1 - aV1bLast;
+ if(aDelta > aTol)
+ {
+ theV1 = aV1bLast;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = aU2bFirst - theU2;
+ if(aDelta > aTol)
+ {
+ theU2 = aU2bFirst;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = theU2 - aU2bLast;
+ if(aDelta > aTol)
+ {
+ theU2 = aU2bLast;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = aV2bFirst - theV2;
+ if(aDelta > aTol)
+ {
+ theV2 = aV2bFirst;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ aDelta = theV2 - aV2bLast;
+ if(aDelta > aTol)
+ {
+ theV2 = aV2bLast;
+ theFactTol = Max(theFactTol, aDelta);
+ isOnOrIn = Standard_False;
+ }
+
+ return isOnOrIn;
+}
+
+//==================================================================================
+// function : IntWalk_PWalking::IntWalk_PWalking
+// purpose :
+//==================================================================================
+IntWalk_PWalking::IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1,
+ const Handle(Adaptor3d_HSurface)& Caro2,
+ const Standard_Real TolTangency,
+ const Standard_Real Epsilon,
+ const Standard_Real Deflection,
+ const Standard_Real Increment )
+ :
+
+done(Standard_True),
+close(Standard_False),
+fleche(Deflection),
+tolconf(Epsilon),
+sensCheminement(1),
+myIntersectionOn2S(Caro1,Caro2,TolTangency),
+STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
+STATIC_PRECEDENT_INFLEXION(0)
+{
+ Standard_Real KELARG=20.;
+ //
+ pasMax=Increment*0.2; //-- June 25 99 after problems with precision
+ Um1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
+ Vm1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
+ UM1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
+ VM1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
+
+ Um2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
+ Vm2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
+ UM2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
+ VM2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
+
+ ResoU1 = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
+ ResoV1 = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
+
+ ResoU2 = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
+ ResoV2 = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
+
+ Standard_Real NEWRESO;
+ Standard_Real MAXVAL;
+ Standard_Real MAXVAL2;
+ //
+ MAXVAL = Abs(Um1); MAXVAL2 = Abs(UM1);
+ if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
+ NEWRESO = ResoU1 * MAXVAL ;
+ if(NEWRESO > ResoU1 &&NEWRESO<10) { ResoU1 = NEWRESO; }
+
+
+ MAXVAL = Abs(Um2); MAXVAL2 = Abs(UM2);
+ if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
+ NEWRESO = ResoU2 * MAXVAL ;
+ if(NEWRESO > ResoU2 && NEWRESO<10) { ResoU2 = NEWRESO; }
+
+
+ MAXVAL = Abs(Vm1); MAXVAL2 = Abs(VM1);
+ if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
+ NEWRESO = ResoV1 * MAXVAL ;
+ if(NEWRESO > ResoV1 && NEWRESO<10) { ResoV1 = NEWRESO; }
+
+
+ MAXVAL = Abs(Vm2); MAXVAL2 = Abs(VM2);
+ if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
+ NEWRESO = ResoV2 * MAXVAL ;
+ if(NEWRESO > ResoV2 && NEWRESO<10) { ResoV2 = NEWRESO; }
+
+ pasuv[0]=pasMax*Abs(UM1-Um1);
+ pasuv[1]=pasMax*Abs(VM1-Vm1);
+ pasuv[2]=pasMax*Abs(UM2-Um2);
+ pasuv[3]=pasMax*Abs(VM2-Vm2);
+
+ if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
+ if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
+ if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
+ if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
+
+
+ if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)==Standard_False) {
+ //UM1+=KELARG*pasuv[0]; Um1-=KELARG*pasuv[0];
+ }
+ else {
+ Standard_Real t = UM1-Um1;
+ if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro1)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro1)-t);
+ t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
+ UM1+=t; Um1-=t;
+ }
+ }
+
+ if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro1)==Standard_False) {
+ //VM1+=KELARG*pasuv[1]; Vm1-=KELARG*pasuv[1];
+ }
+ else {
+ Standard_Real t = VM1-Vm1;
+ if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro1)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro1)-t);
+ t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
+ VM1+=t; Vm1-=t;
+ }
+ }
+
+ if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro2)==Standard_False) {
+ //UM2+=KELARG*pasuv[2]; Um2-=KELARG*pasuv[2];
+ }
+ else {
+ Standard_Real t = UM2-Um2;
+ if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro2)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro2)-t);
+ t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
+ UM2+=t; Um2-=t;
+ }
+ }
+
+ if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {
+ //VM2+=KELARG*pasuv[3]; Vm2-=KELARG*pasuv[3];
+ }
+ else {
+ Standard_Real t = VM2-Vm2;
+ if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro2)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro2)-t);
+ t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
+ VM2+=t; Vm2-=t;
+ }
+ }
+
+ //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
+
+ for (Standard_Integer i = 0; i<=3;i++) {
+ if(pasuv[i]>10)
+ pasuv[i] = 10;
+ pasInit[i] = pasSav[i] = pasuv[i];
+ }
+
+
+}
+//==================================================================================
+// function : IntWalk_PWalking
+// purpose :
+//==================================================================================
+IntWalk_PWalking::IntWalk_PWalking(const Handle(Adaptor3d_HSurface)& Caro1,
+ const Handle(Adaptor3d_HSurface)& Caro2,
+ const Standard_Real TolTangency,
+ const Standard_Real Epsilon,
+ const Standard_Real Deflection,
+ const Standard_Real Increment,
+ const Standard_Real U1,
+ const Standard_Real V1,
+ const Standard_Real U2,
+ const Standard_Real V2)
+ :
+
+done(Standard_True),
+close(Standard_False),
+fleche(Deflection),
+tolconf(Epsilon),
+sensCheminement(1),
+myIntersectionOn2S(Caro1,Caro2,TolTangency),
+STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
+STATIC_PRECEDENT_INFLEXION(0)
+{
+ Standard_Real KELARG=20.;
+ //
+ pasMax=Increment*0.2; //-- June 25 99 after problems with precision
+ //
+ Um1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
+ Vm1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
+ UM1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1);
+ VM1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1);
+
+ Um2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
+ Vm2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
+ UM2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2);
+ VM2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2);
+
+ ResoU1 = Adaptor3d_HSurfaceTool::UResolution(Caro1,Precision::Confusion());
+ ResoV1 = Adaptor3d_HSurfaceTool::VResolution(Caro1,Precision::Confusion());
+
+ ResoU2 = Adaptor3d_HSurfaceTool::UResolution(Caro2,Precision::Confusion());
+ ResoV2 = Adaptor3d_HSurfaceTool::VResolution(Caro2,Precision::Confusion());
+ //
+ Standard_Real NEWRESO, MAXVAL, MAXVAL2;
+ //
+ MAXVAL = Abs(Um1);
+ MAXVAL2 = Abs(UM1);
+ if(MAXVAL2 > MAXVAL) {
+ MAXVAL = MAXVAL2;
+ }
+ NEWRESO = ResoU1 * MAXVAL ;
+ if(NEWRESO > ResoU1) {
+ ResoU1 = NEWRESO;
+ }
+ //
+ MAXVAL = Abs(Um2);
+ MAXVAL2 = Abs(UM2);
+ if(MAXVAL2 > MAXVAL){
+ MAXVAL = MAXVAL2;
+ }
+ NEWRESO = ResoU2 * MAXVAL ;
+ if(NEWRESO > ResoU2) {
+ ResoU2 = NEWRESO;
+ }
+ //
+ MAXVAL = Abs(Vm1);
+ MAXVAL2 = Abs(VM1);
+ if(MAXVAL2 > MAXVAL) {
+ MAXVAL = MAXVAL2;
+ }
+ NEWRESO = ResoV1 * MAXVAL ;
+ if(NEWRESO > ResoV1) {
+ ResoV1 = NEWRESO;
+ }
+ //
+ MAXVAL = Abs(Vm2);
+ MAXVAL2 = Abs(VM2);
+ if(MAXVAL2 > MAXVAL){
+ MAXVAL = MAXVAL2;
+ }
+ NEWRESO = ResoV2 * MAXVAL ;
+ if(NEWRESO > ResoV2) {
+ ResoV2 = NEWRESO;
+ }
+ //
+ pasuv[0]=pasMax*Abs(UM1-Um1);
+ pasuv[1]=pasMax*Abs(VM1-Vm1);
+ pasuv[2]=pasMax*Abs(UM2-Um2);
+ pasuv[3]=pasMax*Abs(VM2-Vm2);
+ //
+ if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro1)==Standard_False) {
+ UM1+=KELARG*pasuv[0];
+ Um1-=KELARG*pasuv[0];
+ }
+ else {
+ Standard_Real t = UM1-Um1;
+ if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro1)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro1)-t);
+ t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
+ UM1+=t;
+ Um1-=t;
+ }
+ }
+ //
+ if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro1)==Standard_False) {
+ VM1+=KELARG*pasuv[1];
+ Vm1-=KELARG*pasuv[1];
+ }
+ else {
+ Standard_Real t = VM1-Vm1;
+ if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro1)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro1)-t);
+ t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
+ VM1+=t; Vm1-=t;
+ }
+ }
+ //
+ if(Adaptor3d_HSurfaceTool::IsUPeriodic(Caro2)==Standard_False) {
+ UM2+=KELARG*pasuv[2];
+ Um2-=KELARG*pasuv[2];
+ }
+ else {
+ Standard_Real t = UM2-Um2;
+ if(t<Adaptor3d_HSurfaceTool::UPeriod(Caro2)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::UPeriod(Caro2)-t);
+ t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
+ UM2+=t;
+ Um2-=t;
+ }
+ }
+
+ if(Adaptor3d_HSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {
+ VM2+=KELARG*pasuv[3];
+ Vm2-=KELARG*pasuv[3];
+ }
+ else {
+ Standard_Real t = VM2-Vm2;
+ if(t<Adaptor3d_HSurfaceTool::VPeriod(Caro2)) {
+ t=0.5*(Adaptor3d_HSurfaceTool::VPeriod(Caro2)-t);
+ t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
+ VM2+=t;
+ Vm2-=t;
+ }
+ }
+ //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
+
+ for (Standard_Integer i = 0; i<=3;i++) {
+ pasInit[i] = pasSav[i] = pasuv[i];
+ }
+
+ if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
+ if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
+ if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
+ if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
+ //
+ TColStd_Array1OfReal Par(1,4);
+ Par(1) = U1;
+ Par(2) = V1;
+ Par(3) = U2;
+ Par(4) = V2;
+ Perform(Par);
+}
+
+//==================================================================================
+// function : PerformFirstPoint
+// purpose :
+//==================================================================================
+Standard_Boolean IntWalk_PWalking::PerformFirstPoint (const TColStd_Array1OfReal& ParDep,
+ IntSurf_PntOn2S& FirstPoint)
+{
+ sensCheminement = 1;
+ close = Standard_False;
+ //
+ Standard_Integer i;
+ TColStd_Array1OfReal Param(1,4);
+ //
+ for (i=1; i<=4; ++i) {
+ Param(i) = ParDep(i);
+ }
+ //-- calculate the first solution point
+ math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
+ //
+ myIntersectionOn2S.Perform(Param,Rsnld);
+ if (!myIntersectionOn2S.IsDone()) {
+ return Standard_False;
+ }
+
+ if (myIntersectionOn2S.IsEmpty()) {
+ return Standard_False;
+ }
+
+ FirstPoint = myIntersectionOn2S.Point();
+ return Standard_True;
+}
+//==================================================================================
+// function : Perform
+// purpose :
+//==================================================================================
+void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep)
+{
+ Perform(ParDep,Um1,Vm1,Um2,Vm2,UM1,VM1,UM2,VM2);
+}
+//==================================================================================
+// function : Perform
+// purpose :
+//==================================================================================
+void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
+ const Standard_Real u1min,
+ const Standard_Real v1min,
+ const Standard_Real u2min,
+ const Standard_Real v2min,
+ const Standard_Real u1max,
+ const Standard_Real v1max,
+ const Standard_Real u2max,
+ const Standard_Real v2max)
+{
+ const Standard_Real aSQDistMax = 1.0e-14;
+ //xf
+
+ Standard_Integer NbPasOKConseq=0;
+ Standard_Real pasMaxSV[4], aTmp;
+ TColStd_Array1OfReal Param(1,4);
+ IntImp_ConstIsoparametric ChoixIso;
+ //xt
+ //
+ done = Standard_False;
+ //
+ // Caro1 and Caro2
+ const Handle(Adaptor3d_HSurface)& Caro1 =myIntersectionOn2S.Function().AuxillarSurface1();
+ const Handle(Adaptor3d_HSurface)& Caro2 =myIntersectionOn2S.Function().AuxillarSurface2();
+ //
+ const Standard_Real UFirst1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1);
+ const Standard_Real VFirst1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1);
+ const Standard_Real ULast1 = Adaptor3d_HSurfaceTool::LastUParameter (Caro1);
+ const Standard_Real VLast1 = Adaptor3d_HSurfaceTool::LastVParameter (Caro1);
+
+ const Standard_Real UFirst2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2);
+ const Standard_Real VFirst2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2);
+ const Standard_Real ULast2 = Adaptor3d_HSurfaceTool::LastUParameter (Caro2);
+ const Standard_Real VLast2 = Adaptor3d_HSurfaceTool::LastVParameter (Caro2);
+ //
+ ComputePasInit(pasuv,u1min,u1max,v1min,v1max,u2min,u2max,v2min,v2max,
+ Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2,pasMax+pasMax);
+ //
+ if(pasuv[0]<100.0*ResoU1) {
+ pasuv[0]=100.0*ResoU1;
+ }
+ if(pasuv[1]<100.0*ResoV1) {
+ pasuv[1]=100.0*ResoV1;
+ }
+ if(pasuv[2]<100.0*ResoU2) {
+ pasuv[2]=100.0*ResoU2;
+ }
+ if(pasuv[3]<100.0*ResoV2) {
+ pasuv[3]=100.0*ResoV2;
+ }
+ //
+ for (Standard_Integer i=0; i<4; ++i)
+ {
+ if(pasuv[i]>10)
+ {
+ pasuv[i] = 10;
+ }
+
+ pasInit[i] = pasSav[i] = pasuv[i];
+ }
+ //
+ line = new IntSurf_LineOn2S ();
+ //
+ for (Standard_Integer i=1; i<=4; ++i)
+ {
+ aTmp=ParDep(i);
+ Param(i)=ParDep(i);
+ }
+ //-- reproduce steps uv connected to surfaces Caro1 and Caro2
+ //-- pasuv[] and pasSav[] are modified during the marching
+ for(Standard_Integer i = 0; i < 4; ++i)
+ {
+ pasMaxSV[i] = pasSav[i] = pasuv[i] = pasInit[i];
+ }
+
+ //-- calculate the first solution point
+ math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
+ //
+ ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld);
+ if (!myIntersectionOn2S.IsDone())
+ {
+ return;
+ }
+
+ //
+ if (myIntersectionOn2S.IsEmpty())
+ {
+ return;
+ }
+ //
+ if(myIntersectionOn2S.IsTangent())
+ {
+ return;
+ }
+ //
+ Standard_Boolean Arrive, DejaReparti;
+ const Standard_Integer RejectIndexMAX = 250000;
+ Standard_Integer IncKey, RejectIndex;
+ gp_Pnt pf,pl;
+ //
+ DejaReparti = Standard_False;
+ IncKey = 0;
+ RejectIndex = 0;
+ //
+ previousPoint = myIntersectionOn2S.Point();
+ previoustg = Standard_False;
+ previousd = myIntersectionOn2S.Direction();
+ previousd1 = myIntersectionOn2S.DirectionOnS1();
+ previousd2 = myIntersectionOn2S.DirectionOnS2();
+ indextg = 1;
+ tgdir = previousd;
+ firstd1 = previousd1;
+ firstd2 = previousd2;
+ tgfirst = tglast = Standard_False;
+ choixIsoSav = ChoixIso;
+ //------------------------------------------------------------
+ //-- Test if the first point of marching corresponds
+ //-- to a point on borders.
+ //-- In this case, DejaReparti is initialized as True
+ //--
+ pf = previousPoint.Value();
+ Standard_Boolean bTestFirstPoint = Standard_True;
+
+ previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+ AddAPoint(line,previousPoint);
+ //
+ IntWalk_StatusDeflection Status = IntWalk_OK;
+ Standard_Boolean NoTestDeflection = Standard_False;
+ Standard_Real SvParam[4], f;
+ Standard_Integer LevelOfEmptyInmyIntersectionOn2S=0;
+ Standard_Integer LevelOfPointConfondu = 0;
+ Standard_Integer LevelOfIterWithoutAppend = -1;
+ //
+ Arrive = Standard_False;
+ while(!Arrive) //010
+ {
+ LevelOfIterWithoutAppend++;
+ if(LevelOfIterWithoutAppend>20)
+ {
+ Arrive = Standard_True;
+ if(DejaReparti) {
+ break;
+ }
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ LevelOfIterWithoutAppend = 0;
+ }
+ //
+ // compute f
+ f = 0.;
+ switch (ChoixIso) {
+ case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
+ case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
+ case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
+ case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
+ default:break;
+ }
+ //
+ if(f<0.1) {
+ f=0.1;
+ }
+ //
+ previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+ //
+ //--ofv.begin
+ Standard_Real aIncKey, aEps, dP1, dP2, dP3, dP4;
+ //
+ dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
+ dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f;
+ dP3 = sensCheminement * pasuv[2] * previousd2.X() /f;
+ dP4 = sensCheminement * pasuv[3] * previousd2.Y() /f;
+ //
+ aIncKey=5.*(Standard_Real)IncKey;
+ aEps=1.e-7;
+ if(ChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < aEps)
+ {
+ dP1 *= aIncKey;
+ }
+
+ if(ChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < aEps)
+ {
+ dP2 *= aIncKey;
+ }
+
+ if(ChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < aEps)
+ {
+ dP3 *= aIncKey;
+ }
+
+ if(ChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < aEps)
+ {
+ dP4 *= aIncKey;
+ }
+ //--ofv.end
+ //
+ Param(1) += dP1;
+ Param(2) += dP2;
+ Param(3) += dP3;
+ Param(4) += dP4;
+ //==========================
+ SvParam[0]=Param(1);
+ SvParam[1]=Param(2);
+ SvParam[2]=Param(3);
+ SvParam[3]=Param(4);
+ //
+ ChoixIso= myIntersectionOn2S.Perform(Param, Rsnld, ChoixIso);
+ //
+ if (!myIntersectionOn2S.IsDone())
+ {
+ //end of line, division
+ Arrive = Standard_False;
+ Param(1)=SvParam[0];
+ Param(2)=SvParam[1];
+ Param(3)=SvParam[2];
+ Param(4)=SvParam[3];
+ RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
+ }
+ else //009
+ {
+ //== Calculation of exact point from Param(.) is possible
+ if (myIntersectionOn2S.IsEmpty())
+ {
+ Standard_Real u1,v1,u2,v2;
+ previousPoint.Parameters(u1,v1,u2,v2);
+ //
+ Arrive = Standard_False;
+ if(u1<UFirst1 || u1>ULast1)
+ {
+ Arrive=Standard_True;
+ }
+
+ if(u2<UFirst2 || u2>ULast2)
+ {
+ Arrive=Standard_True;
+ }
+
+ if(v1<VFirst1 || v1>VLast1)
+ {
+ Arrive=Standard_True;
+ }
+
+ if(v2<VFirst2 || v2>VLast2)
+ {
+ Arrive=Standard_True;
+ }
+
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ LevelOfEmptyInmyIntersectionOn2S++;
+ //
+ if(LevelOfEmptyInmyIntersectionOn2S>10)
+ {
+ pasuv[0]=pasSav[0];
+ pasuv[1]=pasSav[1];
+ pasuv[2]=pasSav[2];
+ pasuv[3]=pasSav[3];
+ }
+ }
+ else //008
+ {
+ //============================================================
+ //== A point has been found : T E S T D E F L E C T I O N
+ //============================================================
+ if(NoTestDeflection)
+ {
+ NoTestDeflection = Standard_False;
+ }
+ else
+ {
+ if(--LevelOfEmptyInmyIntersectionOn2S<=0)
+ {
+ LevelOfEmptyInmyIntersectionOn2S=0;
+ if(LevelOfIterWithoutAppend < 10)
+ {
+ Status = TestDeflection();
+ }
+ else
+ {
+ pasuv[0]*=0.5;
+ pasuv[1]*=0.5;
+ pasuv[2]*=0.5;
+ pasuv[3]*=0.5;
+ }
+ }
+ }
+
+ //============================================================
+ //== T r a i t e m e n t s u r S t a t u s ==
+ //============================================================
+ if(LevelOfPointConfondu > 5)
+ {
+ Status = IntWalk_ArretSurPoint;
+ LevelOfPointConfondu = 0;
+ }
+ //
+ if(Status==IntWalk_OK)
+ {
+ NbPasOKConseq++;
+ if(NbPasOKConseq >= 5)
+ {
+ NbPasOKConseq=0;
+ Standard_Boolean pastroppetit;
+ Standard_Real t;
+ //
+ do
+ {
+ pastroppetit=Standard_True;
+ //
+ if(pasuv[0]<pasInit[0])
+ {
+ t = (pasInit[0]-pasuv[0])*0.25;
+ if(t>0.1*pasInit[0])
+ {
+ t=0.1*pasuv[0];
+ }
+
+ pasuv[0]+=t;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[1]<pasInit[1])
+ {
+ t = (pasInit[1]-pasuv[1])*0.25;
+ if(t>0.1*pasInit[1]) {
+ t=0.1*pasuv[1];
+ }
+
+ pasuv[1]+=t;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[2]<pasInit[2])
+ {
+ t = (pasInit[2]-pasuv[2])*0.25;
+ if(t>0.1*pasInit[2])
+ {
+ t=0.1*pasuv[2];
+ }
+
+ pasuv[2]+=t;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[3]<pasInit[3])
+ {
+ t = (pasInit[3]-pasuv[3])*0.25;
+ if(t>0.1*pasInit[3]) {
+ t=0.1*pasuv[3];
+ }
+ pasuv[3]+=t;
+ pastroppetit=Standard_False;
+ }
+ if(pastroppetit)
+ {
+ if(pasMax<0.1)
+ {
+ pasMax*=1.1;
+ pasInit[0]*=1.1;
+ pasInit[1]*=1.1;
+ pasInit[2]*=1.1;
+ pasInit[3]*=1.1;
+ }
+ else
+ {
+ pastroppetit=Standard_False;
+ }
+ }
+ }
+ while(pastroppetit);
+ }
+ }//Status==IntWalk_OK
+ else
+ NbPasOKConseq=0;
+
+ //
+ switch(Status)//007
+ {
+ case IntWalk_ArretSurPointPrecedent:
+ {
+ Arrive = Standard_False;
+ RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
+ break;
+ }
+ case IntWalk_PasTropGrand:
+ {
+ Param(1)=SvParam[0];
+ Param(2)=SvParam[1];
+ Param(3)=SvParam[2];
+ Param(4)=SvParam[3];
+
+ if(LevelOfIterWithoutAppend > 5)
+ {
+ if(pasSav[0]<pasInit[0])
+ {
+ pasInit[0]-=(pasInit[0]-pasSav[0])*0.25;
+ LevelOfIterWithoutAppend=0;
+ }
+
+ if(pasSav[1]<pasInit[1])
+ {
+ pasInit[1]-=(pasInit[1]-pasSav[1])*0.25;
+ LevelOfIterWithoutAppend=0;
+ }
+
+ if(pasSav[2]<pasInit[2])
+ {
+ pasInit[2]-=(pasInit[2]-pasSav[2])*0.25;
+ LevelOfIterWithoutAppend=0;
+ }
+
+ if(pasSav[3]<pasInit[3])
+ {
+ pasInit[3]-=(pasInit[3]-pasSav[3])*0.25;
+ LevelOfIterWithoutAppend=0;
+ }
+ }
+
+ break;
+ }
+ case IntWalk_PointConfondu:
+ {
+ LevelOfPointConfondu++;
+
+ if(LevelOfPointConfondu>5)
+ {
+ Standard_Boolean pastroppetit;
+ //
+ do
+ {
+ pastroppetit=Standard_True;
+
+ if(pasuv[0]<pasInit[0])
+ {
+ pasuv[0]+=(pasInit[0]-pasuv[0])*0.25;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[1]<pasInit[1])
+ {
+ pasuv[1]+=(pasInit[1]-pasuv[1])*0.25;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[2]<pasInit[2])
+ {
+ pasuv[2]+=(pasInit[2]-pasuv[2])*0.25;
+ pastroppetit=Standard_False;
+ }
+
+ if(pasuv[3]<pasInit[3])
+ {
+ pasuv[3]+=(pasInit[3]-pasuv[3])*0.25;
+ pastroppetit=Standard_False;
+ }
+
+ if(pastroppetit)
+ {
+ if(pasMax<0.1)
+ {
+ pasMax*=1.1;
+ pasInit[0]*=1.1;
+ pasInit[1]*=1.1;
+ pasInit[2]*=1.1;
+ pasInit[3]*=1.1;
+ }
+ else
+ {
+ pastroppetit=Standard_False;
+ }
+ }
+ }
+ while(pastroppetit);
+ }
+
+ break;
+ }
+ case IntWalk_OK:
+ case IntWalk_ArretSurPoint://006
+ {
+ //=======================================================
+ //== Stop Test t : Frame on Param(.) ==
+ //=======================================================
+ //xft arrive here
+ Arrive = TestArret(DejaReparti,Param,ChoixIso);
+ // JMB 30th December 1999.
+ // Some statement below should not be put in comment because they are useful.
+ // See grid CTO 909 A1 which infinitely loops
+ if(Arrive==Standard_False && Status==IntWalk_ArretSurPoint)
+ {
+ Arrive=Standard_True;
+#ifdef DEB
+ cout << "Compile with option DEB : if problems with intersection : ";
+ cout << "IntWalk_PWalking_1.gxx (lbr le 1erdec98)"<<endl;
+#endif
+ }
+
+ if(Arrive)
+ {
+ NbPasOKConseq = -10;
+ }
+
+ if(!Arrive)//005
+ {
+ //=====================================================
+ //== Param(.) is in the limits ==
+ //== and does not end a closed line ==
+ //=====================================================
+ //== Check on the current point of myInters
+ Standard_Boolean pointisvalid = Standard_False;
+ {
+ Standard_Real u1,v1,u2,v2;
+ myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
+
+ //
+ if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
+ v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
+ v1 >= Vm1 && v2 >= Vm2)
+ {
+ pointisvalid=Standard_True;
+ }
+ }
+
+ //
+ if(pointisvalid)
+ {
+ previousPoint = myIntersectionOn2S.Point();
+ previoustg = myIntersectionOn2S.IsTangent();
+
+ if(!previoustg)
+ {
+ previousd = myIntersectionOn2S.Direction();
+ previousd1 = myIntersectionOn2S.DirectionOnS1();
+ previousd2 = myIntersectionOn2S.DirectionOnS2();
+ }
+ //=====================================================
+ //== Check on the previous Point
+ {
+ Standard_Real u1,v1,u2,v2;
+ previousPoint.Parameters(u1,v1,u2,v2);
+ if( u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
+ v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
+ v1 >= Vm1 && v2 >= Vm2)
+ {
+ pl = previousPoint.Value();
+ if(bTestFirstPoint)
+ {
+ if(pf.SquareDistance(pl) < aSQDistMax)
+ {
+ IncKey++;
+ if(IncKey == 5000)
+ return;
+ else
+ continue;
+ }
+ else
+ {
+ bTestFirstPoint = Standard_False;
+ }
+ }
+ //
+ AddAPoint(line,previousPoint);
+ RejectIndex++;
+
+ if(RejectIndex >= RejectIndexMAX)
+ {
+ break;
+ }
+
+ //
+ LevelOfIterWithoutAppend = 0;
+ }
+ }
+ }//pointisvalid
+ //====================================================
+
+ if(Status == IntWalk_ArretSurPoint)
+ {
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ }
+ else
+ {
+ if (line->NbPoints() == 2)
+ {
+ pasSav[0] = pasuv[0];
+ pasSav[1] = pasuv[1];
+ pasSav[2] = pasuv[2];
+ pasSav[3] = pasuv[3];
+ }
+ }
+ }//005 if(!Arrive)
+ else //004
+ {
+ if(close)
+ {
+ //================= la ligne est fermee ===============
+ AddAPoint(line,line->Value(1)); //ligne fermee
+ LevelOfIterWithoutAppend=0;
+ }
+ else //$$$
+ {
+ //====================================================
+ //== Param was not in the limits (was reframed)
+ //====================================================
+ Standard_Boolean bPrevNotTangent = !previoustg || !myIntersectionOn2S.IsTangent();
+
+ IntImp_ConstIsoparametric SauvChoixIso = ChoixIso;
+ ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
+ //
+ if(!myIntersectionOn2S.IsEmpty()) //002
+ {
+ // mutially outpasses in the square or intersection in corner
+
+ if(TestArret(Standard_True,Param,ChoixIso))
+ {
+ NbPasOKConseq = -10;
+ ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
+
+ if(!myIntersectionOn2S.IsEmpty())
+ {
+ previousPoint = myIntersectionOn2S.Point();
+ previoustg = myIntersectionOn2S.IsTangent();
+
+ if (!previoustg)
+ {
+ previousd = myIntersectionOn2S.Direction();
+ previousd1 = myIntersectionOn2S.DirectionOnS1();
+ previousd2 = myIntersectionOn2S.DirectionOnS2();
+ }
+
+ pl = previousPoint.Value();
+
+ if(bTestFirstPoint)
+ {
+ if(pf.SquareDistance(pl) < aSQDistMax)
+ {
+ IncKey++;
+ if(IncKey == 5000)
+ return;
+ else
+ continue;
+ }
+ else
+ {
+ bTestFirstPoint = Standard_False;
+ }
+ }
+ //
+ AddAPoint(line,previousPoint);
+ RejectIndex++;
+
+ if(RejectIndex >= RejectIndexMAX)
+ {
+ break;
+ }
+
+ //
+ LevelOfIterWithoutAppend=0;
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ }
+ else
+ {
+ //fail framing divides the step
+ Arrive = Standard_False;
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ NoTestDeflection = Standard_True;
+ ChoixIso = SauvChoixIso;
+ }
+ }//if(TestArret())
+ else
+ {
+ // save the last point
+ // to revert to it if the current point is out of bounds
+
+ IntSurf_PntOn2S previousPointSave = previousPoint;
+ Standard_Boolean previoustgSave = previoustg;
+ gp_Dir previousdSave = previousd;
+ gp_Dir2d previousd1Save = previousd1;
+ gp_Dir2d previousd2Save = previousd2;
+
+ previousPoint = myIntersectionOn2S.Point();
+ previoustg = myIntersectionOn2S.IsTangent();
+ Arrive = Standard_False;
+
+ if(!previoustg)
+ {
+ previousd = myIntersectionOn2S.Direction();
+ previousd1 = myIntersectionOn2S.DirectionOnS1();
+ previousd2 = myIntersectionOn2S.DirectionOnS2();
+ }
+
+ //========================================
+ //== Check on PreviousPoint @@
+
+ {
+ Standard_Real u1,v1,u2,v2;
+ previousPoint.Parameters(u1,v1,u2,v2);
+
+ //To save initial 2d points
+ gp_Pnt2d ParamPntOnS1(Param(1), Param(2));
+ gp_Pnt2d ParamPntOnS2(Param(3), Param(4));
+
+ ///////////////////////////
+ Param(1) = u1;
+ Param(2) = v1;
+ Param(3) = u2;
+ Param(4) = v2;
+ //
+
+ //xf
+ Standard_Boolean bFlag1, bFlag2;
+ Standard_Real aTol2D=1.e-11;
+ //
+ bFlag1=u1 >= Um1-aTol2D && v1 >= Vm1-aTol2D && u1 <= UM1+aTol2D && v1 <= VM1+aTol2D;
+ bFlag2=u2 >= Um2-aTol2D && v2 >= Vm2-aTol2D && u2 <= UM2+aTol2D && v2 <= VM2+aTol2D;
+ if (bFlag1 && bFlag2)
+ {
+ /*
+ if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
+ v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
+ v1 >= Vm1 && v2 >= Vm2) {
+ */
+ //xt
+ pl = previousPoint.Value();
+
+ if(bTestFirstPoint)
+ {
+ if(pf.SquareDistance(pl) < aSQDistMax)
+ {
+ IncKey++;
+
+ if(IncKey == 5000)
+ return;
+ else
+ continue;
+ }
+ else
+ {
+ bTestFirstPoint = Standard_False;
+ }
+ }
+
+ //To avoid walking around the same point
+ //in the tangent zone near a border
+
+ if (previoustg)
+ {
+ Standard_Real prevU1, prevV1, prevU2, prevV2;
+ previousPointSave.Parameters(prevU1, prevV1, prevU2, prevV2);
+ gp_Pnt2d prevPntOnS1(prevU1, prevV1), prevPntOnS2(prevU2, prevV2);
+ gp_Pnt2d curPntOnS1(u1, v1), curPntOnS2(u2, v2);
+ gp_Vec2d PrevToParamOnS1(prevPntOnS1, ParamPntOnS1);
+ gp_Vec2d PrevToCurOnS1(prevPntOnS1, curPntOnS1);
+ gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2);
+ gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2);
+ Standard_Real MaxAngle = 3*M_PI/4;
+
+ if (Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)) > MaxAngle &&
+ Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle)
+ {
+ Arrive = Standard_True;
+ break;
+ }
+ }
+
+ ////////////////////////////////////////
+ AddAPoint(line,previousPoint);
+ RejectIndex++;
+
+ if(RejectIndex >= RejectIndexMAX)
+ {
+ break;
+ }
+
+ //
+
+ LevelOfIterWithoutAppend=0;
+ Arrive = Standard_True;
+ }
+ else
+ {
+ // revert to the last correctly calculated point
+ previousPoint = previousPointSave;
+ previoustg = previoustgSave;
+ previousd = previousdSave;
+ previousd1 = previousd1Save;
+ previousd2 = previousd2Save;
+ }
+ }
+
+ //
+ Standard_Boolean wasExtended = Standard_False;
+
+ if(Arrive && myIntersectionOn2S.IsTangent() && bPrevNotTangent)
+ {
+ if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
+ {
+ wasExtended = Standard_True;
+ Arrive = Standard_False;
+ ChoixIso = SauvChoixIso;
+ }
+ }
+
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+
+ if(Arrive &&
+ myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty() &&
+ myIntersectionOn2S.IsTangent() && bPrevNotTangent &&
+ !wasExtended)
+ {
+ if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
+ {
+ wasExtended = Standard_True;
+ Arrive = Standard_False;
+ ChoixIso = SauvChoixIso;
+ }
+ }
+ }//else !TestArret() $
+ }//$$ end successful framing on border (!myIntersectionOn2S.IsEmpty())
+ else
+ {
+ //echec framing on border; division of step
+ Arrive = Standard_False;
+ NoTestDeflection = Standard_True;
+ RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+ }
+ }//$$$ end framing on border (!close)
+ }//004 fin TestArret return Arrive = True
+ } // 006case IntWalk_ArretSurPoint: end Processing Status = OK or ArretSurPoint
+ } //007 switch(Status)
+ } //008 end processing point (TEST DEFLECTION)
+ } //009 end processing line (else if myIntersectionOn2S.IsDone())
+ } //010 end if first departure point allows marching while (!Arrive)
+
+ done = Standard_True;
+}
+// ===========================================================================================================
+// function: ExtendLineInCommonZone
+// purpose: Extends already computed line inside tangent zone in the direction given by theChoixIso.
+// Returns Standard_True if the line was extended through tangent zone and the last computed point
+// is outside the tangent zone (but it is not put into the line). Otherwise returns Standard_False.
+// ===========================================================================================================
+Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric theChoixIso,
+ const Standard_Boolean theDirectionFlag)
+{
+ Standard_Boolean bOutOfTangentZone = Standard_False;
+ Standard_Boolean bStop = !myIntersectionOn2S.IsTangent();
+ Standard_Integer dIncKey = 1;
+ TColStd_Array1OfReal Param(1,4);
+ IntWalk_StatusDeflection Status = IntWalk_OK;
+ Standard_Integer nbIterWithoutAppend = 0;
+ Standard_Integer nbEqualPoints = 0;
+ Standard_Integer parit = 0;
+ Standard_Integer uvit = 0;
+ IntSurf_SequenceOfPntOn2S aSeqOfNewPoint;
+
+ while (!bStop) {
+ nbIterWithoutAppend++;
+
+ if((nbIterWithoutAppend > 20) || (nbEqualPoints > 20)) {
+#ifdef DEB
+ cout<<"Compile with option DEB:";
+ cout<<"Infinite loop has detected. Stop iterations (IntWalk_PWalking_1.gxx)" << endl;
+#endif
+ bStop = Standard_True;
+ break;
+ }
+ Standard_Real f = 0.;
+
+ switch (theChoixIso)
+ {
+ case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
+ case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
+ case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
+ case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
+ }
+
+ if(f<0.1) f=0.1;
+
+ previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+
+ Standard_Real dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
+ Standard_Real dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f;
+ Standard_Real dP3 = sensCheminement * pasuv[2] * previousd2.X() /f;
+ Standard_Real dP4 = sensCheminement * pasuv[3] * previousd2.Y() /f;
+
+ if(theChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < 1.e-7) dP1 *= (5. * (Standard_Real)dIncKey);
+ if(theChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < 1.e-7) dP2 *= (5. * (Standard_Real)dIncKey);
+ if(theChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < 1.e-7) dP3 *= (5. * (Standard_Real)dIncKey);
+ if(theChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < 1.e-7) dP4 *= (5. * (Standard_Real)dIncKey);
+
+ Param(1) += dP1;
+ Param(2) += dP2;
+ Param(3) += dP3;
+ Param(4) += dP4;
+ Standard_Real SvParam[4];
+ IntImp_ConstIsoparametric ChoixIso = theChoixIso;
+
+ for(parit = 0; parit < 4; parit++) {
+ SvParam[parit] = Param(parit+1);
+ }
+ math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
+ ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld, theChoixIso);
+
+ if (!myIntersectionOn2S.IsDone()) {
+ return bOutOfTangentZone;
+ }
+ else {
+ if (myIntersectionOn2S.IsEmpty()) {
+ return bOutOfTangentZone;
+ }
+
+ Status = TestDeflection();
+
+ if(Status == IntWalk_OK) {
+
+ for(uvit = 0; uvit < 4; uvit++) {
+ if(pasuv[uvit] < pasInit[uvit]) {
+ pasuv[uvit] = pasInit[uvit];
+ }
+ }
+ }
+
+ switch(Status) {
+ case IntWalk_ArretSurPointPrecedent:
+ {
+ bStop = Standard_True;
+ bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+ break;
+ }
+ case IntWalk_PasTropGrand:
+ {
+ for(parit = 0; parit < 4; parit++) {
+ Param(parit+1) = SvParam[parit];
+ }
+ Standard_Boolean bDecrease = Standard_False;
+
+ for(uvit = 0; uvit < 4; uvit++) {
+ if(pasSav[uvit] < pasInit[uvit]) {
+ pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * 0.1;
+ bDecrease = Standard_True;
+ }
+ }
+
+ if(bDecrease) nbIterWithoutAppend--;
+ break;
+ }
+ case IntWalk_PointConfondu:
+ {
+ for(uvit = 0; uvit < 4; uvit++) {
+ if(pasuv[uvit] < pasInit[uvit]) {
+ pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * 0.1;
+ }
+ }
+ break;
+ }
+ case IntWalk_OK:
+ case IntWalk_ArretSurPoint:
+ {
+ //
+ bStop = TestArret(theDirectionFlag, Param, ChoixIso);
+ //
+
+ //
+ if(!bStop) {
+ Standard_Real u11,v11,u12,v12;
+ myIntersectionOn2S.Point().Parameters(u11,v11,u12,v12);
+ Standard_Real u21,v21,u22,v22;
+ previousPoint.Parameters(u21,v21,u22,v22);
+
+ if(((fabs(u11-u21) < ResoU1) && (fabs(v11-v21) < ResoV1)) ||
+ ((fabs(u12-u22) < ResoU2) && (fabs(v12-v22) < ResoV2))) {
+ nbEqualPoints++;
+ }
+ else {
+ nbEqualPoints = 0;
+ }
+ }
+ //
+
+ bStop = bStop || !myIntersectionOn2S.IsTangent();
+ bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+
+ if(!bStop) {
+ Standard_Boolean pointisvalid = Standard_False;
+ Standard_Real u1,v1,u2,v2;
+ myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
+
+ if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
+ v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
+ v1 >= Vm1 && v2 >= Vm2)
+ pointisvalid = Standard_True;
+
+ if(pointisvalid) {
+ previousPoint = myIntersectionOn2S.Point();
+ previoustg = myIntersectionOn2S.IsTangent();
+
+ if(!previoustg) {
+ previousd = myIntersectionOn2S.Direction();
+ previousd1 = myIntersectionOn2S.DirectionOnS1();
+ previousd2 = myIntersectionOn2S.DirectionOnS2();
+ }
+ Standard_Boolean bAddPoint = Standard_True;
+
+ if(line->NbPoints() >= 1) {
+ gp_Pnt pf = line->Value(1).Value();
+ gp_Pnt pl = previousPoint.Value();
+
+ if(pf.Distance(pl) < Precision::Confusion()) {
+ dIncKey++;
+ if(dIncKey == 5000) return bOutOfTangentZone;
+ else bAddPoint = Standard_False;
+ }
+ }
+
+ if(bAddPoint) {
+ aSeqOfNewPoint.Append(previousPoint);
+ nbIterWithoutAppend = 0;
+ }
+ }
+
+ if (line->NbPoints() == 2) {
+ for(uvit = 0; uvit < 4; uvit++) {
+ pasSav[uvit] = pasuv[uvit];
+ }
+ }
+
+ if ( !pointisvalid ) {
+ // decrease step if out of bounds
+ // otherwise the same calculations will be
+ // repeated several times
+ if ( ( u1 > UM1 ) || ( u1 < Um1 ) )
+ pasuv[0] *= 0.5;
+
+ if ( ( v1 > VM1 ) || ( v1 < Vm1 ) )
+ pasuv[1] *= 0.5;
+
+ if ( ( u2 > UM2 ) || ( u2 < Um2 ) )
+ pasuv[2] *= 0.5;
+
+ if ( ( v2 > VM2 ) || ( v2 < Vm2 ) )
+ pasuv[3] *= 0.5;
+ }
+ } // end if(!bStop)
+ else { //if(bStop)
+ if(close && (line->NbPoints() >= 1)) {
+
+ if(!bOutOfTangentZone) {
+ aSeqOfNewPoint.Append(line->Value(1)); // line end
+ }
+ nbIterWithoutAppend = 0;
+ }
+ else {
+ ChoixIso = myIntersectionOn2S.Perform(Param, Rsnld, theChoixIso);
+
+ if(myIntersectionOn2S.IsEmpty()) {
+ bStop = !myIntersectionOn2S.IsTangent();
+ bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+ }
+ else {
+ Standard_Boolean bAddPoint = Standard_True;
+ Standard_Boolean pointisvalid = Standard_False;
+
+ previousPoint = myIntersectionOn2S.Point();
+ Standard_Real u1,v1,u2,v2;
+ previousPoint.Parameters(u1,v1,u2,v2);
+
+ if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
+ v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
+ v1 >= Vm1 && v2 >= Vm2)
+ pointisvalid = Standard_True;
+
+ if(pointisvalid) {
+
+ if(line->NbPoints() >= 1) {
+ gp_Pnt pf = line->Value(1).Value();
+ gp_Pnt pl = previousPoint.Value();
+
+ if(pf.Distance(pl) < Precision::Confusion()) {
+ dIncKey++;
+ if(dIncKey == 5000) return bOutOfTangentZone;
+ else bAddPoint = Standard_False;
+ }
+ }
+
+ if(bAddPoint && !bOutOfTangentZone) {
+ aSeqOfNewPoint.Append(previousPoint);
+ nbIterWithoutAppend = 0;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+ Standard_Boolean bExtendLine = Standard_False;
+ Standard_Real u1 = 0., v1 = 0., u2 = 0., v2 = 0.;
+
+ Standard_Integer pit = 0;
+
+ for(pit = 0; !bExtendLine && (pit < 2); pit++) {
+ if(pit == 0)
+ previousPoint.Parameters(u1,v1,u2,v2);
+ else {
+ if(aSeqOfNewPoint.Length() > 0)
+ aSeqOfNewPoint.Value(aSeqOfNewPoint.Length()).Parameters(u1,v1,u2,v2);
+ else
+ break;
+ }
+
+ if(((u1 - Um1) < ResoU1) ||
+ ((UM1 - u1) < ResoU1) ||
+ ((u2 - Um2) < ResoU2) ||
+ ((UM2 - u2) < ResoU2) ||
+ ((v1 - Vm1) < ResoV1) ||
+ ((VM1 - v1) < ResoV1) ||
+ ((v2 - Vm2) < ResoV2) ||
+ ((VM2 - v2) < ResoV2))
+ bExtendLine = Standard_True;
+ }
+
+ if(!bExtendLine) {
+ // if(Status == IntWalk_OK || Status == IntWalk_ArretSurPoint) {
+ if(Status == IntWalk_OK) {
+ bExtendLine = Standard_True;
+
+ if(aSeqOfNewPoint.Length() > 1) {
+ TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3), Resolutions(0, 3);
+ Resolutions(0) = ResoU1; Resolutions(1) = ResoV1; Resolutions(2) = ResoU2; Resolutions(3) = ResoV2;
+
+ aSeqOfNewPoint(1).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+ FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+ aSeqOfNewPoint(aSeqOfNewPoint.Length()).Parameters(LastParams.ChangeValue(0),
+ LastParams.ChangeValue(1),
+ LastParams.ChangeValue(2),
+ LastParams.ChangeValue(3));
+ Standard_Integer indexofiso = 0;
+
+ if(theChoixIso == IntImp_UIsoparametricOnCaro1) indexofiso = 0;
+ if(theChoixIso == IntImp_VIsoparametricOnCaro1) indexofiso = 1;
+ if(theChoixIso == IntImp_UIsoparametricOnCaro2) indexofiso = 2;
+ if(theChoixIso == IntImp_VIsoparametricOnCaro2) indexofiso = 3;
+
+ Standard_Integer afirstindex = (indexofiso < 2) ? 0 : 2;
+ gp_Vec2d aTangentZoneDir(gp_Pnt2d(FirstParams.Value(afirstindex), FirstParams.Value(afirstindex + 1)),
+ gp_Pnt2d(LastParams.Value(afirstindex), LastParams.Value(afirstindex + 1)));
+
+ gp_Dir2d anIsoDir(0, 1);
+
+ if((indexofiso == 1) || (indexofiso == 3))
+ anIsoDir = gp_Dir2d(1, 0);
+
+ if(aTangentZoneDir.SquareMagnitude() > gp::Resolution()) {
+ Standard_Real piquota = M_PI*0.25;
+
+ if(fabs(aTangentZoneDir.Angle(anIsoDir)) > piquota) {
+ Standard_Integer ii = 1, nextii = 2;
+ gp_Vec2d d1(0, 0);
+ Standard_Real asqresol = gp::Resolution();
+ asqresol *= asqresol;
+
+ do {
+ aSeqOfNewPoint(ii).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+ FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+ aSeqOfNewPoint(ii + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
+ LastParams.ChangeValue(2), LastParams.ChangeValue(3));
+ d1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
+ FirstParams.Value(afirstindex + 1)),
+ gp_Pnt2d(LastParams.Value(afirstindex),
+ LastParams.Value(afirstindex + 1)));
+ ii++;
+ }
+ while((d1.SquareMagnitude() < asqresol) &&
+ (ii < aSeqOfNewPoint.Length()));
+
+ nextii = ii;
+
+ while(nextii < aSeqOfNewPoint.Length()) {
+
+ gp_Vec2d nextd1(0, 0);
+ Standard_Integer jj = nextii;
+
+ do {
+ aSeqOfNewPoint(jj).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+ FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+ aSeqOfNewPoint(jj + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
+ LastParams.ChangeValue(2), LastParams.ChangeValue(3));
+ nextd1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
+ FirstParams.Value(afirstindex + 1)),
+ gp_Pnt2d(LastParams.Value(afirstindex),
+ LastParams.Value(afirstindex + 1)));
+ jj++;
+
+ }
+ while((nextd1.SquareMagnitude() < asqresol) &&
+ (jj < aSeqOfNewPoint.Length()));
+ nextii = jj;
+
+ if(fabs(d1.Angle(nextd1)) > piquota) {
+ bExtendLine = Standard_False;
+ break;
+ }
+ d1 = nextd1;
+ }
+ }
+ // end if(fabs(aTangentZoneDir.Angle(anIsoDir)
+ }
+ }
+ }
+ }
+
+ if(!bExtendLine) {
+ return Standard_False;
+ }
+ Standard_Integer i = 0;
+
+ for(i = 1; i <= aSeqOfNewPoint.Length(); i++) {
+ AddAPoint(line, aSeqOfNewPoint.Value(i));
+ }
+
+ return bOutOfTangentZone;
+}
+
+//=======================================================================
+//function : DistanceMinimizeByGradient
+//purpose :
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+DistanceMinimizeByGradient( const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ Standard_Real& theU1,
+ Standard_Real& theV1,
+ Standard_Real& theU2,
+ Standard_Real& theV2,
+ const Standard_Real theStep0U1V1,
+ const Standard_Real theStep0U2V2)
+{
+ const Standard_Integer aNbIterMAX = 60;
+ const Standard_Real aTol = 1.0e-14;
+ Handle(Geom_Surface) aS1, aS2;
+
+ switch(theASurf1->GetType())
+ {
+ case GeomAbs_BezierSurface:
+ aS1 = theASurf1->Surface().Bezier();
+ break;
+ case GeomAbs_BSplineSurface:
+ aS1 = theASurf1->Surface().BSpline();
+ break;
+ default:
+ return Standard_True;
+ }
+
+ switch(theASurf2->GetType())
+ {
+ case GeomAbs_BezierSurface:
+ aS2 = theASurf2->Surface().Bezier();
+ break;
+ case GeomAbs_BSplineSurface:
+ aS2 = theASurf2->Surface().BSpline();
+ break;
+ default:
+ return Standard_True;
+ }
+
+ Standard_Boolean aStatus = Standard_False;
+
+ gp_Pnt aP1, aP2;
+ gp_Vec aD1u, aD1v, aD2U, aD2V;
+
+ aS1->D1(theU1, theV1, aP1, aD1u, aD1v);
+ aS2->D1(theU2, theV2, aP2, aD2U, aD2V);
+
+ Standard_Real aSQDistPrev = aP1.SquareDistance(aP2);
+
+ gp_Vec aP12(aP1, aP2);
+
+ Standard_Real aGradFu(-aP12.Dot(aD1u));
+ Standard_Real aGradFv(-aP12.Dot(aD1v));
+ Standard_Real aGradFU( aP12.Dot(aD2U));
+ Standard_Real aGradFV( aP12.Dot(aD2V));
+
+ Standard_Real aSTEPuv = theStep0U1V1, aStepUV = theStep0U2V2;
+
+ Standard_Boolean flRepeat = Standard_True;
+ Standard_Integer aNbIter = aNbIterMAX;
+
+ while(flRepeat)
+ {
+ Standard_Real anAdd = aGradFu*aSTEPuv;
+ Standard_Real aPARu = (anAdd >= 0.0)?
+ (theU1 - Max(anAdd, Epsilon(theU1))) :
+ (theU1 + Max(-anAdd, Epsilon(theU1)));
+ anAdd = aGradFv*aSTEPuv;
+ Standard_Real aPARv = (anAdd >= 0.0)?
+ (theV1 - Max(anAdd, Epsilon(theV1))) :
+ (theV1 + Max(-anAdd, Epsilon(theV1)));
+ anAdd = aGradFU*aStepUV;
+ Standard_Real aParU = (anAdd >= 0.0)?
+ (theU2 - Max(anAdd, Epsilon(theU2))) :
+ (theU2 + Max(-anAdd, Epsilon(theU2)));
+ anAdd = aGradFV*aStepUV;
+ Standard_Real aParV = (anAdd >= 0.0)?
+ (theV2 - Max(anAdd, Epsilon(theV2))) :
+ (theV2 + Max(-anAdd, Epsilon(theV2)));
+
+ gp_Pnt aPt1, aPt2;
+
+ aS1->D1(aPARu, aPARv, aPt1, aD1u, aD1v);
+ aS2->D1(aParU, aParV, aPt2, aD2U, aD2V);
+
+ Standard_Real aSQDist = aPt1.SquareDistance(aPt2);
+
+ if(aSQDist < aSQDistPrev)
+ {
+ aSQDistPrev = aSQDist;
+ theU1 = aPARu;
+ theV1 = aPARv;
+ theU2 = aParU;
+ theV2 = aParV;
+
+ aStatus = aSQDistPrev < aTol;
+ aSTEPuv *= 1.2;
+ aStepUV *= 1.2;
+ }
+ else
+ {
+ if(--aNbIter < 0)
+ {
+ flRepeat = Standard_False;
+ }
+ else
+ {
+ aS1->D1(theU1, theV1, aPt1, aD1u, aD1v);
+ aS2->D1(theU2, theV2, aPt2, aD2U, aD2V);
+
+ gp_Vec aP12(aPt1, aPt2);
+ aGradFu = -aP12.Dot(aD1u);
+ aGradFv = -aP12.Dot(aD1v);
+ aGradFU = aP12.Dot(aD2U);
+ aGradFV = aP12.Dot(aD2V);
+ aSTEPuv = theStep0U1V1;
+ aStepUV = theStep0U2V2;
+ }
+ }
+ }
+
+ return aStatus;
+}
+
+//=======================================================================
+//function : DistanceMinimizeByExtrema
+//purpose :
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+DistanceMinimizeByExtrema(const Handle(Adaptor3d_HSurface)& theASurf,
+ const gp_Pnt& theP0,
+ Standard_Real& theU0,
+ Standard_Real& theV0,
+ const Standard_Real theStep0U,
+ const Standard_Real theStep0V)
+{
+ const Standard_Real aTol = 1.0e-14;
+ gp_Pnt aPS;
+ gp_Vec aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp;
+ Standard_Real aSQDistPrev = RealLast();
+ Standard_Real aU = theU0, aV = theV0;
+
+ Standard_Integer aNbIter = 10;
+ do
+ {
+ theASurf->D2(aU, aV, aPS, aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp);
+
+ gp_Vec aVec(theP0, aPS);
+
+ Standard_Real aSQDist = aVec.SquareMagnitude();
+
+ if(aSQDist >= aSQDistPrev)
+ break;
+
+ aSQDistPrev = aSQDist;
+ theU0 = aU;
+ theV0 = aV;
+ aNbIter--;
+
+ if(aSQDistPrev < aTol)
+ break;
+
+ //Functions
+ const Standard_Real aF1 = aD1Su.Dot(aVec), aF2 = aD1Sv.Dot(aVec);
+
+ //Derivatives
+ const Standard_Real aDf1u = aD2Su.Dot(aVec) + aD1Su.Dot(aD1Su),
+ aDf1v = aD2Su.Dot(aD1Sv),
+ aDf2u = aDf1v,
+ aDf2v = aD2Sv.Dot(aVec) + aD1Sv.Dot(aD1Sv);
+
+ const Standard_Real aDet = aDf1u*aDf2v - aDf1v*aDf2u;
+ aU -= theStep0U*(aDf2v*aF1 - aDf1v*aF2)/aDet;
+ aV += theStep0V*(aDf2u*aF1 - aDf1u*aF2)/aDet;
+ }
+ while(aNbIter > 0);
+
+ return (aSQDistPrev < aTol);
+}
+
+//=======================================================================
+//function : SeekPointOnBoundary
+//purpose :
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+SeekPointOnBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ const Standard_Real theU1,
+ const Standard_Real theV1,
+ const Standard_Real theU2,
+ const Standard_Real theV2,
+ const Standard_Boolean isTheFirst)
+{
+ const Standard_Real aTol = 1.0e-14;
+ Standard_Boolean isOK = Standard_False;
+ Standard_Real U1prec = theU1, V1prec = theV1, U2prec = theU2, V2prec = theV2;
+
+ Standard_Boolean flFinish = Standard_False;
+
+ Standard_Integer aNbIter = 20;
+ while(!flFinish)
+ {
+ flFinish = Standard_False;
+ Standard_Boolean aStatus = Standard_False;
+
+ do
+ {
+ aNbIter--;
+ aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+ }
+ while(!aStatus && (aNbIter > 0));
+
+ if(aStatus)
+ {
+ const Standard_Real aTolMax = 1.0e-8;
+ Standard_Real aTolF = 0.0;
+
+ Standard_Real u1 = U1prec, v1 = V1prec, u2 = U2prec, v2 = V2prec;
+
+ flFinish = Checking(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aTolF);
+
+ if(aTolF <= aTolMax)
+ {
+ gp_Pnt aP1 = theASurf1->Value(u1, v1),
+ aP2 = theASurf2->Value(u2, v2);
+ gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+ const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+ aSQDist2 = aPInt.SquareDistance(aP2);
+ if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+ {
+ IntSurf_PntOn2S anIP;
+ anIP.SetValue(aPInt, u1, v1, u2, v2);
+
+ if(isTheFirst)
+ line->InsertBefore(1,anIP);
+ else
+ line->Add(anIP);
+
+ isOK = Standard_True;
+ }
+ }
+ }
+ else
+ {
+ break;
+ }
+
+ if(aNbIter < 0)
+ break;
+ }
+
+ return isOK;
+}
+
+//=======================================================================
+//function : PutToBoundary
+//purpose :
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+PutToBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2)
+{
+ const Standard_Real aTolMin = Precision::Confusion();
+
+ Standard_Boolean hasBeenAdded = Standard_False;
+
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+ Standard_Real aTol = 1.0;
+ aTol = Min(aTol, aU1bLast - aU1bFirst);
+ aTol = Min(aTol, aU2bLast - aU2bFirst);
+ aTol = Min(aTol, aV1bLast - aV1bFirst);
+ aTol = Min(aTol, aV2bLast - aV2bFirst)*1.0e-3;
+
+ if(aTol <= 2.0*aTolMin)
+ return hasBeenAdded;
+
+ Standard_Boolean isNeedAdding = Standard_False;
+ Standard_Boolean isU1parallel = Standard_False, isV1parallel = Standard_False;
+ Standard_Boolean isU2parallel = Standard_False, isV2parallel = Standard_False;
+ IsParallel(line, Standard_True, aTol, isU1parallel, isV1parallel);
+ IsParallel(line, Standard_False, aTol, isU2parallel, isV2parallel);
+
+ const Standard_Integer aNbPnts = line->NbPoints();
+ Standard_Real u1, v1, u2, v2;
+ line->Value(1).Parameters(u1, v1, u2, v2);
+ Standard_Real aDelta = 0.0;
+
+ if(!isV1parallel)
+ {
+ aDelta = u1 - aU1bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u1 = aU1bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aU1bLast - u1;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u1 = aU1bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isV2parallel)
+ {
+ aDelta = u2 - aU2bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u2 = aU2bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aU2bLast - u2;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u2 = aU2bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isU1parallel)
+ {
+ aDelta = v1 - aV1bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v1 = aV1bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aV1bLast - v1;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v1 = aV1bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isU2parallel)
+ {
+ aDelta = v2 - aV2bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v2 = aV2bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aV2bLast - v2;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v2 = aV2bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(isNeedAdding)
+ {
+ hasBeenAdded =
+ SeekPointOnBoundary(theASurf1, theASurf2, u1,
+ v1, u2, v2, Standard_True);
+ }
+
+ isNeedAdding = Standard_False;
+ line->Value(aNbPnts).Parameters(u1, v1, u2, v2);
+
+ if(!isV1parallel)
+ {
+ aDelta = u1 - aU1bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u1 = aU1bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aU1bLast - u1;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u1 = aU1bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isV2parallel)
+ {
+ aDelta = u2 - aU2bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u2 = aU2bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aU2bLast - u2;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ u2 = aU2bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isU1parallel)
+ {
+ aDelta = v1 - aV1bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v1 = aV1bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aV1bLast - v1;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v1 = aV1bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(!isU2parallel)
+ {
+ aDelta = v2 - aV2bFirst;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v2 = aV2bFirst - aDelta;
+ isNeedAdding = Standard_True;
+ }
+ else
+ {
+ aDelta = aV2bLast - v2;
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ v2 = aV2bLast + aDelta;
+ isNeedAdding = Standard_True;
+ }
+ }
+ }
+
+ if(isNeedAdding)
+ {
+ hasBeenAdded =
+ SeekPointOnBoundary(theASurf1, theASurf2, u1,
+ v1, u2, v2, Standard_False);
+ }
+
+ return hasBeenAdded;
+}
+
+//=======================================================================
+//function : SeekAdditionalPoints
+//purpose :
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+SeekAdditionalPoints( const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ const Standard_Integer theMinNbPoints)
+{
+ const Standard_Real aTol = 1.0e-14;
+ Standard_Integer aNbPoints = line->NbPoints();
+ if(aNbPoints > theMinNbPoints)
+ return Standard_True;
+
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+
+ Standard_Boolean isPrecise = Standard_False;
+
+ Standard_Real U1prec = 0.0, V1prec = 0.0, U2prec = 0.0, V2prec = 0.0;
+
+ Standard_Integer aNbPointsPrev = 0;
+ while(aNbPoints < theMinNbPoints && (aNbPoints != aNbPointsPrev))
+ {
+ aNbPointsPrev = aNbPoints;
+ for(Standard_Integer fp = 1, lp = 2; fp < aNbPoints; fp = lp + 1)
+ {
+ Standard_Real U1f, V1f, U2f, V2f; //first point in 1st and 2nd surafaces
+ Standard_Real U1l, V1l, U2l, V2l; //last point in 1st and 2nd surafaces
+
+ lp = fp+1;
+ line->Value(fp).Parameters(U1f, V1f, U2f, V2f);
+ line->Value(lp).Parameters(U1l, V1l, U2l, V2l);
+
+ U1prec = 0.5*(U1f+U1l);
+ if(U1prec < aU1bFirst)
+ U1prec = aU1bFirst;
+ if(U1prec > aU1bLast)
+ U1prec = aU1bLast;
+
+ V1prec = 0.5*(V1f+V1l);
+ if(V1prec < aV1bFirst)
+ V1prec = aV1bFirst;
+ if(V1prec > aV1bLast)
+ V1prec = aV1bLast;
+
+ U2prec = 0.5*(U2f+U2l);
+ if(U2prec < aU2bFirst)
+ U2prec = aU2bFirst;
+ if(U2prec > aU2bLast)
+ U2prec = aU2bLast;
+
+ V2prec = 0.5*(V2f+V2l);
+ if(V2prec < aV2bFirst)
+ V2prec = aV2bFirst;
+ if(V2prec > aV2bLast)
+ V2prec = aV2bLast;
+
+ Standard_Boolean aStatus = Standard_False;
+ Standard_Integer aNbIter = 5;
+ do
+ {
+ aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+ }
+ while(!aStatus && (--aNbIter > 0));
+
+ if(aStatus)
+ {
+ gp_Pnt aP1 = theASurf1->Value(U1prec, V1prec),
+ aP2 = theASurf2->Value(U2prec, V2prec);
+ gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+ const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+ aSQDist2 = aPInt.SquareDistance(aP2);
+
+ if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+ {
+ IntSurf_PntOn2S anIP;
+ anIP.SetValue(aPInt, U1prec, V1prec, U2prec, V2prec);
+ line->InsertBefore(lp, anIP);
+
+ isPrecise = Standard_True;
+
+ if(++aNbPoints >= theMinNbPoints)
+ break;
+ }
+ else
+ {
+ lp--;
+ }
+ }
+ }
+ }
+
+ return isPrecise;
+}
+
+void IntWalk_PWalking::
+RepartirOuDiviser(Standard_Boolean& DejaReparti,
+ IntImp_ConstIsoparametric& ChoixIso,
+ Standard_Boolean& Arrive)
+
+ // at the neighborhood of a point, there is a fail of marching
+ // it is required to divide the steps to try to continue
+ // if the step is too small if we are on border
+ // restart in another direction if it was not done, otherwise stop
+
+{
+ // Standard_Integer i;
+ if (Arrive) { //restart in the other direction
+ if (!DejaReparti ) {
+ Arrive = Standard_False;
+ DejaReparti = Standard_True;
+ previousPoint = line->Value(1);
+ previoustg = Standard_False;
+ previousd1 = firstd1;
+ previousd2 = firstd2;
+ previousd = tgdir;
+ indextg = line->NbPoints();
+ tgdir.Reverse();
+ line->Reverse();
+
+ //-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
+ sensCheminement = -1;
+ tgfirst = tglast;
+ tglast = Standard_False;
+ ChoixIso = choixIsoSav;
+#if 0
+ pasuv[0]=pasSav[0];
+ pasuv[1]=pasSav[1];
+ pasuv[2]=pasSav[2];
+ pasuv[3]=pasSav[3];
+#else
+ Standard_Real u1,v1,u2,v2;
+ Standard_Real U1,V1,U2,V2;
+ Standard_Integer nn=line->NbPoints();
+ if(nn>2) {
+ line->Value(nn).Parameters(u1,v1,u2,v2);
+ line->Value(nn-1).Parameters(U1,V1,U2,V2);
+ pasuv[0]=Abs(u1-U1);
+ pasuv[1]=Abs(v1-V1);
+ pasuv[2]=Abs(u2-U2);
+ pasuv[3]=Abs(v2-V2);
+ }
+#endif
+
+ }
+ }
+ else {
+ if ( pasuv[0]*0.5 < ResoU1
+ && pasuv[1]*0.5 < ResoV1
+ && pasuv[2]*0.5 < ResoU2
+ && pasuv[3]*0.5 < ResoV2
+ ) {
+ if (!previoustg) {
+ tglast = Standard_True; // IS IT ENOUGH ????
+ }
+
+ if (!DejaReparti) { //restart in the other direction
+ DejaReparti = Standard_True;
+ previousPoint = line->Value(1);
+ previoustg = Standard_False;
+ previousd1 = firstd1;
+ previousd2 = firstd2;
+ previousd = tgdir;
+ indextg = line->NbPoints();
+ tgdir.Reverse();
+ line->Reverse();
+
+ //-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
+
+ sensCheminement = -1;
+ tgfirst = tglast;
+ tglast = Standard_False;
+ ChoixIso = choixIsoSav;
+
+#if 0
+ pasuv[0]=pasSav[0];
+ pasuv[1]=pasSav[1];
+ pasuv[2]=pasSav[2];
+ pasuv[3]=pasSav[3];
+#else
+ Standard_Real u1,v1,u2,v2;
+ Standard_Real U1,V1,U2,V2;
+ Standard_Integer nn=line->NbPoints();
+ if(nn>2) {
+ line->Value(nn).Parameters(u1,v1,u2,v2);
+ line->Value(nn-1).Parameters(U1,V1,U2,V2);
+ pasuv[0]=Abs(u1-U1);
+ pasuv[1]=Abs(v1-V1);
+ pasuv[2]=Abs(u2-U2);
+ pasuv[3]=Abs(v2-V2);
+ }
+#endif
+ }
+ else Arrive = Standard_True;
+ }
+ else {
+ pasuv[0]*=0.5;
+ pasuv[1]*=0.5;
+ pasuv[2]*=0.5;
+ pasuv[3]*=0.5;
+ }
+ }
+}
+
+namespace {
+ //OCC431(apo): modified ->
+ static const Standard_Real CosRef2D = Cos(M_PI/9.0), AngRef2D = M_PI/2.0;
+
+ static const Standard_Real d = 7.0;
+}
+
+IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection()
+
+// test if vector is observed by calculating an increase of vector
+// or the previous point and its tangent, the new calculated point and its
+// tangent; it is possible to find a cube passing by the 2 points and having as a
+// derivative the tangents of the intersection
+// calculate the point with parameter 0.5 on cube=p1
+// calculate the medium point of 2 points of intersection=p2
+// if arrow/2<=||p1p2||<= arrow consider that the vector is observed
+// otherwise adjust the step depending on the ratio ||p1p2||/vector
+// and the previous step
+// test if in 2 tangent planes of surfaces there is no too great angle2d
+// grand : if yes divide the step
+// test if there is no change of side
+//
+{
+ if(line->NbPoints() ==1 ) {
+ STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=STATIC_PRECEDENT_INFLEXION=0;
+ }
+
+ IntWalk_StatusDeflection Status = IntWalk_OK;
+ Standard_Real FlecheCourante ,Ratio;
+
+
+ const IntSurf_PntOn2S& CurrentPoint = myIntersectionOn2S.Point();
+ //==================================================================================
+ //========= S t o p o n p o i n t ============
+ //==================================================================================
+ if (myIntersectionOn2S.IsTangent()) {
+ return IntWalk_ArretSurPoint;
+ }
+
+ const gp_Dir& TgCourante = myIntersectionOn2S.Direction();
+
+ //==================================================================================
+ //========= R i s k o f i n f l e x i o n p o i n t ============
+ //==================================================================================
+ if (TgCourante.Dot(previousd)<0) {
+ //------------------------------------------------------------
+ //-- Risk of inflexion point : Divide the step by 2
+ //-- Initialize STATIC_PRECEDENT_INFLEXION so that
+ //-- at the next call to return Pas_OK if there is no
+ //-- more risk of the point of inflexion
+ //------------------------------------------------------------
+
+ pasuv[0]*=0.5;
+ pasuv[1]*=0.5;
+ pasuv[2]*=0.5;
+ pasuv[3]*=0.5;
+ STATIC_PRECEDENT_INFLEXION+=3;
+ if (pasuv[0] < ResoU1 && pasuv[1] <ResoV1 && pasuv[2] <ResoU2 && pasuv[3] < ResoV2)
+ return IntWalk_ArretSurPointPrecedent;
+ else
+ return IntWalk_PasTropGrand;
+ }
+
+ else {
+ if(STATIC_PRECEDENT_INFLEXION > 0) {
+ STATIC_PRECEDENT_INFLEXION -- ;
+ return IntWalk_OK;
+ }
+ }
+
+ //==================================================================================
+ //========= D e t e c t c o n f u s e d P o in t s ===========
+ //==================================================================================
+
+ Standard_Real Dist = previousPoint.Value().
+ SquareDistance(CurrentPoint.Value());
+
+
+ if (Dist < tolconf*tolconf ) {
+ pasuv[0] = Max(5.*ResoU1,Min(1.5*pasuv[0],pasInit[0]));
+ pasuv[1] = Max(5.*ResoV1,Min(1.5*pasuv[1],pasInit[1]));
+ pasuv[2] = Max(5.*ResoU2,Min(1.5*pasuv[2],pasInit[2]));
+ pasuv[3] = Max(5.*ResoV2,Min(1.5*pasuv[3],pasInit[3]));
+ Status = IntWalk_PointConfondu;
+ }
+
+ //==================================================================================
+ Standard_Real Up1,Vp1,Uc1,Vc1,Du1,Dv1,AbsDu1,AbsDu2,AbsDv1,AbsDv2;
+ Standard_Real Up2,Vp2,Uc2,Vc2,Du2,Dv2;
+
+ previousPoint.Parameters(Up1,Vp1,Up2,Vp2);
+ CurrentPoint.Parameters(Uc1,Vc1,Uc2,Vc2);
+
+ Du1 = Uc1 - Up1; Dv1 = Vc1 - Vp1;
+ Du2 = Uc2 - Up2; Dv2 = Vc2 - Vp2;
+
+ AbsDu1 = Abs(Du1);
+ AbsDu2 = Abs(Du2);
+ AbsDv1 = Abs(Dv1);
+ AbsDv2 = Abs(Dv2);
+ //=================================================================================
+ //==== S t e p o f p r o g r e s s i o n (between previous and Current) =======
+ //=================================================================================
+ if ( AbsDu1 < ResoU1 && AbsDv1 < ResoV1
+ && AbsDu2 < ResoU2 && AbsDv2 < ResoV2) {
+ pasuv[0] = ResoU1; pasuv[1] = ResoV1; pasuv[2] = ResoU2; pasuv[3] = ResoV2;
+ return(IntWalk_ArretSurPointPrecedent);
+ }
+ //==================================================================================
+
+ Standard_Real tolArea = 100.0;
+ if (ResoU1 < Precision::PConfusion() ||
+ ResoV1 < Precision::PConfusion() ||
+ ResoU2 < Precision::PConfusion() ||
+ ResoV2 < Precision::PConfusion() )
+ tolArea = tolArea*2.0;
+
+ Standard_Real Cosi1, CosRef1, Ang1, AngRef1, ResoUV1, Duv1, d1, tolCoeff1;
+ Standard_Real Cosi2, CosRef2, Ang2, AngRef2, ResoUV2, Duv2, d2, tolCoeff2;
+ Cosi1 = Du1*previousd1.X() + Dv1*previousd1.Y();
+ Cosi2 = Du2*previousd2.X() + Dv2*previousd2.Y();
+ Duv1 = Du1*Du1 + Dv1*Dv1;
+ Duv2 = Du2*Du2 + Dv2*Dv2;
+ ResoUV1 = ResoU1*ResoU1 + ResoV1*ResoV1;
+ ResoUV2 = ResoU2*ResoU2 + ResoV2*ResoV2;
+ //
+ //modified by NIZNHY-PKV Wed Nov 13 12:25:44 2002 f
+ //
+ Standard_Real aMinDiv2=Precision::Confusion();
+ aMinDiv2=aMinDiv2*aMinDiv2;
+ //
+ d1=d;
+ if (Duv1>aMinDiv2) {
+ d1 = Abs(ResoUV1/Duv1);
+ d1 = Min(Sqrt(d1)*tolArea, d);
+ }
+ //d1 = Abs(ResoUV1/Duv1);
+ //d1 = Min(Sqrt(d1)*tolArea,d);
+ //modified by NIZNHY-PKV Wed Nov 13 12:34:30 2002 t
+ tolCoeff1 = Exp(d1);
+ //
+ //modified by NIZNHY-PKV Wed Nov 13 12:34:43 2002 f
+ d2=d;
+ if (Duv2>aMinDiv2) {
+ d2 = Abs(ResoUV2/Duv2);
+ d2 = Min(Sqrt(d2)*tolArea,d);
+ }
+ //d2 = Abs(ResoUV2/Duv2);
+ //d2 = Min(Sqrt(d2)*tolArea,d);
+ //modified by NIZNHY-PKV Wed Nov 13 12:34:53 2002 t
+ tolCoeff2 = Exp(d2);
+ CosRef1 = CosRef2D/tolCoeff1;
+ CosRef2 = CosRef2D/tolCoeff2;
+ //
+ //==================================================================================
+ //== The points are not confused : ==
+ //== D e t e c t t h e S t o p a t p r e v i o u s p o i n t ==
+ //== N o t T o o G r e a t (angle in space UV) ==
+ //== C h a n g e o f s i d e ==
+ //==================================================================================
+ if (Status != IntWalk_PointConfondu) {
+ if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2) {
+ pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
+ if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2) {
+ return(IntWalk_ArretSurPointPrecedent);
+ }
+ else {
+ pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
+ return(IntWalk_PasTropGrand);
+ }
+ }
+ const gp_Dir2d& Tg2dcourante1 = myIntersectionOn2S.DirectionOnS1();
+ const gp_Dir2d& Tg2dcourante2 = myIntersectionOn2S.DirectionOnS2();
+ Cosi1 = Du1*Tg2dcourante1.X() + Dv1*Tg2dcourante1.Y();
+ Cosi2 = Du2*Tg2dcourante2.X() + Dv2*Tg2dcourante2.Y();
+ Ang1 = Abs(previousd1.Angle(Tg2dcourante1));
+ Ang2 = Abs(previousd2.Angle(Tg2dcourante2));
+ AngRef1 = AngRef2D*tolCoeff1;
+ AngRef2 = AngRef2D*tolCoeff2;
+ //-------------------------------------------------------
+ //-- Test : Angle too great in space UV -----
+ //-- Change of side -----
+ //-------------------------------------------------------
+ if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2 || Ang1 > AngRef1 || Ang2 > AngRef2) {
+ pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
+ if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2)
+ return(IntWalk_ArretSurPoint);
+ else
+ return(IntWalk_PasTropGrand);
+ }
+ }
+ //<-OCC431(apo)
+ //==================================================================================
+ //== D e t e c t i o n o f : Step Too Small
+ //== STEP TOO Great
+ //==================================================================================
+
+ //---------------------------------------
+ //-- Estimate of the vector --
+ //---------------------------------------
+ FlecheCourante =
+ Sqrt(Abs((previousd.XYZ()-TgCourante.XYZ()).SquareModulus()*Dist))/8.;
+
+ if ( FlecheCourante<= fleche*0.5) { //-- Current step too small
+ if(FlecheCourante>1e-16) {
+ Ratio = 0.5*(fleche/FlecheCourante);
+ }
+ else {
+ Ratio = 10.0;
+ }
+ Standard_Real pasSu1 = pasuv[0];
+ Standard_Real pasSv1 = pasuv[1];
+ Standard_Real pasSu2 = pasuv[2];
+ Standard_Real pasSv2 = pasuv[3];
+
+ //-- In case if
+ //-- a point at U+DeltaU is required, ....
+ //-- return a point at U + Epsilon
+ //-- Epsilon << DeltaU.
+
+ if(pasuv[0]< AbsDu1) pasuv[0] = AbsDu1;
+ if(pasuv[1]< AbsDv1) pasuv[1] = AbsDv1;
+ if(pasuv[2]< AbsDu2) pasuv[2] = AbsDu2;
+ if(pasuv[3]< AbsDv2) pasuv[3] = AbsDv2;
+
+ if(pasuv[0]<ResoU1) pasuv[0]=ResoU1;
+ if(pasuv[1]<ResoV1) pasuv[1]=ResoV1;
+ if(pasuv[2]<ResoU2) pasuv[2]=ResoU2;
+ if(pasuv[3]<ResoV2) pasuv[3]=ResoV2;
+ //-- if(Ratio>10.0 ) { Ratio=10.0; }
+ Standard_Real R1,R = pasInit[0]/pasuv[0];
+ R1= pasInit[1]/pasuv[1]; if(R1<R) R=R1;
+ R1= pasInit[2]/pasuv[2]; if(R1<R) R=R1;
+ R1= pasInit[3]/pasuv[3]; if(R1<R) R=R1;
+ if(Ratio > R) Ratio=R;
+ pasuv[0] = Min(Ratio*pasuv[0],pasInit[0]);
+ pasuv[1] = Min(Ratio*pasuv[1],pasInit[1]);
+ pasuv[2] = Min(Ratio*pasuv[2],pasInit[2]);
+ pasuv[3] = Min(Ratio*pasuv[3],pasInit[3]);
+ if (pasuv[0] != pasSu1 || pasuv[2] != pasSu2||
+ pasuv[1] != pasSv1 || pasuv[3] != pasSv2) {
+ if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
+ STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
+ return IntWalk_PasTropGrand;
+ }
+ }
+ if(Status == IntWalk_OK) {
+ STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
+ //-- Try to increase the step
+ }
+ return Status;
+ }
+ else { //-- CurrentVector > vector*0.5
+ if (FlecheCourante > fleche) { //-- Current step too Great
+ Ratio = fleche/FlecheCourante;
+ pasuv[0] = Ratio*pasuv[0];
+ pasuv[1] = Ratio*pasuv[1];
+ pasuv[2] = Ratio*pasuv[2];
+ pasuv[3] = Ratio*pasuv[3];
+ //if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
+ // STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
+ return IntWalk_PasTropGrand;
+ //}
+ }
+ else { //-- vector/2 < CurrentVector <= vector
+ Ratio = 0.75 * (fleche / FlecheCourante);
+ }
+ }
+ pasuv[0] = Max(5.*ResoU1,Min(Min(Ratio*AbsDu1,pasuv[0]),pasInit[0]));
+ pasuv[1] = Max(5.*ResoV1,Min(Min(Ratio*AbsDv1,pasuv[1]),pasInit[1]));
+ pasuv[2] = Max(5.*ResoU2,Min(Min(Ratio*AbsDu2,pasuv[2]),pasInit[2]));
+ pasuv[3] = Max(5.*ResoV2,Min(Min(Ratio*AbsDv2,pasuv[3]),pasInit[3]));
+ if(Status == IntWalk_OK) STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
+ return Status;
+}
+
+Standard_Boolean IntWalk_PWalking::
+TestArret(const Standard_Boolean DejaReparti,
+ TColStd_Array1OfReal& Param,
+ IntImp_ConstIsoparametric& ChoixIso)
+
+ //
+ // test if the point of intersection set by these parameters remains in the
+ // natural domain of each square.
+ // if the point outpasses reframe to find the best iso (border)
+ // that intersects easiest the other square
+ // otherwise test if closed line is present
+ //
+{
+ Standard_Real Uvd[4],Uvf[4],Epsuv[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
+ Standard_Real DPc,DPb;
+ Standard_Integer i = 0, k = 0;
+ Epsuv[0] = ResoU1;
+ Epsuv[1] = ResoV1;
+ Epsuv[2] = ResoU2;
+ Epsuv[3] = ResoV2;
+ previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
+
+ Standard_Real SolParam[4];
+ myIntersectionOn2S.Point().Parameters(SolParam[0],SolParam[1],SolParam[2],SolParam[3]);
+
+ Standard_Boolean Trouve = Standard_False;
+
+ Uvd[0]=Um1; Uvf[0]=UM1; Uvd[1]=Vm1; Uvf[1]=VM1;
+ Uvd[2]=Um2; Uvf[2]=UM2; Uvd[3]=Vm2; Uvf[3]=VM2;
+
+ Standard_Integer im1;
+ for ( i = 1,im1 = 0;i<=4;i++,im1++) {
+ switch(i) {
+ case 1: k=2; break;
+ case 2: k=1; break;
+ case 3: k=4; break;
+ case 4: k=3; break;
+ }
+ if (Param(i) < (Uvd[im1]-Epsuv[im1]) ||
+ SolParam[im1] < (Uvd[im1]-Epsuv[im1])) //-- Current ----- Bound Inf ----- Previous
+ {
+ Trouve = Standard_True; //--
+ DPc = Uvp[im1]-Param(i); //-- Previous - Current
+ DPb = Uvp[im1]-Uvd[im1]; //-- Previous - Bound Inf
+ ParC[im1] = Uvd[im1]; //-- ParamCorrige
+ dv = Param(k)-Uvp[k-1]; //-- Current - Previous (other Direction)
+ dv2 = dv*dv;
+ if(dv2>RealEpsilon()) { //-- Progress at the other Direction ?
+ Duv[im1] = DPc*DPb + dv2;
+ Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
+ }
+ else {
+ Duv[im1]=-1.0; //-- If no progress, do not change
+ } //-- the choice of iso
+ }
+ else if (Param(i) > (Uvf[im1] + Epsuv[im1]) ||
+ SolParam[im1] > (Uvf[im1] + Epsuv[im1]))//-- Previous ----- Bound Sup ----- Current
+ {
+ Trouve = Standard_True; //--
+ DPc = Param(i)-Uvp[im1]; //-- Current - Previous
+ DPb = Uvf[im1]-Uvp[im1]; //-- Bound Sup - Previous
+ ParC[im1] = Uvf[im1]; //-- Param Corrige
+ dv = Param(k)-Uvp[k-1]; //-- Current - Previous (other Direction)
+ dv2 = dv*dv;
+ if(dv2>RealEpsilon()) { //-- Progress in other Direction ?
+ Duv[im1] = DPc*DPb + dv2;
+ Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
+ }
+ else {
+ Duv[im1]=-1.0; //-- If no progress, do not change
+ } //-- the choice of iso
+ }
+ else {
+ Duv[im1]= -1.;
+ ParC[im1]=Param(i);
+ }
+ }
+
+ if (Trouve) {
+ //--------------------------------------------------
+ //-- One of Parameters u1,v1,u2,v2 is outside of --
+ //-- the natural limits. --
+ //-- Find the best direction of --
+ //-- progress and reframe the parameters. --
+ //--------------------------------------------------
+ Standard_Real ddv = -1.0;
+ k=-1;
+ for (i=0;i<=3;i++) {
+ Param(i+1) = ParC[i];
+ if(Duv[i]>ddv) {
+ ddv = Duv[i];
+ k=i;
+ }
+ }
+ if(k!=-1) {
+ ChoixIso = ChoixRef[k];
+ }
+ else {
+ if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
+ ChoixIso = IntImp_UIsoparametricOnCaro1;
+ }
+ else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
+ ChoixIso = IntImp_VIsoparametricOnCaro1;
+ }
+ else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
+ ChoixIso = IntImp_UIsoparametricOnCaro2;
+ }
+ else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
+ ChoixIso = IntImp_VIsoparametricOnCaro2;
+ }
+ }
+ close = Standard_False;
+ return Standard_True;
+ }
+ else
+ {
+ if (!DejaReparti) { // find if line closed
+
+ Standard_Real u,v;
+ const IntSurf_PntOn2S& POn2S1=line->Value(1);
+ //On S1
+ POn2S1.ParametersOnS1(u,v);
+ gp_Pnt2d P1uvS1(u,v);
+ previousPoint.ParametersOnS1(u,v);
+ gp_Pnt2d PrevuvS1(u,v);
+ myIntersectionOn2S.Point().ParametersOnS1(u,v);
+ gp_Pnt2d myIntersuvS1(u,v);
+ Standard_Boolean close2dS1 = (P1uvS1.XY()-PrevuvS1.XY())*
+ (P1uvS1.XY()-myIntersuvS1.XY()) < 0.0;
+ //On S2
+ POn2S1.ParametersOnS2(u,v);
+ gp_Pnt2d P1uvS2(u,v);
+ previousPoint.ParametersOnS2(u,v);
+ gp_Pnt2d PrevuvS2(u,v);
+ myIntersectionOn2S.Point().ParametersOnS2(u,v);
+ gp_Pnt2d myIntersuvS2(u,v);
+ Standard_Boolean close2dS2 = (P1uvS2.XY()-PrevuvS2.XY())*
+ (P1uvS2.XY()-myIntersuvS2.XY()) < 0.0;
+
+ close = close2dS1 && close2dS2;
+ return close;
+ }
+ else return Standard_False;
+ }
+}
+
+++ /dev/null
-// Copyright (c) 1995-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 <IntWalk_StatusDeflection.hxx>
-
-#include <TColgp_Array1OfPnt.hxx>
-#include <IntImp_ComputeTangence.hxx>
-#include <TColStd_Array1OfReal.hxx>
-
-#include <IntWalk_PWalking_1.gxx>
-#include <IntWalk_PWalking_2.gxx>
-#include <IntWalk_PWalking_3.gxx>
-#include <IntWalk_PWalking_4.gxx>
+++ /dev/null
-// Copyright (c) 1995-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.
-
-//-----------------------------
-//-- IntWalk_PWalking_1.gxx
-//--
-
-#include <Precision.hxx>
-#include <math_FunctionSetRoot.hxx>
-
-#include <Geom_Surface.hxx>
-
-//#define KELARG 20.0
-
-//==================================================================================
-// function : IntWalk_PWalking::IntWalk_PWalking
-// purpose :
-// estimate of max step : To avoid abrupt changes
-// during change of isos
-//==================================================================================
-void ComputePasInit(Standard_Real *pasuv,
- Standard_Real Um1,Standard_Real UM1,
- Standard_Real Vm1,Standard_Real VM1,
- Standard_Real Um2,Standard_Real UM2,
- Standard_Real Vm2,Standard_Real VM2,
- Standard_Real _Um1,Standard_Real _UM1,
- Standard_Real _Vm1,Standard_Real _VM1,
- Standard_Real _Um2,Standard_Real _UM2,
- Standard_Real _Vm2,Standard_Real _VM2,
- const ThePSurface& ,
- const ThePSurface& ,
- const Standard_Real Increment)
-{
- Standard_Real du1=Abs(UM1-Um1);
- Standard_Real dv1=Abs(VM1-Vm1);
- Standard_Real du2=Abs(UM2-Um2);
- Standard_Real dv2=Abs(VM2-Vm2);
-
- Standard_Real _du1=Abs(_UM1-_Um1);
- Standard_Real _dv1=Abs(_VM1-_Vm1);
- Standard_Real _du2=Abs(_UM2-_Um2);
- Standard_Real _dv2=Abs(_VM2-_Vm2);
-
- //-- limit the reduction of uv box estimate to 0.01 natural box
- //-- du1 : On box of Inter
- //-- _du1 : On parametric space
- if(_du1<1e50 && du1<0.01*_du1) du1=0.01*_du1;
- if(_dv1<1e50 && dv1<0.01*_dv1) dv1=0.01*_dv1;
- if(_du2<1e50 && du2<0.01*_du2) du2=0.01*_du2;
- if(_dv2<1e50 && dv2<0.01*_dv2) dv2=0.01*_dv2;
-
- pasuv[0]=Increment*du1;
- pasuv[1]=Increment*dv1;
- pasuv[2]=Increment*du2;
- pasuv[3]=Increment*dv2;
-}
-
-//=======================================================================
-//function : IsParallel
-//purpose : Checks if theLine is parallel of some boundary of given
-// surface (it is determined by theCheckSurf1 flag).
-// Parallelism assumes small oscillations (swing is less or
-// equal than theToler).
-// Small lines (if first and last parameters in the Surface
-// are almost equal) are classified as parallel (as same as
-// any point can be considered as parallel of any line).
-//=======================================================================
-static void IsParallel(const Handle(IntSurf_LineOn2S)& theLine,
- const Standard_Boolean theCheckSurf1,
- const Standard_Real theToler,
- Standard_Boolean& theIsUparallel,
- Standard_Boolean& theIsVparallel)
-{
- const Standard_Integer aNbPointsMAX = 23;
-
- theIsUparallel = theIsVparallel = Standard_True;
-
- Standard_Integer aNbPoints = theLine->NbPoints();
- if(aNbPoints > aNbPointsMAX)
- {
- aNbPoints = aNbPointsMAX;
- }
- else if(aNbPoints < 3)
- {
- //Here we cannot estimate parallelism.
- //Do all same as for small lines
- return;
- }
-
- Standard_Real aStep = IntToReal(theLine->NbPoints()) / aNbPoints;
- Standard_Real aNPoint = 1.0;
-
- Standard_Real aUmin = RealLast(), aUmax = RealFirst(), aVmin = RealLast(), aVmax = RealFirst();
- for(Standard_Integer aNum = 1; aNum <= aNbPoints; aNum++, aNPoint += aStep)
- {
- if(aNPoint > aNbPoints)
- {
- aNPoint = aNbPoints;
- }
-
- Standard_Real u, v;
- if(theCheckSurf1)
- theLine->Value(RealToInt(aNPoint)).ParametersOnS1(u, v);
- else
- theLine->Value(RealToInt(aNPoint)).ParametersOnS2(u, v);
-
- if(u < aUmin)
- aUmin = u;
-
- if(u > aUmax)
- aUmax = u;
-
- if(v < aVmin)
- aVmin = v;
-
- if(v > aVmax)
- aVmax = v;
- }
-
- theIsVparallel = ((aUmax - aUmin) < theToler);
- theIsUparallel = ((aVmax - aVmin) < theToler);
-}
-
-//=======================================================================
-//function : Checking
-//purpose : Check, if given point is in surface's boundaries.
-// If "yes" then theFactTol = 0.0, else theFactTol is
-// equal maximal deviation.
-//=======================================================================
-static Standard_Boolean Checking( const Handle(Adaptor3d_HSurface)& theASurf1,
- const Handle(Adaptor3d_HSurface)& theASurf2,
- Standard_Real& theU1,
- Standard_Real& theV1,
- Standard_Real& theU2,
- Standard_Real& theV2,
- Standard_Real& theFactTol)
-{
- const Standard_Real aTol = Precision::PConfusion();
- const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
- const Standard_Real aU1bLast = theASurf1->LastUParameter();
- const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
- const Standard_Real aU2bLast = theASurf2->LastUParameter();
- const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
- const Standard_Real aV1bLast = theASurf1->LastVParameter();
- const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
- const Standard_Real aV2bLast = theASurf2->LastVParameter();
-
- Standard_Boolean isOnOrIn = Standard_True;
- theFactTol = 0.0;
-
- Standard_Real aDelta = aU1bFirst - theU1;
- if(aDelta > aTol)
- {
- theU1 = aU1bFirst;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = theU1 - aU1bLast;
- if(aDelta > aTol)
- {
- theU1 = aU1bLast;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = aV1bFirst - theV1;
- if(aDelta > aTol)
- {
- theV1 = aV1bFirst;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = theV1 - aV1bLast;
- if(aDelta > aTol)
- {
- theV1 = aV1bLast;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = aU2bFirst - theU2;
- if(aDelta > aTol)
- {
- theU2 = aU2bFirst;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = theU2 - aU2bLast;
- if(aDelta > aTol)
- {
- theU2 = aU2bLast;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = aV2bFirst - theV2;
- if(aDelta > aTol)
- {
- theV2 = aV2bFirst;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- aDelta = theV2 - aV2bLast;
- if(aDelta > aTol)
- {
- theV2 = aV2bLast;
- theFactTol = Max(theFactTol, aDelta);
- isOnOrIn = Standard_False;
- }
-
- return isOnOrIn;
-}
-
-//==================================================================================
-// function : IntWalk_PWalking::IntWalk_PWalking
-// purpose :
-//==================================================================================
-IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
- const ThePSurface& Caro2,
- const Standard_Real TolTangency,
- const Standard_Real Epsilon,
- const Standard_Real Deflection,
- const Standard_Real Increment )
- :
-
-done(Standard_True),
-close(Standard_False),
-fleche(Deflection),
-tolconf(Epsilon),
-sensCheminement(1),
-myIntersectionOn2S(Caro1,Caro2,TolTangency),
-STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-STATIC_PRECEDENT_INFLEXION(0)
-{
- Standard_Real KELARG=20.;
- //
- pasMax=Increment*0.2; //-- June 25 99 after problems with precision
- Um1 = ThePSurfaceTool::FirstUParameter(Caro1);
- Vm1 = ThePSurfaceTool::FirstVParameter(Caro1);
- UM1 = ThePSurfaceTool::LastUParameter(Caro1);
- VM1 = ThePSurfaceTool::LastVParameter(Caro1);
-
- Um2 = ThePSurfaceTool::FirstUParameter(Caro2);
- Vm2 = ThePSurfaceTool::FirstVParameter(Caro2);
- UM2 = ThePSurfaceTool::LastUParameter(Caro2);
- VM2 = ThePSurfaceTool::LastVParameter(Caro2);
-
- ResoU1 = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
- ResoV1 = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
-
- ResoU2 = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
- ResoV2 = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
-
- Standard_Real NEWRESO;
- Standard_Real MAXVAL;
- Standard_Real MAXVAL2;
- //
- MAXVAL = Abs(Um1); MAXVAL2 = Abs(UM1);
- if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
- NEWRESO = ResoU1 * MAXVAL ;
- if(NEWRESO > ResoU1 &&NEWRESO<10) { ResoU1 = NEWRESO; }
-
-
- MAXVAL = Abs(Um2); MAXVAL2 = Abs(UM2);
- if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
- NEWRESO = ResoU2 * MAXVAL ;
- if(NEWRESO > ResoU2 && NEWRESO<10) { ResoU2 = NEWRESO; }
-
-
- MAXVAL = Abs(Vm1); MAXVAL2 = Abs(VM1);
- if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
- NEWRESO = ResoV1 * MAXVAL ;
- if(NEWRESO > ResoV1 && NEWRESO<10) { ResoV1 = NEWRESO; }
-
-
- MAXVAL = Abs(Vm2); MAXVAL2 = Abs(VM2);
- if(MAXVAL2 > MAXVAL) MAXVAL = MAXVAL2;
- NEWRESO = ResoV2 * MAXVAL ;
- if(NEWRESO > ResoV2 && NEWRESO<10) { ResoV2 = NEWRESO; }
-
- pasuv[0]=pasMax*Abs(UM1-Um1);
- pasuv[1]=pasMax*Abs(VM1-Vm1);
- pasuv[2]=pasMax*Abs(UM2-Um2);
- pasuv[3]=pasMax*Abs(VM2-Vm2);
-
- if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
- if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
- if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
- if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
-
-
- if(ThePSurfaceTool::IsUPeriodic(Caro1)==Standard_False) {
- //UM1+=KELARG*pasuv[0]; Um1-=KELARG*pasuv[0];
- }
- else {
- Standard_Real t = UM1-Um1;
- if(t<ThePSurfaceTool::UPeriod(Caro1)) {
- t=0.5*(ThePSurfaceTool::UPeriod(Caro1)-t);
- t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
- UM1+=t; Um1-=t;
- }
- }
-
- if(ThePSurfaceTool::IsVPeriodic(Caro1)==Standard_False) {
- //VM1+=KELARG*pasuv[1]; Vm1-=KELARG*pasuv[1];
- }
- else {
- Standard_Real t = VM1-Vm1;
- if(t<ThePSurfaceTool::VPeriod(Caro1)) {
- t=0.5*(ThePSurfaceTool::VPeriod(Caro1)-t);
- t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
- VM1+=t; Vm1-=t;
- }
- }
-
- if(ThePSurfaceTool::IsUPeriodic(Caro2)==Standard_False) {
- //UM2+=KELARG*pasuv[2]; Um2-=KELARG*pasuv[2];
- }
- else {
- Standard_Real t = UM2-Um2;
- if(t<ThePSurfaceTool::UPeriod(Caro2)) {
- t=0.5*(ThePSurfaceTool::UPeriod(Caro2)-t);
- t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
- UM2+=t; Um2-=t;
- }
- }
-
- if(ThePSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {
- //VM2+=KELARG*pasuv[3]; Vm2-=KELARG*pasuv[3];
- }
- else {
- Standard_Real t = VM2-Vm2;
- if(t<ThePSurfaceTool::VPeriod(Caro2)) {
- t=0.5*(ThePSurfaceTool::VPeriod(Caro2)-t);
- t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
- VM2+=t; Vm2-=t;
- }
- }
-
- //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
-
- for (Standard_Integer i = 0; i<=3;i++) {
- if(pasuv[i]>10)
- pasuv[i] = 10;
- pasInit[i] = pasSav[i] = pasuv[i];
- }
-
-
-}
-//==================================================================================
-// function : IntWalk_PWalking
-// purpose :
-//==================================================================================
-IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
- const ThePSurface& Caro2,
- const Standard_Real TolTangency,
- const Standard_Real Epsilon,
- const Standard_Real Deflection,
- const Standard_Real Increment,
- const Standard_Real U1,
- const Standard_Real V1,
- const Standard_Real U2,
- const Standard_Real V2)
- :
-
-done(Standard_True),
-close(Standard_False),
-fleche(Deflection),
-tolconf(Epsilon),
-sensCheminement(1),
-myIntersectionOn2S(Caro1,Caro2,TolTangency),
-STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-STATIC_PRECEDENT_INFLEXION(0)
-{
- Standard_Real KELARG=20.;
- //
- pasMax=Increment*0.2; //-- June 25 99 after problems with precision
- //
- Um1 = ThePSurfaceTool::FirstUParameter(Caro1);
- Vm1 = ThePSurfaceTool::FirstVParameter(Caro1);
- UM1 = ThePSurfaceTool::LastUParameter(Caro1);
- VM1 = ThePSurfaceTool::LastVParameter(Caro1);
-
- Um2 = ThePSurfaceTool::FirstUParameter(Caro2);
- Vm2 = ThePSurfaceTool::FirstVParameter(Caro2);
- UM2 = ThePSurfaceTool::LastUParameter(Caro2);
- VM2 = ThePSurfaceTool::LastVParameter(Caro2);
-
- ResoU1 = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
- ResoV1 = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
-
- ResoU2 = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
- ResoV2 = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
- //
- Standard_Real NEWRESO, MAXVAL, MAXVAL2;
- //
- MAXVAL = Abs(Um1);
- MAXVAL2 = Abs(UM1);
- if(MAXVAL2 > MAXVAL) {
- MAXVAL = MAXVAL2;
- }
- NEWRESO = ResoU1 * MAXVAL ;
- if(NEWRESO > ResoU1) {
- ResoU1 = NEWRESO;
- }
- //
- MAXVAL = Abs(Um2);
- MAXVAL2 = Abs(UM2);
- if(MAXVAL2 > MAXVAL){
- MAXVAL = MAXVAL2;
- }
- NEWRESO = ResoU2 * MAXVAL ;
- if(NEWRESO > ResoU2) {
- ResoU2 = NEWRESO;
- }
- //
- MAXVAL = Abs(Vm1);
- MAXVAL2 = Abs(VM1);
- if(MAXVAL2 > MAXVAL) {
- MAXVAL = MAXVAL2;
- }
- NEWRESO = ResoV1 * MAXVAL ;
- if(NEWRESO > ResoV1) {
- ResoV1 = NEWRESO;
- }
- //
- MAXVAL = Abs(Vm2);
- MAXVAL2 = Abs(VM2);
- if(MAXVAL2 > MAXVAL){
- MAXVAL = MAXVAL2;
- }
- NEWRESO = ResoV2 * MAXVAL ;
- if(NEWRESO > ResoV2) {
- ResoV2 = NEWRESO;
- }
- //
- pasuv[0]=pasMax*Abs(UM1-Um1);
- pasuv[1]=pasMax*Abs(VM1-Vm1);
- pasuv[2]=pasMax*Abs(UM2-Um2);
- pasuv[3]=pasMax*Abs(VM2-Vm2);
- //
- if(ThePSurfaceTool::IsUPeriodic(Caro1)==Standard_False) {
- UM1+=KELARG*pasuv[0];
- Um1-=KELARG*pasuv[0];
- }
- else {
- Standard_Real t = UM1-Um1;
- if(t<ThePSurfaceTool::UPeriod(Caro1)) {
- t=0.5*(ThePSurfaceTool::UPeriod(Caro1)-t);
- t=(t>KELARG*pasuv[0])? KELARG*pasuv[0] : t;
- UM1+=t;
- Um1-=t;
- }
- }
- //
- if(ThePSurfaceTool::IsVPeriodic(Caro1)==Standard_False) {
- VM1+=KELARG*pasuv[1];
- Vm1-=KELARG*pasuv[1];
- }
- else {
- Standard_Real t = VM1-Vm1;
- if(t<ThePSurfaceTool::VPeriod(Caro1)) {
- t=0.5*(ThePSurfaceTool::VPeriod(Caro1)-t);
- t=(t>KELARG*pasuv[1])? KELARG*pasuv[1] : t;
- VM1+=t; Vm1-=t;
- }
- }
- //
- if(ThePSurfaceTool::IsUPeriodic(Caro2)==Standard_False) {
- UM2+=KELARG*pasuv[2];
- Um2-=KELARG*pasuv[2];
- }
- else {
- Standard_Real t = UM2-Um2;
- if(t<ThePSurfaceTool::UPeriod(Caro2)) {
- t=0.5*(ThePSurfaceTool::UPeriod(Caro2)-t);
- t=(t>KELARG*pasuv[2])? KELARG*pasuv[2] : t;
- UM2+=t;
- Um2-=t;
- }
- }
-
- if(ThePSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {
- VM2+=KELARG*pasuv[3];
- Vm2-=KELARG*pasuv[3];
- }
- else {
- Standard_Real t = VM2-Vm2;
- if(t<ThePSurfaceTool::VPeriod(Caro2)) {
- t=0.5*(ThePSurfaceTool::VPeriod(Caro2)-t);
- t=(t>KELARG*pasuv[3])? KELARG*pasuv[3] : t;
- VM2+=t;
- Vm2-=t;
- }
- }
- //-- ComputePasInit(pasuv,Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2);
-
- for (Standard_Integer i = 0; i<=3;i++) {
- pasInit[i] = pasSav[i] = pasuv[i];
- }
-
- if(ResoU1>0.0001*pasuv[0]) ResoU1=0.00001*pasuv[0];
- if(ResoV1>0.0001*pasuv[1]) ResoV1=0.00001*pasuv[1];
- if(ResoU2>0.0001*pasuv[2]) ResoU2=0.00001*pasuv[2];
- if(ResoV2>0.0001*pasuv[3]) ResoV2=0.00001*pasuv[3];
- //
- TColStd_Array1OfReal Par(1,4);
- Par(1) = U1;
- Par(2) = V1;
- Par(3) = U2;
- Par(4) = V2;
- Perform(Par);
-}
-
-//==================================================================================
-// function : PerformFirstPoint
-// purpose :
-//==================================================================================
-Standard_Boolean IntWalk_PWalking::PerformFirstPoint (const TColStd_Array1OfReal& ParDep,
- IntSurf_PntOn2S& FirstPoint)
-{
- sensCheminement = 1;
- close = Standard_False;
- //
- Standard_Integer i;
- TColStd_Array1OfReal Param(1,4);
- //
- for (i=1; i<=4; ++i) {
- Param(i) = ParDep(i);
- }
- //-- calculate the first solution point
- math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
- //
- myIntersectionOn2S.Perform(Param,Rsnld);
- if (!myIntersectionOn2S.IsDone()) {
- return Standard_False;
- }
-
- if (myIntersectionOn2S.IsEmpty()) {
- return Standard_False;
- }
-
- FirstPoint = myIntersectionOn2S.Point();
- return Standard_True;
-}
-//==================================================================================
-// function : Perform
-// purpose :
-//==================================================================================
-void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep)
-{
- Perform(ParDep,Um1,Vm1,Um2,Vm2,UM1,VM1,UM2,VM2);
-}
-//==================================================================================
-// function : Perform
-// purpose :
-//==================================================================================
-void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
- const Standard_Real u1min,
- const Standard_Real v1min,
- const Standard_Real u2min,
- const Standard_Real v2min,
- const Standard_Real u1max,
- const Standard_Real v1max,
- const Standard_Real u2max,
- const Standard_Real v2max)
-{
- const Standard_Real aSQDistMax = 1.0e-14;
- //xf
-
- Standard_Integer NbPasOKConseq=0;
- Standard_Real pasMaxSV[4], aTmp;
- TColStd_Array1OfReal Param(1,4);
- IntImp_ConstIsoparametric ChoixIso;
- //xt
- //
- done = Standard_False;
- //
- // Caro1 and Caro2
- const ThePSurface& Caro1 =myIntersectionOn2S.Function().AuxillarSurface1();
- const ThePSurface& Caro2 =myIntersectionOn2S.Function().AuxillarSurface2();
- //
- const Standard_Real UFirst1 = ThePSurfaceTool::FirstUParameter(Caro1);
- const Standard_Real VFirst1 = ThePSurfaceTool::FirstVParameter(Caro1);
- const Standard_Real ULast1 = ThePSurfaceTool::LastUParameter (Caro1);
- const Standard_Real VLast1 = ThePSurfaceTool::LastVParameter (Caro1);
-
- const Standard_Real UFirst2 = ThePSurfaceTool::FirstUParameter(Caro2);
- const Standard_Real VFirst2 = ThePSurfaceTool::FirstVParameter(Caro2);
- const Standard_Real ULast2 = ThePSurfaceTool::LastUParameter (Caro2);
- const Standard_Real VLast2 = ThePSurfaceTool::LastVParameter (Caro2);
- //
- ComputePasInit(pasuv,u1min,u1max,v1min,v1max,u2min,u2max,v2min,v2max,
- Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2,pasMax+pasMax);
- //
- if(pasuv[0]<100.0*ResoU1) {
- pasuv[0]=100.0*ResoU1;
- }
- if(pasuv[1]<100.0*ResoV1) {
- pasuv[1]=100.0*ResoV1;
- }
- if(pasuv[2]<100.0*ResoU2) {
- pasuv[2]=100.0*ResoU2;
- }
- if(pasuv[3]<100.0*ResoV2) {
- pasuv[3]=100.0*ResoV2;
- }
- //
- for (Standard_Integer i=0; i<4; ++i)
- {
- if(pasuv[i]>10)
- {
- pasuv[i] = 10;
- }
-
- pasInit[i] = pasSav[i] = pasuv[i];
- }
- //
- line = new IntSurf_LineOn2S ();
- //
- for (Standard_Integer i=1; i<=4; ++i)
- {
- aTmp=ParDep(i);
- Param(i)=ParDep(i);
- }
- //-- reproduce steps uv connected to surfaces Caro1 and Caro2
- //-- pasuv[] and pasSav[] are modified during the marching
- for(Standard_Integer i = 0; i < 4; ++i)
- {
- pasMaxSV[i] = pasSav[i] = pasuv[i] = pasInit[i];
- }
-
- //-- calculate the first solution point
- math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
- //
- ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld);
- if (!myIntersectionOn2S.IsDone())
- {
- return;
- }
-
- //
- if (myIntersectionOn2S.IsEmpty())
- {
- return;
- }
- //
- if(myIntersectionOn2S.IsTangent())
- {
- return;
- }
- //
- Standard_Boolean Arrive, DejaReparti;
- const Standard_Integer RejectIndexMAX = 250000;
- Standard_Integer IncKey, RejectIndex;
- gp_Pnt pf,pl;
- //
- DejaReparti = Standard_False;
- IncKey = 0;
- RejectIndex = 0;
- //
- previousPoint = myIntersectionOn2S.Point();
- previoustg = Standard_False;
- previousd = myIntersectionOn2S.Direction();
- previousd1 = myIntersectionOn2S.DirectionOnS1();
- previousd2 = myIntersectionOn2S.DirectionOnS2();
- indextg = 1;
- tgdir = previousd;
- firstd1 = previousd1;
- firstd2 = previousd2;
- tgfirst = tglast = Standard_False;
- choixIsoSav = ChoixIso;
- //------------------------------------------------------------
- //-- Test if the first point of marching corresponds
- //-- to a point on borders.
- //-- In this case, DejaReparti is initialized as True
- //--
- pf = previousPoint.Value();
- Standard_Boolean bTestFirstPoint = Standard_True;
-
- previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
- AddAPoint(line,previousPoint);
- //
- IntWalk_StatusDeflection Status = IntWalk_OK;
- Standard_Boolean NoTestDeflection = Standard_False;
- Standard_Real SvParam[4], f;
- Standard_Integer LevelOfEmptyInmyIntersectionOn2S=0;
- Standard_Integer LevelOfPointConfondu = 0;
- Standard_Integer LevelOfIterWithoutAppend = -1;
- //
- Arrive = Standard_False;
- while(!Arrive) //010
- {
- LevelOfIterWithoutAppend++;
- if(LevelOfIterWithoutAppend>20)
- {
- Arrive = Standard_True;
- if(DejaReparti) {
- break;
- }
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- LevelOfIterWithoutAppend = 0;
- }
- //
- // compute f
- f = 0.;
- switch (ChoixIso) {
- case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
- case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
- case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
- case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
- default:break;
- }
- //
- if(f<0.1) {
- f=0.1;
- }
- //
- previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
- //
- //--ofv.begin
- Standard_Real aIncKey, aEps, dP1, dP2, dP3, dP4;
- //
- dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
- dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f;
- dP3 = sensCheminement * pasuv[2] * previousd2.X() /f;
- dP4 = sensCheminement * pasuv[3] * previousd2.Y() /f;
- //
- aIncKey=5.*(Standard_Real)IncKey;
- aEps=1.e-7;
- if(ChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < aEps)
- {
- dP1 *= aIncKey;
- }
-
- if(ChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < aEps)
- {
- dP2 *= aIncKey;
- }
-
- if(ChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < aEps)
- {
- dP3 *= aIncKey;
- }
-
- if(ChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < aEps)
- {
- dP4 *= aIncKey;
- }
- //--ofv.end
- //
- Param(1) += dP1;
- Param(2) += dP2;
- Param(3) += dP3;
- Param(4) += dP4;
- //==========================
- SvParam[0]=Param(1);
- SvParam[1]=Param(2);
- SvParam[2]=Param(3);
- SvParam[3]=Param(4);
- //
- ChoixIso= myIntersectionOn2S.Perform(Param, Rsnld, ChoixIso);
- //
- if (!myIntersectionOn2S.IsDone())
- {
- //end of line, division
- Arrive = Standard_False;
- Param(1)=SvParam[0];
- Param(2)=SvParam[1];
- Param(3)=SvParam[2];
- Param(4)=SvParam[3];
- RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
- }
- else //009
- {
- //== Calculation of exact point from Param(.) is possible
- if (myIntersectionOn2S.IsEmpty())
- {
- Standard_Real u1,v1,u2,v2;
- previousPoint.Parameters(u1,v1,u2,v2);
- //
- Arrive = Standard_False;
- if(u1<UFirst1 || u1>ULast1)
- {
- Arrive=Standard_True;
- }
-
- if(u2<UFirst2 || u2>ULast2)
- {
- Arrive=Standard_True;
- }
-
- if(v1<VFirst1 || v1>VLast1)
- {
- Arrive=Standard_True;
- }
-
- if(v2<VFirst2 || v2>VLast2)
- {
- Arrive=Standard_True;
- }
-
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- LevelOfEmptyInmyIntersectionOn2S++;
- //
- if(LevelOfEmptyInmyIntersectionOn2S>10)
- {
- pasuv[0]=pasSav[0];
- pasuv[1]=pasSav[1];
- pasuv[2]=pasSav[2];
- pasuv[3]=pasSav[3];
- }
- }
- else //008
- {
- //============================================================
- //== A point has been found : T E S T D E F L E C T I O N
- //============================================================
- if(NoTestDeflection)
- {
- NoTestDeflection = Standard_False;
- }
- else
- {
- if(--LevelOfEmptyInmyIntersectionOn2S<=0)
- {
- LevelOfEmptyInmyIntersectionOn2S=0;
- if(LevelOfIterWithoutAppend < 10)
- {
- Status = TestDeflection();
- }
- else
- {
- pasuv[0]*=0.5;
- pasuv[1]*=0.5;
- pasuv[2]*=0.5;
- pasuv[3]*=0.5;
- }
- }
- }
-
- //============================================================
- //== T r a i t e m e n t s u r S t a t u s ==
- //============================================================
- if(LevelOfPointConfondu > 5)
- {
- Status = IntWalk_ArretSurPoint;
- LevelOfPointConfondu = 0;
- }
- //
- if(Status==IntWalk_OK)
- {
- NbPasOKConseq++;
- if(NbPasOKConseq >= 5)
- {
- NbPasOKConseq=0;
- Standard_Boolean pastroppetit;
- Standard_Real t;
- //
- do
- {
- pastroppetit=Standard_True;
- //
- if(pasuv[0]<pasInit[0])
- {
- t = (pasInit[0]-pasuv[0])*0.25;
- if(t>0.1*pasInit[0])
- {
- t=0.1*pasuv[0];
- }
-
- pasuv[0]+=t;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[1]<pasInit[1])
- {
- t = (pasInit[1]-pasuv[1])*0.25;
- if(t>0.1*pasInit[1]) {
- t=0.1*pasuv[1];
- }
-
- pasuv[1]+=t;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[2]<pasInit[2])
- {
- t = (pasInit[2]-pasuv[2])*0.25;
- if(t>0.1*pasInit[2])
- {
- t=0.1*pasuv[2];
- }
-
- pasuv[2]+=t;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[3]<pasInit[3])
- {
- t = (pasInit[3]-pasuv[3])*0.25;
- if(t>0.1*pasInit[3]) {
- t=0.1*pasuv[3];
- }
- pasuv[3]+=t;
- pastroppetit=Standard_False;
- }
- if(pastroppetit)
- {
- if(pasMax<0.1)
- {
- pasMax*=1.1;
- pasInit[0]*=1.1;
- pasInit[1]*=1.1;
- pasInit[2]*=1.1;
- pasInit[3]*=1.1;
- }
- else
- {
- pastroppetit=Standard_False;
- }
- }
- }
- while(pastroppetit);
- }
- }//Status==IntWalk_OK
- else
- NbPasOKConseq=0;
-
- //
- switch(Status)//007
- {
- case IntWalk_ArretSurPointPrecedent:
- {
- Arrive = Standard_False;
- RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
- break;
- }
- case IntWalk_PasTropGrand:
- {
- Param(1)=SvParam[0];
- Param(2)=SvParam[1];
- Param(3)=SvParam[2];
- Param(4)=SvParam[3];
-
- if(LevelOfIterWithoutAppend > 5)
- {
- if(pasSav[0]<pasInit[0])
- {
- pasInit[0]-=(pasInit[0]-pasSav[0])*0.25;
- LevelOfIterWithoutAppend=0;
- }
-
- if(pasSav[1]<pasInit[1])
- {
- pasInit[1]-=(pasInit[1]-pasSav[1])*0.25;
- LevelOfIterWithoutAppend=0;
- }
-
- if(pasSav[2]<pasInit[2])
- {
- pasInit[2]-=(pasInit[2]-pasSav[2])*0.25;
- LevelOfIterWithoutAppend=0;
- }
-
- if(pasSav[3]<pasInit[3])
- {
- pasInit[3]-=(pasInit[3]-pasSav[3])*0.25;
- LevelOfIterWithoutAppend=0;
- }
- }
-
- break;
- }
- case IntWalk_PointConfondu:
- {
- LevelOfPointConfondu++;
-
- if(LevelOfPointConfondu>5)
- {
- Standard_Boolean pastroppetit;
- //
- do
- {
- pastroppetit=Standard_True;
-
- if(pasuv[0]<pasInit[0])
- {
- pasuv[0]+=(pasInit[0]-pasuv[0])*0.25;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[1]<pasInit[1])
- {
- pasuv[1]+=(pasInit[1]-pasuv[1])*0.25;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[2]<pasInit[2])
- {
- pasuv[2]+=(pasInit[2]-pasuv[2])*0.25;
- pastroppetit=Standard_False;
- }
-
- if(pasuv[3]<pasInit[3])
- {
- pasuv[3]+=(pasInit[3]-pasuv[3])*0.25;
- pastroppetit=Standard_False;
- }
-
- if(pastroppetit)
- {
- if(pasMax<0.1)
- {
- pasMax*=1.1;
- pasInit[0]*=1.1;
- pasInit[1]*=1.1;
- pasInit[2]*=1.1;
- pasInit[3]*=1.1;
- }
- else
- {
- pastroppetit=Standard_False;
- }
- }
- }
- while(pastroppetit);
- }
-
- break;
- }
- case IntWalk_OK:
- case IntWalk_ArretSurPoint://006
- {
- //=======================================================
- //== Stop Test t : Frame on Param(.) ==
- //=======================================================
- //xft arrive here
- Arrive = TestArret(DejaReparti,Param,ChoixIso);
- // JMB 30th December 1999.
- // Some statement below should not be put in comment because they are useful.
- // See grid CTO 909 A1 which infinitely loops
- if(Arrive==Standard_False && Status==IntWalk_ArretSurPoint)
- {
- Arrive=Standard_True;
-#ifdef DEB
- cout << "Compile with option DEB : if problems with intersection : ";
- cout << "IntWalk_PWalking_1.gxx (lbr le 1erdec98)"<<endl;
-#endif
- }
-
- if(Arrive)
- {
- NbPasOKConseq = -10;
- }
-
- if(!Arrive)//005
- {
- //=====================================================
- //== Param(.) is in the limits ==
- //== and does not end a closed line ==
- //=====================================================
- //== Check on the current point of myInters
- Standard_Boolean pointisvalid = Standard_False;
- {
- Standard_Real u1,v1,u2,v2;
- myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
-
- //
- if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
- v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
- v1 >= Vm1 && v2 >= Vm2)
- {
- pointisvalid=Standard_True;
- }
- }
-
- //
- if(pointisvalid)
- {
- previousPoint = myIntersectionOn2S.Point();
- previoustg = myIntersectionOn2S.IsTangent();
-
- if(!previoustg)
- {
- previousd = myIntersectionOn2S.Direction();
- previousd1 = myIntersectionOn2S.DirectionOnS1();
- previousd2 = myIntersectionOn2S.DirectionOnS2();
- }
- //=====================================================
- //== Check on the previous Point
- {
- Standard_Real u1,v1,u2,v2;
- previousPoint.Parameters(u1,v1,u2,v2);
- if( u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
- v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
- v1 >= Vm1 && v2 >= Vm2)
- {
- pl = previousPoint.Value();
- if(bTestFirstPoint)
- {
- if(pf.SquareDistance(pl) < aSQDistMax)
- {
- IncKey++;
- if(IncKey == 5000)
- return;
- else
- continue;
- }
- else
- {
- bTestFirstPoint = Standard_False;
- }
- }
- //
- AddAPoint(line,previousPoint);
- RejectIndex++;
-
- if(RejectIndex >= RejectIndexMAX)
- {
- break;
- }
-
- //
- LevelOfIterWithoutAppend = 0;
- }
- }
- }//pointisvalid
- //====================================================
-
- if(Status == IntWalk_ArretSurPoint)
- {
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- }
- else
- {
- if (line->NbPoints() == 2)
- {
- pasSav[0] = pasuv[0];
- pasSav[1] = pasuv[1];
- pasSav[2] = pasuv[2];
- pasSav[3] = pasuv[3];
- }
- }
- }//005 if(!Arrive)
- else //004
- {
- if(close)
- {
- //================= la ligne est fermee ===============
- AddAPoint(line,line->Value(1)); //ligne fermee
- LevelOfIterWithoutAppend=0;
- }
- else //$$$
- {
- //====================================================
- //== Param was not in the limits (was reframed)
- //====================================================
- Standard_Boolean bPrevNotTangent = !previoustg || !myIntersectionOn2S.IsTangent();
-
- IntImp_ConstIsoparametric SauvChoixIso = ChoixIso;
- ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
- //
- if(!myIntersectionOn2S.IsEmpty()) //002
- {
- // mutially outpasses in the square or intersection in corner
-
- if(TestArret(Standard_True,Param,ChoixIso))
- {
- NbPasOKConseq = -10;
- ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
-
- if(!myIntersectionOn2S.IsEmpty())
- {
- previousPoint = myIntersectionOn2S.Point();
- previoustg = myIntersectionOn2S.IsTangent();
-
- if (!previoustg)
- {
- previousd = myIntersectionOn2S.Direction();
- previousd1 = myIntersectionOn2S.DirectionOnS1();
- previousd2 = myIntersectionOn2S.DirectionOnS2();
- }
-
- pl = previousPoint.Value();
-
- if(bTestFirstPoint)
- {
- if(pf.SquareDistance(pl) < aSQDistMax)
- {
- IncKey++;
- if(IncKey == 5000)
- return;
- else
- continue;
- }
- else
- {
- bTestFirstPoint = Standard_False;
- }
- }
- //
- AddAPoint(line,previousPoint);
- RejectIndex++;
-
- if(RejectIndex >= RejectIndexMAX)
- {
- break;
- }
-
- //
- LevelOfIterWithoutAppend=0;
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- }
- else
- {
- //fail framing divides the step
- Arrive = Standard_False;
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- NoTestDeflection = Standard_True;
- ChoixIso = SauvChoixIso;
- }
- }//if(TestArret())
- else
- {
- // save the last point
- // to revert to it if the current point is out of bounds
-
- IntSurf_PntOn2S previousPointSave = previousPoint;
- Standard_Boolean previoustgSave = previoustg;
- gp_Dir previousdSave = previousd;
- gp_Dir2d previousd1Save = previousd1;
- gp_Dir2d previousd2Save = previousd2;
-
- previousPoint = myIntersectionOn2S.Point();
- previoustg = myIntersectionOn2S.IsTangent();
- Arrive = Standard_False;
-
- if(!previoustg)
- {
- previousd = myIntersectionOn2S.Direction();
- previousd1 = myIntersectionOn2S.DirectionOnS1();
- previousd2 = myIntersectionOn2S.DirectionOnS2();
- }
-
- //========================================
- //== Check on PreviousPoint @@
-
- {
- Standard_Real u1,v1,u2,v2;
- previousPoint.Parameters(u1,v1,u2,v2);
-
- //To save initial 2d points
- gp_Pnt2d ParamPntOnS1(Param(1), Param(2));
- gp_Pnt2d ParamPntOnS2(Param(3), Param(4));
-
- ///////////////////////////
- Param(1) = u1;
- Param(2) = v1;
- Param(3) = u2;
- Param(4) = v2;
- //
-
- //xf
- Standard_Boolean bFlag1, bFlag2;
- Standard_Real aTol2D=1.e-11;
- //
- bFlag1=u1 >= Um1-aTol2D && v1 >= Vm1-aTol2D && u1 <= UM1+aTol2D && v1 <= VM1+aTol2D;
- bFlag2=u2 >= Um2-aTol2D && v2 >= Vm2-aTol2D && u2 <= UM2+aTol2D && v2 <= VM2+aTol2D;
- if (bFlag1 && bFlag2)
- {
- /*
- if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
- v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
- v1 >= Vm1 && v2 >= Vm2) {
- */
- //xt
- pl = previousPoint.Value();
-
- if(bTestFirstPoint)
- {
- if(pf.SquareDistance(pl) < aSQDistMax)
- {
- IncKey++;
-
- if(IncKey == 5000)
- return;
- else
- continue;
- }
- else
- {
- bTestFirstPoint = Standard_False;
- }
- }
-
- //To avoid walking around the same point
- //in the tangent zone near a border
-
- if (previoustg)
- {
- Standard_Real prevU1, prevV1, prevU2, prevV2;
- previousPointSave.Parameters(prevU1, prevV1, prevU2, prevV2);
- gp_Pnt2d prevPntOnS1(prevU1, prevV1), prevPntOnS2(prevU2, prevV2);
- gp_Pnt2d curPntOnS1(u1, v1), curPntOnS2(u2, v2);
- gp_Vec2d PrevToParamOnS1(prevPntOnS1, ParamPntOnS1);
- gp_Vec2d PrevToCurOnS1(prevPntOnS1, curPntOnS1);
- gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2);
- gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2);
- Standard_Real MaxAngle = 3*M_PI/4;
-
- if (Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)) > MaxAngle &&
- Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle)
- {
- Arrive = Standard_True;
- break;
- }
- }
-
- ////////////////////////////////////////
- AddAPoint(line,previousPoint);
- RejectIndex++;
-
- if(RejectIndex >= RejectIndexMAX)
- {
- break;
- }
-
- //
-
- LevelOfIterWithoutAppend=0;
- Arrive = Standard_True;
- }
- else
- {
- // revert to the last correctly calculated point
- previousPoint = previousPointSave;
- previoustg = previoustgSave;
- previousd = previousdSave;
- previousd1 = previousd1Save;
- previousd2 = previousd2Save;
- }
- }
-
- //
- Standard_Boolean wasExtended = Standard_False;
-
- if(Arrive && myIntersectionOn2S.IsTangent() && bPrevNotTangent)
- {
- if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
- {
- wasExtended = Standard_True;
- Arrive = Standard_False;
- ChoixIso = SauvChoixIso;
- }
- }
-
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-
- if(Arrive &&
- myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty() &&
- myIntersectionOn2S.IsTangent() && bPrevNotTangent &&
- !wasExtended)
- {
- if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
- {
- wasExtended = Standard_True;
- Arrive = Standard_False;
- ChoixIso = SauvChoixIso;
- }
- }
- }//else !TestArret() $
- }//$$ end successful framing on border (!myIntersectionOn2S.IsEmpty())
- else
- {
- //echec framing on border; division of step
- Arrive = Standard_False;
- NoTestDeflection = Standard_True;
- RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
- }
- }//$$$ end framing on border (!close)
- }//004 fin TestArret return Arrive = True
- } // 006case IntWalk_ArretSurPoint: end Processing Status = OK or ArretSurPoint
- } //007 switch(Status)
- } //008 end processing point (TEST DEFLECTION)
- } //009 end processing line (else if myIntersectionOn2S.IsDone())
- } //010 end if first departure point allows marching while (!Arrive)
-
- done = Standard_True;
-}
-// ===========================================================================================================
-// function: ExtendLineInCommonZone
-// purpose: Extends already computed line inside tangent zone in the direction given by theChoixIso.
-// Returns Standard_True if the line was extended through tangent zone and the last computed point
-// is outside the tangent zone (but it is not put into the line). Otherwise returns Standard_False.
-// ===========================================================================================================
-Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric theChoixIso,
- const Standard_Boolean theDirectionFlag)
-{
- Standard_Boolean bOutOfTangentZone = Standard_False;
- Standard_Boolean bStop = !myIntersectionOn2S.IsTangent();
- Standard_Integer dIncKey = 1;
- TColStd_Array1OfReal Param(1,4);
- IntWalk_StatusDeflection Status = IntWalk_OK;
- Standard_Integer nbIterWithoutAppend = 0;
- Standard_Integer nbEqualPoints = 0;
- Standard_Integer parit = 0;
- Standard_Integer uvit = 0;
- IntSurf_SequenceOfPntOn2S aSeqOfNewPoint;
-
- while (!bStop) {
- nbIterWithoutAppend++;
-
- if((nbIterWithoutAppend > 20) || (nbEqualPoints > 20)) {
-#ifdef DEB
- cout<<"Compile with option DEB:";
- cout<<"Infinite loop has detected. Stop iterations (IntWalk_PWalking_1.gxx)" << endl;
-#endif
- bStop = Standard_True;
- break;
- }
- Standard_Real f = 0.;
-
- switch (theChoixIso)
- {
- case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
- case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
- case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
- case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
- }
-
- if(f<0.1) f=0.1;
-
- previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
-
- Standard_Real dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
- Standard_Real dP2 = sensCheminement * pasuv[1] * previousd1.Y() /f;
- Standard_Real dP3 = sensCheminement * pasuv[2] * previousd2.X() /f;
- Standard_Real dP4 = sensCheminement * pasuv[3] * previousd2.Y() /f;
-
- if(theChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < 1.e-7) dP1 *= (5. * (Standard_Real)dIncKey);
- if(theChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < 1.e-7) dP2 *= (5. * (Standard_Real)dIncKey);
- if(theChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < 1.e-7) dP3 *= (5. * (Standard_Real)dIncKey);
- if(theChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < 1.e-7) dP4 *= (5. * (Standard_Real)dIncKey);
-
- Param(1) += dP1;
- Param(2) += dP2;
- Param(3) += dP3;
- Param(4) += dP4;
- Standard_Real SvParam[4];
- IntImp_ConstIsoparametric ChoixIso = theChoixIso;
-
- for(parit = 0; parit < 4; parit++) {
- SvParam[parit] = Param(parit+1);
- }
- math_FunctionSetRoot Rsnld(myIntersectionOn2S.Function());
- ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld, theChoixIso);
-
- if (!myIntersectionOn2S.IsDone()) {
- return bOutOfTangentZone;
- }
- else {
- if (myIntersectionOn2S.IsEmpty()) {
- return bOutOfTangentZone;
- }
-
- Status = TestDeflection();
-
- if(Status == IntWalk_OK) {
-
- for(uvit = 0; uvit < 4; uvit++) {
- if(pasuv[uvit] < pasInit[uvit]) {
- pasuv[uvit] = pasInit[uvit];
- }
- }
- }
-
- switch(Status) {
- case IntWalk_ArretSurPointPrecedent:
- {
- bStop = Standard_True;
- bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
- break;
- }
- case IntWalk_PasTropGrand:
- {
- for(parit = 0; parit < 4; parit++) {
- Param(parit+1) = SvParam[parit];
- }
- Standard_Boolean bDecrease = Standard_False;
-
- for(uvit = 0; uvit < 4; uvit++) {
- if(pasSav[uvit] < pasInit[uvit]) {
- pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * 0.1;
- bDecrease = Standard_True;
- }
- }
-
- if(bDecrease) nbIterWithoutAppend--;
- break;
- }
- case IntWalk_PointConfondu:
- {
- for(uvit = 0; uvit < 4; uvit++) {
- if(pasuv[uvit] < pasInit[uvit]) {
- pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * 0.1;
- }
- }
- break;
- }
- case IntWalk_OK:
- case IntWalk_ArretSurPoint:
- {
- //
- bStop = TestArret(theDirectionFlag, Param, ChoixIso);
- //
-
- //
- if(!bStop) {
- Standard_Real u11,v11,u12,v12;
- myIntersectionOn2S.Point().Parameters(u11,v11,u12,v12);
- Standard_Real u21,v21,u22,v22;
- previousPoint.Parameters(u21,v21,u22,v22);
-
- if(((fabs(u11-u21) < ResoU1) && (fabs(v11-v21) < ResoV1)) ||
- ((fabs(u12-u22) < ResoU2) && (fabs(v12-v22) < ResoV2))) {
- nbEqualPoints++;
- }
- else {
- nbEqualPoints = 0;
- }
- }
- //
-
- bStop = bStop || !myIntersectionOn2S.IsTangent();
- bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
-
- if(!bStop) {
- Standard_Boolean pointisvalid = Standard_False;
- Standard_Real u1,v1,u2,v2;
- myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
-
- if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
- v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
- v1 >= Vm1 && v2 >= Vm2)
- pointisvalid = Standard_True;
-
- if(pointisvalid) {
- previousPoint = myIntersectionOn2S.Point();
- previoustg = myIntersectionOn2S.IsTangent();
-
- if(!previoustg) {
- previousd = myIntersectionOn2S.Direction();
- previousd1 = myIntersectionOn2S.DirectionOnS1();
- previousd2 = myIntersectionOn2S.DirectionOnS2();
- }
- Standard_Boolean bAddPoint = Standard_True;
-
- if(line->NbPoints() >= 1) {
- gp_Pnt pf = line->Value(1).Value();
- gp_Pnt pl = previousPoint.Value();
-
- if(pf.Distance(pl) < Precision::Confusion()) {
- dIncKey++;
- if(dIncKey == 5000) return bOutOfTangentZone;
- else bAddPoint = Standard_False;
- }
- }
-
- if(bAddPoint) {
- aSeqOfNewPoint.Append(previousPoint);
- nbIterWithoutAppend = 0;
- }
- }
-
- if (line->NbPoints() == 2) {
- for(uvit = 0; uvit < 4; uvit++) {
- pasSav[uvit] = pasuv[uvit];
- }
- }
-
- if ( !pointisvalid ) {
- // decrease step if out of bounds
- // otherwise the same calculations will be
- // repeated several times
- if ( ( u1 > UM1 ) || ( u1 < Um1 ) )
- pasuv[0] *= 0.5;
-
- if ( ( v1 > VM1 ) || ( v1 < Vm1 ) )
- pasuv[1] *= 0.5;
-
- if ( ( u2 > UM2 ) || ( u2 < Um2 ) )
- pasuv[2] *= 0.5;
-
- if ( ( v2 > VM2 ) || ( v2 < Vm2 ) )
- pasuv[3] *= 0.5;
- }
- } // end if(!bStop)
- else { //if(bStop)
- if(close && (line->NbPoints() >= 1)) {
-
- if(!bOutOfTangentZone) {
- aSeqOfNewPoint.Append(line->Value(1)); // line end
- }
- nbIterWithoutAppend = 0;
- }
- else {
- ChoixIso = myIntersectionOn2S.Perform(Param, Rsnld, theChoixIso);
-
- if(myIntersectionOn2S.IsEmpty()) {
- bStop = !myIntersectionOn2S.IsTangent();
- bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
- }
- else {
- Standard_Boolean bAddPoint = Standard_True;
- Standard_Boolean pointisvalid = Standard_False;
-
- previousPoint = myIntersectionOn2S.Point();
- Standard_Real u1,v1,u2,v2;
- previousPoint.Parameters(u1,v1,u2,v2);
-
- if(u1 <= UM1 && u2 <= UM2 && v1 <= VM1 &&
- v2 <= VM2 && u1 >= Um1 && u2 >= Um2 &&
- v1 >= Vm1 && v2 >= Vm2)
- pointisvalid = Standard_True;
-
- if(pointisvalid) {
-
- if(line->NbPoints() >= 1) {
- gp_Pnt pf = line->Value(1).Value();
- gp_Pnt pl = previousPoint.Value();
-
- if(pf.Distance(pl) < Precision::Confusion()) {
- dIncKey++;
- if(dIncKey == 5000) return bOutOfTangentZone;
- else bAddPoint = Standard_False;
- }
- }
-
- if(bAddPoint && !bOutOfTangentZone) {
- aSeqOfNewPoint.Append(previousPoint);
- nbIterWithoutAppend = 0;
- }
- }
- }
- }
- }
- break;
- }
- default:
- {
- break;
- }
- }
- }
- }
- Standard_Boolean bExtendLine = Standard_False;
- Standard_Real u1 = 0., v1 = 0., u2 = 0., v2 = 0.;
-
- Standard_Integer pit = 0;
-
- for(pit = 0; !bExtendLine && (pit < 2); pit++) {
- if(pit == 0)
- previousPoint.Parameters(u1,v1,u2,v2);
- else {
- if(aSeqOfNewPoint.Length() > 0)
- aSeqOfNewPoint.Value(aSeqOfNewPoint.Length()).Parameters(u1,v1,u2,v2);
- else
- break;
- }
-
- if(((u1 - Um1) < ResoU1) ||
- ((UM1 - u1) < ResoU1) ||
- ((u2 - Um2) < ResoU2) ||
- ((UM2 - u2) < ResoU2) ||
- ((v1 - Vm1) < ResoV1) ||
- ((VM1 - v1) < ResoV1) ||
- ((v2 - Vm2) < ResoV2) ||
- ((VM2 - v2) < ResoV2))
- bExtendLine = Standard_True;
- }
-
- if(!bExtendLine) {
- // if(Status == IntWalk_OK || Status == IntWalk_ArretSurPoint) {
- if(Status == IntWalk_OK) {
- bExtendLine = Standard_True;
-
- if(aSeqOfNewPoint.Length() > 1) {
- TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3), Resolutions(0, 3);
- Resolutions(0) = ResoU1; Resolutions(1) = ResoV1; Resolutions(2) = ResoU2; Resolutions(3) = ResoV2;
-
- aSeqOfNewPoint(1).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
- FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
- aSeqOfNewPoint(aSeqOfNewPoint.Length()).Parameters(LastParams.ChangeValue(0),
- LastParams.ChangeValue(1),
- LastParams.ChangeValue(2),
- LastParams.ChangeValue(3));
- Standard_Integer indexofiso = 0;
-
- if(theChoixIso == IntImp_UIsoparametricOnCaro1) indexofiso = 0;
- if(theChoixIso == IntImp_VIsoparametricOnCaro1) indexofiso = 1;
- if(theChoixIso == IntImp_UIsoparametricOnCaro2) indexofiso = 2;
- if(theChoixIso == IntImp_VIsoparametricOnCaro2) indexofiso = 3;
-
- Standard_Integer afirstindex = (indexofiso < 2) ? 0 : 2;
- gp_Vec2d aTangentZoneDir(gp_Pnt2d(FirstParams.Value(afirstindex), FirstParams.Value(afirstindex + 1)),
- gp_Pnt2d(LastParams.Value(afirstindex), LastParams.Value(afirstindex + 1)));
-
- gp_Dir2d anIsoDir(0, 1);
-
- if((indexofiso == 1) || (indexofiso == 3))
- anIsoDir = gp_Dir2d(1, 0);
-
- if(aTangentZoneDir.SquareMagnitude() > gp::Resolution()) {
- Standard_Real piquota = M_PI*0.25;
-
- if(fabs(aTangentZoneDir.Angle(anIsoDir)) > piquota) {
- Standard_Integer ii = 1, nextii = 2;
- gp_Vec2d d1(0, 0);
- Standard_Real asqresol = gp::Resolution();
- asqresol *= asqresol;
-
- do {
- aSeqOfNewPoint(ii).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
- FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
- aSeqOfNewPoint(ii + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
- LastParams.ChangeValue(2), LastParams.ChangeValue(3));
- d1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
- FirstParams.Value(afirstindex + 1)),
- gp_Pnt2d(LastParams.Value(afirstindex),
- LastParams.Value(afirstindex + 1)));
- ii++;
- }
- while((d1.SquareMagnitude() < asqresol) &&
- (ii < aSeqOfNewPoint.Length()));
-
- nextii = ii;
-
- while(nextii < aSeqOfNewPoint.Length()) {
-
- gp_Vec2d nextd1(0, 0);
- Standard_Integer jj = nextii;
-
- do {
- aSeqOfNewPoint(jj).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
- FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
- aSeqOfNewPoint(jj + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
- LastParams.ChangeValue(2), LastParams.ChangeValue(3));
- nextd1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
- FirstParams.Value(afirstindex + 1)),
- gp_Pnt2d(LastParams.Value(afirstindex),
- LastParams.Value(afirstindex + 1)));
- jj++;
-
- }
- while((nextd1.SquareMagnitude() < asqresol) &&
- (jj < aSeqOfNewPoint.Length()));
- nextii = jj;
-
- if(fabs(d1.Angle(nextd1)) > piquota) {
- bExtendLine = Standard_False;
- break;
- }
- d1 = nextd1;
- }
- }
- // end if(fabs(aTangentZoneDir.Angle(anIsoDir)
- }
- }
- }
- }
-
- if(!bExtendLine) {
- return Standard_False;
- }
- Standard_Integer i = 0;
-
- for(i = 1; i <= aSeqOfNewPoint.Length(); i++) {
- AddAPoint(line, aSeqOfNewPoint.Value(i));
- }
-
- return bOutOfTangentZone;
-}
-
-//=======================================================================
-//function : DistanceMinimizeByGradient
-//purpose :
-//=======================================================================
-Standard_Boolean IntWalk_PWalking::
- DistanceMinimizeByGradient( const Handle(Adaptor3d_HSurface)& theASurf1,
- const Handle(Adaptor3d_HSurface)& theASurf2,
- Standard_Real& theU1,
- Standard_Real& theV1,
- Standard_Real& theU2,
- Standard_Real& theV2,
- const Standard_Real theStep0U1V1,
- const Standard_Real theStep0U2V2)
-{
- const Standard_Integer aNbIterMAX = 60;
- const Standard_Real aTol = 1.0e-14;
- Handle(Geom_Surface) aS1, aS2;
-
- switch(theASurf1->GetType())
- {
- case GeomAbs_BezierSurface:
- aS1 = theASurf1->Surface().Bezier();
- break;
- case GeomAbs_BSplineSurface:
- aS1 = theASurf1->Surface().BSpline();
- break;
- default:
- return Standard_True;
- }
-
- switch(theASurf2->GetType())
- {
- case GeomAbs_BezierSurface:
- aS2 = theASurf2->Surface().Bezier();
- break;
- case GeomAbs_BSplineSurface:
- aS2 = theASurf2->Surface().BSpline();
- break;
- default:
- return Standard_True;
- }
-
- Standard_Boolean aStatus = Standard_False;
-
- gp_Pnt aP1, aP2;
- gp_Vec aD1u, aD1v, aD2U, aD2V;
-
- aS1->D1(theU1, theV1, aP1, aD1u, aD1v);
- aS2->D1(theU2, theV2, aP2, aD2U, aD2V);
-
- Standard_Real aSQDistPrev = aP1.SquareDistance(aP2);
-
- gp_Vec aP12(aP1, aP2);
-
- Standard_Real aGradFu(-aP12.Dot(aD1u));
- Standard_Real aGradFv(-aP12.Dot(aD1v));
- Standard_Real aGradFU( aP12.Dot(aD2U));
- Standard_Real aGradFV( aP12.Dot(aD2V));
-
- Standard_Real aSTEPuv = theStep0U1V1, aStepUV = theStep0U2V2;
-
- Standard_Boolean flRepeat = Standard_True;
- Standard_Integer aNbIter = aNbIterMAX;
-
- while(flRepeat)
- {
- Standard_Real anAdd = aGradFu*aSTEPuv;
- Standard_Real aPARu = (anAdd >= 0.0)?
- (theU1 - Max(anAdd, Epsilon(theU1))) :
- (theU1 + Max(-anAdd, Epsilon(theU1)));
- anAdd = aGradFv*aSTEPuv;
- Standard_Real aPARv = (anAdd >= 0.0)?
- (theV1 - Max(anAdd, Epsilon(theV1))) :
- (theV1 + Max(-anAdd, Epsilon(theV1)));
- anAdd = aGradFU*aStepUV;
- Standard_Real aParU = (anAdd >= 0.0)?
- (theU2 - Max(anAdd, Epsilon(theU2))) :
- (theU2 + Max(-anAdd, Epsilon(theU2)));
- anAdd = aGradFV*aStepUV;
- Standard_Real aParV = (anAdd >= 0.0)?
- (theV2 - Max(anAdd, Epsilon(theV2))) :
- (theV2 + Max(-anAdd, Epsilon(theV2)));
-
- gp_Pnt aPt1, aPt2;
-
- aS1->D1(aPARu, aPARv, aPt1, aD1u, aD1v);
- aS2->D1(aParU, aParV, aPt2, aD2U, aD2V);
-
- Standard_Real aSQDist = aPt1.SquareDistance(aPt2);
-
- if(aSQDist < aSQDistPrev)
- {
- aSQDistPrev = aSQDist;
- theU1 = aPARu;
- theV1 = aPARv;
- theU2 = aParU;
- theV2 = aParV;
-
- aStatus = aSQDistPrev < aTol;
- aSTEPuv *= 1.2;
- aStepUV *= 1.2;
- }
- else
- {
- if(--aNbIter < 0)
- {
- flRepeat = Standard_False;
- }
- else
- {
- aS1->D1(theU1, theV1, aPt1, aD1u, aD1v);
- aS2->D1(theU2, theV2, aPt2, aD2U, aD2V);
-
- gp_Vec aP12(aPt1, aPt2);
- aGradFu = -aP12.Dot(aD1u);
- aGradFv = -aP12.Dot(aD1v);
- aGradFU = aP12.Dot(aD2U);
- aGradFV = aP12.Dot(aD2V);
- aSTEPuv = theStep0U1V1;
- aStepUV = theStep0U2V2;
- }
- }
- }
-
- return aStatus;
-}
-
-//=======================================================================
-//function : DistanceMinimizeByExtrema
-//purpose :
-//=======================================================================
-Standard_Boolean IntWalk_PWalking::
- DistanceMinimizeByExtrema(const Handle(Adaptor3d_HSurface)& theASurf,
- const gp_Pnt& theP0,
- Standard_Real& theU0,
- Standard_Real& theV0,
- const Standard_Real theStep0U,
- const Standard_Real theStep0V)
-{
- const Standard_Real aTol = 1.0e-14;
- gp_Pnt aPS;
- gp_Vec aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp;
- Standard_Real aSQDistPrev = RealLast();
- Standard_Real aU = theU0, aV = theV0;
-
- Standard_Integer aNbIter = 10;
- do
- {
- theASurf->D2(aU, aV, aPS, aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp);
-
- gp_Vec aVec(theP0, aPS);
-
- Standard_Real aSQDist = aVec.SquareMagnitude();
-
- if(aSQDist >= aSQDistPrev)
- break;
-
- aSQDistPrev = aSQDist;
- theU0 = aU;
- theV0 = aV;
- aNbIter--;
-
- if(aSQDistPrev < aTol)
- break;
-
- //Functions
- const Standard_Real aF1 = aD1Su.Dot(aVec), aF2 = aD1Sv.Dot(aVec);
-
- //Derivatives
- const Standard_Real aDf1u = aD2Su.Dot(aVec) + aD1Su.Dot(aD1Su),
- aDf1v = aD2Su.Dot(aD1Sv),
- aDf2u = aDf1v,
- aDf2v = aD2Sv.Dot(aVec) + aD1Sv.Dot(aD1Sv);
-
- const Standard_Real aDet = aDf1u*aDf2v - aDf1v*aDf2u;
- aU -= theStep0U*(aDf2v*aF1 - aDf1v*aF2)/aDet;
- aV += theStep0V*(aDf2u*aF1 - aDf1u*aF2)/aDet;
- }
- while(aNbIter > 0);
-
- return (aSQDistPrev < aTol);
-}
-
-//=======================================================================
-//function : SeekPointOnBoundary
-//purpose :
-//=======================================================================
-Standard_Boolean IntWalk_PWalking::
- SeekPointOnBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
- const Handle(Adaptor3d_HSurface)& theASurf2,
- const Standard_Real theU1,
- const Standard_Real theV1,
- const Standard_Real theU2,
- const Standard_Real theV2,
- const Standard_Boolean isTheFirst)
-{
- const Standard_Real aTol = 1.0e-14;
- Standard_Boolean isOK = Standard_False;
- Standard_Real U1prec = theU1, V1prec = theV1, U2prec = theU2, V2prec = theV2;
-
- Standard_Boolean flFinish = Standard_False;
-
- Standard_Integer aNbIter = 20;
- while(!flFinish)
- {
- flFinish = Standard_False;
- Standard_Boolean aStatus = Standard_False;
-
- do
- {
- aNbIter--;
- aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
- if(aStatus)
- {
- break;
- }
-
- aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
- if(aStatus)
- {
- break;
- }
-
- aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
- if(aStatus)
- {
- break;
- }
- }
- while(!aStatus && (aNbIter > 0));
-
- if(aStatus)
- {
- const Standard_Real aTolMax = 1.0e-8;
- Standard_Real aTolF = 0.0;
-
- Standard_Real u1 = U1prec, v1 = V1prec, u2 = U2prec, v2 = V2prec;
-
- flFinish = Checking(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aTolF);
-
- if(aTolF <= aTolMax)
- {
- gp_Pnt aP1 = theASurf1->Value(u1, v1),
- aP2 = theASurf2->Value(u2, v2);
- gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
-
- const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
- aSQDist2 = aPInt.SquareDistance(aP2);
- if((aSQDist1 < aTol) && (aSQDist2 < aTol))
- {
- IntSurf_PntOn2S anIP;
- anIP.SetValue(aPInt, u1, v1, u2, v2);
-
- if(isTheFirst)
- line->InsertBefore(1,anIP);
- else
- line->Add(anIP);
-
- isOK = Standard_True;
- }
- }
- }
- else
- {
- break;
- }
-
- if(aNbIter < 0)
- break;
- }
-
- return isOK;
-}
-
-//=======================================================================
-//function : PutToBoundary
-//purpose :
-//=======================================================================
-Standard_Boolean IntWalk_PWalking::
- PutToBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
- const Handle(Adaptor3d_HSurface)& theASurf2)
-{
- const Standard_Real aTolMin = Precision::Confusion();
-
- Standard_Boolean hasBeenAdded = Standard_False;
-
- const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
- const Standard_Real aU1bLast = theASurf1->LastUParameter();
- const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
- const Standard_Real aU2bLast = theASurf2->LastUParameter();
- const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
- const Standard_Real aV1bLast = theASurf1->LastVParameter();
- const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
- const Standard_Real aV2bLast = theASurf2->LastVParameter();
-
- Standard_Real aTol = 1.0;
- aTol = Min(aTol, aU1bLast - aU1bFirst);
- aTol = Min(aTol, aU2bLast - aU2bFirst);
- aTol = Min(aTol, aV1bLast - aV1bFirst);
- aTol = Min(aTol, aV2bLast - aV2bFirst)*1.0e-3;
-
- if(aTol <= 2.0*aTolMin)
- return hasBeenAdded;
-
- Standard_Boolean isNeedAdding = Standard_False;
- Standard_Boolean isU1parallel = Standard_False, isV1parallel = Standard_False;
- Standard_Boolean isU2parallel = Standard_False, isV2parallel = Standard_False;
- IsParallel(line, Standard_True, aTol, isU1parallel, isV1parallel);
- IsParallel(line, Standard_False, aTol, isU2parallel, isV2parallel);
-
- const Standard_Integer aNbPnts = line->NbPoints();
- Standard_Real u1, v1, u2, v2;
- line->Value(1).Parameters(u1, v1, u2, v2);
- Standard_Real aDelta = 0.0;
-
- if(!isV1parallel)
- {
- aDelta = u1 - aU1bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u1 = aU1bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aU1bLast - u1;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u1 = aU1bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isV2parallel)
- {
- aDelta = u2 - aU2bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u2 = aU2bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aU2bLast - u2;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u2 = aU2bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isU1parallel)
- {
- aDelta = v1 - aV1bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v1 = aV1bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aV1bLast - v1;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v1 = aV1bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isU2parallel)
- {
- aDelta = v2 - aV2bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v2 = aV2bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aV2bLast - v2;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v2 = aV2bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(isNeedAdding)
- {
- hasBeenAdded =
- SeekPointOnBoundary(theASurf1, theASurf2, u1,
- v1, u2, v2, Standard_True);
- }
-
- isNeedAdding = Standard_False;
- line->Value(aNbPnts).Parameters(u1, v1, u2, v2);
-
- if(!isV1parallel)
- {
- aDelta = u1 - aU1bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u1 = aU1bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aU1bLast - u1;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u1 = aU1bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isV2parallel)
- {
- aDelta = u2 - aU2bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u2 = aU2bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aU2bLast - u2;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- u2 = aU2bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isU1parallel)
- {
- aDelta = v1 - aV1bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v1 = aV1bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aV1bLast - v1;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v1 = aV1bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(!isU2parallel)
- {
- aDelta = v2 - aV2bFirst;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v2 = aV2bFirst - aDelta;
- isNeedAdding = Standard_True;
- }
- else
- {
- aDelta = aV2bLast - v2;
- if((aTolMin < aDelta) && (aDelta < aTol))
- {
- v2 = aV2bLast + aDelta;
- isNeedAdding = Standard_True;
- }
- }
- }
-
- if(isNeedAdding)
- {
- hasBeenAdded =
- SeekPointOnBoundary(theASurf1, theASurf2, u1,
- v1, u2, v2, Standard_False);
- }
-
- return hasBeenAdded;
-}
-
-//=======================================================================
-//function : SeekAdditionalPoints
-//purpose :
-//=======================================================================
-Standard_Boolean IntWalk_PWalking::
- SeekAdditionalPoints( const Handle(Adaptor3d_HSurface)& theASurf1,
- const Handle(Adaptor3d_HSurface)& theASurf2,
- const Standard_Integer theMinNbPoints)
-{
- const Standard_Real aTol = 1.0e-14;
- Standard_Integer aNbPoints = line->NbPoints();
- if(aNbPoints > theMinNbPoints)
- return Standard_True;
-
- const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
- const Standard_Real aU1bLast = theASurf1->LastUParameter();
- const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
- const Standard_Real aU2bLast = theASurf2->LastUParameter();
- const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
- const Standard_Real aV1bLast = theASurf1->LastVParameter();
- const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
- const Standard_Real aV2bLast = theASurf2->LastVParameter();
-
-
- Standard_Boolean isPrecise = Standard_False;
-
- Standard_Real U1prec = 0.0, V1prec = 0.0, U2prec = 0.0, V2prec = 0.0;
-
- Standard_Integer aNbPointsPrev = 0;
- while(aNbPoints < theMinNbPoints && (aNbPoints != aNbPointsPrev))
- {
- aNbPointsPrev = aNbPoints;
- for(Standard_Integer fp = 1, lp = 2; fp < aNbPoints; fp = lp + 1)
- {
- Standard_Real U1f, V1f, U2f, V2f; //first point in 1st and 2nd surafaces
- Standard_Real U1l, V1l, U2l, V2l; //last point in 1st and 2nd surafaces
-
- lp = fp+1;
- line->Value(fp).Parameters(U1f, V1f, U2f, V2f);
- line->Value(lp).Parameters(U1l, V1l, U2l, V2l);
-
- U1prec = 0.5*(U1f+U1l);
- if(U1prec < aU1bFirst)
- U1prec = aU1bFirst;
- if(U1prec > aU1bLast)
- U1prec = aU1bLast;
-
- V1prec = 0.5*(V1f+V1l);
- if(V1prec < aV1bFirst)
- V1prec = aV1bFirst;
- if(V1prec > aV1bLast)
- V1prec = aV1bLast;
-
- U2prec = 0.5*(U2f+U2l);
- if(U2prec < aU2bFirst)
- U2prec = aU2bFirst;
- if(U2prec > aU2bLast)
- U2prec = aU2bLast;
-
- V2prec = 0.5*(V2f+V2l);
- if(V2prec < aV2bFirst)
- V2prec = aV2bFirst;
- if(V2prec > aV2bLast)
- V2prec = aV2bLast;
-
- Standard_Boolean aStatus = Standard_False;
- Standard_Integer aNbIter = 5;
- do
- {
- aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
- if(aStatus)
- {
- break;
- }
-
- aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
- if(aStatus)
- {
- break;
- }
-
- aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
- if(aStatus)
- {
- break;
- }
- }
- while(!aStatus && (--aNbIter > 0));
-
- if(aStatus)
- {
- gp_Pnt aP1 = theASurf1->Value(U1prec, V1prec),
- aP2 = theASurf2->Value(U2prec, V2prec);
- gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
-
- const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
- aSQDist2 = aPInt.SquareDistance(aP2);
-
- if((aSQDist1 < aTol) && (aSQDist2 < aTol))
- {
- IntSurf_PntOn2S anIP;
- anIP.SetValue(aPInt, U1prec, V1prec, U2prec, V2prec);
- line->InsertBefore(lp, anIP);
-
- isPrecise = Standard_True;
-
- if(++aNbPoints >= theMinNbPoints)
- break;
- }
- else
- {
- lp--;
- }
- }
- }
- }
-
- return isPrecise;
-}
-
-
+++ /dev/null
-// Copyright (c) 1995-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.
-
-//-------------------------------------------------------------------
-//-- I n t W a l k _ P W a l k i n g _ 2 . g x x
-//-------------------------------------------------------------------
-
-
-
-void IntWalk_PWalking::
- RepartirOuDiviser(Standard_Boolean& DejaReparti,
- IntImp_ConstIsoparametric& ChoixIso,
- Standard_Boolean& Arrive)
-
-// at the neighborhood of a point, there is a fail of marching
-// it is required to divide the steps to try to continue
-// if the step is too small if we are on border
-// restart in another direction if it was not done, otherwise stop
-
-{
- // Standard_Integer i;
- if (Arrive) { //restart in the other direction
- if (!DejaReparti ) {
- Arrive = Standard_False;
- DejaReparti = Standard_True;
- previousPoint = line->Value(1);
- previoustg = Standard_False;
- previousd1 = firstd1;
- previousd2 = firstd2;
- previousd = tgdir;
- indextg = line->NbPoints();
- tgdir.Reverse();
- line->Reverse();
-
-//-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
- sensCheminement = -1;
- tgfirst = tglast;
- tglast = Standard_False;
- ChoixIso = choixIsoSav;
-#if 0
- pasuv[0]=pasSav[0];
- pasuv[1]=pasSav[1];
- pasuv[2]=pasSav[2];
- pasuv[3]=pasSav[3];
-#else
- Standard_Real u1,v1,u2,v2;
- Standard_Real U1,V1,U2,V2;
- Standard_Integer nn=line->NbPoints();
- if(nn>2) {
- line->Value(nn).Parameters(u1,v1,u2,v2);
- line->Value(nn-1).Parameters(U1,V1,U2,V2);
- pasuv[0]=Abs(u1-U1);
- pasuv[1]=Abs(v1-V1);
- pasuv[2]=Abs(u2-U2);
- pasuv[3]=Abs(v2-V2);
- }
-#endif
-
- }
- }
- else {
- if ( pasuv[0]*0.5 < ResoU1
- && pasuv[1]*0.5 < ResoV1
- && pasuv[2]*0.5 < ResoU2
- && pasuv[3]*0.5 < ResoV2
- ) {
- if (!previoustg) {
- tglast = Standard_True; // IS IT ENOUGH ????
- }
-
- if (!DejaReparti) { //restart in the other direction
- DejaReparti = Standard_True;
- previousPoint = line->Value(1);
- previoustg = Standard_False;
- previousd1 = firstd1;
- previousd2 = firstd2;
- previousd = tgdir;
- indextg = line->NbPoints();
- tgdir.Reverse();
- line->Reverse();
-
-//-- printf("\nIntWalk_PWalking_2.gxx Reverse %3d\n",indextg);
-
- sensCheminement = -1;
- tgfirst = tglast;
- tglast = Standard_False;
- ChoixIso = choixIsoSav;
-
-#if 0
- pasuv[0]=pasSav[0];
- pasuv[1]=pasSav[1];
- pasuv[2]=pasSav[2];
- pasuv[3]=pasSav[3];
-#else
- Standard_Real u1,v1,u2,v2;
- Standard_Real U1,V1,U2,V2;
- Standard_Integer nn=line->NbPoints();
- if(nn>2) {
- line->Value(nn).Parameters(u1,v1,u2,v2);
- line->Value(nn-1).Parameters(U1,V1,U2,V2);
- pasuv[0]=Abs(u1-U1);
- pasuv[1]=Abs(v1-V1);
- pasuv[2]=Abs(u2-U2);
- pasuv[3]=Abs(v2-V2);
- }
-#endif
- }
- else Arrive = Standard_True;
- }
- else {
- pasuv[0]*=0.5;
- pasuv[1]*=0.5;
- pasuv[2]*=0.5;
- pasuv[3]*=0.5;
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1995-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 <Standard_Failure.hxx>
-#include <Precision.hxx>
-
-//#define DEBUG 0
-
-namespace {
-//OCC431(apo): modified ->
-static const Standard_Real CosRef2D = Cos(M_PI/9.0), AngRef2D = M_PI/2.0;
-
-static const Standard_Real d = 7.0;
-}
-
-IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection()
-
-// test if vector is observed by calculating an increase of vector
-// or the previous point and its tangent, the new calculated point and its
-// tangent; it is possible to find a cube passing by the 2 points and having as a
-// derivative the tangents of the intersection
-// calculate the point with parameter 0.5 on cube=p1
-// calculate the medium point of 2 points of intersection=p2
-// if arrow/2<=||p1p2||<= arrow consider that the vector is observed
-// otherwise adjust the step depending on the ratio ||p1p2||/vector
-// and the previous step
-// test if in 2 tangent planes of surfaces there is no too great angle2d
-// grand : if yes divide the step
-// test if there is no change of side
-//
-{
- if(line->NbPoints() ==1 ) {
- STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=STATIC_PRECEDENT_INFLEXION=0;
- }
-
- IntWalk_StatusDeflection Status = IntWalk_OK;
- Standard_Real FlecheCourante ,Ratio;
-
-
- const IntSurf_PntOn2S& CurrentPoint = myIntersectionOn2S.Point();
- //==================================================================================
- //========= S t o p o n p o i n t ============
- //==================================================================================
- if (myIntersectionOn2S.IsTangent()) {
- return IntWalk_ArretSurPoint;
- }
-
- const gp_Dir& TgCourante = myIntersectionOn2S.Direction();
-
- //==================================================================================
- //========= R i s k o f i n f l e x i o n p o i n t ============
- //==================================================================================
- if (TgCourante.Dot(previousd)<0) {
- //------------------------------------------------------------
- //-- Risk of inflexion point : Divide the step by 2
- //-- Initialize STATIC_PRECEDENT_INFLEXION so that
- //-- at the next call to return Pas_OK if there is no
- //-- more risk of the point of inflexion
- //------------------------------------------------------------
-
- pasuv[0]*=0.5;
- pasuv[1]*=0.5;
- pasuv[2]*=0.5;
- pasuv[3]*=0.5;
- STATIC_PRECEDENT_INFLEXION+=3;
- if (pasuv[0] < ResoU1 && pasuv[1] <ResoV1 && pasuv[2] <ResoU2 && pasuv[3] < ResoV2)
- return IntWalk_ArretSurPointPrecedent;
- else
- return IntWalk_PasTropGrand;
- }
-
- else {
- if(STATIC_PRECEDENT_INFLEXION > 0) {
- STATIC_PRECEDENT_INFLEXION -- ;
- return IntWalk_OK;
- }
- }
-
- //==================================================================================
- //========= D e t e c t c o n f u s e d P o in t s ===========
- //==================================================================================
-
- Standard_Real Dist = previousPoint.Value().
- SquareDistance(CurrentPoint.Value());
-
-
- if (Dist < tolconf*tolconf ) {
- pasuv[0] = Max(5.*ResoU1,Min(1.5*pasuv[0],pasInit[0]));
- pasuv[1] = Max(5.*ResoV1,Min(1.5*pasuv[1],pasInit[1]));
- pasuv[2] = Max(5.*ResoU2,Min(1.5*pasuv[2],pasInit[2]));
- pasuv[3] = Max(5.*ResoV2,Min(1.5*pasuv[3],pasInit[3]));
- Status = IntWalk_PointConfondu;
- }
-
- //==================================================================================
- Standard_Real Up1,Vp1,Uc1,Vc1,Du1,Dv1,AbsDu1,AbsDu2,AbsDv1,AbsDv2;
- Standard_Real Up2,Vp2,Uc2,Vc2,Du2,Dv2;
-
- previousPoint.Parameters(Up1,Vp1,Up2,Vp2);
- CurrentPoint.Parameters(Uc1,Vc1,Uc2,Vc2);
-
- Du1 = Uc1 - Up1; Dv1 = Vc1 - Vp1;
- Du2 = Uc2 - Up2; Dv2 = Vc2 - Vp2;
-
- AbsDu1 = Abs(Du1);
- AbsDu2 = Abs(Du2);
- AbsDv1 = Abs(Dv1);
- AbsDv2 = Abs(Dv2);
- //=================================================================================
- //==== S t e p o f p r o g r e s s i o n (between previous and Current) =======
- //=================================================================================
- if ( AbsDu1 < ResoU1 && AbsDv1 < ResoV1
- && AbsDu2 < ResoU2 && AbsDv2 < ResoV2) {
- pasuv[0] = ResoU1; pasuv[1] = ResoV1; pasuv[2] = ResoU2; pasuv[3] = ResoV2;
- return(IntWalk_ArretSurPointPrecedent);
- }
- //==================================================================================
-
- Standard_Real tolArea = 100.0;
- if (ResoU1 < Precision::PConfusion() ||
- ResoV1 < Precision::PConfusion() ||
- ResoU2 < Precision::PConfusion() ||
- ResoV2 < Precision::PConfusion() )
- tolArea = tolArea*2.0;
-
- Standard_Real Cosi1, CosRef1, Ang1, AngRef1, ResoUV1, Duv1, d1, tolCoeff1;
- Standard_Real Cosi2, CosRef2, Ang2, AngRef2, ResoUV2, Duv2, d2, tolCoeff2;
- Cosi1 = Du1*previousd1.X() + Dv1*previousd1.Y();
- Cosi2 = Du2*previousd2.X() + Dv2*previousd2.Y();
- Duv1 = Du1*Du1 + Dv1*Dv1;
- Duv2 = Du2*Du2 + Dv2*Dv2;
- ResoUV1 = ResoU1*ResoU1 + ResoV1*ResoV1;
- ResoUV2 = ResoU2*ResoU2 + ResoV2*ResoV2;
- //
- //modified by NIZNHY-PKV Wed Nov 13 12:25:44 2002 f
- //
- Standard_Real aMinDiv2=Precision::Confusion();
- aMinDiv2=aMinDiv2*aMinDiv2;
- //
- d1=d;
- if (Duv1>aMinDiv2) {
- d1 = Abs(ResoUV1/Duv1);
- d1 = Min(Sqrt(d1)*tolArea, d);
- }
- //d1 = Abs(ResoUV1/Duv1);
- //d1 = Min(Sqrt(d1)*tolArea,d);
- //modified by NIZNHY-PKV Wed Nov 13 12:34:30 2002 t
- tolCoeff1 = Exp(d1);
- //
- //modified by NIZNHY-PKV Wed Nov 13 12:34:43 2002 f
- d2=d;
- if (Duv2>aMinDiv2) {
- d2 = Abs(ResoUV2/Duv2);
- d2 = Min(Sqrt(d2)*tolArea,d);
- }
- //d2 = Abs(ResoUV2/Duv2);
- //d2 = Min(Sqrt(d2)*tolArea,d);
- //modified by NIZNHY-PKV Wed Nov 13 12:34:53 2002 t
- tolCoeff2 = Exp(d2);
- CosRef1 = CosRef2D/tolCoeff1;
- CosRef2 = CosRef2D/tolCoeff2;
- //
- //==================================================================================
- //== The points are not confused : ==
- //== D e t e c t t h e S t o p a t p r e v i o u s p o i n t ==
- //== N o t T o o G r e a t (angle in space UV) ==
- //== C h a n g e o f s i d e ==
- //==================================================================================
- if (Status != IntWalk_PointConfondu) {
- if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2) {
- pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
- if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2) {
- return(IntWalk_ArretSurPointPrecedent);
- }
- else {
- pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
- return(IntWalk_PasTropGrand);
- }
- }
- const gp_Dir2d& Tg2dcourante1 = myIntersectionOn2S.DirectionOnS1();
- const gp_Dir2d& Tg2dcourante2 = myIntersectionOn2S.DirectionOnS2();
- Cosi1 = Du1*Tg2dcourante1.X() + Dv1*Tg2dcourante1.Y();
- Cosi2 = Du2*Tg2dcourante2.X() + Dv2*Tg2dcourante2.Y();
- Ang1 = Abs(previousd1.Angle(Tg2dcourante1));
- Ang2 = Abs(previousd2.Angle(Tg2dcourante2));
- AngRef1 = AngRef2D*tolCoeff1;
- AngRef2 = AngRef2D*tolCoeff2;
- //-------------------------------------------------------
- //-- Test : Angle too great in space UV -----
- //-- Change of side -----
- //-------------------------------------------------------
- if(Cosi1*Cosi1 < CosRef1*Duv1 || Cosi2*Cosi2 < CosRef2*Duv2 || Ang1 > AngRef1 || Ang2 > AngRef2) {
- pasuv[0]*=0.5; pasuv[1]*=0.5; pasuv[2]*=0.5; pasuv[3]*=0.5;
- if (pasuv[0]<ResoU1 && pasuv[1]<ResoV1 && pasuv[2]<ResoU2 && pasuv[3]<ResoV2)
- return(IntWalk_ArretSurPoint);
- else
- return(IntWalk_PasTropGrand);
- }
- }
- //<-OCC431(apo)
- //==================================================================================
- //== D e t e c t i o n o f : Step Too Small
- //== STEP TOO Great
- //==================================================================================
-
- //---------------------------------------
- //-- Estimate of the vector --
- //---------------------------------------
- FlecheCourante =
- Sqrt(Abs((previousd.XYZ()-TgCourante.XYZ()).SquareModulus()*Dist))/8.;
-
- if ( FlecheCourante<= fleche*0.5) { //-- Current step too small
- if(FlecheCourante>1e-16) {
- Ratio = 0.5*(fleche/FlecheCourante);
- }
- else {
- Ratio = 10.0;
- }
- Standard_Real pasSu1 = pasuv[0];
- Standard_Real pasSv1 = pasuv[1];
- Standard_Real pasSu2 = pasuv[2];
- Standard_Real pasSv2 = pasuv[3];
-
- //-- In case if
- //-- a point at U+DeltaU is required, ....
- //-- return a point at U + Epsilon
- //-- Epsilon << DeltaU.
-
- if(pasuv[0]< AbsDu1) pasuv[0] = AbsDu1;
- if(pasuv[1]< AbsDv1) pasuv[1] = AbsDv1;
- if(pasuv[2]< AbsDu2) pasuv[2] = AbsDu2;
- if(pasuv[3]< AbsDv2) pasuv[3] = AbsDv2;
-
- if(pasuv[0]<ResoU1) pasuv[0]=ResoU1;
- if(pasuv[1]<ResoV1) pasuv[1]=ResoV1;
- if(pasuv[2]<ResoU2) pasuv[2]=ResoU2;
- if(pasuv[3]<ResoV2) pasuv[3]=ResoV2;
- //-- if(Ratio>10.0 ) { Ratio=10.0; }
- Standard_Real R1,R = pasInit[0]/pasuv[0];
- R1= pasInit[1]/pasuv[1]; if(R1<R) R=R1;
- R1= pasInit[2]/pasuv[2]; if(R1<R) R=R1;
- R1= pasInit[3]/pasuv[3]; if(R1<R) R=R1;
- if(Ratio > R) Ratio=R;
- pasuv[0] = Min(Ratio*pasuv[0],pasInit[0]);
- pasuv[1] = Min(Ratio*pasuv[1],pasInit[1]);
- pasuv[2] = Min(Ratio*pasuv[2],pasInit[2]);
- pasuv[3] = Min(Ratio*pasuv[3],pasInit[3]);
- if (pasuv[0] != pasSu1 || pasuv[2] != pasSu2||
- pasuv[1] != pasSv1 || pasuv[3] != pasSv2) {
- if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
- STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
- return IntWalk_PasTropGrand;
- }
- }
- if(Status == IntWalk_OK) {
- STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
- //-- Try to increase the step
- }
- return Status;
- }
- else { //-- CurrentVector > vector*0.5
- if (FlecheCourante > fleche) { //-- Current step too Great
- Ratio = fleche/FlecheCourante;
- pasuv[0] = Ratio*pasuv[0];
- pasuv[1] = Ratio*pasuv[1];
- pasuv[2] = Ratio*pasuv[2];
- pasuv[3] = Ratio*pasuv[3];
- //if(++STATIC_BLOCAGE_SUR_PAS_TROP_GRAND > 5) {
- // STATIC_BLOCAGE_SUR_PAS_TROP_GRAND = 0;
- return IntWalk_PasTropGrand;
- //}
- }
- else { //-- vector/2 < CurrentVector <= vector
- Ratio = 0.75 * (fleche / FlecheCourante);
- }
- }
- pasuv[0] = Max(5.*ResoU1,Min(Min(Ratio*AbsDu1,pasuv[0]),pasInit[0]));
- pasuv[1] = Max(5.*ResoV1,Min(Min(Ratio*AbsDv1,pasuv[1]),pasInit[1]));
- pasuv[2] = Max(5.*ResoU2,Min(Min(Ratio*AbsDu2,pasuv[2]),pasInit[2]));
- pasuv[3] = Max(5.*ResoV2,Min(Min(Ratio*AbsDv2,pasuv[3]),pasInit[3]));
- if(Status == IntWalk_OK) STATIC_BLOCAGE_SUR_PAS_TROP_GRAND=0;
- return Status;
-}
-
-
-
+++ /dev/null
-// Copyright (c) 1995-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.
-
-//--
-//-- Modif of 5 October 94 (LBR)
-//-- if(Trouve) ...
-//-- outpasses a border, Duv[.] = -1 -1 -1 -1
-//-- keep the same iso limited (see if(k!=1) )
-//--
-
-//-- Modif of 8 July 96 (LBR)
-//-- simplify processing of auto-intersections.
-//-- Idea : Test closed loop in 3d and in 2d.
-//--
-
-#include <gp_Pnt2d.hxx>
-
-
-Standard_Boolean IntWalk_PWalking::
- TestArret(const Standard_Boolean DejaReparti,
- TColStd_Array1OfReal& Param,
- IntImp_ConstIsoparametric& ChoixIso)
-
-//
-// test if the point of intersection set by these parameters remains in the
-// natural domain of each square.
-// if the point outpasses reframe to find the best iso (border)
-// that intersects easiest the other square
-// otherwise test if closed line is present
-//
-{
- Standard_Real Uvd[4],Uvf[4],Epsuv[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
- Standard_Real DPc,DPb;
- Standard_Integer i = 0, k = 0;
- Epsuv[0] = ResoU1;
- Epsuv[1] = ResoV1;
- Epsuv[2] = ResoU2;
- Epsuv[3] = ResoV2;
- previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
-
- Standard_Real SolParam[4];
- myIntersectionOn2S.Point().Parameters(SolParam[0],SolParam[1],SolParam[2],SolParam[3]);
-
- Standard_Boolean Trouve = Standard_False;
-
- Uvd[0]=Um1; Uvf[0]=UM1; Uvd[1]=Vm1; Uvf[1]=VM1;
- Uvd[2]=Um2; Uvf[2]=UM2; Uvd[3]=Vm2; Uvf[3]=VM2;
-
- Standard_Integer im1;
- for ( i = 1,im1 = 0;i<=4;i++,im1++) {
- switch(i) {
- case 1: k=2; break;
- case 2: k=1; break;
- case 3: k=4; break;
- case 4: k=3; break;
- }
- if (Param(i) < (Uvd[im1]-Epsuv[im1]) ||
- SolParam[im1] < (Uvd[im1]-Epsuv[im1])) //-- Current ----- Bound Inf ----- Previous
- {
- Trouve = Standard_True; //--
- DPc = Uvp[im1]-Param(i); //-- Previous - Current
- DPb = Uvp[im1]-Uvd[im1]; //-- Previous - Bound Inf
- ParC[im1] = Uvd[im1]; //-- ParamCorrige
- dv = Param(k)-Uvp[k-1]; //-- Current - Previous (other Direction)
- dv2 = dv*dv;
- if(dv2>RealEpsilon()) { //-- Progress at the other Direction ?
- Duv[im1] = DPc*DPb + dv2;
- Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
- }
- else {
- Duv[im1]=-1.0; //-- If no progress, do not change
- } //-- the choice of iso
- }
- else if (Param(i) > (Uvf[im1] + Epsuv[im1]) ||
- SolParam[im1] > (Uvf[im1] + Epsuv[im1]))//-- Previous ----- Bound Sup ----- Current
- {
- Trouve = Standard_True; //--
- DPc = Param(i)-Uvp[im1]; //-- Current - Previous
- DPb = Uvf[im1]-Uvp[im1]; //-- Bound Sup - Previous
- ParC[im1] = Uvf[im1]; //-- Param Corrige
- dv = Param(k)-Uvp[k-1]; //-- Current - Previous (other Direction)
- dv2 = dv*dv;
- if(dv2>RealEpsilon()) { //-- Progress in other Direction ?
- Duv[im1] = DPc*DPb + dv2;
- Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
- }
- else {
- Duv[im1]=-1.0; //-- If no progress, do not change
- } //-- the choice of iso
- }
- else {
- Duv[im1]= -1.;
- ParC[im1]=Param(i);
- }
- }
-
- if (Trouve) {
- //--------------------------------------------------
- //-- One of Parameters u1,v1,u2,v2 is outside of --
- //-- the natural limits. --
- //-- Find the best direction of --
- //-- progress and reframe the parameters. --
- //--------------------------------------------------
- Standard_Real ddv = -1.0;
- k=-1;
- for (i=0;i<=3;i++) {
- Param(i+1) = ParC[i];
- if(Duv[i]>ddv) {
- ddv = Duv[i];
- k=i;
- }
- }
- if(k!=-1) {
- ChoixIso = ChoixRef[k];
- }
- else {
- if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
- ChoixIso = IntImp_UIsoparametricOnCaro1;
- }
- else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
- ChoixIso = IntImp_VIsoparametricOnCaro1;
- }
- else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
- ChoixIso = IntImp_UIsoparametricOnCaro2;
- }
- else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
- ChoixIso = IntImp_VIsoparametricOnCaro2;
- }
- }
- close = Standard_False;
- return Standard_True;
- }
- else
- {
- if (!DejaReparti) { // find if line closed
-
- Standard_Real u,v;
- const IntSurf_PntOn2S& POn2S1=line->Value(1);
- //On S1
- POn2S1.ParametersOnS1(u,v);
- gp_Pnt2d P1uvS1(u,v);
- previousPoint.ParametersOnS1(u,v);
- gp_Pnt2d PrevuvS1(u,v);
- myIntersectionOn2S.Point().ParametersOnS1(u,v);
- gp_Pnt2d myIntersuvS1(u,v);
- Standard_Boolean close2dS1 = (P1uvS1.XY()-PrevuvS1.XY())*
- (P1uvS1.XY()-myIntersuvS1.XY()) < 0.0;
- //On S2
- POn2S1.ParametersOnS2(u,v);
- gp_Pnt2d P1uvS2(u,v);
- previousPoint.ParametersOnS2(u,v);
- gp_Pnt2d PrevuvS2(u,v);
- myIntersectionOn2S.Point().ParametersOnS2(u,v);
- gp_Pnt2d myIntersuvS2(u,v);
- Standard_Boolean close2dS2 = (P1uvS2.XY()-PrevuvS2.XY())*
- (P1uvS2.XY()-myIntersuvS2.XY()) < 0.0;
-
- close = close2dS1 && close2dS2;
- return close;
- }
- else return Standard_False;
- }
-}
-
-
-- line and a polyhedron. Points of intersection and zones
-- of tangence.
- generic class InterferencePolyhedron;
- ---Purpose: Compute the interference between two polyhedron. Points
- -- of intersection , polylines of intersection and zones of
- -- tangence.
-
--- Package Methods :
--
+++ /dev/null
--- Created on: 1992-09-29
--- Created by: Didier PIFFAULT
--- Copyright (c) 1992-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.
-
-generic class InterferencePolyhedron from Intf
- (Polyhedron1 as any;
- ToolPolyhe1 as any;
- Polyhedron2 as any;
- ToolPolyhe2 as any)
- inherits Interference from Intf
-
- ---Purpose: Computes the interference between two polyhedra or the
- -- self interference of a polyhedron.
-
-uses Pnt from gp,
- XYZ from gp,
- Box from Bnd,
- SectionPoint from Intf,
- SeqOfSectionPoint from Intf,
- SectionLine from Intf,
- SeqOfSectionLine from Intf,
- TangentZone from Intf,
- SeqOfTangentZone from Intf
-
-is
-
--- Interface :
-
- Create returns InterferencePolyhedron from Intf;
- ---Purpose: Constructs an empty interference of Polyhedron.
-
- Create (Obje1 : in Polyhedron1;
- Obje2 : in Polyhedron2)
- returns InterferencePolyhedron from Intf;
- ---Purpose: Constructs and computes an interference between the two
- -- Polyhedra.
-
- Create (Obje : in Polyhedron1)
- returns InterferencePolyhedron from Intf;
- ---Purpose: Constructs and computes the self interference of a
- -- Polyhedron.
-
- Perform (me : in out;
- Obje1 : in Polyhedron1;
- Obje2 : in Polyhedron2);
- ---Purpose: Computes the interference between the two Polyhedra.
-
- Perform (me : in out;
- Obje : in Polyhedron1);
- ---Purpose: Computes the self interference of a Polyhedron.
-
--- Implementation :
-
- Interference (me : in out;
- Obje1 : in Polyhedron1)
- is private;
- Interference (me : in out;
- Obje1 : in Polyhedron1;
- Obje2 : in Polyhedron2)
- is private;
- ---Purpose: Compares the bounding volumes between the facets of <Obje1>
- -- and the facets of <Obje2> and intersects the facets when the
- -- bounding volumes have a common part.
-
- Intersect (me : in out;
- TriF : in Integer from Standard;
- Obje1 : in Polyhedron1;
- TriS : in Integer from Standard;
- Obje2 : in Polyhedron2)
- is private;
- ---Purpose: Computes the intersection between the facet <Tri1> of
- -- <FirstPol> and the facet <Tri2> of <SecondPol>.
-
- TangentZoneValue
- (me;
- TheTZ : in out TangentZone from Intf;
- Obje1 : Polyhedron1;
- Tri1 : Integer from Standard;
- Obje2 : Polyhedron2;
- Tri2 : Integer from Standard)
- returns Boolean from Standard
- is private;
- ---Purpose: Computes the zone of tangence between the facet <Tri1> of
- -- <FirstPol> and the facet <Tri2> of <SecondPol>.
-
- CoupleCharacteristics (me: in out;
- FirstPol: Polyhedron1;
- SeconPol: Polyhedron2) is private;
-fields
- OI : Integer from Standard[3]; -- index des sommets de l objet
- TI : Integer from Standard[3]; -- index des sommets du tool
- dpOpT : Real from Standard[3, 3]; -- distance point Objet - point Tool
- dpOeT : Real from Standard[3, 3]; -- distance point Objet - edge Tool
- deOpT : Real from Standard[3, 3]; -- distance edge Objet - point Tool
- voo : XYZ from gp[3]; -- vecteur point point Obje
- vtt : XYZ from gp[3]; -- vecteur point point Tool
- Incidence: Real from Standard; -- angle entre les deux plans
-
-end InterferencePolyhedron;
+++ /dev/null
-// Created on: 1992-11-09
-// Created by: Didier PIFFAULT
-// Copyright (c) 1992-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 <gp_XYZ.hxx>
-#include <gp_Vec.hxx>
-#include <gp_Pnt.hxx>
-#include <Intf_SectionPoint.hxx>
-#include <Intf_SeqOfSectionPoint.hxx>
-#include <Intf_SectionLine.hxx>
-#include <Intf_SeqOfSectionLine.hxx>
-#include <Intf_TangentZone.hxx>
-#include <Intf_SeqOfTangentZone.hxx>
-#include <Intf.hxx>
-#include <Bnd_HArray1OfBox.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <Bnd_BoundSortBox.hxx>
-
-static const int Pourcent3[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};
-
-//=======================================================================
-//function : Intf_InterferencePolyhedron
-//purpose : Empty constructor.
-//=======================================================================
-
-Intf_InterferencePolyhedron::Intf_InterferencePolyhedron ()
-: Intf_Interference(Standard_False)
-{}
-
-//=======================================================================
-//function : Intf_InterferencePolyhedron
-//purpose :
-//=======================================================================
-
-Intf_InterferencePolyhedron::Intf_InterferencePolyhedron
- (const Polyhedron1& FirstPol, const Polyhedron2& SeconPol)
-: Intf_Interference(Standard_False)
-{
- if (!ToolPolyhe1::Bounding(FirstPol).IsOut
- (ToolPolyhe2::Bounding(SeconPol))) {
- Tolerance=ToolPolyhe1::DeflectionOverEstimation(FirstPol)+
- ToolPolyhe2::DeflectionOverEstimation(SeconPol);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
- Interference(FirstPol, SeconPol);
- }
-}
-
-//=======================================================================
-//function : Intf_InterferencePolyhedron
-//purpose :
-//=======================================================================
-
-Intf_InterferencePolyhedron::Intf_InterferencePolyhedron
- (const Polyhedron1& Objet)
-: Intf_Interference(Standard_True)
-{
- Tolerance=ToolPolyhe1::DeflectionOverEstimation(Objet)*2;
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
- Interference(Objet,Objet); //-- lbr le 5 juillet 96
- }
-
-
-//=======================================================================
-//function : Perform
-//purpose :
-//=======================================================================
-
-void Intf_InterferencePolyhedron::Perform
- (const Polyhedron1& FirstPol, const Polyhedron2& SeconPol)
-{
- SelfInterference(Standard_False);
- if (!ToolPolyhe1::Bounding(FirstPol).IsOut
- (ToolPolyhe2::Bounding(SeconPol))) {
- Tolerance=ToolPolyhe1::DeflectionOverEstimation(FirstPol)+
- ToolPolyhe2::DeflectionOverEstimation(SeconPol);
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
- Interference(FirstPol, SeconPol);
- }
-}
-
-//=======================================================================
-//function : Perform
-//purpose :
-//=======================================================================
-
-void Intf_InterferencePolyhedron::Perform
- (const Polyhedron1& Objet)
-{
- SelfInterference(Standard_True);
- Tolerance=ToolPolyhe1::DeflectionOverEstimation(Objet)*2;
- if (Tolerance==0.)
- Tolerance=Epsilon(1000.);
- Interference(Objet);
-}
-
-
-//=======================================================================
-//function : Interference
-//purpose :
-//=======================================================================
-
-void Intf_InterferencePolyhedron::Interference
- (const Polyhedron1&)
-{}
-
-void Intf_InterferencePolyhedron::Interference
- (const Polyhedron1& FirstPol, const Polyhedron2& SeconPol)
-{
- Standard_Boolean gridOnFirst=Standard_True;
- Standard_Integer NbTrianglesFirstPol = ToolPolyhe1::NbTriangles(FirstPol);
- Standard_Integer NbTrianglesSecondPol = ToolPolyhe2::NbTriangles(SeconPol);
- Standard_Integer iFirst, iSecon;
-
- //------------------------------------------------------------------------------------------
- //-- the same number of triangles it is necessary to test better on
- //-- the size of boxes.
- //--
- //-- the second is chosen if nbTri1 > 2*nbTri2 or if VolBoit1 > 2*VolBoit2
- //--
- //--if (!SelfIntf && NbTrianglesFirstPol>NbTrianglesSecondPol)
- //-- gridOnFirst=Standard_False;
-
- if(!SelfIntf) {
- if(NbTrianglesFirstPol > NbTrianglesSecondPol+NbTrianglesSecondPol) gridOnFirst=Standard_False;
-
- Standard_Real vol1,vol2,Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
- ToolPolyhe1::Bounding(FirstPol).Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
- vol1 = (Xmax-Xmin)*(Ymax-Ymin)*(Zmax-Zmin);
-
- ToolPolyhe1::Bounding(SeconPol).Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
- vol2 = (Xmax-Xmin)*(Ymax-Ymin)*(Zmax-Zmin);
-
- if(vol1> 8.0*vol2) gridOnFirst=Standard_False;
- }
-
-
- if (gridOnFirst) {
- Bnd_BoundSortBox TheGridFirst;
- TheGridFirst.Initialize(ToolPolyhe1::Bounding(FirstPol),
- ToolPolyhe1::ComponentsBounding(FirstPol));
-
- for (iSecon=1; iSecon<=NbTrianglesSecondPol; iSecon++) {
-
- TColStd_ListIteratorOfListOfInteger iLoI(TheGridFirst.Compare
- (ToolPolyhe2::ComponentsBounding(SeconPol)->Value(iSecon)));
- while (iLoI.More()) {
- iFirst=iLoI.Value();
- if (SelfIntf) {
- if (iFirst<iSecon)
- Intersect(iFirst, FirstPol, iSecon, SeconPol);
- }
- else
- Intersect(iFirst, FirstPol, iSecon, SeconPol);
- iLoI.Next();
- }
- }
- }
-
- else {
- Bnd_BoundSortBox TheGridSecond;
- TheGridSecond.Initialize(ToolPolyhe2::Bounding(SeconPol),
- ToolPolyhe2::ComponentsBounding(SeconPol));
-
- for (iFirst=1; iFirst<=NbTrianglesFirstPol; iFirst++) {
- TColStd_ListIteratorOfListOfInteger
- iLoI(TheGridSecond.Compare
- (ToolPolyhe1::ComponentsBounding(FirstPol)->Value(iFirst)));
-
- while (iLoI.More()) {
- iSecon=iLoI.Value();
- if (SelfIntf) {
- if (iFirst<iSecon)
- Intersect(iFirst, FirstPol, iSecon, SeconPol);
- }
- else
- Intersect(iFirst, FirstPol, iSecon, SeconPol);
- iLoI.Next();
- }
- }
- }
-}
-
-
-//=======================================================================
-//function : Intersect
-//purpose : Intersection of two triangles issue from two Polyhedron.
-//=======================================================================
-
-void Intf_InterferencePolyhedron::Intersect
-(const Standard_Integer Tri1, const Polyhedron1& FirstPol,
- const Standard_Integer Tri2, const Polyhedron2& SeconPol)
-{
- ToolPolyhe1::Triangle(FirstPol, Tri1,OI[0],OI[1],OI[2]);
- ToolPolyhe2::Triangle(SeconPol, Tri2,TI[0],TI[1],TI[2]);
-
- // If there is an intersection of a polyhedron with itself, the
- // intersections are excluded
- // from a triangle with connected triangles :
-
- if (SelfIntf) {
- if (OI[0]==TI[0] || OI[0]==TI[1] || OI[0]==TI[2] ||
- OI[1]==TI[0] || OI[1]==TI[1] || OI[1]==TI[2] ||
- OI[2]==TI[0] || OI[2]==TI[1] || OI[2]==TI[2] ) return;
- }
-
- // The precision of intersections includes two values ;
-
- // - Tolerance :This value allows detecting potential
- // intersections in all cases. The value should be the
- // sum of upper bounds of tops pof two polyhedrons.
-
- // - floatGap : This value is the actual precision of calculation
- // of line of section.Its value is very small, it
- // allows having the same behaviour for
- // geometry tests as for the values used.
-
- Standard_Real floatGap=1e-13 ; //-- Epsilon(1000.);
-
-
- // Equation of the triangle plane of the objet
- gp_XYZ ONor; // Normal vector.
- Standard_Real Odp; // Polar Distance.
- Intf::PlaneEquation(ToolPolyhe1::Point(FirstPol, OI[0]),
- ToolPolyhe1::Point(FirstPol, OI[1]),
- ToolPolyhe1::Point(FirstPol, OI[2]),
- ONor, Odp);
-
-
-// Equation of the triangle plane of the tool
- gp_XYZ TNor; // Normal vector.
- Standard_Real Tdp; // Polar distance.
- Intf::PlaneEquation(ToolPolyhe2::Point(SeconPol, TI[0]),
- ToolPolyhe2::Point(SeconPol, TI[1]),
- ToolPolyhe2::Point(SeconPol, TI[2]),
- TNor, Tdp);
-
-
-// Scalar product of two normalized vectors -> cosinus of the angle
- Incidence= Abs(TNor*ONor);
-
-// Distance of the plane of the triangle from the object by three points of SeconPol
- Standard_Real dfOpT[3];
- dfOpT[0]=ONor*(ToolPolyhe2::Point(SeconPol, TI[0]).XYZ())-Odp;
- dfOpT[1]=ONor*(ToolPolyhe2::Point(SeconPol, TI[1]).XYZ())-Odp;
- dfOpT[2]=ONor*(ToolPolyhe2::Point(SeconPol, TI[2]).XYZ())-Odp;
-
-// Distance of the plane of the triangle from the tool by three points of FirstPol
- Standard_Real dpOfT[3];
- dpOfT[0]=TNor*(ToolPolyhe1::Point(FirstPol, OI[0]).XYZ())-Tdp;
- dpOfT[1]=TNor*(ToolPolyhe1::Point(FirstPol, OI[1]).XYZ())-Tdp;
- dpOfT[2]=TNor*(ToolPolyhe1::Point(FirstPol, OI[2]).XYZ())-Tdp;
-
-// Values defining the couple of triangle dpOpT, dpOeT, deOpT
- CoupleCharacteristics(FirstPol, SeconPol);
-
-// If three points of the triangle of <SeconPol> are in the plane of the
-// triangle of <Obje> within <Tolerance> the eventual tangency zone is found.
-
- Intf_TangentZone TheTZ;
- if ((Abs(dfOpT[0])<=Tolerance &&
- Abs(dfOpT[1])<=Tolerance &&
- Abs(dfOpT[2])<=Tolerance) &&
- (Abs(dpOfT[0])<=Tolerance &&
- Abs(dpOfT[1])<=Tolerance &&
- Abs(dpOfT[2])<=Tolerance) &&
- (Abs(dfOpT[0]+dfOpT[1]+dfOpT[2])!=
- Abs(dfOpT[0])+Abs(dfOpT[1])+Abs(dfOpT[2])) &&
- (Abs(dpOfT[0]+dpOfT[1]+dpOfT[2])!=
- Abs(dpOfT[0])+Abs(dpOfT[1])+Abs(dpOfT[2]))){
-
- if (TangentZoneValue(TheTZ, FirstPol, Tri1, SeconPol, Tri2))
- {
- if (!Insert(TheTZ)) myTZones.Append(TheTZ);
- }
- }
-
-// Otherwise line of section is calculated:
- else {
- Standard_Integer iObj, iToo;
-
- // Zone de stockage des resultats :
- Standard_Integer nbpiOT=0;
- Standard_Integer nbpiO=0;
- Standard_Integer nbpiT=0;
- Intf_SeqOfSectionPoint piOT;
- Standard_Real parO[3];
- Standard_Real parT[3];
-
- // Indicateurs d arete touchee
- Standard_Integer edOT[3];
- Standard_Integer edTT[3];
-
- // Initializations
- //--for (iObj=0; iObj<3; iObj++) {
- // parO[iObj]=parT[iObj]=-1.;
- // edOT[iObj]=edTT[iObj]=1;
- //--}
- parO[0]=parT[0]=parO[1]=parT[1]=parO[2]=parT[2]=-1.0;
- edOT[0]=edTT[0]=edOT[1]=edTT[1]=edOT[2]=edTT[2]= 1;
-
- // Singularite VERTEX VERTEX
- //for (iObj=0; iObj<3; iObj++) {
- // for (iToo=0; iToo<3; iToo++) {
- // if (dpOpT[iObj][iToo] <= floatGap) {
- // piOT.Append(Intf_SectionPoint(ToolPolyhe1::Point(FirstPol, OI[iObj]),
- // Intf_VERTEX, OI[iObj], 0, 0.,
- // Intf_VERTEX, TI[iToo], 0, 0.,
- // Incidence));
- // parO[iObj]=0.;
- // parT[iToo]=0.;
- // edOT[Pourcent3[iObj+2]]=0; edOT[iObj]=0;
- // edTT[Pourcent3[iToo+2]]=0; edTT[iToo]=0;
- // nbpiOT++; nbpiO++; nbpiT++;
- // }
- // }
- //}
- //---------------------------->
- for (iObj=0; iObj<3; iObj++) {
- for (iToo=0; iToo<3; iToo++) {
- if (dpOpT[iObj][iToo] <= floatGap) {
- piOT.Append(Intf_SectionPoint(ToolPolyhe1::Point(FirstPol, OI[iObj]),
- Intf_VERTEX, OI[iObj], 0, 0.,
- Intf_VERTEX, TI[iToo], 0, 0.,
- Incidence));
- parO[iObj]=parT[iToo]=0.0;
- edOT[Pourcent3[iObj+2]]=edOT[iObj]=edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
- nbpiOT++; nbpiO++; nbpiT++;
- }
- }
- }
-
-
- // Singularite VERTEX EDGE
- Standard_Integer inext, jnext;
- for (iObj=0; iObj<3; iObj++) {
- if (parO[iObj]==-1.) {
- for (iToo=0; iToo<3; iToo++) {
- inext=Pourcent3[iToo+1];
- if (edTT[iToo]==1) {
- if (dpOeT[iObj][iToo] <= floatGap && dpOeT[iObj][iToo]>=-floatGap ) {
- if ((dpOpT[iObj][iToo]+dpOpT[iObj][inext])<vtt[iToo].Modulus()) {
- parT[iToo]=dpOpT[iObj][iToo]/(dpOpT[iObj][iToo]+
- dpOpT[iObj][inext]);
- if (TI[iToo]>TI[inext]) parT[iToo]=1.-parT[iToo];
- piOT.Append(Intf_SectionPoint
- (ToolPolyhe1::Point(FirstPol, OI[iObj]),
- Intf_VERTEX, OI[iObj], 0, 0.,
- Intf_EDGE, Min(TI[iToo],TI[inext]),
- Max(TI[iToo],TI[inext]), parT[iToo],
- Incidence));
- parO[iObj]=0.;
- edOT[Pourcent3[iObj+2]]=0; edOT[iObj]=0;
- edTT[iToo]=0;
- nbpiOT++; nbpiO++; nbpiT++;
- }
- }
- }
- }
- }
- }
-
- // Singularite EDGE VERTEX
- for (iToo=0; iToo<3; iToo++) {
- if (parT[iToo]==-1.) {
- for (iObj=0; iObj<3; iObj++) {
- inext=Pourcent3[iObj+1];
- if (edOT[iObj]==1) {
- if (Abs(deOpT[iObj][iToo]) <= floatGap) {
- if ((dpOpT[iObj][iToo]+dpOpT[inext][iToo])<voo[iObj].Modulus()){
- parO[iObj]=dpOpT[iObj][iToo]/(dpOpT[iObj][iToo]+
- dpOpT[inext][iToo]);
- if (OI[iObj]>OI[inext]) parO[iObj]=1.-parO[iObj];
- piOT.Append(Intf_SectionPoint
- (ToolPolyhe2::Point(SeconPol, TI[iToo]),
- Intf_EDGE, Min(OI[iObj],OI[inext]),
- Max(OI[iObj],OI[inext]), parO[iObj],
- Intf_VERTEX, TI[iToo], 0, 0.,
- Incidence));
- parT[iToo]=0.;
- edOT[iObj]=edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
- nbpiOT++; nbpiO++; nbpiT++;
- }
- }
- }
- }
- }
- }
-
- // Singularite FACE VERTEX
- for (iToo=0; iToo<3; iToo++) {
- if (parT[iToo]!=0.) {
- if (Abs(dfOpT[iToo]) <= floatGap) {
- piOT.Append(Intf_SectionPoint(ToolPolyhe2::Point(SeconPol, TI[iToo]),
- Intf_FACE, Tri1, 0, 0.,
- Intf_VERTEX, TI[iToo], 0, 0.,
- Incidence));
- parT[iToo]=0.;
- edTT[Pourcent3[iToo+2]]=edTT[iToo]=0;
- nbpiOT++; nbpiT++;
- }
- }
- }
-
- // Singularite VERTEX FACE
- for (iObj=0; iObj<3; iObj++) {
- if (parO[iObj]!=0.) {
- if (Abs(dpOfT[iObj]) <= floatGap) {
- piOT.Append(Intf_SectionPoint(ToolPolyhe1::Point(FirstPol, OI[iObj]),
- Intf_VERTEX, OI[iObj], 0, 0.,
- Intf_FACE, Tri2, 0, 0.,
- Incidence));
- parO[iObj]=0.;
- edOT[Pourcent3[iObj+2]]=edOT[iObj]=0;
- nbpiOT++; nbpiO++;
- }
- }
- }
-
- // Singularite EDGE EDGE
- gp_Pnt piO;
- gp_XYZ piT;
- Standard_Real lg;
- for (iObj=0; iObj<3; iObj++) {
- inext=Pourcent3[iObj+1];
- if (edOT[iObj]==1 && (dpOfT[iObj]*dpOfT[inext])<0.) {
- lg=dpOfT[iObj]/(dpOfT[iObj]-dpOfT[inext]);
- if (lg>0. && lg<1.) {
- for (iToo=0; iToo<3; iToo++) {
- jnext=Pourcent3[iToo+1];
- if (edTT[iToo]==1 && (dfOpT[iToo]*dfOpT[jnext])<0.) {
- lg=dfOpT[iToo]/(dfOpT[iToo]-dfOpT[jnext]);
- if (lg>0. && lg<1.) {
- Standard_Boolean Pb=Standard_False;
- if (OI[iObj]>OI[inext]) {
- Standard_Real div=(dpOeT[inext][iToo]-dpOeT[iObj][iToo]);
- if(div>floatGap || div<-floatGap) {
- parO[iObj]=dpOeT[inext][iToo]/div;
- piO=(ToolPolyhe1::Point(FirstPol,OI[inext]).XYZ()) +
- (voo[iObj].Reversed()*parO[iObj]);
- }
- else
- Pb=Standard_True;
- }
- else {
- Standard_Real div = dpOeT[iObj][iToo]-dpOeT[inext][iToo];
- if(div>floatGap || div<-floatGap) {
- parO[iObj]=dpOeT[iObj][iToo]/
- (dpOeT[iObj][iToo]-dpOeT[inext][iToo]);;
- piO=(ToolPolyhe1::Point(FirstPol,OI[iObj]).XYZ()) +
- (voo[iObj]*parO[iObj]);
- }
- else
- Pb=Standard_True;
- }
- if (TI[iToo]>TI[jnext]) {
- Standard_Real div=(deOpT[iObj][jnext]-deOpT[iObj][iToo]);
- if(div>floatGap || div<-floatGap) {
- parT[iToo]=deOpT[iObj][jnext]/div;
- piT=(ToolPolyhe2::Point(SeconPol,TI[jnext]).XYZ()) +
- (vtt[iToo].Reversed()*parT[iToo]);
- }
- else
- Pb=Standard_True;
- }
- else {
- Standard_Real div=(deOpT[iObj][iToo]-deOpT[iObj][jnext]);
- if(div>floatGap || div<-floatGap) {
- parT[iToo]=deOpT[iObj][iToo]/div;
- piT=(ToolPolyhe2::Point(SeconPol,TI[iToo]).XYZ()) +
- (vtt[iToo]*parT[iToo]);
- }
- else
- Pb=Standard_True;
- }
- if(Pb==Standard_False) {
- piT-=piO.XYZ();
- lg=piT.Modulus();
- if (lg <= floatGap){
- piOT.Append(Intf_SectionPoint
- (piO,
- Intf_EDGE, Min(OI[iObj],OI[inext]),
- Max(OI[iObj],OI[inext]), parO[iObj],
- Intf_EDGE, Min(TI[iToo],TI[jnext]),
- Max(TI[iToo],TI[jnext]), parT[iToo],
- Incidence));
- edOT[iObj]=edTT[iToo]=0;
- nbpiOT++; nbpiO++; nbpiT++;
- }
- }
- }
- }
- }
- }
- }
- }
-
- // Intersection EDGE FACE
- for (iObj=0; iObj<3; iObj++) {
- inext=Pourcent3[iObj+1];
- if (edOT[iObj]==1 && (dpOfT[iObj]*dpOfT[inext])<0.) {
- lg=dpOfT[iObj]/(dpOfT[iObj]-dpOfT[inext]);
- if (lg>0. && lg<1.) {
- parO[iObj]=lg;
- piO=(ToolPolyhe1::Point(FirstPol, OI[iObj]).XYZ())+
- (voo[iObj]*parO[iObj]);
- if (OI[iObj]>OI[inext]) parO[iObj]=1.-parO[iObj];
- piOT.Append(
- Intf_SectionPoint (piO,
- Intf_EDGE, Min(OI[iObj],OI[inext]),
- Max(OI[iObj],OI[inext]), parO[iObj],
- Intf_FACE, Tri2, 0, 0., Incidence));
- nbpiOT++; nbpiO++;
- }
- }
- }
-
- // Intersection FACE EDGE
- for (iToo=0; iToo<3; iToo++) {
- jnext=Pourcent3[iToo+1];
- if (edTT[iToo]==1 && (dfOpT[iToo]*dfOpT[jnext])<0.) {
- lg=dfOpT[iToo]/(dfOpT[iToo]-dfOpT[jnext]);
- if (lg>0. && lg<1.) {
- parT[iToo]=lg;
- piO=(ToolPolyhe2::Point(SeconPol, TI[iToo]).XYZ())+
- (vtt[iToo]*parT[iToo]);
- if (TI[iToo]>TI[jnext]) parT[iToo]=1.-parT[iToo];
- piOT.Append(Intf_SectionPoint
- (piO,
- Intf_FACE, Tri1, 0, 0.,
- Intf_EDGE, Min(TI[iToo],TI[jnext]),
- Max(TI[iToo],TI[jnext]), parT[iToo],
- Incidence));
- nbpiOT++; nbpiT++;
- }
- }
- }
-
-
- Standard_Integer id[4];
- Standard_Integer ideb=-1;
- Standard_Integer ifin=-2;
-
- if (nbpiOT>1) {
-
-// Sort the <nbpiOT> sections points along the intersection beetween the
-// two triangles :
-
- gp_XYZ dir=ONor^TNor;
- Standard_Real d[4];
- Standard_Integer iPi, iPs;
- for (iPi=0; iPi<nbpiOT; iPi++) {
- d[iPi]=dir*piOT(iPi+1).Pnt().XYZ();
- }
-
- Standard_Integer di;
- id[0]=0;
- for (iPi=1; iPi<nbpiOT; iPi++) {
- id[iPi]=iPi;
- for (iPs=iPi-1; iPs>=0; iPs--) {
- if (d[id[iPs]] > d[id[iPs+1]]) {
- di=id[iPs+1];
- id[iPs+1]=id[iPs];
- id[iPs]=di;
- }
- else break;
- }
- }
- }
-
-// Possibility of line of section :
-
- if (nbpiO==2 && nbpiT==2) {
-
- // In the case when an edge is in the plane of the other triangle
- // it is necessary to check if it has not been already processed
- // on a connected triangle :
-
- // Pour l objet :
- Standard_Integer pivo=-1;
- Standard_Integer pedg=-1;
- if (parO[0]==0.) {
- pivo=0;
- if (parO[1]==0.) pedg=1;
- else if (parO[2]==0.) pedg=2;
- }
- else if (parO[1]==0.) {
- pivo=1;
- if (parO[2]==0.) pedg=2;
- }
- if (pivo>=0 && pedg>=0) {
- ToolPolyhe1::TriConnex(FirstPol, Tri1,OI[pivo],OI[pedg],pivo,pedg);
- if (pivo > Tri1) {
- nbpiOT=0;
- ideb=-1; // On a deja trouve celle ci
- ifin=-2;
- }
- }
-
- // For the tool :
- pivo=-1;
- pedg=-1;
- if (parT[0]==0.) {
- pivo=0;
- if (parT[1]==0.) pedg=1;
- else if (parT[2]==0.) pedg=2;
- }
- else if (parT[1]==0.) {
- pivo=1;
- if (parT[2]==0.) pedg=2;
- }
- if (pivo>=0 && pedg>=0) {
- ToolPolyhe2::TriConnex(SeconPol, Tri2,TI[pivo],TI[pedg],pivo,pedg);
- if (pivo > Tri2) {
- nbpiOT=0;
- ideb=-1; // It has been already found
- ifin=-2;
- }
- }
-
- if (nbpiOT>0) {
-
-// If there is a covering up : insert the section line in the existent
-// list or create a new section line :
-
- if (piOT(id[0]+1).TypeOnFirst()==Intf_FACE) {
- if (piOT(id[1]+1).TypeOnFirst()==Intf_FACE) {
- ideb=-id[0]-1; // No line of section possible
- ifin=-id[1]-1; //
- }
- else if (piOT(id[1]+1).TypeOnSecond()!=Intf_FACE) {
- ideb=id[1]; // No line of section possible
- ifin=id[1]; // only a pointersec
- }
- else if (nbpiOT>=3) {
- ideb=id[1]; // Retrieve 2 segments of section
- ifin=id[2]; //
- }
- else {
- ideb=-999; // No line of section possible
- ifin=-999;
- }
- }
- else if (piOT(id[0]+1).TypeOnSecond()==Intf_FACE) {
- if (piOT(id[1]+1).TypeOnSecond()==Intf_FACE) {
- ideb=-id[0]-1; // No line of section possible
- ifin=-id[1]-1; //
- }
- else if (piOT(id[1]+1).TypeOnFirst()!=Intf_FACE) {
- ideb=id[1]; // No line of section possible
- ifin=id[1]; // only a pointersec
- }
- else if (nbpiOT>=3) {
- ideb=id[1]; // Recouvrement des 2 segments de section
- ifin=id[2]; //
- }
- else {
- ideb=-999; // No line of section possible
- ifin=-999;
- }
- }
-
- else { // Singularity on the first point there is only two or
- ideb=id[0]; // three pointersec, so the first is a solution
- ifin=id[1]; // and the second too.
- }
- }
-
-
-// Insertion of the segment found in the existing section lines :
-
- if(ideb<0) {
- if(ifin<0) {
- if(ideb!=-999) {
- //static unsigned nisp=0;
- Standard_Real d=piOT(-ideb).Pnt().Distance(piOT(-ifin).Pnt());
- if(d<Tolerance) {
- Insert(piOT(-ideb), piOT(-ifin));
- //-- cout<<"Insertion Point Intf_InterferencePolyhedron 1,2 d="<<d<<" Tol="<<Tolerance<<" num:"<<++nisp<<endl;
- //-- piOT(-ideb).Dump(1); piOT(-ifin).Dump(0);
- //-- cout<<"point p"<<++nisp<<" "<<piOT(-ideb).Pnt().X()<<" "<<piOT(-ideb).Pnt().Y()<<" "<<piOT(-ideb).Pnt().Z()<<endl;
- }
- else {
- //-- cout<<"Insertion Point Intf_InterferencePolyhedron 1,2 d="<<d<<" Tol="<<Tolerance<<" NON INSERE "<<endl;
- }
- }
- }
- }
- else if (ideb>=0) {
- if (ideb!=ifin) {
- Insert(piOT(ideb+1), piOT(ifin+1));
-
- // else
- // un pointersec : It is necessary to check if it has not been already found
- // and if not insert it in the list.
- // Attention! It is necessary to check
- // for each new segment if a point is in the list
- // and in this case remove it from the list.
- }
- }
- }
- }
-}
-
-
-//=======================================================================
-//function : TangentZoneValue
-//purpose :
-//=======================================================================
-
-Standard_Boolean Intf_InterferencePolyhedron::TangentZoneValue
- (Intf_TangentZone& TheTZ,
- const Polyhedron1& FirstPol,
- const Standard_Integer Tri1,
- const Polyhedron2& SeconPol,
- const Standard_Integer Tri2) const
-{
- // Potential tangent Zone !
- // ------------------------
-
- Standard_Boolean finished=Standard_False;
- Standard_Integer nob, nou, nob2, nou2;
- Standard_Real par;
-
- Intf_PIType tOP[3];
- Intf_PIType tTP[3];
- for (nou=0; nou<3; nou++) {
- tOP[nou]= Intf_EXTERNAL;
- tTP[nou]= Intf_EXTERNAL;
- }
-
- Standard_Integer nbpInt=0;
- Intf_SeqOfSectionPoint Tpi;
-
- // Compute the positions of the points of <Tri1> in the triangle <Tri2>.
- for (nob=0; nob<=2; nob++) {
- nob2=Pourcent3[nob+1];
- for (nou=0; nou<=2; nou++) {
- nou2=Pourcent3[nou+1];
- if (dpOpT[nob][nou]<=Tolerance) {
- Tpi.Append(Intf_SectionPoint(ToolPolyhe1::Point(FirstPol, OI[nob]),
- Intf_VERTEX, OI[nob], 0, 0.,
- Intf_VERTEX, TI[nou], 0, 0.,
- 1.));
- tOP[nob]=Intf_VERTEX;
- tTP[nou]=Intf_VERTEX;
- nbpInt++;
- break;
- }
- else if (Abs(dpOeT[nob][nou])<=Tolerance) {
- if (dpOpT[nob][nou]+dpOpT[nob][nou2]<vtt[nou].Modulus()) {
- par=dpOpT[nob][nou]/(dpOpT[nob][nou]+dpOpT[nob][nou2]);
- if (TI[nou]>TI[nou2]) par=1.-par;
- Tpi.Append(Intf_SectionPoint (ToolPolyhe1::Point(FirstPol, OI[nob]),
- Intf_VERTEX, OI[nob], 0, 0.,
- Intf_EDGE, Min(TI[nou], TI[nou2]),
- Max(TI[nou], TI[nou2]), par,
- 1.));
- tOP[nob]=Intf_EDGE;
- nbpInt++;
- break;
- }
- }
- }
- if (tOP[nob]==Intf_EXTERNAL) {
- if (Intf::Contain(ToolPolyhe2::Point(SeconPol, TI[0]),
- ToolPolyhe2::Point(SeconPol, TI[1]),
- ToolPolyhe2::Point(SeconPol, TI[2]),
- ToolPolyhe1::Point(FirstPol, OI[nob]))) {
- Tpi.Append(Intf_SectionPoint(ToolPolyhe1::Point(FirstPol, OI[nob]),
- Intf_VERTEX, OI[nob], 0, 0.,
- Intf_FACE, Tri2, 0, 0.,
- 1.));
- tOP[nob]=Intf_FACE;
- nbpInt++;
- }
- }
- }
-
- // If the three points of <Tri1> are in <Tri2> the triangle Tri1 is
- // itself the tangent zone else compute the positions of the points
- // of <Tri2> in <Tri1>.
- if (nbpInt < 3) {
- for (nou=0; nou<=2; nou++) {
- nou2=Pourcent3[nou+1];
- if (tTP[nou]==Intf_EXTERNAL) {
- for (nob=0; nob<=2; nob++) {
- nob2=Pourcent3[nob+1];
- if (Abs(deOpT[nob][nou])<=Tolerance) {
- if (dpOpT[nob][nou]+dpOpT[nob2][nou]<voo[nob].Modulus()) {
- par=dpOpT[nob][nou]/(dpOpT[nob][nou]+dpOpT[nob2][nou]);
- if (OI[nob]>OI[nob2]) par=1.-par;
- Tpi.Append(Intf_SectionPoint(ToolPolyhe2::Point(SeconPol,TI[nou]),
- Intf_EDGE, Min(OI[nob], OI[nob2]),
- Max(OI[nob], OI[nob2]), par,
- Intf_VERTEX, TI[nou], 0, 0., 1.));
- tTP[nou]=Intf_EDGE;
- nbpInt++;
- break;
- }
- }
- }
- if (tTP[nou]==Intf_EXTERNAL) {
- if (Intf::Contain(ToolPolyhe1::Point(FirstPol, OI[0]),
- ToolPolyhe1::Point(FirstPol, OI[1]),
- ToolPolyhe1::Point(FirstPol, OI[2]),
- ToolPolyhe2::Point(SeconPol, TI[nou]))) {
- Tpi.Append(Intf_SectionPoint(ToolPolyhe2::Point(SeconPol, TI[nou]),
- Intf_FACE, Tri1, 0, 0.,
- Intf_VERTEX, TI[nou], 0, 0.,
- 1.));
- tTP[nou]=Intf_FACE;
- nbpInt++;
- }
- }
- }
- }
- if (tTP[0]!=Intf_EXTERNAL &&
- tTP[1]!=Intf_EXTERNAL &&
- tTP[2]!=Intf_EXTERNAL)
- finished=Standard_True;
- }
- else
- finished=Standard_True;
-
- // Insertion of the points of intersection in the zone of tangency :
- for (nob=1; nob<=nbpInt; nob++)
- TheTZ.Append(Tpi(nob));
-
- if (!finished) {
- // If one of the triangles is not in the zone of tangency, it is necessary to find
- // the points of intersection edge/edge :
-
- Standard_Real parO[6], parT[6];
- Standard_Integer nbNoInserted=0;
- Standard_Integer piToInsert[6];
-
- for (nob=0; nob<3; nob++) {
- //processing of the object segment P[nob], P[nob+1]
- nob2=Pourcent3[nob+1];
-
- for (nou=0; nou<3; nou++) {
- //processing of the segment of the tool P[nou], P[nou+1]
- nou2=Pourcent3[nou+1];
-
- if (dpOeT[nob][nou]*dpOeT[nob2][nou]<0. &&
- deOpT[nob][nou]*deOpT[nob][nou2]<0.) {
-
- if (nbpInt>=6) {
- break;
- }
- else {
- parO[nbpInt]=dpOeT[nob][nou]/(dpOeT[nob][nou]-dpOeT[nob2][nou]);
- parT[nbpInt]=deOpT[nob][nou]/(deOpT[nob][nou]-deOpT[nob][nou2]);
- gp_Pnt lepi=ToolPolyhe2::Point(SeconPol, TI[nou]).Translated
- (gp_Vec(vtt[nou]*parT[nbpInt]));
- if (OI[nob]>OI[nob2]) parO[nbpInt]=1.-parO[nbpInt];
- if (TI[nou]>TI[nou2]) parT[nbpInt]=1.-parT[nbpInt];
- Tpi.Append(Intf_SectionPoint(lepi,
- Intf_EDGE, Min(OI[nob],OI[nob2]),
- Max(OI[nob],OI[nob2]), parO[nbpInt],
- Intf_EDGE, Min(TI[nou],TI[nou2]),
- Max(TI[nou],TI[nou2]), parT[nbpInt],
- Incidence));
- nbpInt++;
- if (!TheTZ.Insert(Tpi(nbpInt))) {
- piToInsert[nbNoInserted]=nbpInt;
- nbNoInserted++;
- }
- }
- }
- }
- if (nbpInt>=6) break; // Number of pi passed in TZ !
- }
- nob=nbNoInserted-1;
- while (nob>=0) {
- while (!TheTZ.Insert(Tpi(piToInsert[nob]))) {
- nob--;
- if (nob<0) break;
- }
- if (nob>=0) {
- while (nob<nbNoInserted) {
- piToInsert[nob]=piToInsert[nob+1];
- nob++;
- }
- nbNoInserted--;
- nob=nbNoInserted-1;
- }
- }
- if (nbNoInserted>0) {
- nob=nbNoInserted-1;
- while (nob>=0) {
- Tpi(piToInsert[nob--]).Dump(4);
- }
- }
- }
- if (nbpInt<3) nbpInt=0;
- return nbpInt>0;
-}
-
-
-//=======================================================================
-//function : CoupleCharacteristics
-//purpose :
-//=======================================================================
-
-void Intf_InterferencePolyhedron::CoupleCharacteristics (const Polyhedron1& FirstPol,
- const Polyhedron2& SeconPol)
-{
- Standard_Integer n1, n2;
- Standard_Real lg;
-
- for (n1=0; n1<3; n1++) {
- n2=Pourcent3[n1+1];
- voo[n1]=ToolPolyhe1::Point(FirstPol, OI[n2]).XYZ()-
- ToolPolyhe1::Point(FirstPol, OI[n1]).XYZ();
- vtt[n1]=ToolPolyhe2::Point(SeconPol, TI[n2]).XYZ()-
- ToolPolyhe2::Point(SeconPol, TI[n1]).XYZ();
- }
-
- gp_XYZ vvec=(voo[0]^voo[1])+(voo[1]^voo[2])+(voo[2]^voo[0]);
- gp_XYZ vnorT=(vtt[0]^vtt[1])+(vtt[1]^vtt[2])+(vtt[2]^vtt[0]);
- if (vnorT.Modulus()>vvec.Modulus())
- vvec=vnorT;
-
- for (n1=0; n1<3; n1++) {
-
- for (n2=0; n2<3; n2++) {
-
- gp_XYZ vto=ToolPolyhe1::Point(FirstPol, OI[n1]).XYZ()-
- ToolPolyhe2::Point(SeconPol, TI[n2]).XYZ();
- dpOpT[n1][n2]=vto.Modulus();
-
- lg=vtt[n2].Modulus();
- if (lg > 1e-16) { //-- RealEpsilon()
- gp_XYZ vv=vto^vtt[n2];
- lg=(vvec*vv)>0.0 ? lg : -lg;
- dpOeT[n1][n2]=vv.Modulus()/lg;
- }
- else
- dpOeT[n1][n2]=dpOpT[n1][n2];
-
- lg=voo[n1].Modulus();
- if (lg > 1e-16) { //-- RealEpsilon())
- gp_XYZ vv=vto^voo[n1];
- lg=(vvec*vv)>0.0 ? -lg : lg;
- deOpT[n1][n2]=vv.Modulus()/lg;
- }
- else
- deOpT[n1][n2]=dpOpT[n1][n2];
- }
- }
-}
is
- generic class Mat;
- --- Purpose: The Algorithm of Computation of the Map of
- -- bisecting locus.
-
-
--------------------------------------------------
-- Classes of exploration of the Bisecting Locus.
--------------------------------------------------
+++ /dev/null
--- Created on: 1992-09-22
--- Created by: Gilles DEBARBOUILLE
--- Copyright (c) 1992-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.
-
-generic class Mat from MAT (Tool as any)
-
- ---Purpose: this class contains the generic algoritm of
- -- computation of the bisecting locus.
-
-uses
- Side from MAT,
- Bisector from MAT,
- ListOfEdge from MAT,
- ListOfBisector from MAT,
- DataMapOfIntegerBisector from MAT,
- DataMapOfIntegerInteger from TColStd
-
-is
-
- Create
- ---Purpose: Empty construtor.
- returns Mat from MAT;
-
---- Category : Computation.
-
- CreateMat(me : in out ; aTool : in out Tool)
- ---Purpose: Algoritm of computation of the bisecting locus.
- is static;
-
- IsDone(me) returns Boolean from Standard
- ---Purpose: Returns <TRUE> if CreateMat has succeeded.
- is static;
-
- LoadBisectorsToRemove(me : in out ;
- noofbisectorstoremove : in out Integer;
- distance1 : Real;
- distance2 : Real;
- bisector1 : Bisector from MAT;
- bisector2 : Bisector from MAT;
- bisector3 : Bisector from MAT;
- bisector4 : Bisector from MAT)
- is static private;
-
-
- Intersect( me : in out ;
- atool : in out Tool ;
- aside : Integer ;
- noofbisectorstoremove: in out Integer ;
- bisector1 : mutable Bisector from MAT;
- bisector2 : mutable Bisector from MAT)
- is static private;
-
-
---- Category : Querying.
-
- Init(me : in out)
- --- Purpose : Initialize an iterator on the set of the roots
- -- of the trees of bisectors.
- is static;
-
- More(me) returns Boolean
- --- Purpose : Return False if there is no more roots.
- is static;
-
- Next(me : in out)
- --- Purpose : Move to the next root.
- is static;
-
- Bisector(me) returns any Bisector from MAT
- --- Purpose : Returns the current root.
- is static;
-
- SemiInfinite(me) returns Boolean from Standard
- --- Purpose : Returns True if there are semi_infinite bisectors.
- -- So there is a tree for each semi_infinte bisector.
- is static;
-
- NumberOfBisectors(me) returns Integer from Standard
- --- Purpose : Returns the total number of bisectors.
- is static;
-
-fields
-
- thenumberofbisectors : Integer;
- thenumberofedges : Integer;
- semiInfinite : Boolean;
- theedgelist : ListOfEdge from MAT;
- typeofbisectortoremove: DataMapOfIntegerInteger from TColStd;
- bisectoronetoremove : DataMapOfIntegerBisector from MAT;
- bisectortwotoremove : DataMapOfIntegerBisector from MAT;
- bisectormap : DataMapOfIntegerBisector from MAT;
- roots : ListOfBisector from MAT;
- thecurrentindex : Integer;
- isDone : Boolean;
-
-end Mat;
+++ /dev/null
-// Created on: 1992-09-22
-// Created by: Gilles DEBARBOUILLE
-// Copyright (c) 1992-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 <MAT_Edge.hxx>
-#include <MAT_ListOfEdge.hxx>
-#include <MAT_Bisector.hxx>
-#include <MAT_ListOfBisector.hxx>
-#include <TColStd_DataMapOfIntegerInteger.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <MAT_DataMapOfIntegerBisector.hxx>
-#include <Precision.hxx>
-
-//========================================================================
-// function : MAT_Mat
-// purpose :
-//========================================================================
-
-MAT_Mat::MAT_Mat()
-{
- thenumberofbisectors = 0;
- thenumberofedges = 0;
-}
-
-
-//========================================================================
-// function : CreateMat
-// purpose : Calcul des lieux Bisecteurs.
-//
-// Structure de la carte.
-// ======================
-// La carte des lieux bisecteurs se presente sous la forme d un ou plusieurs
-// arbres de bisectrices.
-// ( un arbre, si calcul a l interieur du contour, plusieurs sinon).
-//
-// Les branches de plus bas niveau de l arbre separent deux elements voisins
-// du contour.
-//
-// Principe de l algorithme.
-// -------------------------
-// l arbre est construit des branches les plus basses vers les plus hautes.
-//
-// 0 . Calcul des bisectrices entre elements voisins du contour.
-// 1 . Elimination de certains element du contour => nouveau contour
-// 2 . Retour en 0.
-//
-// Principales etapes de l algorithme.
-// ===================================
-//
-// etape 1: Initialisation de l algorithme .
-// -----------------------------------------
-// Recuperation via le tool du nombre d'elements sur le contour
-// Initialisation de <theedgelist>, un edge correspond a chaque
-// element du contour.
-//
-// etape 2 : Boucle principale.
-// ----------------------------
-// 0 - Tant que Nombre d'edge > 1
-//
-// 1. Pour chaque edge: construction de la bissectrice entre l edge
-// et l edge suivante.
-// La bissectrice est semi_infinie, elle est soit trimmee par le
-// point commun des deux edges, soit par l intersection de deux
-// bissectrices antecedentes.
-//
-// 2. Intersection des Bisectrices issue du meme edge
-// => une bisectrice est intersectee avec sa voisine a gauche
-// et sa voisine a droite.
-//
-// 3. Analyse des intersections.
-// Si pas d'intersection entre deux bisectrices B1 et B2
-// - Recherche de l intersection la plus basse de B1 avec les
-// Bisectrices antecedentes a B2 du cote de B1. Soit Bi la
-// bissectrice intersectee. Toutes les bissectrices constituant la
-// branche qui relie B2 a Bi sont marquees a effacer
-// - idem pour B2.
-//
-// 4. Suppresion des bisectrices a effacer.
-// une bisectrise est a effacer :
-// - Anulation de l intersection dont la bissectrice est issue
-// => Prolongement des deux bisectrices posterieures.
-// - Reinsertion des edge correspondant dans <theedgelist>.
-//
-// 5. Pour chaque edge, analyse des distances entre les points d inter
-// section et l edge.
-// B1 B2 les bisectrices liee a l edge
-// Soit P0 le point d intersection des bissectrices .
-// Soit P1 le point d intersection de B1 avec son autre voisine .
-// Soit P2 le point d intersection de B2 avec son autre voisine .
-//
-// si sur B1 le parametre de P0 < parametre de P1 et
-// si sur B2 le parametre de P0 < parametre de P2
-// alors suppression de l edge de la liste des edges <theedgelist>.
-//
-// rq: le parametre sur une bissectirce est croissant par rapport
-// a la distance du point courant aux edges.
-
-// 6. Si aucune edge est elimine alors sortie de la boucle principale.
-//
-// 7. Retour en 0.
-//
-// etape 3 : Creation des racines des arbres de bisectrices.
-// ---------------------------------------------------------
-// Recuperation des bissectrices calculees lors du dernier passage
-// dans la boucle.
-//
-//========================================================================
-void MAT_Mat::CreateMat(Tool& atool)
-{
-
-#ifdef ICONTINUE
- Standard_Boolean Icontinue;
-#endif
-
- Standard_Boolean interrupt = Standard_False;
-
- Handle(MAT_Edge) edgetoremove;
- Handle(MAT_Edge) previousedge,currentedge;
-
- Standard_Integer noofbisectorstoremove;
- Handle(MAT_Bisector) firstbisector,secondbisector;
- Handle(MAT_Edge) edge;
- Standard_Integer intersectionpoint;
- Standard_Integer beginbisector;
- Standard_Integer noofbisectors;
-
- Standard_Integer NbIterBis = 0;
- Standard_Integer EvenNbIterBis = 10;
- TColStd_Array1OfInteger EdgeNumbers(1, EvenNbIterBis+1);
- EdgeNumbers.Init(-1);
- Standard_Boolean ToNullifyNoofbisectorstoremove = Standard_False;
-
- Handle(MAT_ListOfBisector) currentbisectorlist;
-
- Handle(MAT_Bisector) bisectortoremove,lastbisector,currentbisector;
- Handle(MAT_Bisector) previousbisector;
-
- Standard_Integer i,j,k,narea,shift,compact,all;
- Standard_Integer noofedges;
- Standard_Integer NumberMaxOfIte;
- Standard_Real toleranceofconfusion;
-
- noofedges = atool.NumberOfItems();
- toleranceofconfusion = atool.ToleranceOfConfusion();
- NumberMaxOfIte = noofedges*noofedges;
-
- TColStd_Array1OfInteger firstarea(0, noofedges);
- TColStd_Array1OfInteger lastarea(0, noofedges);
- TColStd_Array1OfInteger noofarea(0, noofedges);
-
- Standard_Integer parama[2];
- Standard_Integer paramb[2];
-
-// -----------------------------------------
-// Initialisation et remise a zero des maps.
-// -----------------------------------------
- bisectoronetoremove.Clear();
- bisectortwotoremove.Clear();
- typeofbisectortoremove.Clear();
- bisectormap.Clear();
-
- isDone = Standard_True;
- noofbisectors = noofedges;
- beginbisector = 0;
-
-// --------------------------------------------------------------------
-// Construction de <theedgelist> un edge correspond a un element simple
-// du contour.
-// --------------------------------------------------------------------
- theedgelist = new MAT_ListOfEdge();
-
- for(i=0; i<noofedges; i++) {
- edge = new MAT_Edge();
- edge->EdgeNumber(i+1);
- edge->Distance(-1);
- theedgelist->BackAdd(edge);
- }
-
- theedgelist->Loop();
-
-//---------------------------------------------------
-// Initialisation des bissectrices issues du contour.
-//---------------------------------------------------
- Standard_Real Dist;
- theedgelist->First();
-
- for(i=0; i<theedgelist->Number(); i++) {
- bisectormap.Bind(i,new MAT_Bisector());
- bisectormap(i)->IndexNumber(i);
- bisectormap(i)->FirstEdge(theedgelist->Current());
- bisectormap(i)->FirstVector
- (atool.TangentBefore(theedgelist->Current()->EdgeNumber()));
- theedgelist->Next();
- bisectormap(i)->SecondEdge(theedgelist->Current());
- bisectormap(i)->IssuePoint
- (atool.FirstPoint(theedgelist->Current()->EdgeNumber(),Dist));
- bisectormap(i)->DistIssuePoint(Dist);
- bisectormap(i)->SecondVector
- (atool.TangentAfter(theedgelist->Current()->EdgeNumber()));
- }
-
-//----------------------------------------------------
-// Affectation a chaque edge de ses deux bissectrices.
-//----------------------------------------------------
- theedgelist->First();
-
- for(i=0; i<theedgelist->Number(); i++) {
- theedgelist->Current()->FirstBisector
- (bisectormap((i-1+noofbisectors)%noofbisectors));
- theedgelist->Current()->SecondBisector
- (bisectormap(i));
- theedgelist->Next();
- }
-
-//===========================================================================
-// Boucle Principale (etape 2)
-//===========================================================================
- Standard_Integer NumberOfIte = 0;
-
- while(theedgelist->Number()>1) {
-
-
- // ------------------------------------------------------------------
- // Creation des geometries des bissectrices via le tool. (etape 2.1)
- // -------------------------------------------------------------------
-
- for(i=beginbisector; i<noofbisectors; i++) {
-
- atool.CreateBisector(bisectormap(i));
- thenumberofbisectors++;
-
-#ifdef DEBUG_Mat
- atool.Dump(bisectormap(i)->BisectorNumber(),1);
-#ifdef ICONTINUE
- cin>>Icontinue;
-#endif
-#endif
- }
-
- // ---------------------------------------------
- // Condition de sortie de la boucle principale.
- // ---------------------------------------------
-
-// Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin
- if (theedgelist->Number() < 3)
- break;
-// Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End
-
- //---------------------------------------------------
- // boucle 2 Tant qu il y a des bisectrices a effacer.
- //---------------------------------------------------
- for(;;) {
- NbIterBis++;
-
- noofbisectorstoremove = 0;
- theedgelist->First();
-
- //--------------------------------------------------------------
- // Calcul des intersections des bisectrices voisines.(etape 2.2)
- //--------------------------------------------------------------
-
- if (NbIterBis <= EvenNbIterBis+1)
- EdgeNumbers(NbIterBis) = theedgelist->Number();
- else
- {
- for (k = 1; k <= EvenNbIterBis; k++)
- EdgeNumbers(k) = EdgeNumbers(k+1);
- EdgeNumbers(EvenNbIterBis+1) = theedgelist->Number();
- }
- if (EdgeNumbers(EvenNbIterBis+1) == EdgeNumbers(1))
- ToNullifyNoofbisectorstoremove = Standard_True;
-
- for(i=0; i<theedgelist->Number(); i++) {
- edge = theedgelist->Current();
- if(edge->Distance() == -1.) {
- firstbisector = edge->FirstBisector();
- secondbisector = edge->SecondBisector();
- edge->Distance(atool.IntersectBisector
- (firstbisector,secondbisector,intersectionpoint));
- edge->IntersectionPoint(intersectionpoint);
-
- if(edge->Distance() == Precision::Infinite()) {
- if(firstbisector->IndexNumber() >= beginbisector ||
- secondbisector->IndexNumber() >= beginbisector)
- Intersect(atool,0,noofbisectorstoremove,
- firstbisector,secondbisector );
- }
- else {
- if(firstbisector->IndexNumber() >= beginbisector) {
- Intersect(atool,1,noofbisectorstoremove,
- firstbisector,secondbisector );
- }
- if(secondbisector->IndexNumber() >= beginbisector) {
- Intersect(atool,2,noofbisectorstoremove,
- firstbisector,secondbisector );
- }
- }
- }
- theedgelist->Next();
- }
-
- //-------------------------------
- // Test de sortie de la boucle 2.
- //-------------------------------
-
- if (ToNullifyNoofbisectorstoremove)
- noofbisectorstoremove = 0;
- if(noofbisectorstoremove == 0) break;
-
- //---------------------------------------------------
- // Annulation des bissectrices a effacer. (etape 2.4)
- //---------------------------------------------------
-
- for(i=0; i<noofbisectorstoremove; i++) {
-
- bisectortoremove = bisectoronetoremove(i);
-
- //---------------------------------------------------------------
- // Destruction des bisectrices descendantes de <bisectortoremove>
- // On descend dans l arbre jusqu a ce qu on atteigne
- // <bisectortwotoremove(i).
- //---------------------------------------------------------------
-
- for(;;){
-
-#ifdef DEBUG_Mat
- atool.Dump(bisectortoremove->BisectorNumber(),0);
-#endif
- // ----------------------------------
- // Annulation de <bisectortoremove>.
- // ----------------------------------
- thenumberofbisectors--;
- currentbisectorlist = bisectortoremove->List();
- currentbisectorlist->First();
- currentbisector = currentbisectorlist->FirstItem();
- previousedge = currentbisector->FirstEdge();
- theedgelist->Init(previousedge);
- previousedge->Distance(-1.);
- previousedge->FirstBisector()->SecondParameter(Precision::Infinite());
- previousedge->SecondBisector()->FirstParameter(Precision::Infinite());
-
- //------------------------------------------
- // Annulation des fils de <currentbisector>.
- //------------------------------------------
-
- while(currentbisectorlist->More()) {
- currentbisector = currentbisectorlist->Current();
- currentedge = currentbisector->SecondEdge();
-
- //---------------------------------------
- // Reinsertion de l edge dans le contour.
- //---------------------------------------
- theedgelist->LinkAfter(currentedge);
- theedgelist->Next();
-
- currentedge->FirstBisector(currentbisector);
- previousedge->SecondBisector(currentbisector);
-#ifdef DEBUG_Mat
- atool.Dump(currentbisector->BisectorNumber(),0);
-#endif
-
- //------------------------------------------------------
- // Annulation de l intersection ie les fils qui
- // ont generes l intersection sont prolonges a l infini.
- //------------------------------------------------------
-
- currentbisector->FirstParameter (Precision::Infinite());
- currentbisector->SecondParameter(Precision::Infinite());
-
- atool.TrimBisector(currentbisector);
-
-#ifdef DEBUG_Mat
- atool.Dump(currentbisector->BisectorNumber(),1);
-#endif
- currentedge->Distance(-1.);
- currentedge->FirstBisector()->SecondParameter(Precision::Infinite());
- currentedge->SecondBisector()->FirstParameter(Precision::Infinite());
-
- previousedge = currentedge;
- currentbisectorlist->Next();
- }
-
- theedgelist->Unlink();
-
- //-----------------------------------------------------------
- // Test de sortie de la boucle d annulation des bissectrices.
- //-----------------------------------------------------------
-
- if(bisectortoremove->BisectorNumber() ==
- bisectortwotoremove(i)->BisectorNumber()) break;
-
- //-----------------------
- // Descente dans l arbre.
- //-----------------------
-
- if(typeofbisectortoremove(i) == 1)
- bisectortoremove = bisectortoremove->FirstBisector();
- else
- bisectortoremove = bisectortoremove->LastBisector();
-
- } //----------------------------------------------------
- // Fin boucle d annulation des bissectrices issue de
- // <bisectoronetoremove(i)>.
- //----------------------------------------------------
-
- } //------------------------------------------
- // Fin boucle d annulation des bissectrices.
- //-------------------------------------------
-
-#ifdef ICONTINUE
- cin>>Icontinue;
-#endif
- } //--------------
- // Fin Boucle 2.
- //--------------
-
- // ----------------------------------------------------------------------
- // Analyse des parametres des intersections sur les bisectrices de chaque
- // edge et determination des portions de contour a supprimees. (etape 2.5)
- // ----------------------------------------------------------------------
-
- theedgelist->First();
-
- currentbisector = theedgelist->Current()->FirstBisector();
- if (currentbisector->FirstParameter() == Precision::Infinite() &&
- currentbisector->SecondParameter() == Precision::Infinite()) {
- parama[0] = -1;
- paramb[0] = -1;
- }
- else if(currentbisector->FirstParameter() == Precision::Infinite()) {
- parama[0] = -1;
- paramb[0] = 1;
- }
- else if(currentbisector->SecondParameter() == Precision::Infinite()) {
- paramb[0] = -1;
- parama[0] = 1;
- }
- else if (atool.Distance(currentbisector,
- currentbisector->FirstParameter(),
- currentbisector->SecondParameter())
- > toleranceofconfusion) {
- if((currentbisector->FirstParameter() -
- currentbisector->SecondParameter())
- *currentbisector->Sense() > 0.) {
- parama[0] = -1;
- paramb[0] = 1;
- }
- else {
- paramb[0] = -1;
- parama[0] = 1;
- }
- }
- else {
- parama[0] = 1;
- paramb[0] = 1;
- }
-
- narea = -1;
-
- for(i=0; i<theedgelist->Number(); i++) {
- currentbisector = theedgelist->Current()->SecondBisector();
- if (currentbisector->FirstParameter() == Precision::Infinite() &&
- currentbisector->SecondParameter() == Precision::Infinite()) {
- parama[1] = -1;
- paramb[1] = -1;
- }
- else if(currentbisector->FirstParameter() == Precision::Infinite()) {
- parama[1] = -1;
- paramb[1] = 1;
- }
- else if(currentbisector->SecondParameter() == Precision::Infinite()) {
- paramb[1] = -1;
- parama[1] = 1;
- }
- else if (atool.Distance(currentbisector,
- currentbisector->FirstParameter(),
- currentbisector->SecondParameter())
- > toleranceofconfusion) {
- if((currentbisector->FirstParameter() -
- currentbisector->SecondParameter())
- *currentbisector->Sense() > 0.) {
- parama[1] = -1;
- paramb[1] = 1;
- }
- else {
- paramb[1] = -1;
- parama[1] = 1;
- }
- }
- else {
- parama[1] = 1;
- paramb[1] = 1;
- }
-
- //-----------------------------------------------------------------
- // Test si l edge est a enlever du contour
- // Construction des portions de contour a eliminer.
- //
- // narea : nombre de portions continues du contour a eliminer.
- // firstarea[i] : indice premier edge de la portion i.
- // lastarea[i] : indice dernier edge de la portion i.
- //-----------------------------------------------------------------
-
-#ifdef DEBUG_Mat
- cout <<" Test sur les parametres pour elimination"<<endl;
- cout << " Edge number :"<<theedgelist->Current()->EdgeNumber()<<endl;
-#endif
-
- if(paramb[0] > 0 && parama[1] > 0) {
-
-#ifdef DEBUG_Mat
- cout <<" A ELIMINER "<<endl;
-#endif
- if(narea < 0) {
- firstarea(++narea) = theedgelist->Index();
- lastarea(narea) = firstarea(narea);
- noofarea(narea) = 1;
- }
- else {
- if(theedgelist->Index() == lastarea(narea)+1) {
- lastarea(narea)++;
- noofarea(narea)++;
- }
- else {
- firstarea(++narea) = theedgelist->Index();
- lastarea(narea) = firstarea(narea);
- noofarea(narea) = 1;
- }
- }
- }
- parama[0] = parama[1];
- paramb[0] = paramb[1];
- theedgelist->Next();
-
- }
-
- compact = 0;
- if(narea > 0) {
- if(lastarea(narea) == theedgelist->Number() && firstarea(0) == 1) {
- firstarea(0) = firstarea(narea);
- noofarea(0) = noofarea(0)+noofarea(narea);
- compact = noofarea(narea);
- narea--;
- }
- }
-
- narea++;
-
- //------------------------------------------------------------------
- // Sortie de la boucle principale si il n y a pas d edge a eliminer.
- // (etape 2.6)
- //------------------------------------------------------------------
- if(narea == 0) {
- interrupt = Standard_True;
- break;
- }
-
-
- //----------------------------------------------------------------
- // Elimination des edges a enlever du contour
- // => Mise a jour du nouveau contour.
- // => Creation des bissectrices entre les nouvelles edges voisines.
- //----------------------------------------------------------------
-
- beginbisector = noofbisectors;
- shift = 0;
- all = 0;
- if(narea == 1 && noofarea(0) == theedgelist->Number()) all = 1;
-
- for(i=0; i<narea; i++) {
- if(i == 1)shift = shift-compact;
- theedgelist->First();
- edgetoremove = theedgelist->Brackets(firstarea(i)-shift);
-
- edgetoremove->FirstBisector()->EndPoint(edgetoremove
- ->IntersectionPoint());
-
-#ifdef DEBUG_Mat
- atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),0);
-#endif
-
- edgetoremove->FirstBisector()->FirstParameter
- (edgetoremove->FirstBisector()->SecondParameter());
-
-#ifdef DEBUG_Mat
- if(atool.TrimBisector(edgetoremove->FirstBisector()))
- atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),1);
-#else
- atool.TrimBisector(edgetoremove->FirstBisector());
-#endif
-
- bisectormap.Bind(noofbisectors,new MAT_Bisector());
- bisectormap(noofbisectors)->IndexNumber(noofbisectors);
- bisectormap(noofbisectors)->DistIssuePoint(edgetoremove->Distance());
- bisectormap(noofbisectors)->IssuePoint(edgetoremove
- ->IntersectionPoint());
- bisectormap(noofbisectors)->FirstEdge(theedgelist->PreviousItem());
- bisectormap(noofbisectors)->AddBisector(edgetoremove
- ->FirstBisector());
-
- for(j=0; j<noofarea(i); j++) {
- theedgelist->Unlink();
- theedgelist->Next();
- shift++;
-
-#ifdef DEBUG_Mat
- cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<endl;
-#endif
-
- if(all == 0 || j+1 != noofarea(i)) {
- bisectormap(noofbisectors)->AddBisector(edgetoremove
- ->SecondBisector());
- }
- edgetoremove->SecondBisector()->EndPoint(edgetoremove
- ->IntersectionPoint());
-
-#ifdef DEBUG_Mat
- atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),0);
-#endif
-
- edgetoremove->SecondBisector()->SecondParameter
- (edgetoremove->SecondBisector()->FirstParameter());
-#ifdef DEBUG_Mat
- if(atool.TrimBisector(edgetoremove->SecondBisector()))
- atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),1);
-#else
- atool.TrimBisector(edgetoremove->SecondBisector());
-#endif
- edgetoremove = theedgelist->Current();
- }
- bisectormap(noofbisectors)->SecondEdge(theedgelist->Current());
-
- theedgelist->PreviousItem()
- ->SecondBisector(bisectormap(noofbisectors));
- theedgelist->Current()->FirstBisector(bisectormap(noofbisectors));
-
- bisectormap(noofbisectors)->FirstVector
- (atool.Tangent
- (bisectormap(noofbisectors)->FirstBisector()
- ->BisectorNumber()));
-
- bisectormap(noofbisectors)->SecondVector
- (atool.Tangent
- (bisectormap(noofbisectors)->LastBisector()
- ->BisectorNumber()));
-
- noofbisectors++;
-
- theedgelist->PreviousItem()->Distance(-1);
- theedgelist->Current()->Distance(-1);
-
- theedgelist->PreviousItem()->FirstBisector()
- ->SecondParameter(Precision::Infinite());
- theedgelist->Current()->SecondBisector()->FirstParameter(Precision::Infinite());
- }
-
- //-----------------------------------------------------------------------
- // Test sur le nombre d iterations :
- // A chaque iteration est elimine un element du contour qui ne sera plus
- // reinsere par la suite => le nombre d iterartions doit etre < au nombre
- // d elements.
- // Le nombre d iteration maximum est fixe a numberofedges*numberofedges.
- //-----------------------------------------------------------------------
- if (NumberOfIte > NumberMaxOfIte) {
- isDone = Standard_False; //Echec calcul de la carte.
- break;
- }
- NumberOfIte++;
-
- } //===============================================
- // Fin Boucle Principale.
- //===============================================
-
- //----------
- // etape 3.
- //----------
-
-
- //----------------------------------------------
- // interupt = True => bissectrices semi_infinies.
- //----------------------------------------------
-
- if(interrupt)
- semiInfinite = Standard_True;
- else {
- semiInfinite = Standard_False;
-
- //------------------------------------------------------------------
- // Si le nombre d edge > 1 => le nombre d edge = 2
- // (cf test sortie boucle principale)
- // Les deux dernieres bisectrices separent les memes edges .
- // Soit elles sont confondues si calcul a l interieur, soit elles
- // sont semi-Infinies (exemple : contour compose seulement de deux
- // arcs de cercles).
- //------------------------------------------------------------------
-
- if(theedgelist->Number() > 1) { //Now this branch is never reachable
- //because the case edgenumber = 2 is processed in the main loop
- theedgelist->First();
- edge = theedgelist->Current();
- if(edge->FirstBisector()->IndexNumber() == noofbisectors-1) {
-// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
- if (atool.TrimBisector(edge->SecondBisector(),
- edge->FirstBisector()->IssuePoint())) {
- if (edge->SecondBisector()->EndPoint() == 0)
- edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint());
- bisectormap(noofbisectors-1)->AddBisector(edge->SecondBisector());
- } else
- semiInfinite = Standard_True;
-// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
- }
- else {
-// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
- if (atool.TrimBisector(edge->FirstBisector(),
- edge->SecondBisector()->IssuePoint())) {
- if (edge->FirstBisector()->EndPoint() == 0)
- edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint());
- bisectormap(noofbisectors-1)->AddBisector(edge->FirstBisector());
- } else
- semiInfinite = Standard_True;
-// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
- }
- if (!semiInfinite) {
- thenumberofbisectors--;
- bisectormap(noofbisectors-1)->SecondEdge(edge);
- bisectormap(noofbisectors-1)->BisectorNumber(-1);
- }
- }
- }
- if(semiInfinite) {
- beginbisector = noofbisectors;
- theedgelist->First();
- for(i=0; i<theedgelist->Number(); i++) {
- edge = theedgelist->Current();
- bisectormap.Bind(noofbisectors,edge->SecondBisector());
- noofbisectors++;
- theedgelist->Next();
- }
-
- }
-
- //---------------------------
- // Recuperations des racines.
- //---------------------------
-
- roots = new MAT_ListOfBisector;
-
- if (bisectormap(noofbisectors-1)->BisectorNumber() == -1) {
- roots = bisectormap(noofbisectors-1)->List();
- roots->First();
- roots->Current()->FirstEdge()
- ->Distance(bisectormap(noofbisectors-1)->DistIssuePoint());
- }
- else {
- for (i=beginbisector;i<noofbisectors;i++) {
- roots->BackAdd(bisectormap(i));
- }
- }
-
-}
-
-//========================================================================
-// function : LoadBisectorsToRemove
-// purpose : Chargement des bisectrices a effacer.
-//========================================================================
-void MAT_Mat::LoadBisectorsToRemove
- ( Standard_Integer& noofbisectorstoremove,
- const Standard_Real distance1,
- const Standard_Real distance2,
- const Handle(MAT_Bisector)& firstbisectortoremove1,
- const Handle(MAT_Bisector)& firstbisectortoremove2,
- const Handle(MAT_Bisector)& lastbisectortoremove1,
- const Handle(MAT_Bisector)& lastbisectortoremove2 )
-{
-
- Standard_Integer found,index;
- Handle(MAT_Bisector) firstbisectortoremove[2];
- Handle(MAT_Bisector) lastbisectortoremove[2];
-
- firstbisectortoremove[0] = firstbisectortoremove1;
- firstbisectortoremove[1] = firstbisectortoremove2;
- lastbisectortoremove[0] = lastbisectortoremove1;
- lastbisectortoremove[1] = lastbisectortoremove2;
-
- if (distance1 < Precision::Infinite() &&
- distance2 == Precision::Infinite() ) index = 0;
- else if(distance2 < Precision::Infinite() &&
- distance1 == Precision::Infinite() ) index = 1;
- else index = -1;
-
- if(index != -1) {
- found = noofbisectorstoremove;
- for(int j=0; j<noofbisectorstoremove; j++) {
- if(bisectoronetoremove(j)->BisectorNumber() ==
- firstbisectortoremove[index]->BisectorNumber()) {
- found = j;
- if(bisectortwotoremove(j)->BisectorNumber() <
- lastbisectortoremove[index]->BisectorNumber())found = -1;
- break;
- }
- }
-
- if(found != -1) {
-#ifdef DEBUG_Mat
- cout<<" first last bisector to remove :"<<
- firstbisectortoremove[index]->BisectorNumber()<<" "<<
- lastbisectortoremove[index]->BisectorNumber()<<endl;
-#endif
- bisectoronetoremove.Bind(found,firstbisectortoremove[index]);
- bisectortwotoremove.Bind(found,lastbisectortoremove[index]);
- typeofbisectortoremove.Bind(found,index+1);
-
- if(found == noofbisectorstoremove)noofbisectorstoremove++;
- }
- }
-}
-
-//========================================================================
-// function : Intersect
-// purpose : Si <aside=0> Intersection de <firstbisector> avec les
-// descendants de <secondbisector> les plus a gauche
-// (ie secondbisector->FirstBisector()->FirstBisector...)
-// Intersection de <secondbisector> avec les
-// descendants de <firstbisector> les plus a droite
-// (ie firstbisector->LastBisector()->LastBisector...)
-//
-// Si <aside=1> Intersection de <firstbisector> avec ses
-// descendants les plus a gauche et les plus a droite.
-//
-// Si <aside=2> Intersection de <secondbisector> avec ses
-// descendants les plus a gauche et les plus a droite.
-//========================================================================v
-void MAT_Mat::Intersect( Tool& atool,
- const Standard_Integer aside,
- Standard_Integer& noofbisectortoremove,
- const Handle(MAT_Bisector)& firstbisector,
- const Handle(MAT_Bisector)& secondbisector)
-{
- Standard_Integer bisectornumber;
- Standard_Real distant,saveparameter;
- Standard_Real distance[2];
- Standard_Integer intersectionpoint;
- Handle(MAT_Bisector) lastbisector,previousbisector;
- Handle(MAT_Bisector) firstbisectortoremove[2];
- Handle(MAT_Bisector) lastbisectortoremove[2];
-
- distance[0] = Precision::Infinite();
- distance[1] = Precision::Infinite();
-
- for(bisectornumber = 0; bisectornumber<2; bisectornumber++) {
- if(aside == 0) {
- if(bisectornumber == 0)
- firstbisectortoremove[bisectornumber] = secondbisector;
- else
- firstbisectortoremove[bisectornumber] = firstbisector;
- }
- else if(aside == 1) {
- firstbisectortoremove[bisectornumber] = firstbisector;
- }
- else {
- firstbisectortoremove[bisectornumber] = secondbisector;
- }
-
- lastbisector = firstbisectortoremove[bisectornumber];
-
- if(aside == 0) {
- previousbisector = firstbisectortoremove[bisectornumber];
- }
- else {
- if(firstbisectortoremove[bisectornumber]->List()->IsEmpty())continue;
-
- if(bisectornumber == 0)
- previousbisector = firstbisectortoremove[bisectornumber]
- ->FirstBisector();
- else
- previousbisector = firstbisectortoremove[bisectornumber]
- ->LastBisector();
- }
-
- distant = distance[bisectornumber];
- while(!previousbisector->List()->IsEmpty()) {
-
- if(bisectornumber == 0)
- previousbisector = previousbisector->FirstBisector();
- else
- previousbisector = previousbisector->LastBisector();
-
- if(aside == 1 || (aside == 0 && bisectornumber == 0)) {
- saveparameter = previousbisector->FirstParameter();
- distant = atool.IntersectBisector
- (firstbisector,previousbisector,intersectionpoint);
- previousbisector->FirstParameter(saveparameter);
- }
- else {
- saveparameter = previousbisector->SecondParameter();
- distant = atool.IntersectBisector
- (previousbisector,secondbisector,intersectionpoint);
- previousbisector->SecondParameter(saveparameter);
- }
-
- if(distant < Precision::Infinite()) {
- distance[bisectornumber] = distant;
- lastbisectortoremove[bisectornumber] = lastbisector;
- }
-
- lastbisector = previousbisector;
- }
- }
-
- //---------------------------------------
- // Chargement des bissectrices a effacer.
- //---------------------------------------
-
- LoadBisectorsToRemove(noofbisectortoremove,
- distance[0],distance[1],
- firstbisectortoremove[0],firstbisectortoremove[1],
- lastbisectortoremove[0] ,lastbisectortoremove[1]);
-}
-
-//========================================================================
-// function : Init
-// purpose :
-//========================================================================
-void MAT_Mat::Init()
-{
- roots->First();
-}
-
-//========================================================================
-// function : More
-// purpose :
-//========================================================================
-Standard_Boolean MAT_Mat::More() const
-{
- return roots->More();
-}
-
-//========================================================================
-// function : Next
-// purpose :
-//========================================================================
-void MAT_Mat::Next()
-{
- roots->Next();
-}
-
-//========================================================================
-// function : Bisector
-// purpose :
-//========================================================================
-Handle(MAT_Bisector) MAT_Mat::Bisector() const
-{
- return roots->Current();
-}
-
-//========================================================================
-// function : NumberOfBisectors
-// purpose :
-//========================================================================
-Standard_Integer MAT_Mat::NumberOfBisectors() const
-{
- return thenumberofbisectors;
-}
-
-//========================================================================
-// function : SemiInfinite
-// purpose :
-//========================================================================
-Standard_Boolean MAT_Mat::SemiInfinite() const
-{
- return semiInfinite;
-}
-
-//========================================================================
-// function : IsDone
-// purpose :
-//========================================================================
-Standard_Boolean MAT_Mat::IsDone() const
-{
- return isDone;
-}
-
deferred class SketchExplorer;
---Purpose: SletchExplorer contains an iterator on a set of geometrys
-- from Geom2d. It's use by BisectingLocus.
-
- generic class BisectingLocus;
- ---Purpose: Constuction of the map of the bisector locus on a
- -- set of geometrys from Geom2d.
+
class Tool2d;
---Purpose: Tool2d contains the geometrys of the map. Tool2d
-- contains the set of the geometric's methode used for
-- the map's computation.
- class Mat2d instantiates Mat from MAT (Tool2d);
+ class Mat2d;
+ --- Purpose: The Algorithm of Computation of the Map of
+ -- bisecting locus.
class Connexion;
---Purpose: a Connexion links two lines.
+++ /dev/null
--- Created on: 1993-07-06
--- Created by: Yves FRICAUD
--- Copyright (c) 1993-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.
-
-generic class BisectingLocus from MAT2d (Explorer as any)
- -- as SketchExplorer from MAT2d
-
- ---Purpose : BisectingLocus generates and contains the Bisecting_Locus
- -- of a set of lines from Geom2d, defined by <ExploSet>.
- --
- -- If the set of lines contains closed lines:
- -- ------------------------------------------
- -- These lines cut the plane in areas.
- -- One map can be computed for each area.
- --
- -- Bisecting locus computes a map in an area.
- -- The area is defined by a side (MAT_Left,MAT_Right)
- -- on one of the closed lines.
- --
- -- If the set of lines contains only open lines:
- -- --------------------------------------------
- -- the map recovers all the plane.
- --
- -- Warning: Assume the orientation of the closed lines are
- -- compatible.
- --
- -- Assume the explo contains only lines located in the
- -- area where the bisecting locus will be computed.
- --
- -- Assume a line don't cross itself or an other line.
- --
- -- Remark:
- -- the curves coming from the explorer can be
- -- decomposed in different parts. It the case for the
- -- curves other than circles or lines.
- --
- -- The map of bisecting locus is described by a graph.
- -- - The BasicsElements correspond to elements on
- -- the figure described by the Explorer.
- -- - The Arcs correspond to the bisectors.
- -- - The Nodes are the extremities of the arcs.
-
-uses
- Graph from MAT,
- Arc from MAT,
- BasicElt from MAT,
- Node from MAT,
- Side from MAT,
- DataMapOfIntegerBasicElt from MAT,
- DataMapOfBiIntInteger from MAT2d,
- Bisec from Bisector,
- Geometry from Geom2d,
- Pnt2d from gp,
- Tool2d from MAT2d
-
-is
- Create returns BisectingLocus from MAT2d;
-
----Category: Construction.
-
- Compute (me : in out ;
- anExplo : in out Explorer;
- LineIndex : Integer = 1;
- aSide : Side from MAT = MAT_Left )
- --- Purpose : Computation of the Bisector_Locus in a set of Lines
- -- defined in <anExplo>.
- -- The bisecting locus are computed on the side <aSide>
- -- from the line <LineIndex> in <anExplo>.
- is static;
-
----Category: Querying.
-
- IsDone (me) returns Boolean from Standard
- ---Purpose: Returns True if Compute has succeeded.
- is static;
-
- Graph(me) returns Graph from MAT
- --- Purpose : Returns <theGraph> of <me>.
- is static;
-
- NumberOfContours (me)
- ---Purpose: Returns the number of contours.
- returns Integer from Standard
- is static;
-
- NumberOfElts( me ; IndLine : Integer)
- ---Purpose: Returns the number of BasicElts on the line
- -- <IndLine>.
- returns Integer from Standard
- is static;
-
- NumberOfSections (me; IndLine : Integer; Index : Integer)
- ---Purpose: Returns the number of sections of a curve.
- -- this curve is the Indexth curve in the IndLineth contour
- -- given by anExplo.
- --
- returns Integer from Standard
- is static;
-
- BasicElt ( me ; IndLine : Integer ; Index : Integer)
- ---Purpose: Returns the BasicElts located at the position
- -- <Index> on the contour designed by <IndLine>.
- -- Remark: the BasicElts on a contour are sorted.
- --
- returns BasicElt from MAT
- is static;
-
- GeomElt(me ; aBasicElt : BasicElt from MAT)
- --- Purpose : Returns the geometry linked to the <BasicElt>.
- returns Geometry from Geom2d
- is static;
-
- GeomElt(me ; aNode : Node from MAT)
- --- Purpose : Returns the geometry of type <gp> linked to
- -- the <Node>.
- returns Pnt2d from gp
- is static;
-
- GeomBis(me ; anArc : Arc from MAT ; Reverse :in out Boolean from Standard)
- --- Purpose : Returns the geometry of type <Bissec>
- -- linked to the arc <ARC>.
- -- <Reverse> is False when the FirstNode of <anArc>
- -- correspond to the first point of geometry.
- --
- returns Bisec from Bisector
- is static;
-
----Category: private methods.
-
- Fusion(me : in out)
- is static private;
-
- RenumerationAndFusion
- (me : in out;
- IndexLine : Integer;
- LengthLine : Integer;
- IndexLast : in out Integer;
- NewMap : in out DataMapOfIntegerBasicElt from MAT)
- is static private;
-
-fields
-
- theGraph : Graph from MAT;
- theTool : Tool2d from MAT2d;
- isDone : Boolean from Standard;
- nbSect : DataMapOfBiIntInteger from MAT2d;
- nbContours : Integer from Standard;
-
-end BisectingLocus;
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1993-07-13
-// Created by: Yves FRICAUD
-// Copyright (c) 1993-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 <MAT2d_Mat2d.hxx>
-# include <MAT2d_Tool2d.hxx>
-# include <MAT2d_Circuit.hxx>
-# include <MAT2d_CutCurve.hxx>
-# include <MAT2d_BiInt.hxx>
-# include <MAT2d_SequenceOfSequenceOfGeometry.hxx>
-# include <MAT_Graph.hxx>
-# include <MAT_Arc.hxx>
-# include <MAT_BasicElt.hxx>
-# include <MAT_Node.hxx>
-# include <MAT_Bisector.hxx>
-# include <MAT_ListOfBisector.hxx>
-# include <MAT_DataMapOfIntegerBasicElt.hxx>
-# include <MAT_DataMapIteratorOfDataMapOfIntegerBasicElt.hxx>
-# include <Geom2d_Curve.hxx>
-# include <gp_Pnt2d.hxx>
-# include <TColGeom2d_SequenceOfGeometry.hxx>
-# include <Precision.hxx>
-
-#include <Standard_OutOfRange.hxx>
-
-static void CutSketch (MAT2d_SequenceOfSequenceOfGeometry& Figure,
- MAT2d_DataMapOfBiIntInteger& NbSect);
-
-
-//=============================================================================
-//function : MAT2d_BisectingLocus
-//purpose : Constructeur vide.
-//=============================================================================
-MAT2d_BisectingLocus::MAT2d_BisectingLocus()
-{
-}
-
-
-//=============================================================================
-//function : Compute
-//purpose : Calcul de la carte des lieux bisecteurs sur le contour defini par
-// <anExplo>.
-//=============================================================================
-void MAT2d_BisectingLocus::Compute( Explorer& anExplo,
- const Standard_Integer IndexLine,
- const MAT_Side aSide )
-{
- MAT2d_Mat2d TheMAT;
- Handle(MAT_ListOfBisector) TheRoots = new MAT_ListOfBisector();
- MAT2d_SequenceOfSequenceOfGeometry Figure;
- Standard_Integer i;
-
- nbSect.Clear();
- nbContours = anExplo.NumberOfContours();
-
- //---------------------------------
- // Lecture des donnees de anExplo.
- //---------------------------------
- for (i = 1; i <= anExplo.NumberOfContours(); i++) {
- TColGeom2d_SequenceOfGeometry Line;
- Figure.Append(Line);
- for (anExplo.Init(i); anExplo.More(); anExplo.Next()) {
- Figure.ChangeValue(i).Append(anExplo.Value());
- }
- }
-
- //-----------------------
- // Decoupage des courbes.
- //-----------------------
- CutSketch(Figure,nbSect);
-
- //----------------------------------------------------------
- // Construction du circuit sur lequel est calcule la carte.
- //----------------------------------------------------------
- Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit();
-// Modified by Sergey KHROMOV - Wed Mar 6 17:43:47 2002 Begin
-// ACircuit->Perform(Figure,IndexLine,(aSide == MAT_Left));
- ACircuit->Perform(Figure,anExplo.GetIsClosed(), IndexLine,(aSide == MAT_Left));
-// Modified by Sergey KHROMOV - Wed Mar 6 17:43:48 2002 End
-
- // -----------------------
- // Initialistion du Tool.
- // -----------------------
- theTool.Sense(aSide);
- theTool.InitItems(ACircuit);
-
- // --------------------------------------------
- // Initialisation et execution de l algorithme.
- // --------------------------------------------
- TheMAT.CreateMat(theTool);
-
- isDone = TheMAT.IsDone(); if (!isDone) return;
-
- // ----------------------------------------------------------------
- // Recuperation du resultat de l algorithme et creation du graphe.
- // ----------------------------------------------------------------
- for (TheMAT.Init(); TheMAT.More(); TheMAT.Next()) {
- TheRoots->BackAdd(TheMAT.Bisector());
- }
-
- theGraph = new MAT_Graph();
- theGraph->Perform(TheMAT.SemiInfinite(),
- TheRoots,
- theTool.NumberOfItems(),
- TheMAT.NumberOfBisectors());
-
- //-----------------------------------------------------------------------
- // Fusion des elements de base doubles si plusieurs lignes dans Exploset.
- //-----------------------------------------------------------------------
- if (anExplo.NumberOfContours() > 1) {
- MAT_DataMapOfIntegerBasicElt NewMap;
- Standard_Integer IndexLast = 1;
-
- //-----------------------------------------------------------------------
- // Construction de NewMap dont les elements sont ordonnes suivant les
- // lignes du contour et qui ne contient pas d element dupliques.
- // em meme temps fusion des arcs dupliques et mise a jour des noeuds.
- //-----------------------------------------------------------------------
- for ( i = 1; i <= anExplo.NumberOfContours(); i++) {
- RenumerationAndFusion(i,
- theTool.Circuit()->LineLength(i),
- IndexLast,
- NewMap);
- }
-
- //-----------------------------------------------------------------------
- // Chargement dans le graph de la nouvelle map.
- // et compactage de la map des Arcs (ie Elimination des trous du a la
- // fusion d arcs ).et de celle des Nodes.
- //-----------------------------------------------------------------------
- theGraph->ChangeBasicElts(NewMap);
- theGraph->CompactArcs();
- theGraph->CompactNodes();
- }
-}
-
-//=============================================================================
-//function : RenumerationAndFusion
-//purpose :
-//=============================================================================
-void MAT2d_BisectingLocus::RenumerationAndFusion
- (const Standard_Integer ILine,
- const Standard_Integer LengthLine,
- Standard_Integer& IndexLast,
- MAT_DataMapOfIntegerBasicElt& NewMap)
-{
- Standard_Integer IndFirst;
- Standard_Integer i,j;
- Standard_Integer GeomIndexArc1,GeomIndexArc2,GeomIndexArc3,GeomIndexArc4;
- Standard_Boolean MergeArc1,MergeArc2;
-
- for ( i = 1; i <= LengthLine; i++) {
- const TColStd_SequenceOfInteger& S = theTool.Circuit()->RefToEqui(ILine,i);
-
- IndFirst = S.Value(1);
- NewMap.Bind(IndexLast,theGraph->ChangeBasicElt(IndFirst));
- IndexLast++;
-
- for(j = 2; j <= S.Length(); j++){
- theGraph->FusionOfBasicElts(IndFirst,
- S.Value(j),
- MergeArc1,
- GeomIndexArc1,
- GeomIndexArc2,
- MergeArc2,
- GeomIndexArc3,
- GeomIndexArc4);
- if(MergeArc1) {
- theTool.BisecFusion(GeomIndexArc1,GeomIndexArc2);
- }
- if(MergeArc2) {
- theTool.BisecFusion(GeomIndexArc3,GeomIndexArc4);
- }
- }
- }
-}
-
-//=============================================================================
-//function : IsDone
-//Purpose :
-//=============================================================================
-Standard_Boolean MAT2d_BisectingLocus::IsDone() const
-{
- return isDone;
-}
-
-//=============================================================================
-//function : Graph
-//
-//=============================================================================
-Handle(MAT_Graph) MAT2d_BisectingLocus::Graph() const
-{
- return theGraph;
-}
-
-//=============================================================================
-//function : NumberOfContours
-//
-//=============================================================================
-Standard_Integer MAT2d_BisectingLocus::NumberOfContours () const
-{
- return nbContours;
-}
-
-//=============================================================================
-//function : NumberOfElts
-//
-//=============================================================================
-Standard_Integer MAT2d_BisectingLocus::NumberOfElts
- (const Standard_Integer IndLine) const
-{
- return theTool.Circuit()->LineLength(IndLine);
-}
-
-//=============================================================================
-//function : NumberOfSect
-//
-//=============================================================================
-Standard_Integer MAT2d_BisectingLocus::NumberOfSections
-(const Standard_Integer IndLine,
- const Standard_Integer Index )
- const
-{
- MAT2d_BiInt B(IndLine,Index);
- return nbSect(B);
-}
-
-//=============================================================================
-//function : BasicElt
-//
-//=============================================================================
-Handle(MAT_BasicElt) MAT2d_BisectingLocus::BasicElt
- (const Standard_Integer IndLine,
- const Standard_Integer Index )
- const
-{
- Standard_Integer i;
- Standard_Integer Ind = Index;
-
- for (i = 1 ; i < IndLine ; i++){
- Ind = Ind + theTool.Circuit()->LineLength(i);
- }
- return theGraph->BasicElt(Ind);
-}
-
-
-//=============================================================================
-//function : GeomBis
-//
-//=============================================================================
-Bisector_Bisec MAT2d_BisectingLocus::GeomBis (const Handle(MAT_Arc)& anArc,
- Standard_Boolean& Reverse)
-const
-{
- Reverse = Standard_False;
-
- Handle(Geom2d_Curve) Bis = theTool.GeomBis(anArc->GeomIndex()).Value();
-
- if (Bis->FirstParameter() <= -Precision::Infinite()) {
- Reverse = Standard_True;
- }
- else if (Bis->LastParameter() < Precision::Infinite()) {
- gp_Pnt2d PF = Bis->Value(Bis->FirstParameter());
- gp_Pnt2d PL = Bis->Value(Bis->LastParameter());
- gp_Pnt2d PNode = GeomElt(anArc->FirstNode());
- if (PNode.SquareDistance(PF) > PNode.SquareDistance(PL))
- Reverse = Standard_True;
- }
- return theTool.GeomBis(anArc->GeomIndex());
-}
-
-//=============================================================================
-//function : GeomElt
-//
-//=============================================================================
-Handle(Geom2d_Geometry) MAT2d_BisectingLocus::GeomElt
- (const Handle(MAT_BasicElt)& aBasicElt) const
-{
- return theTool.GeomElt(aBasicElt->GeomIndex());
-}
-
-
-//=============================================================================
-//function : GeomElt
-//
-//=============================================================================
-gp_Pnt2d MAT2d_BisectingLocus::GeomElt(const Handle(MAT_Node)& aNode) const
-{
- return theTool.GeomPnt(aNode->GeomIndex());
-}
-
-
-//=============================================================================
-//function : CutSketch
-//
-//=============================================================================
-static void CutSketch (MAT2d_SequenceOfSequenceOfGeometry& Figure,
- MAT2d_DataMapOfBiIntInteger& NbSect)
-{
- MAT2d_CutCurve Cuter;
- Standard_Integer i,j,k,ico;
- Standard_Integer ICurveInit;
- Standard_Integer NbSection;
-
- for ( i = 1; i <= Figure.Length(); i++) {
- TColGeom2d_SequenceOfGeometry& Contour = Figure.ChangeValue(i);
- ICurveInit = 0;
-
- for ( j = 1; j <= Contour.Length(); j++) {
- ICurveInit++;
- Cuter.Perform(Handle(Geom2d_Curve)::DownCast(Contour.ChangeValue(j)));
- NbSection = 1;
- if (!Cuter.UnModified()) {
- ico = j;
- NbSection = Cuter.NbCurves();
- for ( k = 1; k <= NbSection; k++) {
- Contour.InsertAfter(j,Cuter.Value(k));
- j++;
- }
- Contour.Remove(ico);
- j--;
- }
- MAT2d_BiInt B(i,ICurveInit);
- NbSect.Bind(B,NbSection);
- }
- }
-}
-
--- /dev/null
+-- Created on: 1992-09-22
+-- Created by: Gilles DEBARBOUILLE
+-- Copyright (c) 1992-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.
+
+class Mat2d from MAT2d
+
+ ---Purpose: this class contains the generic algoritm of
+ -- computation of the bisecting locus.
+
+uses
+ Side from MAT,
+ Bisector from MAT,
+ ListOfEdge from MAT,
+ ListOfBisector from MAT,
+ DataMapOfIntegerBisector from MAT,
+ DataMapOfIntegerInteger from TColStd,
+ Tool2d from MAT2d
+
+is
+
+ Create
+ ---Purpose: Empty construtor.
+ returns Mat2d from MAT2d;
+
+--- Category : Computation.
+
+ CreateMat(me : in out ; aTool : in out Tool2d from MAT2d)
+ ---Purpose: Algoritm of computation of the bisecting locus.
+ is static;
+
+ IsDone(me) returns Boolean from Standard
+ ---Purpose: Returns <TRUE> if CreateMat has succeeded.
+ is static;
+
+ LoadBisectorsToRemove(me : in out ;
+ noofbisectorstoremove : in out Integer;
+ distance1 : Real;
+ distance2 : Real;
+ bisector1 : Bisector from MAT;
+ bisector2 : Bisector from MAT;
+ bisector3 : Bisector from MAT;
+ bisector4 : Bisector from MAT)
+ is static private;
+
+
+ Intersect( me : in out ;
+ atool : in out Tool2d from MAT2d;
+ aside : Integer ;
+ noofbisectorstoremove: in out Integer ;
+ bisector1 : mutable Bisector from MAT;
+ bisector2 : mutable Bisector from MAT)
+ is static private;
+
+
+--- Category : Querying.
+
+ Init(me : in out)
+ --- Purpose : Initialize an iterator on the set of the roots
+ -- of the trees of bisectors.
+ is static;
+
+ More(me) returns Boolean
+ --- Purpose : Return False if there is no more roots.
+ is static;
+
+ Next(me : in out)
+ --- Purpose : Move to the next root.
+ is static;
+
+ Bisector(me) returns any Bisector from MAT
+ --- Purpose : Returns the current root.
+ is static;
+
+ SemiInfinite(me) returns Boolean from Standard
+ --- Purpose : Returns True if there are semi_infinite bisectors.
+ -- So there is a tree for each semi_infinte bisector.
+ is static;
+
+ NumberOfBisectors(me) returns Integer from Standard
+ --- Purpose : Returns the total number of bisectors.
+ is static;
+
+fields
+
+ thenumberofbisectors : Integer;
+ thenumberofedges : Integer;
+ semiInfinite : Boolean;
+ theedgelist : ListOfEdge from MAT;
+ typeofbisectortoremove: DataMapOfIntegerInteger from TColStd;
+ bisectoronetoremove : DataMapOfIntegerBisector from MAT;
+ bisectortwotoremove : DataMapOfIntegerBisector from MAT;
+ bisectormap : DataMapOfIntegerBisector from MAT;
+ roots : ListOfBisector from MAT;
+ thecurrentindex : Integer;
+ isDone : Boolean;
+
+end Mat2d;
--- /dev/null
+// Created on: 1992-09-22
+// Created by: Gilles DEBARBOUILLE
+// Copyright (c) 1992-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 <MAT2d_Mat2d.ixx>
+
+#include <MAT_Edge.hxx>
+#include <MAT_ListOfEdge.hxx>
+#include <MAT_Bisector.hxx>
+#include <MAT_ListOfBisector.hxx>
+#include <TColStd_DataMapOfIntegerInteger.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <MAT_DataMapOfIntegerBisector.hxx>
+#include <Precision.hxx>
+#include <MAT2d_Tool2d.hxx>
+
+//========================================================================
+// function : MAT2d_Mat2d
+// purpose :
+//========================================================================
+
+MAT2d_Mat2d::MAT2d_Mat2d()
+{
+ thenumberofbisectors = 0;
+ thenumberofedges = 0;
+}
+
+
+//========================================================================
+// function : CreateMat
+// purpose : Calcul des lieux Bisecteurs.
+//
+// Structure de la carte.
+// ======================
+// La carte des lieux bisecteurs se presente sous la forme d un ou plusieurs
+// arbres de bisectrices.
+// ( un arbre, si calcul a l interieur du contour, plusieurs sinon).
+//
+// Les branches de plus bas niveau de l arbre separent deux elements voisins
+// du contour.
+//
+// Principe de l algorithme.
+// -------------------------
+// l arbre est construit des branches les plus basses vers les plus hautes.
+//
+// 0 . Calcul des bisectrices entre elements voisins du contour.
+// 1 . Elimination de certains element du contour => nouveau contour
+// 2 . Retour en 0.
+//
+// Principales etapes de l algorithme.
+// ===================================
+//
+// etape 1: Initialisation de l algorithme .
+// -----------------------------------------
+// Recuperation via le tool du nombre d'elements sur le contour
+// Initialisation de <theedgelist>, un edge correspond a chaque
+// element du contour.
+//
+// etape 2 : Boucle principale.
+// ----------------------------
+// 0 - Tant que Nombre d'edge > 1
+//
+// 1. Pour chaque edge: construction de la bissectrice entre l edge
+// et l edge suivante.
+// La bissectrice est semi_infinie, elle est soit trimmee par le
+// point commun des deux edges, soit par l intersection de deux
+// bissectrices antecedentes.
+//
+// 2. Intersection des Bisectrices issue du meme edge
+// => une bisectrice est intersectee avec sa voisine a gauche
+// et sa voisine a droite.
+//
+// 3. Analyse des intersections.
+// Si pas d'intersection entre deux bisectrices B1 et B2
+// - Recherche de l intersection la plus basse de B1 avec les
+// Bisectrices antecedentes a B2 du cote de B1. Soit Bi la
+// bissectrice intersectee. Toutes les bissectrices constituant la
+// branche qui relie B2 a Bi sont marquees a effacer
+// - idem pour B2.
+//
+// 4. Suppresion des bisectrices a effacer.
+// une bisectrise est a effacer :
+// - Anulation de l intersection dont la bissectrice est issue
+// => Prolongement des deux bisectrices posterieures.
+// - Reinsertion des edge correspondant dans <theedgelist>.
+//
+// 5. Pour chaque edge, analyse des distances entre les points d inter
+// section et l edge.
+// B1 B2 les bisectrices liee a l edge
+// Soit P0 le point d intersection des bissectrices .
+// Soit P1 le point d intersection de B1 avec son autre voisine .
+// Soit P2 le point d intersection de B2 avec son autre voisine .
+//
+// si sur B1 le parametre de P0 < parametre de P1 et
+// si sur B2 le parametre de P0 < parametre de P2
+// alors suppression de l edge de la liste des edges <theedgelist>.
+//
+// rq: le parametre sur une bissectirce est croissant par rapport
+// a la distance du point courant aux edges.
+
+// 6. Si aucune edge est elimine alors sortie de la boucle principale.
+//
+// 7. Retour en 0.
+//
+// etape 3 : Creation des racines des arbres de bisectrices.
+// ---------------------------------------------------------
+// Recuperation des bissectrices calculees lors du dernier passage
+// dans la boucle.
+//
+//========================================================================
+void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool)
+{
+
+#ifdef ICONTINUE
+ Standard_Boolean Icontinue;
+#endif
+
+ Standard_Boolean interrupt = Standard_False;
+
+ Handle(MAT_Edge) edgetoremove;
+ Handle(MAT_Edge) previousedge,currentedge;
+
+ Standard_Integer noofbisectorstoremove;
+ Handle(MAT_Bisector) firstbisector,secondbisector;
+ Handle(MAT_Edge) edge;
+ Standard_Integer intersectionpoint;
+ Standard_Integer beginbisector;
+ Standard_Integer noofbisectors;
+
+ Standard_Integer NbIterBis = 0;
+ Standard_Integer EvenNbIterBis = 10;
+ TColStd_Array1OfInteger EdgeNumbers(1, EvenNbIterBis+1);
+ EdgeNumbers.Init(-1);
+ Standard_Boolean ToNullifyNoofbisectorstoremove = Standard_False;
+
+ Handle(MAT_ListOfBisector) currentbisectorlist;
+
+ Handle(MAT_Bisector) bisectortoremove,lastbisector,currentbisector;
+ Handle(MAT_Bisector) previousbisector;
+
+ Standard_Integer i,j,k,narea,shift,compact,all;
+ Standard_Integer noofedges;
+ Standard_Integer NumberMaxOfIte;
+ Standard_Real toleranceofconfusion;
+
+ noofedges = atool.NumberOfItems();
+ toleranceofconfusion = atool.ToleranceOfConfusion();
+ NumberMaxOfIte = noofedges*noofedges;
+
+ TColStd_Array1OfInteger firstarea(0, noofedges);
+ TColStd_Array1OfInteger lastarea(0, noofedges);
+ TColStd_Array1OfInteger noofarea(0, noofedges);
+
+ Standard_Integer parama[2];
+ Standard_Integer paramb[2];
+
+// -----------------------------------------
+// Initialisation et remise a zero des maps.
+// -----------------------------------------
+ bisectoronetoremove.Clear();
+ bisectortwotoremove.Clear();
+ typeofbisectortoremove.Clear();
+ bisectormap.Clear();
+
+ isDone = Standard_True;
+ noofbisectors = noofedges;
+ beginbisector = 0;
+
+// --------------------------------------------------------------------
+// Construction de <theedgelist> un edge correspond a un element simple
+// du contour.
+// --------------------------------------------------------------------
+ theedgelist = new MAT_ListOfEdge();
+
+ for(i=0; i<noofedges; i++) {
+ edge = new MAT_Edge();
+ edge->EdgeNumber(i+1);
+ edge->Distance(-1);
+ theedgelist->BackAdd(edge);
+ }
+
+ theedgelist->Loop();
+
+//---------------------------------------------------
+// Initialisation des bissectrices issues du contour.
+//---------------------------------------------------
+ Standard_Real Dist;
+ theedgelist->First();
+
+ for(i=0; i<theedgelist->Number(); i++) {
+ bisectormap.Bind(i,new MAT_Bisector());
+ bisectormap(i)->IndexNumber(i);
+ bisectormap(i)->FirstEdge(theedgelist->Current());
+ bisectormap(i)->FirstVector
+ (atool.TangentBefore(theedgelist->Current()->EdgeNumber()));
+ theedgelist->Next();
+ bisectormap(i)->SecondEdge(theedgelist->Current());
+ bisectormap(i)->IssuePoint
+ (atool.FirstPoint(theedgelist->Current()->EdgeNumber(),Dist));
+ bisectormap(i)->DistIssuePoint(Dist);
+ bisectormap(i)->SecondVector
+ (atool.TangentAfter(theedgelist->Current()->EdgeNumber()));
+ }
+
+//----------------------------------------------------
+// Affectation a chaque edge de ses deux bissectrices.
+//----------------------------------------------------
+ theedgelist->First();
+
+ for(i=0; i<theedgelist->Number(); i++) {
+ theedgelist->Current()->FirstBisector
+ (bisectormap((i-1+noofbisectors)%noofbisectors));
+ theedgelist->Current()->SecondBisector
+ (bisectormap(i));
+ theedgelist->Next();
+ }
+
+//===========================================================================
+// Boucle Principale (etape 2)
+//===========================================================================
+ Standard_Integer NumberOfIte = 0;
+
+ while(theedgelist->Number()>1) {
+
+
+ // ------------------------------------------------------------------
+ // Creation des geometries des bissectrices via le tool. (etape 2.1)
+ // -------------------------------------------------------------------
+
+ for(i=beginbisector; i<noofbisectors; i++) {
+
+ atool.CreateBisector(bisectormap(i));
+ thenumberofbisectors++;
+
+#ifdef DEBUG_Mat
+ atool.Dump(bisectormap(i)->BisectorNumber(),1);
+#ifdef ICONTINUE
+ cin>>Icontinue;
+#endif
+#endif
+ }
+
+ // ---------------------------------------------
+ // Condition de sortie de la boucle principale.
+ // ---------------------------------------------
+
+// Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin
+ if (theedgelist->Number() < 3)
+ break;
+// Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End
+
+ //---------------------------------------------------
+ // boucle 2 Tant qu il y a des bisectrices a effacer.
+ //---------------------------------------------------
+ for(;;) {
+ NbIterBis++;
+
+ noofbisectorstoremove = 0;
+ theedgelist->First();
+
+ //--------------------------------------------------------------
+ // Calcul des intersections des bisectrices voisines.(etape 2.2)
+ //--------------------------------------------------------------
+
+ if (NbIterBis <= EvenNbIterBis+1)
+ EdgeNumbers(NbIterBis) = theedgelist->Number();
+ else
+ {
+ for (k = 1; k <= EvenNbIterBis; k++)
+ EdgeNumbers(k) = EdgeNumbers(k+1);
+ EdgeNumbers(EvenNbIterBis+1) = theedgelist->Number();
+ }
+ if (EdgeNumbers(EvenNbIterBis+1) == EdgeNumbers(1))
+ ToNullifyNoofbisectorstoremove = Standard_True;
+
+ for(i=0; i<theedgelist->Number(); i++) {
+ edge = theedgelist->Current();
+ if(edge->Distance() == -1.) {
+ firstbisector = edge->FirstBisector();
+ secondbisector = edge->SecondBisector();
+ edge->Distance(atool.IntersectBisector
+ (firstbisector,secondbisector,intersectionpoint));
+ edge->IntersectionPoint(intersectionpoint);
+
+ if(edge->Distance() == Precision::Infinite()) {
+ if(firstbisector->IndexNumber() >= beginbisector ||
+ secondbisector->IndexNumber() >= beginbisector)
+ Intersect(atool,0,noofbisectorstoremove,
+ firstbisector,secondbisector );
+ }
+ else {
+ if(firstbisector->IndexNumber() >= beginbisector) {
+ Intersect(atool,1,noofbisectorstoremove,
+ firstbisector,secondbisector );
+ }
+ if(secondbisector->IndexNumber() >= beginbisector) {
+ Intersect(atool,2,noofbisectorstoremove,
+ firstbisector,secondbisector );
+ }
+ }
+ }
+ theedgelist->Next();
+ }
+
+ //-------------------------------
+ // Test de sortie de la boucle 2.
+ //-------------------------------
+
+ if (ToNullifyNoofbisectorstoremove)
+ noofbisectorstoremove = 0;
+ if(noofbisectorstoremove == 0) break;
+
+ //---------------------------------------------------
+ // Annulation des bissectrices a effacer. (etape 2.4)
+ //---------------------------------------------------
+
+ for(i=0; i<noofbisectorstoremove; i++) {
+
+ bisectortoremove = bisectoronetoremove(i);
+
+ //---------------------------------------------------------------
+ // Destruction des bisectrices descendantes de <bisectortoremove>
+ // On descend dans l arbre jusqu a ce qu on atteigne
+ // <bisectortwotoremove(i).
+ //---------------------------------------------------------------
+
+ for(;;){
+
+#ifdef DEBUG_Mat
+ atool.Dump(bisectortoremove->BisectorNumber(),0);
+#endif
+ // ----------------------------------
+ // Annulation de <bisectortoremove>.
+ // ----------------------------------
+ thenumberofbisectors--;
+ currentbisectorlist = bisectortoremove->List();
+ currentbisectorlist->First();
+ currentbisector = currentbisectorlist->FirstItem();
+ previousedge = currentbisector->FirstEdge();
+ theedgelist->Init(previousedge);
+ previousedge->Distance(-1.);
+ previousedge->FirstBisector()->SecondParameter(Precision::Infinite());
+ previousedge->SecondBisector()->FirstParameter(Precision::Infinite());
+
+ //------------------------------------------
+ // Annulation des fils de <currentbisector>.
+ //------------------------------------------
+
+ while(currentbisectorlist->More()) {
+ currentbisector = currentbisectorlist->Current();
+ currentedge = currentbisector->SecondEdge();
+
+ //---------------------------------------
+ // Reinsertion de l edge dans le contour.
+ //---------------------------------------
+ theedgelist->LinkAfter(currentedge);
+ theedgelist->Next();
+
+ currentedge->FirstBisector(currentbisector);
+ previousedge->SecondBisector(currentbisector);
+#ifdef DEBUG_Mat
+ atool.Dump(currentbisector->BisectorNumber(),0);
+#endif
+
+ //------------------------------------------------------
+ // Annulation de l intersection ie les fils qui
+ // ont generes l intersection sont prolonges a l infini.
+ //------------------------------------------------------
+
+ currentbisector->FirstParameter (Precision::Infinite());
+ currentbisector->SecondParameter(Precision::Infinite());
+
+ atool.TrimBisector(currentbisector);
+
+#ifdef DEBUG_Mat
+ atool.Dump(currentbisector->BisectorNumber(),1);
+#endif
+ currentedge->Distance(-1.);
+ currentedge->FirstBisector()->SecondParameter(Precision::Infinite());
+ currentedge->SecondBisector()->FirstParameter(Precision::Infinite());
+
+ previousedge = currentedge;
+ currentbisectorlist->Next();
+ }
+
+ theedgelist->Unlink();
+
+ //-----------------------------------------------------------
+ // Test de sortie de la boucle d annulation des bissectrices.
+ //-----------------------------------------------------------
+
+ if(bisectortoremove->BisectorNumber() ==
+ bisectortwotoremove(i)->BisectorNumber()) break;
+
+ //-----------------------
+ // Descente dans l arbre.
+ //-----------------------
+
+ if(typeofbisectortoremove(i) == 1)
+ bisectortoremove = bisectortoremove->FirstBisector();
+ else
+ bisectortoremove = bisectortoremove->LastBisector();
+
+ } //----------------------------------------------------
+ // Fin boucle d annulation des bissectrices issue de
+ // <bisectoronetoremove(i)>.
+ //----------------------------------------------------
+
+ } //------------------------------------------
+ // Fin boucle d annulation des bissectrices.
+ //-------------------------------------------
+
+#ifdef ICONTINUE
+ cin>>Icontinue;
+#endif
+ } //--------------
+ // Fin Boucle 2.
+ //--------------
+
+ // ----------------------------------------------------------------------
+ // Analyse des parametres des intersections sur les bisectrices de chaque
+ // edge et determination des portions de contour a supprimees. (etape 2.5)
+ // ----------------------------------------------------------------------
+
+ theedgelist->First();
+
+ currentbisector = theedgelist->Current()->FirstBisector();
+ if (currentbisector->FirstParameter() == Precision::Infinite() &&
+ currentbisector->SecondParameter() == Precision::Infinite()) {
+ parama[0] = -1;
+ paramb[0] = -1;
+ }
+ else if(currentbisector->FirstParameter() == Precision::Infinite()) {
+ parama[0] = -1;
+ paramb[0] = 1;
+ }
+ else if(currentbisector->SecondParameter() == Precision::Infinite()) {
+ paramb[0] = -1;
+ parama[0] = 1;
+ }
+ else if (atool.Distance(currentbisector,
+ currentbisector->FirstParameter(),
+ currentbisector->SecondParameter())
+ > toleranceofconfusion) {
+ if((currentbisector->FirstParameter() -
+ currentbisector->SecondParameter())
+ *currentbisector->Sense() > 0.) {
+ parama[0] = -1;
+ paramb[0] = 1;
+ }
+ else {
+ paramb[0] = -1;
+ parama[0] = 1;
+ }
+ }
+ else {
+ parama[0] = 1;
+ paramb[0] = 1;
+ }
+
+ narea = -1;
+
+ for(i=0; i<theedgelist->Number(); i++) {
+ currentbisector = theedgelist->Current()->SecondBisector();
+ if (currentbisector->FirstParameter() == Precision::Infinite() &&
+ currentbisector->SecondParameter() == Precision::Infinite()) {
+ parama[1] = -1;
+ paramb[1] = -1;
+ }
+ else if(currentbisector->FirstParameter() == Precision::Infinite()) {
+ parama[1] = -1;
+ paramb[1] = 1;
+ }
+ else if(currentbisector->SecondParameter() == Precision::Infinite()) {
+ paramb[1] = -1;
+ parama[1] = 1;
+ }
+ else if (atool.Distance(currentbisector,
+ currentbisector->FirstParameter(),
+ currentbisector->SecondParameter())
+ > toleranceofconfusion) {
+ if((currentbisector->FirstParameter() -
+ currentbisector->SecondParameter())
+ *currentbisector->Sense() > 0.) {
+ parama[1] = -1;
+ paramb[1] = 1;
+ }
+ else {
+ paramb[1] = -1;
+ parama[1] = 1;
+ }
+ }
+ else {
+ parama[1] = 1;
+ paramb[1] = 1;
+ }
+
+ //-----------------------------------------------------------------
+ // Test si l edge est a enlever du contour
+ // Construction des portions de contour a eliminer.
+ //
+ // narea : nombre de portions continues du contour a eliminer.
+ // firstarea[i] : indice premier edge de la portion i.
+ // lastarea[i] : indice dernier edge de la portion i.
+ //-----------------------------------------------------------------
+
+#ifdef DEBUG_Mat
+ cout <<" Test sur les parametres pour elimination"<<endl;
+ cout << " Edge number :"<<theedgelist->Current()->EdgeNumber()<<endl;
+#endif
+
+ if(paramb[0] > 0 && parama[1] > 0) {
+
+#ifdef DEBUG_Mat
+ cout <<" A ELIMINER "<<endl;
+#endif
+ if(narea < 0) {
+ firstarea(++narea) = theedgelist->Index();
+ lastarea(narea) = firstarea(narea);
+ noofarea(narea) = 1;
+ }
+ else {
+ if(theedgelist->Index() == lastarea(narea)+1) {
+ lastarea(narea)++;
+ noofarea(narea)++;
+ }
+ else {
+ firstarea(++narea) = theedgelist->Index();
+ lastarea(narea) = firstarea(narea);
+ noofarea(narea) = 1;
+ }
+ }
+ }
+ parama[0] = parama[1];
+ paramb[0] = paramb[1];
+ theedgelist->Next();
+
+ }
+
+ compact = 0;
+ if(narea > 0) {
+ if(lastarea(narea) == theedgelist->Number() && firstarea(0) == 1) {
+ firstarea(0) = firstarea(narea);
+ noofarea(0) = noofarea(0)+noofarea(narea);
+ compact = noofarea(narea);
+ narea--;
+ }
+ }
+
+ narea++;
+
+ //------------------------------------------------------------------
+ // Sortie de la boucle principale si il n y a pas d edge a eliminer.
+ // (etape 2.6)
+ //------------------------------------------------------------------
+ if(narea == 0) {
+ interrupt = Standard_True;
+ break;
+ }
+
+
+ //----------------------------------------------------------------
+ // Elimination des edges a enlever du contour
+ // => Mise a jour du nouveau contour.
+ // => Creation des bissectrices entre les nouvelles edges voisines.
+ //----------------------------------------------------------------
+
+ beginbisector = noofbisectors;
+ shift = 0;
+ all = 0;
+ if(narea == 1 && noofarea(0) == theedgelist->Number()) all = 1;
+
+ for(i=0; i<narea; i++) {
+ if(i == 1)shift = shift-compact;
+ theedgelist->First();
+ edgetoremove = theedgelist->Brackets(firstarea(i)-shift);
+
+ edgetoremove->FirstBisector()->EndPoint(edgetoremove
+ ->IntersectionPoint());
+
+#ifdef DEBUG_Mat
+ atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),0);
+#endif
+
+ edgetoremove->FirstBisector()->FirstParameter
+ (edgetoremove->FirstBisector()->SecondParameter());
+
+#ifdef DEBUG_Mat
+ if(atool.TrimBisector(edgetoremove->FirstBisector()))
+ atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),1);
+#else
+ atool.TrimBisector(edgetoremove->FirstBisector());
+#endif
+
+ bisectormap.Bind(noofbisectors,new MAT_Bisector());
+ bisectormap(noofbisectors)->IndexNumber(noofbisectors);
+ bisectormap(noofbisectors)->DistIssuePoint(edgetoremove->Distance());
+ bisectormap(noofbisectors)->IssuePoint(edgetoremove
+ ->IntersectionPoint());
+ bisectormap(noofbisectors)->FirstEdge(theedgelist->PreviousItem());
+ bisectormap(noofbisectors)->AddBisector(edgetoremove
+ ->FirstBisector());
+
+ for(j=0; j<noofarea(i); j++) {
+ theedgelist->Unlink();
+ theedgelist->Next();
+ shift++;
+
+#ifdef DEBUG_Mat
+ cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<endl;
+#endif
+
+ if(all == 0 || j+1 != noofarea(i)) {
+ bisectormap(noofbisectors)->AddBisector(edgetoremove
+ ->SecondBisector());
+ }
+ edgetoremove->SecondBisector()->EndPoint(edgetoremove
+ ->IntersectionPoint());
+
+#ifdef DEBUG_Mat
+ atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),0);
+#endif
+
+ edgetoremove->SecondBisector()->SecondParameter
+ (edgetoremove->SecondBisector()->FirstParameter());
+#ifdef DEBUG_Mat
+ if(atool.TrimBisector(edgetoremove->SecondBisector()))
+ atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),1);
+#else
+ atool.TrimBisector(edgetoremove->SecondBisector());
+#endif
+ edgetoremove = theedgelist->Current();
+ }
+ bisectormap(noofbisectors)->SecondEdge(theedgelist->Current());
+
+ theedgelist->PreviousItem()
+ ->SecondBisector(bisectormap(noofbisectors));
+ theedgelist->Current()->FirstBisector(bisectormap(noofbisectors));
+
+ bisectormap(noofbisectors)->FirstVector
+ (atool.Tangent
+ (bisectormap(noofbisectors)->FirstBisector()
+ ->BisectorNumber()));
+
+ bisectormap(noofbisectors)->SecondVector
+ (atool.Tangent
+ (bisectormap(noofbisectors)->LastBisector()
+ ->BisectorNumber()));
+
+ noofbisectors++;
+
+ theedgelist->PreviousItem()->Distance(-1);
+ theedgelist->Current()->Distance(-1);
+
+ theedgelist->PreviousItem()->FirstBisector()
+ ->SecondParameter(Precision::Infinite());
+ theedgelist->Current()->SecondBisector()->FirstParameter(Precision::Infinite());
+ }
+
+ //-----------------------------------------------------------------------
+ // Test sur le nombre d iterations :
+ // A chaque iteration est elimine un element du contour qui ne sera plus
+ // reinsere par la suite => le nombre d iterartions doit etre < au nombre
+ // d elements.
+ // Le nombre d iteration maximum est fixe a numberofedges*numberofedges.
+ //-----------------------------------------------------------------------
+ if (NumberOfIte > NumberMaxOfIte) {
+ isDone = Standard_False; //Echec calcul de la carte.
+ break;
+ }
+ NumberOfIte++;
+
+ } //===============================================
+ // Fin Boucle Principale.
+ //===============================================
+
+ //----------
+ // etape 3.
+ //----------
+
+
+ //----------------------------------------------
+ // interupt = True => bissectrices semi_infinies.
+ //----------------------------------------------
+
+ if(interrupt)
+ semiInfinite = Standard_True;
+ else {
+ semiInfinite = Standard_False;
+
+ //------------------------------------------------------------------
+ // Si le nombre d edge > 1 => le nombre d edge = 2
+ // (cf test sortie boucle principale)
+ // Les deux dernieres bisectrices separent les memes edges .
+ // Soit elles sont confondues si calcul a l interieur, soit elles
+ // sont semi-Infinies (exemple : contour compose seulement de deux
+ // arcs de cercles).
+ //------------------------------------------------------------------
+
+ if(theedgelist->Number() > 1) { //Now this branch is never reachable
+ //because the case edgenumber = 2 is processed in the main loop
+ theedgelist->First();
+ edge = theedgelist->Current();
+ if(edge->FirstBisector()->IndexNumber() == noofbisectors-1) {
+// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
+ if (atool.TrimBisector(edge->SecondBisector(),
+ edge->FirstBisector()->IssuePoint())) {
+ if (edge->SecondBisector()->EndPoint() == 0)
+ edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint());
+ bisectormap(noofbisectors-1)->AddBisector(edge->SecondBisector());
+ } else
+ semiInfinite = Standard_True;
+// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
+ }
+ else {
+// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
+ if (atool.TrimBisector(edge->FirstBisector(),
+ edge->SecondBisector()->IssuePoint())) {
+ if (edge->FirstBisector()->EndPoint() == 0)
+ edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint());
+ bisectormap(noofbisectors-1)->AddBisector(edge->FirstBisector());
+ } else
+ semiInfinite = Standard_True;
+// Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
+ }
+ if (!semiInfinite) {
+ thenumberofbisectors--;
+ bisectormap(noofbisectors-1)->SecondEdge(edge);
+ bisectormap(noofbisectors-1)->BisectorNumber(-1);
+ }
+ }
+ }
+ if(semiInfinite) {
+ beginbisector = noofbisectors;
+ theedgelist->First();
+ for(i=0; i<theedgelist->Number(); i++) {
+ edge = theedgelist->Current();
+ bisectormap.Bind(noofbisectors,edge->SecondBisector());
+ noofbisectors++;
+ theedgelist->Next();
+ }
+
+ }
+
+ //---------------------------
+ // Recuperations des racines.
+ //---------------------------
+
+ roots = new MAT_ListOfBisector;
+
+ if (bisectormap(noofbisectors-1)->BisectorNumber() == -1) {
+ roots = bisectormap(noofbisectors-1)->List();
+ roots->First();
+ roots->Current()->FirstEdge()
+ ->Distance(bisectormap(noofbisectors-1)->DistIssuePoint());
+ }
+ else {
+ for (i=beginbisector;i<noofbisectors;i++) {
+ roots->BackAdd(bisectormap(i));
+ }
+ }
+
+}
+
+//========================================================================
+// function : LoadBisectorsToRemove
+// purpose : Chargement des bisectrices a effacer.
+//========================================================================
+void MAT2d_Mat2d::LoadBisectorsToRemove
+ ( Standard_Integer& noofbisectorstoremove,
+ const Standard_Real distance1,
+ const Standard_Real distance2,
+ const Handle(MAT_Bisector)& firstbisectortoremove1,
+ const Handle(MAT_Bisector)& firstbisectortoremove2,
+ const Handle(MAT_Bisector)& lastbisectortoremove1,
+ const Handle(MAT_Bisector)& lastbisectortoremove2 )
+{
+
+ Standard_Integer found,index;
+ Handle(MAT_Bisector) firstbisectortoremove[2];
+ Handle(MAT_Bisector) lastbisectortoremove[2];
+
+ firstbisectortoremove[0] = firstbisectortoremove1;
+ firstbisectortoremove[1] = firstbisectortoremove2;
+ lastbisectortoremove[0] = lastbisectortoremove1;
+ lastbisectortoremove[1] = lastbisectortoremove2;
+
+ if (distance1 < Precision::Infinite() &&
+ distance2 == Precision::Infinite() ) index = 0;
+ else if(distance2 < Precision::Infinite() &&
+ distance1 == Precision::Infinite() ) index = 1;
+ else index = -1;
+
+ if(index != -1) {
+ found = noofbisectorstoremove;
+ for(int j=0; j<noofbisectorstoremove; j++) {
+ if(bisectoronetoremove(j)->BisectorNumber() ==
+ firstbisectortoremove[index]->BisectorNumber()) {
+ found = j;
+ if(bisectortwotoremove(j)->BisectorNumber() <
+ lastbisectortoremove[index]->BisectorNumber())found = -1;
+ break;
+ }
+ }
+
+ if(found != -1) {
+#ifdef DEBUG_Mat
+ cout<<" first last bisector to remove :"<<
+ firstbisectortoremove[index]->BisectorNumber()<<" "<<
+ lastbisectortoremove[index]->BisectorNumber()<<endl;
+#endif
+ bisectoronetoremove.Bind(found,firstbisectortoremove[index]);
+ bisectortwotoremove.Bind(found,lastbisectortoremove[index]);
+ typeofbisectortoremove.Bind(found,index+1);
+
+ if(found == noofbisectorstoremove)noofbisectorstoremove++;
+ }
+ }
+}
+
+//========================================================================
+// function : Intersect
+// purpose : Si <aside=0> Intersection de <firstbisector> avec les
+// descendants de <secondbisector> les plus a gauche
+// (ie secondbisector->FirstBisector()->FirstBisector...)
+// Intersection de <secondbisector> avec les
+// descendants de <firstbisector> les plus a droite
+// (ie firstbisector->LastBisector()->LastBisector...)
+//
+// Si <aside=1> Intersection de <firstbisector> avec ses
+// descendants les plus a gauche et les plus a droite.
+//
+// Si <aside=2> Intersection de <secondbisector> avec ses
+// descendants les plus a gauche et les plus a droite.
+//========================================================================v
+void MAT2d_Mat2d::Intersect( MAT2d_Tool2d& atool,
+ const Standard_Integer aside,
+ Standard_Integer& noofbisectortoremove,
+ const Handle(MAT_Bisector)& firstbisector,
+ const Handle(MAT_Bisector)& secondbisector)
+{
+ Standard_Integer bisectornumber;
+ Standard_Real distant,saveparameter;
+ Standard_Real distance[2];
+ Standard_Integer intersectionpoint;
+ Handle(MAT_Bisector) lastbisector,previousbisector;
+ Handle(MAT_Bisector) firstbisectortoremove[2];
+ Handle(MAT_Bisector) lastbisectortoremove[2];
+
+ distance[0] = Precision::Infinite();
+ distance[1] = Precision::Infinite();
+
+ for(bisectornumber = 0; bisectornumber<2; bisectornumber++) {
+ if(aside == 0) {
+ if(bisectornumber == 0)
+ firstbisectortoremove[bisectornumber] = secondbisector;
+ else
+ firstbisectortoremove[bisectornumber] = firstbisector;
+ }
+ else if(aside == 1) {
+ firstbisectortoremove[bisectornumber] = firstbisector;
+ }
+ else {
+ firstbisectortoremove[bisectornumber] = secondbisector;
+ }
+
+ lastbisector = firstbisectortoremove[bisectornumber];
+
+ if(aside == 0) {
+ previousbisector = firstbisectortoremove[bisectornumber];
+ }
+ else {
+ if(firstbisectortoremove[bisectornumber]->List()->IsEmpty())continue;
+
+ if(bisectornumber == 0)
+ previousbisector = firstbisectortoremove[bisectornumber]
+ ->FirstBisector();
+ else
+ previousbisector = firstbisectortoremove[bisectornumber]
+ ->LastBisector();
+ }
+
+ distant = distance[bisectornumber];
+ while(!previousbisector->List()->IsEmpty()) {
+
+ if(bisectornumber == 0)
+ previousbisector = previousbisector->FirstBisector();
+ else
+ previousbisector = previousbisector->LastBisector();
+
+ if(aside == 1 || (aside == 0 && bisectornumber == 0)) {
+ saveparameter = previousbisector->FirstParameter();
+ distant = atool.IntersectBisector
+ (firstbisector,previousbisector,intersectionpoint);
+ previousbisector->FirstParameter(saveparameter);
+ }
+ else {
+ saveparameter = previousbisector->SecondParameter();
+ distant = atool.IntersectBisector
+ (previousbisector,secondbisector,intersectionpoint);
+ previousbisector->SecondParameter(saveparameter);
+ }
+
+ if(distant < Precision::Infinite()) {
+ distance[bisectornumber] = distant;
+ lastbisectortoremove[bisectornumber] = lastbisector;
+ }
+
+ lastbisector = previousbisector;
+ }
+ }
+
+ //---------------------------------------
+ // Chargement des bissectrices a effacer.
+ //---------------------------------------
+
+ LoadBisectorsToRemove(noofbisectortoremove,
+ distance[0],distance[1],
+ firstbisectortoremove[0],firstbisectortoremove[1],
+ lastbisectortoremove[0] ,lastbisectortoremove[1]);
+}
+
+//========================================================================
+// function : Init
+// purpose :
+//========================================================================
+void MAT2d_Mat2d::Init()
+{
+ roots->First();
+}
+
+//========================================================================
+// function : More
+// purpose :
+//========================================================================
+Standard_Boolean MAT2d_Mat2d::More() const
+{
+ return roots->More();
+}
+
+//========================================================================
+// function : Next
+// purpose :
+//========================================================================
+void MAT2d_Mat2d::Next()
+{
+ roots->Next();
+}
+
+//========================================================================
+// function : Bisector
+// purpose :
+//========================================================================
+Handle(MAT_Bisector) MAT2d_Mat2d::Bisector() const
+{
+ return roots->Current();
+}
+
+//========================================================================
+// function : NumberOfBisectors
+// purpose :
+//========================================================================
+Standard_Integer MAT2d_Mat2d::NumberOfBisectors() const
+{
+ return thenumberofbisectors;
+}
+
+//========================================================================
+// function : SemiInfinite
+// purpose :
+//========================================================================
+Standard_Boolean MAT2d_Mat2d::SemiInfinite() const
+{
+ return semiInfinite;
+}
+
+//========================================================================
+// function : IsDone
+// purpose :
+//========================================================================
+Standard_Boolean MAT2d_Mat2d::IsDone() const
+{
+ return isDone;
+}
+
-- Element, generic Elem, and instance for Transient
class DataInfo; -- used in Elem : this one is for Transient
deferred class Element;
- generic class Elem;
- class TransientElem instantiates Elem
- (Transient, MapTransientHasher from TColStd, DataInfo);
+ class TransientElem;
class ElemHasher;
+++ /dev/null
--- Created on: 1994-11-04
--- Created by: Christian CAILLET
--- Copyright (c) 1994-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.
-
-generic class Elem from MoniTool
- (TheKey as any;
- TheHasher as any;
- TheInfo as any)
- inherits Element
-
- ---Purpose : an Elem defines an Element for a specific input class
- -- its definition includes the value of the Key to be mapped,
- -- and the HashCoder associated to the class of the Key
- --
- -- TheKey defines the class to be keyed
- -- TheHasher is the associated Hasher
- -- TheInfo is an additionnal class which helps to provide
- -- informations on the value (template : see DataInfo)
-
-uses CString
-
-is
-
- Create (akey : any TheKey) returns mutable Elem;
- ---Purpose : Creates a Elem with a Value. This Value can then not be
- -- changed. It is used by the Hasher to compute the HashCode,
- -- which will then be stored for an immediate reading.
-
- Value (me) returns any TheKey is static;
- ---Purpose : Returns the contained value
- ---C++ : return const &
-
- Equates (me; other : Element) returns Boolean;
- ---Purpose : Specific testof equallity : defined as False if <other> has
- -- not the same true Type, else contents are compared (by
- -- C++ operator ==)
-
- ValueType (me) returns Type is redefined;
- ---Purpose : Returns the Type of the Value. By default, returns the
- -- DynamicType of <me>, but can be redefined
-
- ValueTypeName (me) returns CString is redefined;
- ---Purpose : Returns the name of the Type of the Value. Default is name
- -- of ValueType, unless it is for a non-handled object
-
-fields
-
- theval : TheKey;
-
-end Elem;
+++ /dev/null
-// 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 <MoniTool_Elem.ixx>
-#include <Standard_Integer.hxx>
-
-
-MoniTool_Elem::MoniTool_Elem (const TheKey& akey)
- : theval (akey)
-{ SetHashCode ( TheHasher::HashCode (akey, IntegerLast() ) ); }
-
-
- const TheKey& MoniTool_Elem::Value () const
- { return theval; }
-
- Standard_Boolean MoniTool_Elem::Equates
- (const Handle(MoniTool_Element)& other) const
-{
- if (other.IsNull()) return Standard_False;
- if (GetHashCode() != other->GetHashCode()) return Standard_False;
- if (other->DynamicType() != DynamicType()) return Standard_False;
- Handle(MoniTool_Elem) another = Handle(MoniTool_Elem)::DownCast(other);
-// return (theval == another->Value());
- return TheHasher::IsEqual (theval,another->Value());
-}
-
- Handle(Standard_Type) MoniTool_Elem::ValueType () const
- { return TheInfo::Type(theval); }
-
- Standard_CString MoniTool_Elem::ValueTypeName () const
- { return TheInfo::TypeName(theval); }
--- /dev/null
+-- Created on: 1994-11-04
+-- Created by: Christian CAILLET
+-- Copyright (c) 1994-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.
+
+class TransientElem from MoniTool inherits Element
+
+ ---Purpose : an TransientElem defines an Element for a specific input class
+ -- its definition includes the value of the Key to be mapped,
+ -- and the HashCoder associated to the class of the Key
+ --
+ -- Transient from Standard defines the class to be keyed
+ -- MapTransientHasher from TColStd is the associated Hasher
+ -- DataInfo from MoniTool is an additionnal class which helps to provide
+ -- informations on the value (template : see DataInfo)
+
+uses CString,
+ Transient from Standard,
+ MapTransientHasher from TColStd,
+ DataInfo from MoniTool
+
+is
+
+ Create (akey : any Transient from Standard) returns mutable TransientElem;
+ ---Purpose : Creates a TransientElem with a Value. This Value can then not be
+ -- changed. It is used by the Hasher to compute the HashCode,
+ -- which will then be stored for an immediate reading.
+
+ Value (me) returns any Transient from Standard is static;
+ ---Purpose : Returns the contained value
+ ---C++ : return const &
+
+ Equates (me; other : Element) returns Boolean;
+ ---Purpose : Specific testof equallity : defined as False if <other> has
+ -- not the same true Type, else contents are compared (by
+ -- C++ operator ==)
+
+ ValueType (me) returns Type is redefined;
+ ---Purpose : Returns the Type of the Value. By default, returns the
+ -- DynamicType of <me>, but can be redefined
+
+ ValueTypeName (me) returns CString is redefined;
+ ---Purpose : Returns the name of the Type of the Value. Default is name
+ -- of ValueType, unless it is for a non-handled object
+
+fields
+
+ theval : Transient from Standard;
+
+end TransientElem;
--- /dev/null
+// 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 <MoniTool_TransientElem.ixx>
+
+#include <Standard_Integer.hxx>
+#include <Standard_Transient.hxx>
+#include <TColStd_MapTransientHasher.hxx>
+#include <MoniTool_DataInfo.hxx>
+
+
+MoniTool_TransientElem::MoniTool_TransientElem (const Handle(Standard_Transient)& akey)
+ : theval (akey)
+{ SetHashCode ( TColStd_MapTransientHasher::HashCode (akey, IntegerLast() ) ); }
+
+
+ const Handle_Standard_Transient& MoniTool_TransientElem::Value () const
+ { return theval; }
+
+ Standard_Boolean MoniTool_TransientElem::Equates
+ (const Handle(MoniTool_Element)& other) const
+{
+ if (other.IsNull()) return Standard_False;
+ if (GetHashCode() != other->GetHashCode()) return Standard_False;
+ if (other->DynamicType() != DynamicType()) return Standard_False;
+ Handle(MoniTool_TransientElem) another = Handle(MoniTool_TransientElem)::DownCast(other);
+// return (theval == another->Value());
+ return TColStd_MapTransientHasher::IsEqual (theval,another->Value());
+}
+
+ Handle(Standard_Type) MoniTool_TransientElem::ValueType () const
+ { return MoniTool_DataInfo::Type(theval); }
+
+ Standard_CString MoniTool_TransientElem::ValueTypeName () const
+ { return MoniTool_DataInfo::TypeName(theval); }
deferred class Binder;
class VoidBinder;
- generic class SimpleBinder;
class SimpleBinderOfTransient;
class BinderOfTransientInteger;
class TransientListBinder;
+++ /dev/null
--- Created on: 1992-02-17
--- Created by: Christian CAILLET
--- Copyright (c) 1992-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.
-
-generic class SimpleBinder from Transfer
-
- (TheResult as any; -- any : avoid Transient classes
- TheInfo as any) -- template : DataInfo
-
- inherits Binder
-
- ---Purpose : Allows direct binding between a starting Object and the Result
- -- of its transfer when it is Unique.
- -- The Result itself is defined as a formal parameter <TheResult>
- -- Warning : While it is possible to instantiate SimpleBinder with any Type
- -- for the Result, it is not advisable to instantiate it with
- -- Transient Classes, because such Results are directly known and
- -- managed by TransferProcess & Co, through
- -- SimpleBinderOfTransient : this class looks like instantiation
- -- of SimpleBinder, but its method ResultType
- -- is adapted (reads DynamicType of the Result)
-
-uses CString, Type
-
-raises TransferFailure
-
-is
-
- Create returns mutable SimpleBinder;
- ---Purpose : normal standard constructor, creates an empty SimpleBinder
-
- Create (res : any TheResult) returns mutable SimpleBinder;
- ---Purpose : constructor which in the same time defines the result
-
--- IsMultiple (me) returns Boolean;
- ---Purpose : Returns True if a starting object is bound with SEVERAL
- -- results : Here, returns allways False
- -- But it can have next results
-
- ResultType (me) returns Type;
- ---Purpose : Returns the Type permitted for the Result, i.e. the Type
- -- of the Parameter Class <TheResult> (statically defined)
-
- ResultTypeName (me) returns CString;
- ---Purpose : Returns the Type Name computed for the Result (dynamic)
-
- SetResult (me : mutable; res : any TheResult)
- ---Purpose : Defines the Result
- raises TransferFailure;
- -- Error if the Result is already used (see class Binder)
-
- Result (me) returns any TheResult
- ---Purpose : Returns the defined Result, if there is one
- raises TransferFailure;
- -- Error if the Result is not defined (see class Binder)
- ---C++ : return const &
-
- CResult (me : mutable) returns any TheResult;
- ---Purpose : Returns the defined Result, if there is one, and allows to
- -- change it (avoids Result + SetResult).
- -- Admits that Result can be not yet defined
- -- Warning : a call to CResult causes Result to be known as defined
- ---C++ : return &
-
-fields
-
- theres : TheResult;
-
-end SimpleBinder;
+++ /dev/null
-// 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 <Transfer_SimpleBinder.ixx> classe generique
-
-
-// "TheResult" identifie la classe donnee en parametre du Resultat
-
-
-Transfer_SimpleBinder::Transfer_SimpleBinder () { }
-
- Transfer_SimpleBinder::Transfer_SimpleBinder (const TheResult& res)
- : theres (res)
- { SetResultPresent(); }
-
-
-// Standard_Boolean Transfer_SimpleBinder::IsMultiple() const
-// { return Standard_False; }
-
-
- Handle(Standard_Type) Transfer_SimpleBinder::ResultType () const
- { return TheInfo::Type (theres); } // correspond a "STANDARD_TYPE(TheResult)"
-
- Standard_CString Transfer_SimpleBinder::ResultTypeName () const
- { return TheInfo::TypeName (theres); } // correspond a "STANDARD_TYPE(TheResult)"
-
-
- void Transfer_SimpleBinder::SetResult (const TheResult& res)
-{
- SetResultPresent();
- theres = res;
-}
-
- const TheResult& Transfer_SimpleBinder::Result () const
- { return theres; }
-
- TheResult& Transfer_SimpleBinder::CResult ()
- { SetResultPresent(); return theres; }
-- class Analyzer;
class ShapeInfo;
- class BinderOfShape instantiates SimpleBinder from Transfer
- (Shape from TopoDS, ShapeInfo);
+ class BinderOfShape;
class ShapeBinder;
class ShapeListBinder;
--- /dev/null
+-- Created on: 1992-02-17
+-- Created by: Christian CAILLET
+-- Copyright (c) 1992-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.
+
+class BinderOfShape from TransferBRep inherits Binder from Transfer
+
+ ---Purpose : Allows direct binding between a starting Object and the Result
+ -- of its transfer when it is Unique.
+ -- The Result itself is defined as a formal parameter <Shape from TopoDS>
+ -- Warning : While it is possible to instantiate BinderOfShape with any Type
+ -- for the Result, it is not advisable to instantiate it with
+ -- Transient Classes, because such Results are directly known and
+ -- managed by TransferProcess & Co, through
+ -- SimpleBinderOfTransient : this class looks like instantiation
+ -- of BinderOfShape, but its method ResultType
+ -- is adapted (reads DynamicType of the Result)
+
+uses CString,
+ Type,
+ Shape from TopoDS,
+ ShapeInfo from TransferBRep
+
+raises TransferFailure
+
+is
+
+ Create returns mutable BinderOfShape;
+ ---Purpose : normal standard constructor, creates an empty BinderOfShape
+
+ Create (res : any Shape from TopoDS) returns mutable BinderOfShape;
+ ---Purpose : constructor which in the same time defines the result
+
+-- IsMultiple (me) returns Boolean;
+ ---Purpose : Returns True if a starting object is bound with SEVERAL
+ -- results : Here, returns allways False
+ -- But it can have next results
+
+ ResultType (me) returns Type;
+ ---Purpose : Returns the Type permitted for the Result, i.e. the Type
+ -- of the Parameter Class <Shape from TopoDS> (statically defined)
+
+ ResultTypeName (me) returns CString;
+ ---Purpose : Returns the Type Name computed for the Result (dynamic)
+
+ SetResult (me : mutable; res : any Shape from TopoDS)
+ ---Purpose : Defines the Result
+ raises TransferFailure;
+ -- Error if the Result is already used (see class Binder)
+
+ Result (me) returns any Shape from TopoDS
+ ---Purpose : Returns the defined Result, if there is one
+ raises TransferFailure;
+ -- Error if the Result is not defined (see class Binder)
+ ---C++ : return const &
+
+ CResult (me : mutable) returns any Shape from TopoDS;
+ ---Purpose : Returns the defined Result, if there is one, and allows to
+ -- change it (avoids Result + SetResult).
+ -- Admits that Result can be not yet defined
+ -- Warning : a call to CResult causes Result to be known as defined
+ ---C++ : return &
+
+fields
+
+ theres : Shape from TopoDS;
+
+end BinderOfShape;
--- /dev/null
+// 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 <TransferBRep_BinderOfShape.ixx>
+
+#include <TransferBRep_ShapeInfo.hxx>
+
+
+TransferBRep_BinderOfShape::TransferBRep_BinderOfShape (){ }
+
+TransferBRep_BinderOfShape::TransferBRep_BinderOfShape (const TopoDS_Shape& res)
+: theres (res)
+{ SetResultPresent(); }
+
+
+// Standard_Boolean TransferBRep_BinderOfShape::IsMultiple() const
+// { return Standard_False; }
+
+
+Handle(Standard_Type) TransferBRep_BinderOfShape::ResultType () const
+{ return TransferBRep_ShapeInfo::Type (theres); } // correspond a "STANDARD_TYPE(TopoDS_Shape)"
+
+Standard_CString TransferBRep_BinderOfShape::ResultTypeName () const
+{ return TransferBRep_ShapeInfo::TypeName (theres); } // correspond a "STANDARD_TYPE(TopoDS_Shape)"
+
+
+void TransferBRep_BinderOfShape::SetResult (const TopoDS_Shape& res)
+{
+ SetResultPresent();
+ theres = res;
+}
+
+const TopoDS_Shape& TransferBRep_BinderOfShape::Result () const
+{ return theres; }
+
+TopoDS_Shape& TransferBRep_BinderOfShape::CResult ()
+{ SetResultPresent(); return theres; }