mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
55
src/BRepMAT2d/BRepMAT2d.cdl
Executable file
55
src/BRepMAT2d/BRepMAT2d.cdl
Executable file
@@ -0,0 +1,55 @@
|
||||
-- File: BRepMAT2d.cdl
|
||||
-- Created: Mon Oct 3 17:32:10 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <dub@fuegox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
package BRepMAT2d
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
MAT2d,
|
||||
MAT,
|
||||
TCollection,
|
||||
TColStd,
|
||||
TColGeom2d,
|
||||
Geom2d,
|
||||
gp,
|
||||
TopoDS,
|
||||
TopTools
|
||||
|
||||
is
|
||||
class Explorer;
|
||||
---Purpose: Construct an explorer for the computation of the
|
||||
-- bisecting locus from a Wire, a Face, or a set of
|
||||
-- curves from Geom2d.
|
||||
|
||||
class BisectingLocus instantiates BisectingLocus from MAT2d
|
||||
(Explorer from BRepMAT2d);
|
||||
---Purpose: the map of bisecting locus.
|
||||
|
||||
class LinkTopoBilo;
|
||||
---Purpose: Constucts links between the Wire or the Face and
|
||||
-- the BasicElts contained in the bisecting locus.
|
||||
|
||||
|
||||
class SequenceOfBasicElt instantiates Sequence from TCollection
|
||||
(BasicElt from MAT);
|
||||
|
||||
class DataMapOfShapeSequenceOfBasicElt instantiates DataMap from TCollection
|
||||
(Shape from TopoDS,
|
||||
SequenceOfBasicElt from BRepMAT2d,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
class DataMapOfBasicEltShape instantiates
|
||||
DataMap from TCollection (BasicElt from MAT,
|
||||
Shape from TopoDS,
|
||||
MapTransientHasher from TColStd);
|
||||
|
||||
end BRepMAT2d;
|
||||
|
||||
|
||||
|
||||
|
146
src/BRepMAT2d/BRepMAT2d_Explorer.cdl
Executable file
146
src/BRepMAT2d/BRepMAT2d_Explorer.cdl
Executable file
@@ -0,0 +1,146 @@
|
||||
-- File: BRepMAT2d_Explorer.cdl
|
||||
-- Created: Tue Oct 4 09:03:34 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <dub@fuegox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class Explorer from BRepMAT2d
|
||||
|
||||
---Purpose: Construct an explorer from wires, face, set of curves
|
||||
-- from Geom2d to compute the bisecting Locus.
|
||||
|
||||
uses
|
||||
SequenceOfCurve from TColGeom2d,
|
||||
SequenceOfSequenceOfCurve from MAT2d,
|
||||
SequenceOfBoolean from TColStd,
|
||||
Curve from Geom2d,
|
||||
Wire from TopoDS,
|
||||
Face from TopoDS,
|
||||
Shape from TopoDS,
|
||||
IndexedDataMapOfShapeShape from TopTools
|
||||
|
||||
is
|
||||
Create returns Explorer from BRepMAT2d;
|
||||
|
||||
Create (aFace : Face from TopoDS) returns Explorer from BRepMAT2d;
|
||||
|
||||
Clear (me : in out)
|
||||
--- Purpose : Clear the contents of <me>.
|
||||
is static;
|
||||
|
||||
---Category: Construction from a face
|
||||
|
||||
Perform ( me : in out ;aFace : Face from TopoDS)
|
||||
is static;
|
||||
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 15:48:41 2002 Begin
|
||||
-- Correction of a face. Creation of a new face where all wires are
|
||||
-- connected in 2d.
|
||||
|
||||
-- Add (me : in out; Spine : Wire from TopoDS; aFace : Face from TopoDS)
|
||||
-- is static private;
|
||||
|
||||
Add (me : in out; Spine : Wire from TopoDS; aFace : Face from TopoDS;
|
||||
aNewFace: in out Face from TopoDS)
|
||||
is static private;
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 15:48:43 2002 End
|
||||
|
||||
---Purpose: Construction from a set of cuves from Geom2d.
|
||||
-- Assume the orientation of the closed lines are
|
||||
-- compatible. (ie if A is in B, the orientation of A and B
|
||||
-- has to be different.
|
||||
--
|
||||
-- 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.
|
||||
--
|
||||
-- A contour has to be construct in adding each curve in
|
||||
-- respect to the sense of the contour.
|
||||
--
|
||||
-- afirst point of a curve in a contour is equal to the last
|
||||
-- point of the precedent curve.
|
||||
--
|
||||
-- No control of this rules is done in the construction
|
||||
-- of the explorer
|
||||
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 17:19:09 2002 Begin
|
||||
--This method is useless. All its functionality is
|
||||
--in the previous method Add(..) now.
|
||||
-- CheckConnection (me : in out)
|
||||
-- is static private;
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 17:19:09 2002 End
|
||||
|
||||
NewContour (me : in out)
|
||||
is static private;
|
||||
|
||||
Add (me : in out ; aCurve : Curve from Geom2d)
|
||||
--- Purpose : Add the curve <aCurve> at me.
|
||||
is static private;
|
||||
|
||||
---Category: Querying
|
||||
|
||||
NumberOfContours(me) returns Integer
|
||||
--- Purpose : Returns the Number of contours.
|
||||
is static;
|
||||
|
||||
NumberOfCurves(me ; IndexContour : Integer) returns Integer
|
||||
--- Purpose : Returns the Number of Curves in the Contour number
|
||||
-- <IndexContour>.
|
||||
is static;
|
||||
|
||||
Init(me : in out ; IndexContour : Integer)
|
||||
--- Purpose : Initialisation of an Iterator on the curves of
|
||||
-- the Contour number <IndexContour>.
|
||||
is static;
|
||||
|
||||
More(me) returns Boolean from Standard
|
||||
--- Purpose : Return False if there is no more curves on the Contour
|
||||
-- initialised by the method Init.
|
||||
is static;
|
||||
|
||||
Next(me : in out)
|
||||
--- Purpose : Move to the next curve of the current Contour.
|
||||
is static;
|
||||
|
||||
Value(me) returns Curve from Geom2d
|
||||
--- Purpose : Returns the current curve on the current Contour.
|
||||
is static;
|
||||
|
||||
Shape (me) returns Shape from TopoDS
|
||||
is static ;
|
||||
|
||||
Contour (me; IndexContour : Integer from Standard)
|
||||
returns SequenceOfCurve from TColGeom2d
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 15:51:56 2002
|
||||
IsModified(me; aShape: Shape from TopoDS)
|
||||
returns Boolean from Standard
|
||||
is static;
|
||||
|
||||
ModifiedShape(me; aShape: Shape from TopoDS)
|
||||
--- Purpose : If the shape is not modified, returns the shape itself.
|
||||
returns Shape from TopoDS
|
||||
is static;
|
||||
|
||||
GetIsClosed (me)
|
||||
returns SequenceOfBoolean from TColStd
|
||||
---C++: return const&
|
||||
is static;
|
||||
-- Modified by Sergey KHROMOV - Wed Mar 6 16:05:52 2002
|
||||
|
||||
fields
|
||||
|
||||
theCurves : SequenceOfSequenceOfCurve from MAT2d;
|
||||
current : Integer;
|
||||
currentContour : Integer;
|
||||
myShape : Shape from TopoDS;
|
||||
myIsClosed : SequenceOfBoolean from TColStd;
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 15:48:02 2002 Begin
|
||||
myModifShapes : IndexedDataMapOfShapeShape from TopTools;
|
||||
-- Modified by Sergey KHROMOV - Tue Nov 26 15:48:03 2002 End
|
||||
|
||||
end Explorer;
|
490
src/BRepMAT2d/BRepMAT2d_Explorer.cxx
Executable file
490
src/BRepMAT2d/BRepMAT2d_Explorer.cxx
Executable file
@@ -0,0 +1,490 @@
|
||||
// File: BRepMAT2d_Explorer.cxx
|
||||
// Created: Tue Oct 4 09:25:21 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <dub@fuegox>
|
||||
|
||||
|
||||
#include <BRepMAT2d_Explorer.ixx>
|
||||
#include <MAT2d_SequenceOfSequenceOfCurve.hxx>
|
||||
#include <TColGeom2d_SequenceOfCurve.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <GeomAPI.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2dConvert.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
|
||||
|
||||
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:14 2002 Begin
|
||||
static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
|
||||
const TopoDS_Face &theFace,
|
||||
const TopoDS_Vertex &theVFirst,
|
||||
const TopoDS_Vertex &theVLast);
|
||||
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:16 2002 End
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepMAT2d_Explorer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepMAT2d_Explorer::BRepMAT2d_Explorer()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepMAT2d_Explorer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepMAT2d_Explorer::BRepMAT2d_Explorer(const TopoDS_Face& aFace)
|
||||
{
|
||||
Perform (aFace);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
|
||||
{
|
||||
Clear();
|
||||
myShape = aFace;
|
||||
TopoDS_Face F = TopoDS::Face(aFace);
|
||||
F.Orientation(TopAbs_FORWARD);
|
||||
TopExp_Explorer Exp (F,TopAbs_WIRE);
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
|
||||
TopoDS_Face aNewF = BRepBuilderAPI_MakeFace(aSurf);
|
||||
|
||||
while (Exp.More()) {
|
||||
Add (TopoDS::Wire (Exp.Current()),F, aNewF);
|
||||
Exp.Next();
|
||||
}
|
||||
|
||||
BRepLib::BuildCurves3d(aNewF);
|
||||
|
||||
myModifShapes.Add(aFace, aNewF);
|
||||
// CheckConnection();
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
|
||||
const TopoDS_Face& aFace,
|
||||
TopoDS_Face& aNewFace)
|
||||
{
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
|
||||
// This method is totally rewroted to include check
|
||||
// of connection and creation of a new spine.
|
||||
NewContour();
|
||||
myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
|
||||
|
||||
// Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
|
||||
// Taking into account side of bisecting loci construction.
|
||||
// TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
|
||||
// BRepTools_WireExplorer anExp(aWFwd, aFace);
|
||||
BRepTools_WireExplorer anExp(Spine, aFace);
|
||||
// Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
|
||||
TopTools_IndexedDataMapOfShapeShape anOldNewE;
|
||||
|
||||
if (!anExp.More())
|
||||
return;
|
||||
|
||||
TopoDS_Edge aFirstEdge = anExp.Current();
|
||||
Standard_Real UFirst,ULast, aD;
|
||||
Handle(Geom2d_BSplineCurve) BCurve;
|
||||
Handle(Geom2d_Curve) C2d;
|
||||
Handle(Geom2d_TrimmedCurve) CT2d;
|
||||
Handle(Geom2d_TrimmedCurve) aFirstCurve;
|
||||
gp_Pnt2d aPFirst;
|
||||
gp_Pnt2d aPLast;
|
||||
gp_Pnt2d aPCurFirst;
|
||||
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
|
||||
// Set the confusion tolerance in accordance with the further algo
|
||||
// Standard_Real aTolConf = Precision::Confusion();
|
||||
Standard_Real aTolConf = 1.e-8;
|
||||
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
|
||||
Standard_Boolean isModif = Standard_False;
|
||||
|
||||
// Treatment of the first edge of a wire.
|
||||
anOldNewE.Add(aFirstEdge, aFirstEdge);
|
||||
C2d = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast);
|
||||
CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
|
||||
|
||||
if (aFirstEdge.Orientation() == TopAbs_REVERSED)
|
||||
CT2d->Reverse();
|
||||
|
||||
aPFirst = CT2d->Value(CT2d->FirstParameter());
|
||||
aPLast = CT2d->Value(CT2d->LastParameter());
|
||||
|
||||
Add(CT2d);
|
||||
aFirstCurve = CT2d;
|
||||
anExp.Next();
|
||||
|
||||
// Treatment of the next edges:
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
TopoDS_Edge anEdge = anExp.Current();
|
||||
|
||||
anOldNewE.Add(anEdge, anEdge);
|
||||
C2d = BRep_Tool::CurveOnSurface (anEdge, aFace, UFirst, ULast);
|
||||
CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
|
||||
|
||||
if (anEdge.Orientation() == TopAbs_REVERSED)
|
||||
CT2d->Reverse();
|
||||
|
||||
aPCurFirst = CT2d->Value(CT2d->FirstParameter());
|
||||
//
|
||||
aD=aPLast.Distance(aPCurFirst);
|
||||
if (aD > aTolConf) {
|
||||
// There are two ways how to fill holes:
|
||||
// First, to create a line between these two points.
|
||||
// Second, create a BSpline curve and to add the last point of the previous
|
||||
// curve as the first pole of the current one. Second method which
|
||||
// is worse was performed before and leaved here. Otherwise too much
|
||||
// code should be rewritten.
|
||||
isModif = Standard_True;
|
||||
//
|
||||
//modified by NIZNHY-PKV Tue Aug 7 09:14:03 2007f
|
||||
//BCurve = Geom2dConvert::CurveToBSplineCurve(CT2d);
|
||||
BCurve=Geom2dConvert::CurveToBSplineCurve(CT2d, Convert_QuasiAngular);
|
||||
//modified by NIZNHY-PKV Tue Aug 7 09:14:07 2007t
|
||||
|
||||
BCurve->SetPole(1, aPLast);
|
||||
CT2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
|
||||
BCurve->LastParameter());
|
||||
|
||||
// Creation of new edge.
|
||||
TopoDS_Edge aNewEdge;
|
||||
TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
|
||||
TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
|
||||
|
||||
if (anEdge.Orientation() == TopAbs_FORWARD)
|
||||
aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
|
||||
else
|
||||
aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
|
||||
|
||||
aNewEdge.Orientation(anEdge.Orientation());
|
||||
|
||||
anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
|
||||
}
|
||||
|
||||
aPLast = CT2d->Value(CT2d->LastParameter());
|
||||
Add(CT2d);
|
||||
}
|
||||
|
||||
// Check of the distance between the first and the last point of wire
|
||||
// if the wire is closed.
|
||||
if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
|
||||
isModif = Standard_True;
|
||||
|
||||
|
||||
//modified by NIZNHY-PKV Tue Aug 7 09:20:08 2007f
|
||||
//Handle(Geom2d_BSplineCurve)
|
||||
//BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve);
|
||||
BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve, Convert_QuasiAngular);
|
||||
//modified by NIZNHY-PKV Tue Aug 7 09:20:11 2007t
|
||||
|
||||
BCurve->SetPole(1, aPLast);
|
||||
aFirstCurve = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
|
||||
BCurve->LastParameter());
|
||||
theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve;
|
||||
|
||||
// Creation of new first edge.
|
||||
TopoDS_Edge aNewEdge;
|
||||
TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge);
|
||||
TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge);
|
||||
|
||||
if (aFirstEdge.Orientation() == TopAbs_FORWARD)
|
||||
aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
|
||||
else
|
||||
aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
|
||||
|
||||
aNewEdge.Orientation(aFirstEdge.Orientation());
|
||||
anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge;
|
||||
}
|
||||
|
||||
TopoDS_Wire aNewWire;
|
||||
BRep_Builder aBuilder;
|
||||
|
||||
if (isModif) {
|
||||
Standard_Integer i;
|
||||
Standard_Integer aNbEdges = anOldNewE.Extent();
|
||||
|
||||
aBuilder.MakeWire(aNewWire);
|
||||
|
||||
for (i = 1; i <= aNbEdges; i++) {
|
||||
const TopoDS_Shape &aKey = anOldNewE.FindKey(i);
|
||||
const TopoDS_Shape &aNewEdge = anOldNewE.FindFromIndex(i);
|
||||
|
||||
aBuilder.Add(aNewWire, aNewEdge);
|
||||
myModifShapes.Add(aKey, aNewEdge);
|
||||
}
|
||||
|
||||
if (myIsClosed(currentContour))
|
||||
aNewWire.Closed(Standard_True);
|
||||
|
||||
// Modified by skv - Fri Nov 12 17:22:12 2004 Integration Begin
|
||||
// The orientation of wire is already taken into account.
|
||||
// aNewWire.Orientation(Spine.Orientation());
|
||||
// Modified by skv - Fri Nov 12 17:22:12 2004 Integration End
|
||||
myModifShapes.Add(Spine, aNewWire);
|
||||
} else
|
||||
aNewWire = Spine;
|
||||
|
||||
aBuilder.Add(aNewFace, aNewWire);
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckConnection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 17:21:44 2002 Begin
|
||||
// void BRepMAT2d_Explorer::CheckConnection()
|
||||
// {
|
||||
// for (Standard_Integer i = 1; i <= theCurves.Length(); i++)
|
||||
// for (Standard_Integer j = 2; j <= theCurves(i).Length(); j++)
|
||||
// {
|
||||
// gp_Pnt2d P1 = theCurves(i)(j-1)->Value( theCurves(i)(j-1)->LastParameter() );
|
||||
// gp_Pnt2d P2 = theCurves(i)(j)->Value( theCurves(i)(j)->FirstParameter() );
|
||||
// if (P1.Distance( P2 ) > Precision::Confusion())
|
||||
// {
|
||||
// Handle( Geom2d_BSplineCurve ) BCurve;
|
||||
// if (theCurves(i)(j)->DynamicType() != STANDARD_TYPE(Geom2d_BSplineCurve))
|
||||
// BCurve = Geom2dConvert::CurveToBSplineCurve( theCurves(i)(j) );
|
||||
// else
|
||||
// BCurve = Handle( Geom2d_BSplineCurve )::DownCast( theCurves(i)(j) );
|
||||
// BCurve->SetPole( 1, P1 );
|
||||
// theCurves(i)(j) = new Geom2d_TrimmedCurve( BCurve, BCurve->FirstParameter(), BCurve->LastParameter() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Modified by Sergey KHROMOV - Tue Nov 26 17:21:29 2002 End
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Clear()
|
||||
{
|
||||
theCurves.Clear() ;
|
||||
currentContour = 0;
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin
|
||||
myIsClosed.Clear();
|
||||
myModifShapes.Clear();
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewContour
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::NewContour()
|
||||
{
|
||||
TColGeom2d_SequenceOfCurve Contour;
|
||||
theCurves.Append(Contour);
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin
|
||||
myIsClosed.Append(Standard_False);
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End
|
||||
currentContour ++ ;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Add(const Handle(Geom2d_Curve)& aCurve)
|
||||
{
|
||||
theCurves.ChangeValue(currentContour).Append(aCurve);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NumberOfContours
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepMAT2d_Explorer::NumberOfContours() const
|
||||
{
|
||||
return theCurves.Length() ;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NumberOfCurves
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepMAT2d_Explorer::NumberOfCurves
|
||||
(const Standard_Integer IndexContour)
|
||||
const
|
||||
{
|
||||
return theCurves.Value(IndexContour).Length();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Init(const Standard_Integer IndexContour)
|
||||
{
|
||||
currentContour = IndexContour;
|
||||
current = 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepMAT2d_Explorer::More() const
|
||||
{
|
||||
return (current <= NumberOfCurves(currentContour));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_Explorer::Next()
|
||||
{
|
||||
current++;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Curve) BRepMAT2d_Explorer::Value() const
|
||||
{
|
||||
return theCurves.Value(currentContour).Value(current);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape BRepMAT2d_Explorer::Shape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Contour
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour
|
||||
(const Standard_Integer IC)
|
||||
const
|
||||
{
|
||||
return theCurves.Value(IC);
|
||||
}
|
||||
|
||||
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 17:40:07 2002 Begin
|
||||
//=======================================================================
|
||||
//function : IsModified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepMAT2d_Explorer::IsModified
|
||||
(const TopoDS_Shape &aShape) const
|
||||
{
|
||||
if (myModifShapes.Contains(aShape)) {
|
||||
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
|
||||
const Standard_Boolean isSame = aNewShape.IsSame(aShape);
|
||||
|
||||
return !isSame;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifiedShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape
|
||||
(const TopoDS_Shape &aShape) const
|
||||
{
|
||||
if (myModifShapes.Contains(aShape)) {
|
||||
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
|
||||
|
||||
return aNewShape;
|
||||
}
|
||||
|
||||
return aShape;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetIsClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TColStd_SequenceOfBoolean &BRepMAT2d_Explorer::GetIsClosed() const
|
||||
{
|
||||
return myIsClosed;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeEdge
|
||||
//purpose : Creation of an edge by 2d curve, face and two vertices.
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
|
||||
const TopoDS_Face &theFace,
|
||||
const TopoDS_Vertex &theVFirst,
|
||||
const TopoDS_Vertex &theVLast)
|
||||
{
|
||||
TopoDS_Edge aNewEdge;
|
||||
BRep_Builder aBuilder;
|
||||
Standard_Real aTol = Precision::Confusion();
|
||||
Standard_Real aFPar = theCurve->FirstParameter();
|
||||
Standard_Real aLPar = theCurve->LastParameter();
|
||||
|
||||
aBuilder.MakeEdge(aNewEdge);
|
||||
aBuilder.UpdateEdge(aNewEdge, theCurve, theFace, aTol);
|
||||
aBuilder.Add(aNewEdge, theVFirst.Oriented(TopAbs_FORWARD));
|
||||
aBuilder.Add(aNewEdge, theVLast.Oriented(TopAbs_REVERSED));
|
||||
aBuilder.Range(aNewEdge, aFPar, aLPar);
|
||||
|
||||
return aNewEdge;
|
||||
}
|
||||
// Modified by Sergey KHROMOV - Wed Mar 6 17:40:14 2002 End
|
98
src/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cdl
Executable file
98
src/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cdl
Executable file
@@ -0,0 +1,98 @@
|
||||
-- File: BRepMAT2d_LinkTopoBilo.cdl
|
||||
-- Created: Fri Oct 7 14:30:11 1994
|
||||
-- Author: Yves FRICAUD
|
||||
-- <yfr@nonox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
class LinkTopoBilo from BRepMAT2d
|
||||
|
||||
---Purpose:Constucts links between the Face of the explorer and
|
||||
-- the BasicElts contained in the bisecting locus.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Wire from TopoDS,
|
||||
Explorer from BRepMAT2d,
|
||||
DataMapOfShapeSequenceOfBasicElt from BRepMAT2d,
|
||||
DataMapOfBasicEltShape from BRepMAT2d,
|
||||
BisectingLocus from BRepMAT2d,
|
||||
BasicElt from MAT
|
||||
|
||||
raises
|
||||
ConstructionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns LinkTopoBilo from BRepMAT2d;
|
||||
|
||||
Create( Explo : Explorer from BRepMAT2d;
|
||||
BiLo : BisectingLocus from BRepMAT2d)
|
||||
returns LinkTopoBilo from BRepMAT2d
|
||||
---Purpose: Constructs the links Between S and BiLo.
|
||||
--
|
||||
raises
|
||||
ConstructionError from Standard;
|
||||
---Purpose: raises if <S> is not a face.
|
||||
|
||||
|
||||
Perform( me : in out;
|
||||
Explo : Explorer from BRepMAT2d;
|
||||
BiLo : BisectingLocus from BRepMAT2d)
|
||||
---Purpose: Constructs the links Between S and BiLo.
|
||||
--
|
||||
raises
|
||||
ConstructionError from Standard
|
||||
---Purpose: raises if <S> is not a face or a wire.
|
||||
is static;
|
||||
|
||||
|
||||
Init (me : in out; S : Shape from TopoDS)
|
||||
---Purpose: Initialise the Iterator on <S>
|
||||
-- <S> is an edge or a vertex of the initial
|
||||
-- wire or face.
|
||||
raises
|
||||
ConstructionError from Standard
|
||||
---Purpose: raises if <S> is not an edge or a vertex.
|
||||
is static;
|
||||
|
||||
|
||||
More (me : in out) returns Boolean from Standard
|
||||
---Purpose: Returns True if there is a current BasicElt.
|
||||
is static;
|
||||
|
||||
|
||||
Next (me : in out)
|
||||
---Purpose: Proceed to the next BasicElt.
|
||||
is static;
|
||||
|
||||
|
||||
Value(me) returns BasicElt from MAT
|
||||
---Purpose: Returns the current BasicElt.
|
||||
is static;
|
||||
|
||||
GeneratingShape (me ; aBE : BasicElt from MAT)
|
||||
---Purpose: Returns the Shape linked to <aBE>.
|
||||
returns Shape from TopoDS
|
||||
is static;
|
||||
|
||||
LinkToWire (me : in out;
|
||||
W : Wire from TopoDS;
|
||||
Explo : Explorer from BRepMAT2d;
|
||||
IndexContour : Integer from Standard;
|
||||
BiLo : BisectingLocus from BRepMAT2d)
|
||||
is static private;
|
||||
|
||||
|
||||
fields
|
||||
myMap : DataMapOfShapeSequenceOfBasicElt from BRepMAT2d;
|
||||
myBEShape : DataMapOfBasicEltShape from BRepMAT2d;
|
||||
myKey : Shape from TopoDS;
|
||||
current : Integer from Standard;
|
||||
isEmpty : Boolean from Standard;
|
||||
|
||||
end ;
|
||||
|
||||
|
||||
|
306
src/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx
Executable file
306
src/BRepMAT2d/BRepMAT2d_LinkTopoBilo.cxx
Executable file
@@ -0,0 +1,306 @@
|
||||
// File: BRepMAT2d_LinkTopoBilo.cxx
|
||||
// Created: Fri Oct 7 16:50:40 1994
|
||||
// Author: Yves FRICAUD
|
||||
// <yfr@nonox>
|
||||
|
||||
|
||||
#include <BRepMAT2d_LinkTopoBilo.ixx>
|
||||
#include <TopAbs.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopTools_SequenceOfShape.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Geom2d_Geometry.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_CartesianPoint.hxx>
|
||||
#include <TColGeom2d_SequenceOfCurve.hxx>
|
||||
#include <MAT_Graph.hxx>
|
||||
#include <MAT_BasicElt.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BRepMAT2d_SequenceOfBasicElt.hxx>
|
||||
#include <BRepMAT2d_DataMapOfShapeSequenceOfBasicElt.hxx>
|
||||
#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
|
||||
#include <TColStd_DataMapOfIntegerInteger.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepMAT2d_LinkTopoBilo
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepMAT2d_LinkTopoBilo::BRepMAT2d_LinkTopoBilo()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepMAT2d_LinkTopoBilo
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepMAT2d_LinkTopoBilo::BRepMAT2d_LinkTopoBilo(
|
||||
const BRepMAT2d_Explorer& Explo,
|
||||
const BRepMAT2d_BisectingLocus& BiLo)
|
||||
{
|
||||
Perform (Explo,BiLo);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_LinkTopoBilo::Perform(const BRepMAT2d_Explorer& Explo,
|
||||
const BRepMAT2d_BisectingLocus& BiLo)
|
||||
{
|
||||
myMap.Clear();
|
||||
myBEShape.Clear();
|
||||
|
||||
TopoDS_Shape S = Explo.Shape();
|
||||
Standard_Integer IndContour = 1;
|
||||
|
||||
if (S.ShapeType() == TopAbs_FACE) {
|
||||
TopExp_Explorer Exp (S,TopAbs_WIRE);
|
||||
|
||||
while (Exp.More()) {
|
||||
LinkToWire(TopoDS::Wire (Exp.Current()),Explo,IndContour,BiLo);
|
||||
Exp.Next();
|
||||
IndContour++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_ConstructionError::Raise("BRepMAT2d_LinkTopoBilo::Perform");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_LinkTopoBilo::Init(const TopoDS_Shape& S)
|
||||
{
|
||||
isEmpty = Standard_False;
|
||||
current = 1;
|
||||
if (myMap.IsBound(S)) myKey = S; else isEmpty = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepMAT2d_LinkTopoBilo::More()
|
||||
{
|
||||
if (isEmpty) return Standard_False;
|
||||
return (current <= myMap(myKey).Length());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_LinkTopoBilo::Next()
|
||||
{
|
||||
current++;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(MAT_BasicElt) BRepMAT2d_LinkTopoBilo::Value() const
|
||||
{
|
||||
return myMap(myKey).Value(current);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GeneratingShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape BRepMAT2d_LinkTopoBilo::GeneratingShape
|
||||
(const Handle(MAT_BasicElt)& BE) const
|
||||
{
|
||||
return myBEShape(BE);
|
||||
}
|
||||
|
||||
static void LinkToContour(const BRepMAT2d_Explorer& Explo,
|
||||
const Standard_Integer IndC,
|
||||
const BRepMAT2d_BisectingLocus& BiLo,
|
||||
TColStd_DataMapOfIntegerInteger& Link);
|
||||
|
||||
//=======================================================================
|
||||
//function : LinkToWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepMAT2d_LinkTopoBilo::LinkToWire(const TopoDS_Wire& W,
|
||||
const BRepMAT2d_Explorer& Explo,
|
||||
const Standard_Integer IndC,
|
||||
const BRepMAT2d_BisectingLocus& BiLo)
|
||||
{
|
||||
BRepTools_WireExplorer TheExp (W);
|
||||
Standard_Integer KC;
|
||||
TopoDS_Vertex VF,VL;
|
||||
TopoDS_Shape S;
|
||||
Handle(MAT_BasicElt) BE;
|
||||
Handle(Standard_Type) Type;
|
||||
TopTools_SequenceOfShape TopoSeq;
|
||||
BRepMAT2d_SequenceOfBasicElt EmptySeq;
|
||||
|
||||
TColStd_DataMapIteratorOfDataMapOfIntegerInteger Ite;
|
||||
TColStd_DataMapOfIntegerInteger LinkBECont;
|
||||
|
||||
|
||||
for (;TheExp.More();TheExp.Next()) {
|
||||
TopoSeq.Append(TheExp.Current());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Construction Liens BasicElt => Curve du contour IndC.
|
||||
//-----------------------------------------------------
|
||||
LinkToContour(Explo,IndC,BiLo,LinkBECont);
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Iteration sur les BasicElts. L indice associe est le meme pour
|
||||
// les courbes du contour et les edges. .
|
||||
//---------------------------------------------------------------
|
||||
for (Ite.Initialize(LinkBECont); Ite.More(); Ite.Next()) {
|
||||
BE = BiLo.Graph()->BasicElt(Ite.Key());
|
||||
Type = BiLo.GeomElt(BE)->DynamicType();
|
||||
KC = Ite.Value();
|
||||
S = TopoSeq.Value(Abs(KC));
|
||||
|
||||
if (Type == STANDARD_TYPE(Geom2d_CartesianPoint)) {
|
||||
if (S.Orientation() == TopAbs_REVERSED) {
|
||||
TopExp::Vertices(TopoDS::Edge(S),VL,VF);
|
||||
}
|
||||
else {
|
||||
TopExp::Vertices(TopoDS::Edge(S),VF,VL);
|
||||
}
|
||||
if (KC > 0) S = VL; else S = VF;
|
||||
}
|
||||
if (!myMap.IsBound(S)) {
|
||||
myMap.Bind(S,EmptySeq);
|
||||
}
|
||||
myMap(S).Append(BE);
|
||||
|
||||
if (KC < 0)
|
||||
myBEShape.Bind(BE, S.Oriented(TopAbs::Reverse(S.Orientation())));
|
||||
else
|
||||
myBEShape.Bind(BE, S);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LinkToContour
|
||||
//purpose : Association a chaque basicElt de la courbe du contour initial
|
||||
// dont il provient.
|
||||
//=======================================================================
|
||||
|
||||
void LinkToContour (const BRepMAT2d_Explorer& Explo,
|
||||
const Standard_Integer IndC,
|
||||
const BRepMAT2d_BisectingLocus& BiLo,
|
||||
TColStd_DataMapOfIntegerInteger& Link)
|
||||
{
|
||||
Handle (MAT_BasicElt) BE;
|
||||
Handle (Geom2d_Geometry) GeomBE;
|
||||
Handle (Standard_Type) Type;
|
||||
Standard_Boolean DirectSense = Standard_True;
|
||||
Standard_Boolean LastPoint = Standard_False;
|
||||
Standard_Integer NbSect,ISect;
|
||||
|
||||
//---------------------------------------------------
|
||||
// NbSect : nombre de sections sur la courbe courrant.
|
||||
// ISect : Compteur sur les sections.
|
||||
//---------------------------------------------------
|
||||
|
||||
const TColGeom2d_SequenceOfCurve& Cont = Explo.Contour(IndC);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//Initialisation de l explorateur sur la premiere courbe du contour.
|
||||
//------------------------------------------------------------------
|
||||
Standard_Integer IndOnCont = 1;
|
||||
Standard_Integer PrecIndOnCont = -1;
|
||||
NbSect = BiLo.NumberOfSections(IndC,1);
|
||||
ISect = 0;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Parcours des elements de base associes au contour IndC.
|
||||
// Rq : les elements de base sont ordonnes.
|
||||
//------------------------------------------------------------------
|
||||
for (Standard_Integer i = 1; i <= BiLo.NumberOfElts(IndC); i++) {
|
||||
|
||||
BE = BiLo.BasicElt(IndC,i);
|
||||
GeomBE = BiLo.GeomElt (BE);
|
||||
Type = GeomBE->DynamicType();
|
||||
|
||||
if (Type != STANDARD_TYPE(Geom2d_CartesianPoint)) {
|
||||
ISect++;
|
||||
//--------------------------------------------------------------------
|
||||
// l element de base est une courbe on lui associe la courbe courante.
|
||||
//--------------------------------------------------------------------
|
||||
if (DirectSense) {
|
||||
Link.Bind(BE->Index(), IndOnCont);
|
||||
}
|
||||
else {
|
||||
Link.Bind(BE->Index(), -IndOnCont);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//--------------------------------------------------------------------
|
||||
// l element de base est un point on lui associe la courbe precedente
|
||||
//--------------------------------------------------------------------
|
||||
if (DirectSense || LastPoint) {
|
||||
Link.Bind(BE->Index(), PrecIndOnCont);
|
||||
}
|
||||
else {
|
||||
Link.Bind(BE->Index(), -PrecIndOnCont);
|
||||
}
|
||||
}
|
||||
|
||||
PrecIndOnCont = IndOnCont;
|
||||
//----------------------------------------------------------------------
|
||||
// Passage a la courbe suivante dans Explo, lorsqu on a parcouru toutes
|
||||
// les portions de courbes correspondante a la courbe initiale.
|
||||
//---------------------------------------------------------------------
|
||||
if (Type != STANDARD_TYPE(Geom2d_CartesianPoint) && ISect == NbSect) {
|
||||
if (IndOnCont < Cont.Length() && DirectSense) {
|
||||
IndOnCont++;
|
||||
NbSect = BiLo.NumberOfSections(IndC,IndOnCont);
|
||||
ISect = 0;
|
||||
}
|
||||
else {
|
||||
//-----------------------------------------------------
|
||||
// Pour les lignes ouvertes on repart dans l autre sens.
|
||||
//-----------------------------------------------------
|
||||
if (!DirectSense) {
|
||||
IndOnCont--;
|
||||
if (IndOnCont != 0) NbSect = BiLo.NumberOfSections(IndC,IndOnCont);
|
||||
LastPoint = Standard_False;
|
||||
}
|
||||
else {
|
||||
LastPoint = Standard_True;
|
||||
}
|
||||
ISect = 0;
|
||||
DirectSense = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user