1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

257
src/BRepFill/BRepFill.cdl Executable file
View File

@@ -0,0 +1,257 @@
-- File: BRepFill.cdl
-- Created: Thu Mar 3 10:02:58 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
-- Modified: Mon Nov 3 10:24:07 1997
-- Author: Joelle CHAUVET
-- new class CurveConstraint
-- Modified: Mon Jan 12 10:46:37 1998
-- Author: Joelle CHAUVET
-- new method Organize
-- Modified: Mon Feb 23 09:28:33 1998
-- Author: Joelle CHAUVET
-- new methods SameNumber, ComputeACR, InsertACR
-- for sections with different number of elements
-- Modified: Thu Apr 30 15:27:04 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
-- methods Organize and SameNumber are dispatched in
-- new methods SearchOrigin and SameNumberByACR for open wires
-- and SameNumberByPolarMethod and ComputeOrigin for closed wires
-- Modified: Tue Nov 3 10:41:06 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
-- add classe CompatibleWires
---Copyright: Matra Datavision 1994
package BRepFill
uses
MMgt,
TCollection,
TColStd,
GeomAbs,
gp,
Bnd,
TopLoc,
TColgp,
MAT,
Geom2d,
TColGeom2d,
TopAbs,
TopoDS,
TopTools,
Geom,
TColGeom,
Geom2dAdaptor,
Approx,
Bisector,
BRep,
BRepTools,
BRepAlgo,
BRepSweep,
GeomFill,
BRepMAT2d,
StdFail,
GeomPlate,
Adaptor3d,
Law,
GeomLProp
is
enumeration TransitionStyle
is Modified, Right, Round end;
-- private class FilledPair;
---Purpose: A pair of bound shapes with the result.
class Generator;
---Purpose: Compute a topological surface ( a shell) using
-- generating wires. The face of the shell will be
-- ruled surfaces through the wires.
-- The wires must have the same number of edges.
deferred class SectionLaw;
class ShapeLaw;
class NSections;
class Draft;
deferred class LocationLaw;
class DraftLaw;
class Edge3DLaw;
class EdgeOnSurfLaw;
class ACRLaw;
class Pipe;
---Purpose: Computes a topological shape using a wire
-- (spine) and a shape (profile).
class PipeShell;
---Purpose: Computes a topological shell using some wires --
-- (spines and profiles) and diplacement option
class Evolved;
---Purpose: Computes an evolved volum using a generating
-- wire and a profile.
class Sweep;
---Purpose: Computes an Sweep shell using a generating
-- wire, an SectionLaw and an LocationLaw.
class CompatibleWires;
---Purpose: Computes Wires with good orientation and origin in order
-- to generate a shell not twisted.
class OffsetWire;
---Purpose: Computes the offset of a Wire or the Wires contained
-- in a Face.
-- The Wire or the Face must be planar.
class OffsetAncestors;
class ListOfOffsetWire instantiates
List from TCollection (OffsetWire from BRepFill);
private class ApproxSeewing;
private class MultiLine;
private class MultiLineTool;
private class ComputeCLine instantiates
ComputeCLine from Approx ( MultiLine, MultiLineTool);
private class TrimSurfaceTool;
---Purpose: Compute the Pcurves and the 3d curves resulting
-- of the trimming of a face by an extruded surface.
private class TrimEdgeTool;
---Purpose: Geometric Tool using to construct Offset Wires.
private class SectionPlacement;
private class Section;
--class TrimCorner;
--modified by NIZHNY-MKK Tue Oct 21 17:43:15 2003
class TrimShellCorner;
private class SequenceOfSection instantiates
Sequence from TCollection (Section);
class DataMapOfNodeDataMapOfShapeShape instantiates
DataMap from TCollection (Node from MAT,
DataMapOfShapeShape from TopTools, MapTransientHasher from TColStd );
class DataMapOfNodeShape instantiates
DataMap from TCollection (Node from MAT,
Shape from TopoDS,
MapTransientHasher from TColStd );
class DataMapOfShapeDataMapOfShapeListOfShape instantiates
DataMap from TCollection (Shape from TopoDS,
DataMapOfShapeListOfShape from TopTools,
ShapeMapHasher from TopTools );
class DataMapOfShapeSequenceOfReal instantiates
DataMap from TCollection (Shape from TopoDS,
SequenceOfReal from TColStd,
ShapeMapHasher from TopTools );
class DataMapOfShapeSequenceOfPnt instantiates
DataMap from TCollection (Shape from TopoDS,
SequenceOfPnt from TColgp,
ShapeMapHasher from TopTools );
class DataMapOfOrientedShapeListOfShape instantiates
DataMap from TCollection (Shape from TopoDS,
ListOfShape from TopTools,
OrientedShapeMapHasher from TopTools);
class CurveConstraint ;
---Purpose: same as CurveConstraint from GeomPlate
-- with BRepAdaptor_Surface instead of
-- GeomAdaptor_Surface
-- inherits CurveConstraint from GeomPlate
class Filling;
---Purpose: N-Side Filling
-- This algorithm avoids to build a face from:
-- * a set of edges defining the bounds of the face and some
-- constraints the surface of the face has to satisfy
-- * a set of edges and points defining some constraints
-- the support surface has to satisfy
-- * an initial surface to deform for satisfying the constraints
-- * a set of parameters to control the constraints.
private class FaceAndOrder;
private class EdgeFaceAndOrder;
private class SequenceOfFaceAndOrder instantiates
Sequence from TCollection (FaceAndOrder from BRepFill);
private class SequenceOfEdgeFaceAndOrder instantiates
Sequence from TCollection (EdgeFaceAndOrder from BRepFill);
Face( Edge1 : Edge from TopoDS;
Edge2 : Edge from TopoDS )
---Purpose: Computes a ruled surface between two edges.
returns Face from TopoDS;
Shell( Wire1 : Wire from TopoDS;
Wire2 : Wire from TopoDS )
---Purpose: Computes a ruled surface between two wires.
-- The wires must have the same number of edges.
returns Shell from TopoDS;
Axe (Spine : Shape from TopoDS;
Profile : Wire from TopoDS;
AxeProf : in out Ax3 from gp;
ProfOnSpine : in out Boolean from Standard;
Tol : Real from Standard);
---Purpose: Computes <AxeProf> as Follow. <Location> is
-- the Position of the nearest vertex V of <Profile>
-- to <Spine>.<XDirection> is confused with the tangent
-- to <Spine> at the projected point of V on the Spine.
-- <Direction> is normal to <Spine>.
-- <Spine> is a plane wire or a plane face.
-- <ProfOnSpine> is <False> if the distance
-- between <Profile> and <Spine> is high to <Tol>.
SearchOrigin( W : in out Wire from TopoDS;
P : Pnt from gp;
V : Vec from gp;
Tol : Real) is private;
---Purpose: Computes origins and orientation on a closed wire
ComputeACR( wire : Wire from TopoDS;
ACR : out Array1OfReal from TColStd );
---Purpose: Compute ACR on a wire
InsertACR( wire : Wire from TopoDS;
ACRcuts : Array1OfReal from TColStd;
prec : Real from Standard )
---Purpose: Insert ACR on a wire
returns Wire from TopoDS;
end BRepFill;

1086
src/BRepFill/BRepFill.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
-- File: BRepFill_Edge3DLaw.cdl
-- Created: Tue Sep 1 13:29:02 1998
-- Author: Stephanie HUMEAU
-- <shu@sun17>
---Copyright: Matra Datavision 1998
class ACRLaw from BRepFill inherits LocationLaw from BRepFill
---Purpose: Build Location Law, with a Wire. dans le cas du
-- contour guide et triedre par Abscisse Curviligne
-- Reduite
--
uses
Wire from TopoDS,
LocationLaw from GeomFill,
LocationGuide from GeomFill,
HArray1OfReal from TColStd
is
Create (Path : Wire from TopoDS;
Law : LocationGuide from GeomFill)
returns ACRLaw from BRepFill;
fields
OrigParam : HArray1OfReal from TColStd;
end ACRLaw;

View File

@@ -0,0 +1,85 @@
// File: BRepFill_ACRLaw.cxx
// Created: Tue Sep 1 14:13:11 1998
// Author: Stephanie Humeau
// <shu@sun17>
#include <BRepFill_ACRLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopExp.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <BRepFill.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <GeomFill_LocationGuide.hxx>
#include <GeomFill_HArray1OfLocationLaw.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <Approx_CurvlinFunc.hxx>
BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path,
const Handle(GeomFill_LocationGuide)& theLaw)
{
Init(Path);
// calcul du nb d'edge du path
BRepTools_WireExplorer wexp;
Standard_Integer NbEdge = 0;
for (wexp.Init(myPath); wexp.More(); wexp.Next()) NbEdge++;
// tab pour memoriser les ACR pour chaque edge
OrigParam = new (TColStd_HArray1OfReal)(0,NbEdge);
TColStd_Array1OfReal Orig (0,NbEdge);
BRepFill::ComputeACR(Path, Orig);
Standard_Integer ipath;
TopAbs_Orientation Or;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
TopoDS_Edge E;
Handle(Geom_Curve) C;
Handle(GeomAdaptor_HCurve) AC;
Standard_Real First, Last;
// on recupere les ACR des edges de la trajectoire
OrigParam->SetValue(0,0);
for (ipath=1;ipath<=NbEdge;ipath++)
OrigParam->SetValue(ipath, Orig(ipath));
// on traite chaque edge de la trajectoire
for (ipath=0, wexp.Init(myPath);
wexp.More(); wexp.Next()) {
E = wexp.Current();
// if (!B.Degenerated(E)) {
if (!BRep_Tool::Degenerated(E)) {
ipath++;
myEdges->SetValue(ipath, E);
C = BRep_Tool::Curve(E,First,Last);
Or = E.Orientation();
if (Or == TopAbs_REVERSED) {
Handle(Geom_TrimmedCurve) CBis =
new (Geom_TrimmedCurve) (C, First, Last);
CBis->Reverse(); // Pour eviter de deteriorer la topologie
C = CBis;
First = C->FirstParameter();
Last = C->LastParameter();
}
AC = new (GeomAdaptor_HCurve) (C, First, Last);
// on Set les parametres pour le cas multi-edges
Standard_Real t1 = OrigParam->Value(ipath-1);
Standard_Real t2 = OrigParam->Value(ipath);
Handle(GeomFill_LocationGuide) Loc;
Loc = Handle(GeomFill_LocationGuide)::DownCast(theLaw);
Loc->SetOrigine(t1,t2);
myLaws->SetValue(ipath, Loc->Copy());
myLaws->ChangeValue(ipath)->SetCurve(AC);
}
}
}

View File

@@ -0,0 +1,73 @@
-- File: BRepFill_ApproxSeewing.cdl
-- Created: Thu Sep 21 18:15:15 1995
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1995
private class ApproxSeewing from BRepFill
---Purpose: Evaluate the 3dCurve and the PCurves described in
-- a MultiLine from BRepFill. The parametrization of
-- those curves is not imposed by the Bissectrice.
-- The parametrization is given approximatively by
-- the abscissa of the curve3d.
uses
MultiLine from BRepFill,
Curve from Geom,
Curve from Geom2d
raises
NotDone from StdFail
is
Create returns ApproxSeewing from BRepFill;
Create( ML : MultiLine from BRepFill)
returns ApproxSeewing from BRepFill;
Perform(me : in out;
ML : MultiLine from BRepFill)
is static;
IsDone(me)
returns Boolean from Standard
is static;
Curve(me)
---Purpose: returns the approximation of the 3d Curve
---C++: return const &
returns Curve from Geom
raises
NotDone from StdFail
is static;
CurveOnF1(me)
---Purpose: returns the approximation of the PCurve on the
-- first face of the MultiLine
---C++: return const &
returns Curve from Geom2d
raises
NotDone from StdFail
is static;
CurveOnF2(me)
---Purpose: returns the approximation of the PCurve on the
-- first face of the MultiLine
---C++: return const &
returns Curve from Geom2d
raises
NotDone from StdFail
is static;
fields
myML : MultiLine from BRepFill;
myIsDone : Boolean from Standard;
myCurve : Curve from Geom;
myPCurve1 : Curve from Geom2d;
myPCurve2 : Curve from Geom2d;
end ApproxSeewing;

View File

@@ -0,0 +1,232 @@
// File: BRepFill_ApproxSeewing.cxx
// Created: Fri Sep 22 08:44:29 1995
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_ApproxSeewing.ixx>
#include <AppParCurves_MultiCurve.hxx>
#include <AppDef_Compute.hxx>
#include <AppDef_MultiLine.hxx>
#include <AppDef_MultiPointConstraint.hxx>
#include <BSplCLib.hxx>
#include <PLib.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
//=======================================================================
//function : BRepFill_ApproxSeewing
//purpose :
//=======================================================================
BRepFill_ApproxSeewing::BRepFill_ApproxSeewing()
:myIsDone(Standard_False)
{
}
//=======================================================================
//function : BRepFill_ApproxSeewing
//purpose :
//=======================================================================
BRepFill_ApproxSeewing::BRepFill_ApproxSeewing(const BRepFill_MultiLine& ML)
:myIsDone(Standard_False)
{
Perform(ML);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepFill_ApproxSeewing::Perform(const BRepFill_MultiLine& ML)
{
myML = ML;
// evaluate the approximative length of the 3dCurve
Standard_Integer i;
Standard_Real Length = 0.;
Standard_Real U1 = myML.FirstParameter();
Standard_Real U2 = myML.LastParameter();
Standard_Integer NbPoints = 50;
Standard_Real Dist, dU = (U2 - U1) / ( 2*NbPoints - 1);
TColgp_Array1OfPnt2d LP(1,2*NbPoints); // tableau Longueur <-> Param
gp_Pnt P1, P2;
P1 = myML.Value(U1);
for ( i = 0; i < 2*NbPoints ; i++) {
P2 = myML.Value(U1 + i*dU);
Dist = P1.Distance(P2);
Length += Dist;
LP(i+1) = gp_Pnt2d( Length, U1 + (i*dU));
P1 = P2;
}
// On cherche a mettre NbPoints dans la curve.
// on met les points environ a Length/NbPoints.
AppDef_MultiLine MLS ( NbPoints);
AppDef_MultiPointConstraint MP ( 1, 2);
gp_Pnt P3d;
gp_Pnt2d PF1,PF2;
ML.Value3dOnF1OnF2(U1,P3d,PF1,PF2);
MP.SetPoint (1, P3d);
MP.SetPoint2d(2, PF1);
MP.SetPoint2d(3, PF2);
MLS.SetValue (1, MP);
Standard_Real DCorde = Length / ( NbPoints - 1);
Standard_Real Corde = DCorde;
Standard_Integer Index = 1;
Standard_Real U, Alpha;
for ( i = 2; i < NbPoints; i++) {
while ( LP(Index).X() < Corde) Index ++;
Alpha = (Corde - LP(Index-1).X()) / (LP(Index).X() - LP(Index-1).X());
U = LP(Index-1).Y() + Alpha * ( LP(Index).Y() - LP(Index-1).Y());
AppDef_MultiPointConstraint MPC( 1, 2);
ML.Value3dOnF1OnF2(U,P3d,PF1,PF2);
MPC.SetPoint (1, P3d);
MPC.SetPoint2d(2, PF1);
MPC.SetPoint2d(3, PF2);
MLS.SetValue (i, MPC);
Corde = i*DCorde;
}
AppDef_MultiPointConstraint MPE( 1, 2);
ML.Value3dOnF1OnF2(U2,P3d,PF1,PF2);
MPE.SetPoint (1, P3d);
MPE.SetPoint2d(2, PF1);
MPE.SetPoint2d(3, PF2);
MLS.SetValue (NbPoints, MPE);
AppDef_Compute Fit(MLS);
Standard_Integer NbCurves = Fit.NbMultiCurves();
// Standard_Integer MaxDeg = 0;
if ( NbCurves == 0) {
#ifdef DEBUG_EVOLVED
cout << " TrimSurfaceTool : Approx echoue, on met les polygones" << endl;
#endif
TColStd_Array1OfReal Knots(1,NbPoints);
TColStd_Array1OfInteger Mults(1,NbPoints);
Mults.Init(1);
Mults(1) = Mults(NbPoints) = 2;
TColgp_Array1OfPnt P (1,NbPoints);
TColgp_Array1OfPnt2d P1(1,NbPoints);
TColgp_Array1OfPnt2d P2(1,NbPoints);
Standard_Real Uf = ML.FirstParameter();
Standard_Real Ul = ML.LastParameter();
Standard_Real dU = (Ul-Uf)/(NbPoints-1);
AppDef_MultiPointConstraint MPC;
for ( i = 1; i<= NbPoints-1; i++) {
MPC = MLS.Value(i);
U = Uf + (i-1) * dU;
P (i) = MPC.Point(1);
P1(i) = MPC.Point2d(2);
P2(i) = MPC.Point2d(3);
Knots(i) = U;
}
// eval the last point on Ul
MPC = MLS.Value(NbPoints);
P (NbPoints) = MPC.Point(1);
P1(NbPoints) = MPC.Point2d(2);
P2(NbPoints) = MPC.Point2d(3);
Knots(NbPoints) = Ul;
myCurve = new Geom_BSplineCurve ( P , Knots, Mults, 1);
myPCurve1 = new Geom2d_BSplineCurve( P1, Knots, Mults, 1);
myPCurve2 = new Geom2d_BSplineCurve( P2, Knots, Mults, 1);
myIsDone = Standard_True;
return;
}
// Les approx sont a priori OK.
const AppParCurves_MultiBSpCurve& MBSp =
Fit.SplineValue();
Standard_Integer NbPoles = MBSp.NbPoles();
TColgp_Array1OfPnt Poles (1 , NbPoles);
TColgp_Array1OfPnt2d Poles2d1(1 , NbPoles);
TColgp_Array1OfPnt2d Poles2d2(1 , NbPoles);
MBSp.Curve(1, Poles);
MBSp.Curve(2, Poles2d1);
MBSp.Curve(3, Poles2d2);
const TColStd_Array1OfReal& Knots = MBSp.Knots();
const TColStd_Array1OfInteger& Mults = MBSp.Multiplicities();
Standard_Integer Degree = MBSp.Degree();
myCurve = new Geom_BSplineCurve (Poles, Knots,Mults,Degree);
myPCurve1 = new Geom2d_BSplineCurve(Poles2d1,Knots,Mults,Degree);
myPCurve2 = new Geom2d_BSplineCurve(Poles2d2,Knots,Mults,Degree);
myIsDone = Standard_True;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepFill_ApproxSeewing::IsDone() const
{
return myIsDone;
}
//=======================================================================
//function : Handle_Geom_Curve&
//purpose :
//=======================================================================
const Handle(Geom_Curve)& BRepFill_ApproxSeewing::Curve() const
{
StdFail_NotDone_Raise_if( !myIsDone,
"BRepFill_ApproxSeewing::Curve");
return myCurve;
}
//=======================================================================
//function : Handle_Geom2d_Curve&
//purpose :
//=======================================================================
const Handle(Geom2d_Curve)& BRepFill_ApproxSeewing::CurveOnF1() const
{
StdFail_NotDone_Raise_if( !myIsDone,
"BRepFill_ApproxSeewing::CurveOnF1");
return myPCurve1;
}
//=======================================================================
//function : Handle_Geom2d_Curve&
//purpose :
//=======================================================================
const Handle(Geom2d_Curve)& BRepFill_ApproxSeewing::CurveOnF2() const
{
StdFail_NotDone_Raise_if( !myIsDone,
"BRepFill_ApproxSeewing::CurveOnF2");
return myPCurve2;
}

View File

@@ -0,0 +1,119 @@
-- File: BRepFill_CompatibleWires.cdl
-- Created: Thu Jul 2 16:47:35 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
---Copyright: Matra Datavision 1998
class CompatibleWires from BRepFill
---Purpose: Constructs a sequence of Wires agreed each other
-- so that the surface passing through these sections
-- is not twisted
uses
Edge from TopoDS,
SequenceOfShape from TopTools,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools
raises
ConstructionError from Standard,
NoSuchObject from Standard
is
Create returns CompatibleWires from BRepFill;
Create ( Sections : SequenceOfShape from TopTools)
returns CompatibleWires from BRepFill;
Init ( me : in out;
Sections : SequenceOfShape from TopTools)
raises
ConstructionError from Standard
is static;
SetPercent ( me : in out; percent : Real = 0.01)
is static;
Perform (me : in out;
WithRotation : Boolean = Standard_True)
---Purpose: Performs CompatibleWires According to the orientation
-- and the origin of each other
raises
ConstructionError from Standard
is static;
IsDone ( me)
returns Boolean from Standard
is static;
Shape(me) returns SequenceOfShape from TopTools
---Purpose: returns the generated sequence.
---C++ : return const &
is static;
GeneratedShapes (me ; SubSection : Edge from TopoDS)
---Purpose: Returns the shapes created from a subshape
-- <SubSection> of a section.
--
---C++ : return const &
returns ListOfShape from TopTools
is static;
Generated (me)
---C++: return const &
returns DataMapOfShapeListOfShape from TopTools
is static;
SameNumberByPolarMethod (me : in out;
WithRotation : Boolean = Standard_True)
---Purpose: Insert cutting points on closed wires to have same
-- number of edges. The sequence of shapes must
-- be a sequence of wires.
is static private;
SameNumberByACR (me : in out; report : Boolean from Standard )
---Purpose: Insert cutting points on open wires to have same
-- number of edges. The sequence of shapes must
-- be a sequence of wires.
is static private;
ComputeOrigin (me : in out; polar : Boolean from Standard )
---Purpose: Computes origins and orientation on closed wires to
-- avoid twisted results. The sequence of shapes must
-- be a sequence of wires. <polar> must be true
-- if SameNumberByPolarMethod was used before.
is static private;
SearchOrigin (me : in out)
---Purpose: Computes origins and orientation on open wires to
-- avoid twisted results. The sequence of shapes must
-- be a sequence of wires.
is static private;
fields
myInit : SequenceOfShape from TopTools;
myWork : SequenceOfShape from TopTools;
myPercent : Real from Standard;
myDegen1 : Boolean from Standard;
myDegen2 : Boolean from Standard;
myIsDone : Boolean from Standard;
myMap : DataMapOfShapeListOfShape from TopTools;
end CompatibleWires;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
-- File: BRepFill_CurveConstraint.cdl
-- Created: Fri Oct 31 10:54:23 1997
-- Author: Joelle CHAUVET
-- <jct@sgi64>
---Copyright: Matra Datavision 1997
class CurveConstraint from BRepFill inherits CurveConstraint from GeomPlate
uses
Pnt from gp,
Pnt2d from gp,
Vec from gp,
HCurveOnSurface from Adaptor3d,
HCurve from Adaptor3d,
Surface from Geom,
Curve from Geom2d,
Function from Law,
SLProps from GeomLProp
raises
ConstructionError from Standard
is
Create (Boundary : HCurveOnSurface from Adaptor3d;
Order : Integer from Standard ;
NPt : Integer from Standard = 10;
TolDist : Real from Standard = 0.0001;
TolAng : Real from Standard = 0.01;
TolCurv : Real from Standard = 0.1
)
returns CurveConstraint from BRepFill
raises ConstructionError;
--purpose : if Order is not -1 , 0, 1, 2
--
--- Purpose: Create a constraint
-- Order is the order of the constraint. The possible values for order are -1,0,1,2.
-- Order i means constraints Gi
-- Npt is the number of points associated with the constraint.
-- TolDist is the maximum error to satisfy for G0 constraints
-- TolAng is the maximum error to satisfy for G1 constraints
-- TolCurv is the maximum error to satisfy for G2 constraints
-- These errors can be replaced by laws of criterion.
Create (Boundary : HCurve from Adaptor3d;
Tang : Integer from Standard;
NPt : Integer from Standard = 10;
TolDist : Real from Standard = 0.0001)
returns CurveConstraint from BRepFill
raises ConstructionError;
--purpose : if Order is not 0 or -1
-- Purpose: Create a constraint
-- Order is the order of the constraint. The possible values for order are -1,0.
-- Order i means constraints Gi
-- Npt is the number of points associated with the constraint.
-- TolDist is the maximum error to satisfy for G0 constraints
-- These errors can be replaced by laws of criterion.
end;

View File

@@ -0,0 +1,79 @@
// File: BRepFill_CurveConstraint.cxx
// Created: Fri Oct 31 10:54:42 1997
// Author: Joelle CHAUVET
// <jct@sgi64>
#include <BRepFill_CurveConstraint.ixx>
#include <GeomPlate_CurveConstraint.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <Adaptor3d_HSurface.hxx>
#include <ProjLib_ProjectOnPlane.hxx>
#include <GeomAdaptor.hxx>
#include <GeomAPI.hxx>
#include <Geom_Plane.hxx>
#include <Precision.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRep_Tool.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <ProjLib_ProjectedCurve.hxx>
//---------------------------------------------------------
// Constructeurs avec courbe sur surface
//---------------------------------------------------------
BRepFill_CurveConstraint :: BRepFill_CurveConstraint (const Handle(Adaptor3d_HCurveOnSurface)& Boundary,
const Standard_Integer Tang,
const Standard_Integer NPt,
const Standard_Real TolDist,
const Standard_Real TolAng,
const Standard_Real TolCurv
)
{
myFrontiere=Boundary;
myTolDist=TolDist;
myTolAng=TolAng;
myTolCurv=TolCurv;
GeomLProp_SLProps SLP(2,TolDist);
myLProp=SLP;
myOrder=Tang;
if ((Tang<-1)||(Tang>2))
Standard_Failure::Raise("BRepFill : The continuity is not G0 G1 or G2");
myNbPoints=NPt;
myConstG0=Standard_True;
myConstG1=Standard_True;
myConstG2=Standard_True;
if (myFrontiere.IsNull())
Standard_Failure::Raise("BRepFill_CurveConstraint : Curve must be on a Surface");
Handle(Geom_Surface) Surf;
Handle(GeomAdaptor_HSurface) GS1;
GS1 = Handle(GeomAdaptor_HSurface)::DownCast(myFrontiere->ChangeCurve().GetSurface());
if (!GS1.IsNull()) {
Surf=GS1->ChangeSurface().Surface();
}
else {
Handle(BRepAdaptor_HSurface) BS1;
BS1=Handle(BRepAdaptor_HSurface)::DownCast(myFrontiere->ChangeCurve().GetSurface());
Surf = BRep_Tool::Surface(BS1->ChangeSurface().Face());
}
myLProp.SetSurface(Surf);
}
//---------------------------------------------------------
// Constructeurs avec courbe 3d (pour continuite G0 G-1)
//---------------------------------------------------------
BRepFill_CurveConstraint :: BRepFill_CurveConstraint (const Handle(Adaptor3d_HCurve)& Boundary,
const Standard_Integer Tang,
const Standard_Integer NPt,
const Standard_Real TolDist)
: GeomPlate_CurveConstraint(Boundary,Tang,NPt,TolDist)
{
}

123
src/BRepFill/BRepFill_Draft.cdl Executable file
View File

@@ -0,0 +1,123 @@
class Draft from BRepFill
uses
LocationDraft from GeomFill,
Dir from gp,
Box from Bnd,
Surface from Geom,
SectionLaw from BRepFill,
DraftLaw from BRepFill,
TransitionStyle from BRepFill,
HCurve from Adaptor3d,
Shape from GeomAbs,
Shape from TopoDS,
Shell from TopoDS,
Face from TopoDS,
Wire from TopoDS,
ListOfShape from TopTools,
HArray2OfShape from TopTools
raises
NotDone
is
Create(Shape : Shape from TopoDS;
Dir : Dir from gp;
Angle : Real)
---Purpose:
returns Draft from BRepFill;
SetOptions(me : in out;
Style : TransitionStyle from BRepFill = BRepFill_Right;
AngleMin : Real = 0.01;
AngleMax : Real = 3.0);
---Purpose:
SetDraft(me: in out; IsInternal : Boolean = Standard_False);
---Purpose:
Perform(me : in out;
LengthMax : Real)
is static;
---Purpose:
Perform(me : in out;
Surface : Surface from Geom;
KeepInsideSurface : Boolean = Standard_True)
is static;
---Purpose:
Perform(me : in out;
StopShape : Shape from TopoDS;
KeepOutSide : Boolean = Standard_True)
is static;
---Purpose:
IsDone(me)
returns Boolean;
Shell(me)
---Purpose: Returns the draft surface
-- To have the complete shape
-- you have to use the Shape() methode.
returns Shell from TopoDS
raises NotDone;
Generated (me: in out; S : Shape from TopoDS)
---Purpose: Returns the list of shapes generated from the
-- shape <S>.
---C++: return const &
---Level: Public
returns ListOfShape from TopTools;
Shape(me)
returns Shape from TopoDS;
-- retourne la shape resultat
Init(me:in out; Surf : Surface from Geom;
Length : Real;
Box : Box from Bnd)
is private;
BuildShell(me:in out; Surf : Surface from Geom;
KeepOutSide : Boolean = Standard_False)
is private;
Fuse(me:in out; S : Shape from TopoDS;
KeepOutSide : Boolean)
returns Boolean is private;
Sewing(me: in out)
returns Boolean is private;
fields
myDir : Dir from gp;
myAngle : Real;
angmin, angmax : Real;
myTol : Real;
myLoc : DraftLaw from BRepFill;
mySec : SectionLaw from BRepFill;
mySections: HArray2OfShape from TopTools;
myFaces : HArray2OfShape from TopTools;
myGenerated : ListOfShape from TopTools;
myShape : Shape from TopoDS;
myTop : Shape from TopoDS;
myShell : Shell from TopoDS;
myWire : Wire from TopoDS;
myCont : Shape from GeomAbs;
myStyle : TransitionStyle from BRepFill;
IsInternal : Boolean;
myDone : Boolean;
end Draft;

880
src/BRepFill/BRepFill_Draft.cxx Executable file
View File

@@ -0,0 +1,880 @@
// File: BRepFill_Draft.cxx
// Created: Mon Jun 8 15:13:03 1998
// Author: Stephanie HUMEAU
// <shu@sun17>
#include <BRepFill_Draft.ixx>
#include <BRepFill_DraftLaw.hxx>
#include <BRepFill_ShapeLaw.hxx>
#include <BRepFill_Sweep.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BndLib_AddSurface.hxx>
#include <Bnd_Box.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
#include <gp_Lin.hxx>
#include <gp_Mat.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <GeomLProp_SLProps.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_Plane.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Adaptor3d_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GeomFill_LocationDraft.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopAbs.hxx>
#include <BRepLib_MakeWire.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeFace.hxx>
#include <BRepLib_FindSurface.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepAlgo_DSAccess.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Standard_NoSuchObject.hxx>
#include <StdFail_NotDone.hxx>
#ifdef DRAW
#include <Geom_Circle.hxx>
#include <gp.hxx>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
static Standard_Boolean Affich = 0;
#endif
//=======================================================================
//function : Trsf
//purpose :
//======================================================================
static void ComputeTrsf(const TopoDS_Wire& W,
const gp_Dir& D,
Bnd_Box& Box,
gp_Trsf& Tf)
{
// Calcul d'un barycentre approximatif
BRepTools_WireExplorer Exp(W);
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool BT;
gp_XYZ Bary(0.,0.,0.);
Standard_Integer nb;
for (nb=0; Exp.More(); Exp.Next()) {
// Bary += BT.Pnt(Exp.CurrentVertex()).XYZ();
Bary += BRep_Tool::Pnt(Exp.CurrentVertex()).XYZ();
nb++;
}
Bary /= nb;
// Calcul la Transfo
gp_Ax3 N(Bary, D);
Tf.SetTransformation(N);
BRepAdaptor_Curve AC;
// BndLib_Add3dCurve BC;
// transfo du wire
TopoDS_Wire TheW = W;
TopLoc_Location Loc(Tf);
TheW.Location(Loc);
// Calcul la boite
Box.SetVoid();
for (Exp.Init(TheW); Exp.More(); Exp.Next()) {
AC.Initialize(Exp.Current());
// BC.Add(AC, 0.1, Box);
BndLib_Add3dCurve::Add(AC, 0.1, Box);
}
}
//=======================================================================
//function : Longueur
//purpose :
//======================================================================
static Standard_Real Longueur(const Bnd_Box& WBox,
const Bnd_Box& SBox,
gp_Dir& D,
gp_Pnt& P)
{
// face de la boite la plus eloignee de la face entree dans
//la direction de depouille
Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,WZmin,WZmax,L;
//"coord" de la boite
WBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
WZmin = Zmin;
WZmax = Zmax;
SBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
P.SetCoord( (Xmin+Xmax)/2, (Ymin+Ymax)/2, Zmax);
if (Zmax < WZmin) {
// Depouille dans le mauvais sens. On inverse...
D.Reverse();
L = WZmax - Zmin;
P.SetZ(Zmin);
}
else {
L = Zmax - WZmin;
}
return L;
}
//=======================================================================
//function : GoodOrientation
//purpose : Regarde si la loi est oriente de maniere a avoir une depouille
// "exterieur"
//======================================================================
static Standard_Boolean GoodOrientation(const Bnd_Box& B,
const Handle(BRepFill_LocationLaw)& Law,
const gp_Dir& D)
{
Standard_Real f, l, r, t;
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
gp_Pnt P1(aXmin, aYmin, aZmin), P2(aXmax, aYmax, aZmax);
gp_Vec V(P1, P2);
Law->CurvilinearBounds(Law->NbLaw(), f, l);
r = V.Magnitude()/l;
Standard_Integer ii, Ind;
//#ifndef DEB
Standard_Integer Nb = (Standard_Integer) (4+(10*r));
//#else
// Standard_Integer Nb = 4+(10*r);
//#endif
r = l/Nb;
Nb++; // Nombre de points
TColgp_Array1OfPnt Pnts(1, Nb);
Handle(Adaptor3d_HCurve) AC;
gp_XYZ Bary(0.,0.,0.);
for (ii=1; ii<=Nb; ii++) {
Law->Parameter((ii-1)*r, Ind, t);
AC = Law->Law(Ind)->GetCurve();
AC->D0(t, Pnts(ii));
Bary+= Pnts(ii).XYZ();
}
Bary /= Nb;
gp_Pnt Centre(Bary);
gp_Vec Normal(D.XYZ());
Standard_Real Angle = 0;
gp_Vec Ref(Centre, Pnts(1));
for (ii=2; ii<=Nb; ii++) {
gp_Vec R(Centre, Pnts(ii));
Angle += Ref.AngleWithRef(R, Normal);
Ref = R;
}
return (Angle >= 0);
}
//=======================================================================
//function : Constructeur
//purpose :
//======================================================================
BRepFill_Draft::BRepFill_Draft(const TopoDS_Shape& S,
const gp_Dir& Dir,
const Standard_Real Angle)
{
myLoc.Nullify();
mySec.Nullify();
myFaces.Nullify();
mySections.Nullify();
switch (S.ShapeType()) {
case TopAbs_WIRE :
{
myWire = TopoDS::Wire(S);
break;
}
case TopAbs_FACE :
{
TopoDS_Iterator Exp (S);
myWire = TopoDS::Wire(Exp.Value());
break;
}
case TopAbs_SHELL :
{
TopTools_ListOfShape List;
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
TopExp::MapShapesAndAncestors(S,TopAbs_EDGE,TopAbs_FACE,edgemap);
Standard_Integer iedge, nbf;
for (iedge = 1; iedge <= edgemap.Extent(); iedge++) {
const TopoDS_Edge& theEdge = TopoDS::Edge(edgemap.FindKey(iedge));
// skip degenerated edges
if (!BRep_Tool::Degenerated(theEdge)) {
nbf = edgemap(iedge).Extent();
if (nbf==1) List.Append(theEdge);
}
}
if( List.Extent()>0) {
BRepLib_MakeWire MW;
MW.Add(List);
BRepLib_WireError Err = MW.Error();
if (Err == BRepLib_WireDone) {
myWire = MW.Wire();
}
else {
#if DEB
cout << "Error in MakeWire" << endl;
#endif
Standard_ConstructionError::Raise("BRepFill_Draft");
}
}
else {
#if DEB
cout << "Pas de Bords Libre !" << endl;
#endif
Standard_ConstructionError::Raise("BRepFill_Draft");
}
break;
}
default :
Standard_ConstructionError::Raise("BRepFill_Draft");
}
// Attention aux wire closed non declare !
if (!myWire.Closed()) {
TopoDS_Vertex Vf, Vl;
TopExp::Vertices(myWire, Vf, Vl);
if (Vf.IsSame(Vl)) myWire.Closed(Standard_True);
}
#if DRAW
if (Affich) {
DBRep::Set("TheWire", myWire);
}
#endif
myAngle = Abs(Angle);
myDir = Dir;
myTop = S;
myDone = Standard_False;
myTol = 1.e-4;
myCont = GeomAbs_C1;
SetOptions();
SetDraft();
}
//=======================================================================
//function :SetOptions
//purpose : Definit le style
//======================================================================
void BRepFill_Draft::SetOptions(const BRepFill_TransitionStyle Style,
const Standard_Real Min,
const Standard_Real Max)
{
myStyle = Style;
angmin = Min;
angmax = Max;
}
//=======================================================================
//function :SetDraft
//purpose :
//======================================================================
void BRepFill_Draft::SetDraft(const Standard_Boolean Internal)
{
IsInternal = Internal;
}
//=======================================================================
//function :Perform
//purpose : calcul d'une surface de depouille
//======================================================================
void BRepFill_Draft::Perform(const Standard_Real LengthMax)
{
Handle(Geom_Surface) S;
S.Nullify();
Bnd_Box WBox;//, SBox;
gp_Trsf Trsf;
ComputeTrsf(myWire, myDir, WBox, Trsf);
Init(S, LengthMax, WBox);
BuildShell(S);
Sewing();
}
//=======================================================================
//function :Perform
//purpose : calcul d'une surface de depouille
//======================================================================
void BRepFill_Draft::Perform(const Handle(Geom_Surface)& Surface,
const Standard_Boolean KeepInsideSurface)
{
Bnd_Box WBox, SBox;
gp_Trsf Trsf;
gp_Pnt Pt;
Standard_Real L;
ComputeTrsf(myWire, myDir, WBox, Trsf);
// boite englobant la surface d'arret
Handle(Geom_Surface) Surf;
Surf = Handle(Geom_Surface)::DownCast(Surface->Transformed(Trsf));
GeomAdaptor_Surface S1 (Surf);
// BndLib_AddSurface AS;
// AS.Add(S1, 0.1, SBox);
BndLib_AddSurface::Add(S1, 0.1, SBox);
// on calcule la longueur maximum de la regle.
L = Longueur(WBox, SBox, myDir, Pt);
L /= Abs(Cos(myAngle));
// Constructuion
Init(Surface, L, WBox);
BuildShell(Surface, !KeepInsideSurface);
Sewing();
}
//=======================================================================
//function :Perform
//purpose : calcul de la surface de depouille, arretee par une shape
//======================================================================
void BRepFill_Draft::Perform(const TopoDS_Shape& StopShape,
const Standard_Boolean KeepOutSide)
{
Bnd_Box WBox, SBox;
gp_Trsf Trsf;
gp_Pnt Pt;
Standard_Real L;
ComputeTrsf(myWire, myDir, WBox, Trsf);
// boite englobant la shape d'arret
Bnd_Box BSurf;//, TheBox;
Standard_Real Umin, Umax, Vmin, Vmax;
#ifdef DEB
Standard_Real Tol = Precision::Confusion()/10;
#endif
// BRepTools B;
// BRep_Tool BT;
Handle(Geom_Surface) Surf;
// BndLib_AddSurface AS;
TopExp_Explorer Ex (StopShape, TopAbs_FACE);
SBox.SetVoid();
while (Ex.More()) { // on parcourt les faces de la shape d'arret
// B.UVBounds(TopoDS::Face(Ex.Current()), Umin,Umax,Vmin,Vmax);
BRepTools::UVBounds(TopoDS::Face(Ex.Current()), Umin,Umax,Vmin,Vmax);
Surf = Handle(Geom_Surface)::DownCast(
// BT.Surface(TopoDS::Face(Ex.Current()))->Transformed(Trsf) );
BRep_Tool::Surface(TopoDS::Face(Ex.Current()))->Transformed(Trsf) );
GeomAdaptor_Surface S1 (Surf);
// boite englobant la face courante
// AS.Add(S1, Umin, Umax, Vmin, Vmax, 0.1, BSurf);
BndLib_AddSurface::Add(S1, Umin, Umax, Vmin, Vmax, 0.1, BSurf);
SBox.Add(BSurf); // on regroupe les boites
Ex.Next();
}// while_Ex
// on calcule la longueur maximum de la regle.
L = Longueur(WBox, SBox, myDir, Pt);
L /= Abs(Cos(myAngle));
// surface d'arret
gp_Trsf Inv;
Inv = Trsf.Inverted(); // transfo inverse
Pt.Transform(Inv); // coord dans le repere absolu
Handle(Geom_Plane) Plan = new (Geom_Plane)(Pt, myDir);
Surf = new (Geom_RectangularTrimmedSurface) (Plan,-L, L, -L, L);
#if DRAW
if (Affich) {
char* Temp = "ThePlan" ;
DrawTrSurf::Set(Temp, Surf);
// DrawTrSurf::Set("ThePlan", Surf);
}
#endif
// Balayage et restriction
Init(Plan, L*1.01, WBox);
BuildShell(Surf, Standard_False);
Fuse(StopShape, KeepOutSide);
Sewing();
}
//=======================================================================
//function : Init
//purpose : Construction des lois.
//======================================================================
void BRepFill_Draft::Init(const Handle(Geom_Surface)& ,
const Standard_Real Length,
const Bnd_Box& Box)
{
Standard_Boolean B;
// loi de positionnement
Handle(GeomFill_LocationDraft) Loc
= new (GeomFill_LocationDraft) (myDir, myAngle);
myLoc = new (BRepFill_DraftLaw) (myWire, Loc);
B = GoodOrientation(Box, myLoc, myDir);
if (IsInternal ^ (!B) ) {
myAngle = - myAngle;
Loc->SetAngle(myAngle);
myLoc = new (BRepFill_DraftLaw) (myWire, Loc);
}
myLoc->CleanLaw(angmin); // Nettoie les petites discontinuites.
// loi de section
// generatrice est une droite // a la binormal.
gp_Pnt P(0, 0, 0);
gp_Vec D (0., 1., 0.);
// Controle de l'orientation
Standard_Real f,l;
myLoc->Law(1)->GetDomain(f,l);
gp_Mat M;
gp_Vec Bid;
myLoc->Law(1)->D0( (f+l)/2, M, Bid);
gp_Dir BN(M.Column(2));
Standard_Real ang = myDir.Angle(BN);
if (ang > PI/2) D.Reverse();
Handle(Geom_Line) L = new (Geom_Line) (P, D);
Handle(Geom_Curve) TC = new (Geom_TrimmedCurve) (L, 0, Length);
#if DRAW
if (Affich > 2) {
TC = new (Geom_Circle) (gp::XOY(), Length);
}
#endif
BRepLib_MakeEdge ME(TC);
TopoDS_Edge EG = ME.Edge();
BRepLib_MakeWire MW(EG);
TopoDS_Wire G = MW.Wire();
mySec = new (BRepFill_ShapeLaw) (G, Standard_True);
}
//=======================================================================
//function : BuildShell
//purpose : Construction de la surface de depouille
//======================================================================
void BRepFill_Draft::BuildShell(const Handle(Geom_Surface)& Surf,
const Standard_Boolean KeepOutSide)
{
// construction de la surface
BRepFill_Sweep Sweep(mySec, myLoc, Standard_True);
Sweep.SetTolerance(myTol);
Sweep.SetAngularControl(angmin, angmax);
Sweep.Build(myStyle, GeomFill_Location, myCont);
if (Sweep.IsDone()) {
myShape = Sweep.Shape();
myShell = TopoDS::Shell(myShape);
myFaces = Sweep.SubShape();
mySections = Sweep.Sections();
myDone = Standard_True;
// Controle de l'orientation
Standard_Boolean out=Standard_True;
TopExp_Explorer ex(myShell,TopAbs_FACE);
TopoDS_Face F;
F = TopoDS::Face(ex.Current());
BRepAdaptor_Surface SF(F);
Standard_Real u, v;
gp_Pnt P;
gp_Vec V1, V2, V;
u = SF.FirstUParameter();
v = SF.FirstVParameter();
SF.D1(u,v,P,V1,V2);
V = V1.Crossed(V2);
if (F.Orientation() == TopAbs_REVERSED) V.Reverse();
if (V.Magnitude() > 1.e-10) {
out = myDir.Angle(V) > PI/2;
}
if (out == IsInternal) {
myShell.Reverse();
myShape.Reverse();
}
}
else {
myDone = Standard_False;
return;
}
if (!Surf.IsNull()) { // On ajoute la face en bout
// En attendant une utilisation des traces & retriction dans BRepFill_Sweep
// On fait un Fuse.
BRepLib_MakeFace MkF;
MkF.Init(Surf);
Fuse(MkF.Face(), KeepOutSide);
}
}
//=======================================================================
//function : Fuse
//purpose : Operation booleenne entre la depouille et
// la shape d'arret
//======================================================================
Standard_Boolean BRepFill_Draft::Fuse(const TopoDS_Shape& StopShape,
const Standard_Boolean KeepOutSide)
{
BRep_Builder B;
Standard_Boolean issolid = Standard_False;
TopoDS_Solid Sol1, Sol2;
TopAbs_State State1 = TopAbs_OUT, State2 = TopAbs_OUT;
if (myShape.ShapeType()==TopAbs_SOLID) {
Sol1 = TopoDS::Solid(myShape);
issolid = Standard_True;
}
else {
B.MakeSolid(Sol1);
B.Add(Sol1, myShape); // shell => solid (pour fusion)
}
switch (StopShape.ShapeType()) {
case TopAbs_COMPOUND :
{
TopoDS_Iterator It(StopShape);
return Fuse(It.Value(), KeepOutSide);
}
case TopAbs_SOLID :
{
Sol2 = TopoDS::Solid(StopShape);
break;
}
case TopAbs_SHELL :
{
B.MakeSolid(Sol2);
B.Add(Sol2, StopShape); // shell => solid (pour fusion)
break;
}
case TopAbs_FACE :
{
TopoDS_Shell S;
B.MakeShell(S);
B.Add(S, StopShape);
B.MakeSolid(Sol2);
B.Add(Sol2, S); // shell => solid (pour fusion)
break;
}
default :
{
return Standard_False; // On ne sait pas faire
}
}
BRepAlgo_DSAccess DSA;
DSA.Load(Sol1, Sol2);
DSA.Intersect(Sol1, Sol2); // intersection des 2 solids
// suppression des aretes correspondant aux intersections "inutiles"
Standard_Integer NbPaquet;
// gp_Pnt P1,P2;
TopoDS_Vertex V,V1;
TopTools_ListOfShape List;
List = DSA.GetSectionEdgeSet();// liste des aretes
NbPaquet = List.Extent();
if (NbPaquet == 0) {
#if DRAW
cout << "Pas de fusion" << endl;
DBRep::Set("DepPart", Sol1);
DBRep::Set("StopPart", Sol2);
#endif
return Standard_False;
}
if (NbPaquet > 1) {
// Il faut selectioner les paquets.
TColStd_Array1OfReal Dist(1, NbPaquet);
TopTools_ListIteratorOfListOfShape it(List);
Standard_Real D, Dmin = 1.e10;
Standard_Integer ii;
//On classe les paquets par eloignement.
BRepExtrema_DistShapeShape Dist2;
Dist2.LoadS1( myWire );
for (ii=1; it.More();it.Next(),ii++){
Dist2.LoadS2( it.Value() );
Dist2.Perform();
if (Dist2.IsDone()) {
D = Dist2.Value();
Dist(ii) = D;
if (D < Dmin) Dmin = D;
}
else
Dist(ii) = 1.e10;
}
// on supprime les edges "plus loin" que Dmin
for (ii=1, it.Initialize(List); it.More();it.Next(), ii++){
if (Dist(ii) > Dmin) {
DSA.SuppressEdgeSet(it.Value());
}
#if DRAW
else if (Affich) {
DBRep::Set("KeepEdges", it.Value());
}
#endif
}
}
if (StopShape.ShapeType() != TopAbs_SOLID) {
// Il faut choisir le state par la geometrie
//(1) On recupere une edge de section
List = DSA.GetSectionEdgeSet();// liste des aretes
TopTools_ListIteratorOfListOfShape it(List);
TopoDS_Iterator iter(it.Value());
TopoDS_Edge E = TopoDS::Edge(iter.Value());
// (2) On recupere sa geometrie sur StopShape
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool BT;
Handle(Geom_Surface) S;
Handle(Geom2d_Curve) C2d;
gp_Pnt2d P2d;
Standard_Real f,l;
TopLoc_Location L;
// BT.CurveOnSurface(E, C2d, S, L, f, l, 2);
BRep_Tool::CurveOnSurface(E, C2d, S, L, f, l, 2);
// On Trouve une normale.
C2d->D0((f+l)/2,P2d);
GeomLProp_SLProps SP(S, P2d.X(), P2d.Y(), 1, 1.e-12);
if (! SP.IsNormalDefined()) {
C2d->D0((3*f+l)/4,P2d);
SP.SetParameters(P2d.X(), P2d.Y());
if ( !SP.IsNormalDefined()) {
C2d->D0((f+3*l)/4,P2d);
SP.SetParameters(P2d.X(), P2d.Y());
}
}
// On en deduit State1
if (myDir.Angle(SP.Normal()) < PI/2) State1 = TopAbs_IN;
else State1 = TopAbs_OUT;
}
if (! KeepOutSide) { // On inverse State2;
if (State2 == TopAbs_IN) State2 = TopAbs_OUT;
else State2 = TopAbs_IN;
}
//recalcul de la shape finale
TopoDS_Shape result = DSA.Merge(State1, State2);
if (issolid) myShape = result;
else {
TopExp_Explorer Exp;
Exp.Init(result, TopAbs_SHELL);
if (Exp.More()) myShape = Exp.Current();
}
// Mise a jour de l'Historique
Standard_Integer ii;
for (ii=1; ii<=myLoc->NbLaw(); ii++) {
const TopTools_ListOfShape& L = DSA.Modified(myFaces->Value(1,ii));
if (L.Extent()>0)
myFaces->SetValue(1, ii, L.First());
}
for (ii=1; ii<=myLoc->NbLaw()+1; ii++) {
const TopTools_ListOfShape& L = DSA.Modified(mySections->Value(1,ii));
if (L.Extent()>0)
mySections->SetValue(1, ii, L.First());
}
return Standard_True;
}
//=======================================================================
//function : Sewing
//purpose : Assemble la depouille avec la face du dessus
//======================================================================
Standard_Boolean BRepFill_Draft::Sewing()
{
Standard_Boolean ToAss;
Standard_Boolean Ok = Standard_False;
ToAss = (myTop.ShapeType() != TopAbs_WIRE);
if ((!ToAss) || (!myDone)) return Standard_False;
// Assemblage
// on fait un shell a partir des faces de la shape + la shape en entree
Handle(BRepBuilderAPI_Sewing) Ass = new BRepBuilderAPI_Sewing(5*myTol, Standard_True,
Standard_True, Standard_False);
Ass->Add(myShape);
Ass->Add(myTop);
ToAss = Standard_True;
Standard_Integer NbCE;
Ass->Perform();
// On verifie que l'assemblage est effectif.
NbCE = Ass->NbContigousEdges();
if (NbCE > 0) {
TopoDS_Shape res;
res = Ass->SewedShape();
if ((res.ShapeType() == TopAbs_SHELL)||
(res.ShapeType() == TopAbs_SOLID)) {
myShape = res;
Ok = Standard_True;
}
else if (res.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator It(res);
res = It.Value();
It.Next();
if (!It.More()) {//Une seule partie => c'est bon
myShape = res;
Ok = Standard_True;
}
}
}
if (Ok) {
// Mise a jour de l'Historique
Standard_Integer ii;
for (ii=1; ii<=myLoc->NbLaw(); ii++) {
if (Ass->IsModified(myFaces->Value(1,ii)))
myFaces->SetValue(1, ii,
Ass->Modified(myFaces->Value(1,ii)));
}
for (ii=1; ii<=myLoc->NbLaw()+1; ii++) {
if (Ass->IsModified(mySections->Value(1,ii)))
mySections->SetValue(1, ii,
Ass->Modified(mySections->Value(1,ii)));
}
if (myShape.Closed()) { // On fait un Solid
TopoDS_Solid solid;
BRep_Builder BS;
BS.MakeSolid(solid);
BS.Add(solid,TopoDS::Shell(myShape));
BRepClass3d_SolidClassifier SC(solid);
SC.PerformInfinitePoint(Precision::Confusion());
if ( SC.State() == TopAbs_IN) {
BS.MakeSolid(solid);
myShape.Reverse();
BS.Add(solid,TopoDS::Shell(myShape));
}
myShape = solid;
}
}
#if DEB
else cout << "Draft : Pas d'assemblage !" << endl;
#endif
return Ok;
}
//=======================================================================
//function : Generated
//purpose : retourne une sous partie partie generes par balayage
//======================================================================
const TopTools_ListOfShape&
BRepFill_Draft::Generated(const TopoDS_Shape& S)
{
myGenerated.Clear();
TopoDS_Edge E;
Standard_Integer ii;
E = TopoDS::Edge(S);
if (E.IsNull()) {
for (ii=0; ii<=myLoc->NbLaw(); ii++)
if (E.IsSame(myLoc->Vertex(ii))) {
myGenerated.Append(mySections->Value(1, ii+1));
break;
}
}
else {
for (ii=1; ii<=myLoc->NbLaw(); ii++)
if (E.IsSame(myLoc->Edge(ii))) {
myGenerated.Append(myFaces->Value(1, ii));
break;
}
}
return myGenerated;
}
//=======================================================================
//function : Shape
//purpose : retourne la shape complete
//======================================================================
TopoDS_Shape BRepFill_Draft::Shape()const
{
return myShape;
}
//=======================================================================
//function : Shell
//purpose : surface de depouille avec la face entree (=>shell)
//======================================================================
TopoDS_Shell BRepFill_Draft::Shell()const
{
return myShell;
}
//=======================================================================
//function : IsDone
//purpose :
//======================================================================
Standard_Boolean BRepFill_Draft::IsDone()const
{
return myDone;
}

View File

@@ -0,0 +1,29 @@
-- File: BRepFill_LocationLaw.cdl
-- Created: Wed Jan 14 14:14:49 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class DraftLaw from BRepFill inherits Edge3DLaw from BRepFill
---Purpose: Build Location Law, with a Wire.
uses
LocationDraft from GeomFill,
Wire from TopoDS
is
Create (Path : Wire from TopoDS;
Law : LocationDraft from GeomFill)
returns DraftLaw from BRepFill;
CleanLaw(me : mutable; TolAngular : Real)
---Purpose: To clean the little discontinuities.
is static;
end DraftLaw;

View File

@@ -0,0 +1,61 @@
// File: BRepFill_DraftLaw.cxx
// Created: Wed Jan 14 14:41:23 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_DraftLaw.ixx>
#include <GeomFill_LocationDraft.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <GeomFill_HArray1OfLocationLaw.hxx>
#include <gp_Vec.hxx>
#include <gp_Mat.hxx>
#include <gp_XYZ.hxx>
#include <gp_Trsf.hxx>
//=======================================================================
//function : ToG0
//purpose : Cacul une tranformation T tq T.M2 = M1
//=======================================================================
static void ToG0(const gp_Mat& M1, const gp_Mat& M2, gp_Mat& T) {
T = M2.Inverted();
T *= M1;
}
BRepFill_DraftLaw::BRepFill_DraftLaw(const TopoDS_Wire & Path,
const Handle(GeomFill_LocationDraft) & Law)
:BRepFill_Edge3DLaw(Path, Law)
{
}
void BRepFill_DraftLaw::CleanLaw(const Standard_Real TolAngular)
{
Standard_Real First, Last;//, Angle;
Standard_Integer ipath;
gp_Mat Trsf, M1, M2;
gp_Vec V, T1, T2, N1, N2;
// gp_Dir D;
myLaws->Value(1)->GetDomain(First, Last);
// D = Handle(GeomFill_LocationDraft)::DownCast(myLaws->Value(1))->Direction();
// gp_Vec Vd(D);
for (ipath=2; ipath<=myLaws->Length(); ipath++) {
myLaws->Value(ipath-1)->D0(Last, M1, V);
myLaws->Value(ipath)->GetDomain(First, Last);
myLaws->Value(ipath)->D0(First, M2, V);
T1.SetXYZ(M1.Column(3));
T2.SetXYZ(M2.Column(3));
N1.SetXYZ(M1.Column(1));
N2.SetXYZ(M2.Column(1));
if (N1.IsParallel(N2, TolAngular)) { // Correction G0 des normales...
ToG0(M1, M2, Trsf);
myLaws->Value(ipath)->SetTrsf(Trsf);
}
}
}

View File

@@ -0,0 +1,21 @@
-- File: BRepFill_Edge3DLaw.cdl
-- Created: Mon Jul 27 13:29:02 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class Edge3DLaw from BRepFill inherits LocationLaw from BRepFill
---Purpose: Build Location Law, with a Wire.
uses
Wire from TopoDS,
LocationLaw from GeomFill
is
Create (Path : Wire from TopoDS;
Law : LocationLaw from GeomFill)
returns Edge3DLaw from BRepFill;
end Edge3DLaw;

View File

@@ -0,0 +1,64 @@
// File: BRepFill_Edge3DLaw.cxx
// Created: Mon Jul 27 14:13:11 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_Edge3DLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopExp.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <GeomFill_HArray1OfLocationLaw.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_HCurve.hxx>
BRepFill_Edge3DLaw::BRepFill_Edge3DLaw(const TopoDS_Wire& Path,
const Handle(GeomFill_LocationLaw)& Law)
{
Init(Path);
Standard_Integer ipath;
TopAbs_Orientation Or;
BRepTools_WireExplorer wexp;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
TopoDS_Edge E;
Handle(Geom_Curve) C;
Handle(GeomAdaptor_HCurve) AC;
Standard_Real First, Last;
for (ipath=0, wexp.Init(myPath);
wexp.More(); wexp.Next()) {
E = wexp.Current();
// if (!B.Degenerated(E)) {
if (!BRep_Tool::Degenerated(E)) {
ipath++;
myEdges->SetValue(ipath, E);
C = BRep_Tool::Curve(E,First,Last);
Or = E.Orientation();
if (Or == TopAbs_REVERSED) {
Handle(Geom_TrimmedCurve) CBis =
new (Geom_TrimmedCurve) (C, First, Last);
CBis->Reverse(); // Pour eviter de deteriorer la topologie
C = CBis;
First = C->FirstParameter();
Last = C->LastParameter();
}
AC = new (GeomAdaptor_HCurve) (C,First, Last);
myLaws->SetValue(ipath, Law->Copy());
myLaws->ChangeValue(ipath)->SetCurve(AC);
}
}
}

View File

@@ -0,0 +1,33 @@
-- File: BRepFill_EdgeFaceAndOrder.cdl
-- Created: Fri Oct 2 19:38:40 1998
-- Author: Julia GERASIMOVA
-- <jgv@redfox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
private class EdgeFaceAndOrder from BRepFill
---Purpose:
uses
Edge from TopoDS,
Face from TopoDS,
Shape from GeomAbs
is
Create returns EdgeFaceAndOrder from BRepFill;
Create( anEdge : Edge from TopoDS;
aFace : Face from TopoDS;
anOrder : Shape from GeomAbs )
returns EdgeFaceAndOrder from BRepFill;
fields
myEdge : Edge from TopoDS;
myFace : Face from TopoDS;
myOrder : Shape from GeomAbs;
friends
class Filling from BRepFill
end EdgeFaceAndOrder;

View File

@@ -0,0 +1,20 @@
// File: BRepFill_EdgeFaceAndOrder.cxx
// Created: Fri Oct 2 19:41:14 1998
// Author: Julia GERASIMOVA
// <jgv@redfox.nnov.matra-dtv.fr>
#include <BRepFill_EdgeFaceAndOrder.ixx>
BRepFill_EdgeFaceAndOrder::BRepFill_EdgeFaceAndOrder()
{
}
BRepFill_EdgeFaceAndOrder::BRepFill_EdgeFaceAndOrder( const TopoDS_Edge& anEdge,
const TopoDS_Face& aFace,
const GeomAbs_Shape anOrder )
{
myEdge = anEdge;
myFace = aFace;
myOrder = anOrder;
}

View File

@@ -0,0 +1,31 @@
-- File: BRepFill_EdgeOnSurfLaw.cdl
-- Created: Mon Jul 27 13:37:38 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class EdgeOnSurfLaw from BRepFill inherits LocationLaw from BRepFill
---Purpose: Build Location Law, with a Wire and a Surface.
uses
Wire from TopoDS,
Shape from TopoDS
is
Create (Path : Wire from TopoDS;
Surf : Shape from TopoDS)
returns EdgeOnSurfLaw from BRepFill;
HasResult(me)
---Purpose: returns <False> if one Edge of <Path> do not have
-- representation on <Surf>. In this case it is
-- impossible to use this object.
returns Boolean;
fields
hasresult : Boolean;
end EdgeOnSurfLaw;

View File

@@ -0,0 +1,97 @@
// File: BRepFill_EdgeOnSurfLaw.cxx
// Created: Mon Jul 27 14:30:36 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_EdgeOnSurfLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <GeomFill_HArray1OfLocationLaw.hxx>
#include <GeomFill_Darboux.hxx>
#include <GeomFill_CurveAndTrihedron.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <BRepAdaptor_HSurface.hxx>
BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path,
const TopoDS_Shape& Surf)
{
hasresult = Standard_True;
Init(Path);
Standard_Boolean Trouve;
Standard_Integer ipath;// ,NbEdge;
TopAbs_Orientation Or;
BRepTools_WireExplorer wexp;
TopExp_Explorer exp;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
TopoDS_Edge E;
Handle(Geom2d_Curve) C;
Handle(Geom2dAdaptor_HCurve) AC2d;
Handle(Adaptor3d_HCurveOnSurface) AC;
Handle(BRepAdaptor_HSurface) AS;
Standard_Real First, Last;
Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ;
Handle(GeomFill_CurveAndTrihedron) Law =
new (GeomFill_CurveAndTrihedron) (TLaw);
for (ipath=0, wexp.Init(myPath);
wexp.More(); wexp.Next()) {
E = wexp.Current();
// if (!B.Degenerated(E)) {
if (!BRep_Tool::Degenerated(E)) {
ipath++;
myEdges->SetValue(ipath, E);
for (Trouve=Standard_False, exp.Init(Surf, TopAbs_FACE);
exp.More() && !Trouve; exp.Next()) {
const TopoDS_Face& F = TopoDS::Face(exp.Current());
C = BRep_Tool::CurveOnSurface(E, F, First, Last);
if (!C.IsNull()) {
Trouve=Standard_True;
AS = new (BRepAdaptor_HSurface) (F);
}
}
if (!Trouve) { // Impossible de construire la loi.
hasresult = Standard_False;
myLaws.Nullify();
return;
}
Or = E.Orientation();
if (Or == TopAbs_REVERSED) {
Handle(Geom2d_TrimmedCurve) CBis =
new (Geom2d_TrimmedCurve) (C, First, Last);
CBis->Reverse(); // Pour eviter de deteriorer la topologie
C = CBis;
First = C->FirstParameter();
Last = C->LastParameter();
}
AC2d = new (Geom2dAdaptor_HCurve) (C,First, Last);
AC = new (Adaptor3d_HCurveOnSurface)
(Adaptor3d_CurveOnSurface(AC2d, AS));
myLaws->SetValue(ipath, Law->Copy());
myLaws->ChangeValue(ipath)->SetCurve(AC);
}
}
}
Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const
{
return hasresult;
}

256
src/BRepFill/BRepFill_Evolved.cdl Executable file
View File

@@ -0,0 +1,256 @@
-- File: BRepFill_Evolved.cdl
-- Created: Mon Oct 3 14:28:26 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
class Evolved from BRepFill
---Purpose: Constructs a evolved volume from a spine (wire or face)
-- and a profile ( wire).
uses
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Wire from TopoDS,
Shape from TopoDS,
Location from TopLoc,
Ax3 from gp,
JoinType from GeomAbs,
ListOfShape from TopTools,
DataMapOfShapeShape from TopTools,
DataMapOfShapeDataMapOfShapeListOfShape from BRepFill,
BisectingLocus from BRepMAT2d,
LinkTopoBilo from BRepMAT2d,
Quilt from BRepTools
raises
ConstructionError from Standard,
NoSuchObject from Standard
is
---Level: Public
Create returns Evolved from BRepFill;
Create ( Spine : Wire from TopoDS;
Profile : Wire from TopoDS;
AxeProf : Ax3 from gp;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Solid : Boolean from Standard = Standard_False)
returns Evolved from BRepFill
---Purpose: Creates an evolved shape by sweeping the <Profile>
-- along the <Spine>. <AxeProf> is used to set the
-- position of <Profile> along <Spine> as follow:
-- l <AxeProf> glisse sur le profil avec sa
-- direction colineaire a la normale au <Spine>, et sa
-- <XDirection> confondue avec la tangente au <Spine>.
--
raises
ConstructionError from Standard;
Create ( Spine : Face from TopoDS;
Profile : Wire from TopoDS;
AxeProf : Ax3 from gp;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Solid : Boolean from Standard = Standard_False)
returns Evolved from BRepFill
---Purpose: Creates an evolved shape by sweeping the <Profile>
-- along the <Spine>
raises
ConstructionError from Standard;
Perform (me : in out;
Spine : Wire from TopoDS;
Profile : Wire from TopoDS;
AxeProf : Ax3 from gp;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Solid : Boolean from Standard = Standard_False)
---Purpose: Performs an evolved shape by sweeping the <Profile>
-- along the <Spine>
raises
ConstructionError from Standard
is static;
Perform (me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS;
AxeProf : Ax3 from gp;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Solid : Boolean from Standard = Standard_False)
---Purpose: Performs an evolved shape by sweeping the <Profile>
-- along the <Spine>
raises
ConstructionError from Standard
is static;
IsDone ( me)
returns Boolean from Standard
is static;
Shape(me) returns Shape from TopoDS
---Purpose: returns the generated shape.
---C++ : return const &
is static;
GeneratedShapes (me ;
SpineShape : Shape from TopoDS;
ProfShape : Shape from TopoDS)
---Purpose: Returns the shapes created from a subshape
-- <SpineShape> of the spine and a subshape
-- <ProfShape> on the profile.
--
---C++ : return const &
returns ListOfShape from TopTools
is static;
JoinType (me) returns JoinType from GeomAbs
is static;
Top (me) returns Shape from TopoDS
---Purpose: Return the face Top if <Solid> is True in the constructor.
---C++ : return const &
is static;
Bottom (me) returns Shape from TopoDS
---Purpose: Return the face Bottom if <Solid> is True in the constructor.
---C++ : return const &
is static;
---Level: Internal
PrivatePerform (me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS;
AxeProf : Ax3 from gp;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Solid : Boolean from Standard = Standard_False)
raises
ConstructionError from Standard
is static private;
SetWork (me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS)
is static private;
ElementaryPerform ( me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS;
Locus : BisectingLocus from BRepMAT2d;
Link : in out LinkTopoBilo from BRepMAT2d;
Join : JoinType from GeomAbs = GeomAbs_Arc)
raises
ConstructionError from Standard
is static private;
PlanarPerform ( me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS;
Locus : BisectingLocus from BRepMAT2d;
Link : in out LinkTopoBilo from BRepMAT2d;
Join : JoinType from GeomAbs = GeomAbs_Arc)
raises
ConstructionError from Standard
is static private;
VerticalPerform ( me : in out;
Spine : Face from TopoDS;
Profile : Wire from TopoDS;
Locus : BisectingLocus from BRepMAT2d;
Link : in out LinkTopoBilo from BRepMAT2d;
Join : JoinType from GeomAbs = GeomAbs_Arc)
raises
ConstructionError from Standard
is static private;
Generated (me : in out )
---C++: return &
returns DataMapOfShapeDataMapOfShapeListOfShape from BRepFill
is static private;
Add ( me : in out; Vevo : in out Evolved from BRepFill;
Prof : Wire from TopoDS;
Glue : in out Quilt from BRepTools)
is static private;
ChangeShape(me : in out) returns Shape from TopoDS
---C++: return &
is static private;
Transfert( me : in out;
Vevo : in out Evolved from BRepFill;
MapProf : DataMapOfShapeShape from TopTools;
MapSpine : DataMapOfShapeShape from TopTools;
LS, InitLS, InitLP : Location from TopLoc)
is static private;
PrepareProfile ( me ; WorkProf : in out ListOfShape from TopTools;
MapProf : in out DataMapOfShapeShape from TopTools)
---Purpose: Prepare the profil as follow
-- - Project the profile in the yOz Plane
-- - Cut the profile at the extrema of distance from the
-- Profile to the Oz Axis.
-- - building the new wires with the cutting edges.
is static private;
PrepareSpine ( me ; WorkSpine : in out Face from TopoDS ;
SpineProf : in out DataMapOfShapeShape from TopTools)
---Purpose: Prepare the spine as follow
-- - Cut the spine-Edges at the extrema of curvature and
-- at the inflexion points.
is static private;
MakePipe (me : in out; SpineEdge : Edge from TopoDS ;
ProfRef : Ax3 from gp)
is static private;
MakeRevol(me : in out; SpineEdge : Edge from TopoDS;
SpineVertex : Vertex from TopoDS;
ProfRef : Ax3 from gp)
is static private;
FindLocation(me; Face : Face from TopoDS)
returns Location from TopLoc
---Purpose: Find the location transforming the planar shape <Shape>
-- in the plane xOy
raises NoSuchObject from Standard
---Purpose: if the Shape is not planar.
is static private;
TransformInitWork(me : in out; LS , LP : Location from TopLoc)
---Purpose: Apply the Location <LS> to <mySpine> and <LP> to
-- <myProfil>
-- in order to set the Shapes in the work space.
is static private;
ContinuityOnOffsetEdge (me : in out; WorkProf : ListOfShape from TopTools)
is static private;
AddTopAndBottom (me : in out;Glue : in out Quilt from BRepTools)
is static private;
MakeSolid(me : in out)
is static private;
fields
mySpine : Face from TopoDS;
myProfile : Wire from TopoDS;
myShape : Shape from TopoDS;
myIsDone : Boolean from Standard;
mySpineType : Boolean from Standard; -- True : Face ; False : Wire
myJoinType : JoinType from GeomAbs;
myMap : DataMapOfShapeDataMapOfShapeListOfShape from BRepFill;
myTop : Shape from TopoDS;
myBottom : Shape from TopoDS;
end Evolved;

3360
src/BRepFill/BRepFill_Evolved.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
-- File: BRepFill_FaceAndOrder.cdl
-- Created: Thu Sep 3 17:00:40 1998
-- Author: Julia GERASIMOVA
-- <jgv@clubox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
private class FaceAndOrder from BRepFill
---Purpose: A structure containing Face and Order of constraint
uses
Face from TopoDS,
Shape from GeomAbs
is
Create returns FaceAndOrder from BRepFill;
Create( aFace : Face from TopoDS;
anOrder : Shape from GeomAbs )
returns FaceAndOrder from BRepFill;
--Face(me : in out) returns Face from TopoDS;
-- ---C++: return &
--Order(me : in out) returns Integer from Standard;
-- ---C++: return &
fields
myFace : Face from TopoDS;
myOrder : Shape from GeomAbs;
friends
class Filling from BRepFill
end FaceAndOrder;

View File

@@ -0,0 +1,18 @@
// File: BRepFill_FaceAndOrder.cxx
// Created: Thu Sep 10 18:04:58 1998
// Author: Julia GERASIMOVA
// <jgv@redfox.nnov.matra-dtv.fr>
#include <BRepFill_FaceAndOrder.ixx>
BRepFill_FaceAndOrder::BRepFill_FaceAndOrder()
{
}
BRepFill_FaceAndOrder::BRepFill_FaceAndOrder( const TopoDS_Face& aFace,
const GeomAbs_Shape anOrder )
{
myFace = aFace;
myOrder = anOrder;
}

250
src/BRepFill/BRepFill_Filling.cdl Executable file
View File

@@ -0,0 +1,250 @@
-- File: BRepFill_Filling.cdl
-- Created: Wed Aug 26 11:47:28 1998
-- Author: Julia GERASIMOVA
-- <jgv@clubox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class Filling from BRepFill
---Purpose: N-Side Filling
-- This algorithm avoids to build a face from:
-- * a set of edges defining the bounds of the face and some
-- constraints the surface support has to satisfy
-- * a set of edges and points defining some constraints
-- the support surface has to satisfy
-- * an initial surface to deform for satisfying the constraints
-- * a set of parameters to control the constraints.
--
-- The support surface of the face is computed by deformation
-- of the initial surface in order to satisfy the given constraints.
-- The set of bounding edges defines the wire of the face.
--
-- If no initial surface is given, the algorithm computes it
-- automatically.
-- If the set of edges is not connected (Free constraint)
-- missing edges are automatically computed.
--
-- Limitations:
-- * If some constraints are not compatible
-- The algorithm does not take them into account.
-- So the constraints will not be satisfyed in an area containing
-- the incompatibilitries.
-- * The constraints defining the bound of the face have to be
-- entered in order to have a continuous wire.
--
-- Other Applications:
-- * Deformation of a face to satisfy internal constraints
-- * Deformation of a face to improve Gi continuity with
-- connected faces
---Level: Advanced
uses
Shape from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Pnt from gp,
Shape from GeomAbs,
BuildPlateSurface from GeomPlate,
SequenceOfEdgeFaceAndOrder from BRepFill,
SequenceOfFaceAndOrder from BRepFill,
SequenceOfPointConstraint from GeomPlate,
MapOfShape from TopTools,
SequenceOfPnt from TColgp
raises
NotDone,
OutOfRange,
ConstructionError
is
Create( Degree : Integer from Standard = 3;
NbPtsOnCur : Integer from Standard = 15;
NbIter : Integer from Standard = 2;
Anisotropie : Boolean from Standard = Standard_False;
Tol2d : Real from Standard = 0.00001;
Tol3d : Real from Standard = 0.0001;
TolAng : Real from Standard = 0.01;
TolCurv : Real from Standard = 0.1;
MaxDeg : Integer from Standard = 8;
MaxSegments : Integer from Standard = 9 )
---Purpose: Constructor
--
returns Filling from BRepFill;
SetConstrParam( me : in out; Tol2d : Real from Standard = 0.00001;
Tol3d : Real from Standard = 0.0001;
TolAng : Real from Standard = 0.01;
TolCurv : Real from Standard = 0.1 );
---Purpose: Sets the values of Tolerances used to control the constraint.
-- Tol2d:
-- Tol3d: it is the maximum distance allowed between the support surface
-- and the constraints
-- TolAng: it is the maximum angle allowed between the normal of the surface
-- and the constraints
-- TolCurv: it is the maximum difference of curvature allowed between
-- the surface and the constraint
SetResolParam( me : in out; Degree : Integer from Standard = 3;
NbPtsOnCur : Integer from Standard = 15;
NbIter : Integer from Standard = 2;
Anisotropie : Boolean from Standard = Standard_False );
---Purpose: Sets the parameters used for resolution.
-- The default values of these parameters have been chosen for a good
-- ratio quality/performance.
-- Degree: it is the order of energy criterion to minimize for computing
-- the deformation of the surface.
-- The default value is 3
-- The recommanded value is i+2 where i is the maximum order of the
-- constraints.
-- NbPtsOnCur: it is the average number of points for discretisation
-- of the edges.
-- NbIter: it is the maximum number of iterations of the process.
-- For each iteration the number of discretisation points is
-- increased.
-- Anisotropie:
SetApproxParam( me : in out; MaxDeg : Integer from Standard = 8;
MaxSegments : Integer from Standard = 9 );
---Purpose: Sets the parameters used for approximation of the surface
--
LoadInitSurface( me : in out; aFace : Face from TopoDS );
---Purpose: Loads the initial Surface
Add( me : in out; anEdge : Edge from TopoDS;
Order : Shape from GeomAbs;
IsBound : Boolean from Standard = Standard_True )
returns Integer from Standard
---Purpose: Adds a new constraint which also defines an edge of the wire
-- of the face
-- Order: Order of the constraint:
-- GeomAbs_C0 : the surface has to pass by 3D representation
-- of the edge
-- GeomAbs_G1 : the surface has to pass by 3D representation
-- of the edge and to respect tangency with the first
-- face of the edge
-- GeomAbs_G2 : the surface has to pass by 3D representation
-- of the edge and to respect tangency and curvature
-- with the first face of the edge.
raises ConstructionError from Standard;
-- if the edge has no representation on a face and Order is
-- GeomAbs_G1 or GeomAbs_G2.
Add( me : in out; anEdge : Edge from TopoDS;
Support : Face from TopoDS;
Order : Shape from GeomAbs;
IsBound : Boolean from Standard = Standard_True )
returns Integer from Standard
---Purpose: Adds a new constraint which also defines an edge of the wire
-- of the face
-- Order: Order of the constraint:
-- GeomAbs_C0 : the surface has to pass by 3D representation
-- of the edge
-- GeomAbs_G1 : the surface has to pass by 3D representation
-- of the edge and to respect tangency with the
-- given face
-- GeomAbs_G2 : the surface has to pass by 3D representation
-- of the edge and to respect tangency and curvature
-- with the given face.
raises ConstructionError from Standard;
-- if the edge has no 2d representation on the given face
Add( me : in out; Support : Face from TopoDS;
Order : Shape from GeomAbs )
returns Integer from Standard;
---Purpose: Adds a free constraint on a face. The corresponding edge has to
-- be automatically recomputed.
-- It is always a bound.
Add( me : in out; Point : Pnt from gp )
returns Integer from Standard;
---Purpose: Adds a punctual constraint
Add( me : in out; U, V : Real from Standard;
Support : Face from TopoDS;
Order : Shape from GeomAbs )
returns Integer from Standard;
---Purpose: Adds a punctual constraint.
AddConstraints( me : in out; SeqOfConstraints : SequenceOfEdgeFaceAndOrder from BRepFill )
---Purpose: Adds constraints to builder
is private;
BuildWires( me; EdgeMap : in out MapOfShape from TopTools;
WireList : out MapOfShape from TopTools )
---Purpose: Builds wires of maximum length
is private;
FindExtremitiesOfHoles( me; WireMap : in out MapOfShape from TopTools;
PntSeq : out SequenceOfPnt from TColgp )
---Purpose: Finds extremities of future edges to fix the holes between wires.
-- Can properly operate only with convex contour
is private;
Build( me : in out );
---Purpose: Builds the resulting faces
IsDone(me) returns Boolean from Standard;
Face(me) returns Face from TopoDS;
-- returns the resulting face
G0Error(me) returns Real from Standard;
-- returns the max distance between the result and the constraints
G1Error(me) returns Real from Standard;
-- returns the max angle between the result and the constraints
G2Error(me) returns Real from Standard;
-- returns the max difference of curvature between the result and the constraints
G0Error( me : in out; Index : Integer from Standard ) returns Real from Standard;
-- returns the max distance between the result and the constraint Index
G1Error( me : in out; Index : Integer from Standard ) returns Real from Standard;
-- returns the max angle between the result and the constraint Index
G2Error( me : in out; Index : Integer from Standard ) returns Real from Standard;
-- returns the max difference of curvature between the result and the constraint Index
fields
myBuilder : BuildPlateSurface from GeomPlate;
myBoundary : SequenceOfEdgeFaceAndOrder from BRepFill;
myConstraints : SequenceOfEdgeFaceAndOrder from BRepFill;
myFreeConstraints : SequenceOfFaceAndOrder from BRepFill;
myPoints : SequenceOfPointConstraint from GeomPlate;
myFace : Face from TopoDS;
myInitFace : Face from TopoDS;
-- Tolerances
myTol2d : Real from Standard;
myTol3d : Real from Standard;
myTolAng : Real from Standard;
myTolCurv : Real from Standard;
-- Parameters of approximation
myMaxDeg : Integer from Standard;
myMaxSegments : Integer from Standard;
-- Parameters of resolution
myDegree : Integer from Standard;
myNbPtsOnCur : Integer from Standard;
myNbIter : Integer from Standard;
myAnisotropie : Boolean from Standard;
myIsInitFaceGiven : Boolean from Standard;
myIsDone : Boolean from Standard;
end Filling;

681
src/BRepFill/BRepFill_Filling.cxx Executable file
View File

@@ -0,0 +1,681 @@
// File: BRepFill_Filling.cxx
// Created: Wed Aug 26 12:21:10 1998
// Author: Julia GERASIMOVA
// <jgv@clubox.nnov.matra-dtv.fr>
#include <BRepFill_Filling.ixx>
#include <BRepFill_EdgeFaceAndOrder.hxx>
#include <BRepFill_FaceAndOrder.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepAdaptor_HCurve2d.hxx>
#include <BRepFill_CurveConstraint.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <GeomPlate_MakeApprox.hxx>
#include <GeomPlate_CurveConstraint.hxx>
#include <GeomPlate_PointConstraint.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeEdge2d.hxx>
#include <BRepLib_MakeWire.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepLib_MakeFace.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <TopoDS_Vertex.hxx>
#include <Precision.hxx>
#include <GeomProjLib.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <TColgp_SequenceOfXY.hxx>
#include <GeomPlate_PlateG0Criterion.hxx>
#include <BRep_TVertex.hxx>
static gp_Vec MakeFinVec( const TopoDS_Wire aWire, const TopoDS_Vertex aVertex )
{
TopoDS_Vertex Vfirst, Vlast, Origin;
BRepTools_WireExplorer Explo( aWire );
for (; Explo.More(); Explo.Next())
{
TopExp::Vertices( Explo.Current(), Vfirst, Vlast );
if (Vfirst.IsSame( aVertex ))
{
Origin = Vlast;
break;
}
if (Vlast.IsSame( aVertex ))
{
Origin = Vfirst;
break;
}
}
return gp_Vec( BRep_Tool::Pnt( Origin ), BRep_Tool::Pnt( aVertex ) );
}
BRepFill_Filling::BRepFill_Filling( const Standard_Integer Degree,
const Standard_Integer NbPtsOnCur,
const Standard_Integer NbIter,
const Standard_Boolean Anisotropie,
const Standard_Real Tol2d,
const Standard_Real Tol3d,
const Standard_Real TolAng,
const Standard_Real TolCurv,
const Standard_Integer MaxDeg,
const Standard_Integer MaxSegments )
{
myDegree = Degree;
myNbPtsOnCur = NbPtsOnCur;
myNbIter = NbIter;
myAnisotropie = Anisotropie;
myTol2d = Tol2d;
myTol3d = Tol3d;
myTolAng = TolAng;
myTolCurv = TolCurv;
myMaxDeg = MaxDeg;
myMaxSegments = MaxSegments;
myIsInitFaceGiven = Standard_False;
myIsDone = Standard_False;
}
void BRepFill_Filling::SetConstrParam( const Standard_Real Tol2d,
const Standard_Real Tol3d,
const Standard_Real TolAng,
const Standard_Real TolCurv )
{
myTol2d = Tol2d;
myTol3d = Tol3d;
myTolAng = TolAng;
myTolCurv = TolCurv;
}
void BRepFill_Filling::SetResolParam( const Standard_Integer Degree,
const Standard_Integer NbPtsOnCur,
const Standard_Integer NbIter,
const Standard_Boolean Anisotropie )
{
myDegree = Degree;
myNbPtsOnCur = NbPtsOnCur;
myNbIter = NbIter;
myAnisotropie = Anisotropie;
}
void BRepFill_Filling::SetApproxParam( const Standard_Integer MaxDeg,
const Standard_Integer MaxSegments )
{
myMaxDeg = MaxDeg;
myMaxSegments = MaxSegments;
}
void BRepFill_Filling::LoadInitSurface( const TopoDS_Face& aFace )
{
myInitFace = aFace;
myIsInitFaceGiven = Standard_True;
}
Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
const GeomAbs_Shape Order,
const Standard_Boolean IsBound )
{
TopoDS_Face NullFace;
BRepFill_EdgeFaceAndOrder EdgeFaceAndOrder( anEdge, NullFace, Order );
if (IsBound)
{
myBoundary.Append( EdgeFaceAndOrder );
return myBoundary.Length();
}
else
{
myConstraints.Append( EdgeFaceAndOrder );
return (myBoundary.Length() + myFreeConstraints.Length() + myConstraints.Length());
}
}
Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
const TopoDS_Face& Support,
const GeomAbs_Shape Order,
const Standard_Boolean IsBound )
{
BRepFill_EdgeFaceAndOrder EdgeFaceAndOrder( anEdge, Support, Order );
if (IsBound)
{
myBoundary.Append( EdgeFaceAndOrder );
return myBoundary.Length();
}
else
{
myConstraints.Append( EdgeFaceAndOrder );
return (myBoundary.Length() + myFreeConstraints.Length() + myConstraints.Length());
}
}
Standard_Integer BRepFill_Filling::Add( const TopoDS_Face& Support,
const GeomAbs_Shape Order )
{
BRepFill_FaceAndOrder FaceAndOrder( Support, Order );
myFreeConstraints.Append( FaceAndOrder );
return (myBoundary.Length() + myFreeConstraints.Length());
}
Standard_Integer BRepFill_Filling::Add( const gp_Pnt& Point )
{
Handle( GeomPlate_PointConstraint ) aPC = new GeomPlate_PointConstraint( Point, GeomAbs_C0, myTol3d );
myPoints.Append( aPC );
return (myBoundary.Length() + myFreeConstraints.Length() + myConstraints.Length() + myPoints.Length());
}
Standard_Integer BRepFill_Filling::Add( const Standard_Real U,
const Standard_Real V,
const TopoDS_Face& Support,
const GeomAbs_Shape Order )
{
Handle( BRepAdaptor_HSurface ) HSurf = new BRepAdaptor_HSurface();
HSurf->ChangeSurface().Initialize( Support );
Handle( GeomPlate_PointConstraint ) aPC =
new GeomPlate_PointConstraint( U, V, BRep_Tool::Surface( HSurf->ChangeSurface().Face() ), Order,
myTol3d, myTolAng, myTolCurv );
myPoints.Append( aPC );
return (myBoundary.Length() + myFreeConstraints.Length() + myConstraints.Length() + myPoints.Length());
}
void BRepFill_Filling::AddConstraints( const BRepFill_SequenceOfEdgeFaceAndOrder& SeqOfConstraints )
{
TopoDS_Edge CurEdge;
TopoDS_Face CurFace;
GeomAbs_Shape CurOrder;
Handle(GeomPlate_CurveConstraint) Constr;
for (Standard_Integer i = 1; i <= SeqOfConstraints.Length(); i++)
{
CurEdge = SeqOfConstraints(i).myEdge;
CurFace = SeqOfConstraints(i).myFace;
CurOrder = SeqOfConstraints(i).myOrder;
if (CurFace.IsNull()) {
if (CurOrder == GeomAbs_C0) {
Handle( BRepAdaptor_HCurve ) HCurve = new BRepAdaptor_HCurve();
HCurve->ChangeCurve().Initialize( CurEdge );
Constr = new BRepFill_CurveConstraint(HCurve,
CurOrder,
myNbPtsOnCur,
myTol3d );
}
else { // Pas de representation Topologique
// On prend une representation Geometrique : au pif !
Handle( Geom_Surface ) Surface;
Handle( Geom2d_Curve ) C2d;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool BT;
TopLoc_Location loc;
Standard_Real f, l;
// BT.CurveOnSurface( CurEdge, C2d, Surface, loc, f, l);
BRep_Tool::CurveOnSurface( CurEdge, C2d, Surface, loc, f, l);
if (Surface.IsNull()) {
Standard_Failure::Raise( "Add" );
return;
}
Surface = Handle(Geom_Surface)::DownCast(Surface->Copy());
Surface->Transform(loc.Transformation());
Handle( GeomAdaptor_HSurface ) Surf = new GeomAdaptor_HSurface(Surface);
Handle( Geom2dAdaptor_HCurve ) Curve2d = new Geom2dAdaptor_HCurve(C2d);
Adaptor3d_CurveOnSurface CurvOnSurf( Curve2d, Surf );
Handle (Adaptor3d_HCurveOnSurface) HCurvOnSurf = new Adaptor3d_HCurveOnSurface( CurvOnSurf );
Constr = new GeomPlate_CurveConstraint(HCurvOnSurf,
CurOrder,
myNbPtsOnCur,
myTol3d,
myTolAng,
myTolCurv );
}
}
else
{
Handle( BRepAdaptor_HSurface ) Surf = new BRepAdaptor_HSurface();
Surf->ChangeSurface().Initialize( CurFace );
Handle( BRepAdaptor_HCurve2d ) Curve2d = new BRepAdaptor_HCurve2d();
Curve2d->ChangeCurve2d().Initialize( CurEdge, CurFace );
// If CurEdge has no 2d representation on CurFace,
// there will be exception "Attempt to access to null object"
// in this initialization (null pcurve).
Adaptor3d_CurveOnSurface CurvOnSurf( Curve2d, Surf );
Handle (Adaptor3d_HCurveOnSurface) HCurvOnSurf = new Adaptor3d_HCurveOnSurface( CurvOnSurf );
Constr = new BRepFill_CurveConstraint( HCurvOnSurf,
CurOrder,
myNbPtsOnCur,
myTol3d,
myTolAng,
myTolCurv );
}
if (myIsInitFaceGiven)
{
Handle( Geom2d_Curve ) Curve2d;
Standard_Real FirstPar, LastPar;
Curve2d = BRep_Tool::CurveOnSurface( CurEdge, myInitFace, FirstPar, LastPar );
if (! Curve2d.IsNull())
{
Curve2d = new Geom2d_TrimmedCurve( Curve2d, FirstPar, LastPar );
Constr->SetCurve2dOnSurf( Curve2d );
}
}
myBuilder.Add( Constr );
}
}
void BRepFill_Filling::BuildWires( TopTools_MapOfShape& EdgeMap, TopTools_MapOfShape& WireMap ) const
{
TopoDS_Wire CurWire;
TopoDS_Edge CurEdge;
TopoDS_Vertex Wfirst, Wlast, Efirst, Elast;
gp_Pnt Wp1, Wp2;
TopTools_MapIteratorOfMapOfShape MapIt;
while (! EdgeMap.IsEmpty())
{
BRepLib_MakeWire MW;
MapIt.Initialize( EdgeMap );
MW.Add( TopoDS::Edge( MapIt.Key() ) );
EdgeMap.Remove( MapIt.Key() );
CurWire = MW.Wire();
TopExp::Vertices( CurWire, Wfirst, Wlast );
Wp1 = BRep_Tool::Pnt( Wfirst );
Wp2 = BRep_Tool::Pnt( Wlast );
Standard_Boolean IsFound = Standard_True;
while (IsFound)
{
IsFound = Standard_False;
for (MapIt.Initialize( EdgeMap ); MapIt.More(); MapIt.Next())
{
CurEdge = TopoDS::Edge( MapIt.Key() );
TopExp::Vertices( CurEdge, Efirst, Elast );
Standard_Real dist = Wp1.Distance( BRep_Tool::Pnt( Efirst ) );
if (dist < BRep_Tool::Tolerance( Wfirst ) || dist < BRep_Tool::Tolerance( Efirst ))
{
MW.Add( CurEdge );
CurWire = MW.Wire();
Wfirst = Elast;
Wp1 = BRep_Tool::Pnt( Wfirst );
EdgeMap.Remove( CurEdge );
IsFound = Standard_True;
break;
}
dist = Wp1.Distance( BRep_Tool::Pnt( Elast ) );
if (dist < BRep_Tool::Tolerance( Wfirst ) || dist < BRep_Tool::Tolerance( Elast ))
{
MW.Add( CurEdge );
CurWire = MW.Wire();
Wfirst = Efirst;
Wp1 = BRep_Tool::Pnt( Wfirst );
EdgeMap.Remove( CurEdge );
IsFound = Standard_True;
break;
}
dist = Wp2.Distance( BRep_Tool::Pnt( Efirst ) );
if (dist < BRep_Tool::Tolerance( Wlast ) || dist < BRep_Tool::Tolerance( Efirst ))
{
MW.Add( CurEdge );
CurWire = MW.Wire();
Wlast = Elast;
Wp2 = BRep_Tool::Pnt( Wlast );
EdgeMap.Remove( CurEdge );
IsFound = Standard_True;
break;
}
dist = Wp2.Distance( BRep_Tool::Pnt( Elast ) );
if (dist < BRep_Tool::Tolerance( Wlast ) || dist < BRep_Tool::Tolerance( Elast ))
{
MW.Add( CurEdge );
CurWire = MW.Wire();
Wlast = Efirst;
Wp2 = BRep_Tool::Pnt( Wlast );
EdgeMap.Remove( CurEdge );
IsFound = Standard_True;
break;
}
} //for (MapIt.Init...
} //while (IsFound)
WireMap.Add( CurWire );
} //while (! EdgeMap.IsEmpty())
}
void BRepFill_Filling::FindExtremitiesOfHoles( TopTools_MapOfShape& WireMap, TColgp_SequenceOfPnt& PntSeq ) const
{
TopoDS_Wire theWire, CurWire;
TopTools_MapIteratorOfMapOfShape MapIt( WireMap );
theWire = TopoDS::Wire( MapIt.Key() );
WireMap.Remove( MapIt.Key() );
if (theWire.Closed())
return;
TopoDS_Vertex Vfirst, Vlast;
TopExp::Vertices( theWire, Vfirst, Vlast );
gp_Vec FinVec = MakeFinVec( theWire, Vlast );
gp_Pnt thePoint = BRep_Tool::Pnt( Vlast );
PntSeq.Append( thePoint );
while (! WireMap.IsEmpty())
{
gp_Pnt MinPnt;
TopoDS_Wire MinWire;
#ifndef DEB
Standard_Boolean IsLast = Standard_False;
#else
Standard_Boolean IsLast ;
#endif
Standard_Real MinAngle = PI;
for (MapIt.Initialize( WireMap ); MapIt.More(); MapIt.Next())
{
CurWire = TopoDS::Wire( MapIt.Key() );
TopExp::Vertices( CurWire, Vfirst, Vlast );
Standard_Real angle = FinVec.Angle( gp_Vec( thePoint, BRep_Tool::Pnt( Vfirst ) ) );
if (angle < MinAngle)
{
MinAngle = angle;
MinPnt = BRep_Tool::Pnt( Vfirst );
MinWire = CurWire;
IsLast = Standard_True;
}
angle = FinVec.Angle( gp_Vec( thePoint, BRep_Tool::Pnt( Vlast ) ) );
if (angle < MinAngle)
{
MinAngle = angle;
MinPnt = BRep_Tool::Pnt( Vlast );
MinWire = CurWire;
IsLast = Standard_False;
}
}
PntSeq.Append( MinPnt );
TopExp::Vertices( MinWire, Vfirst, Vlast );
if (IsLast)
{
FinVec = MakeFinVec( MinWire, Vlast );
thePoint = BRep_Tool::Pnt( Vlast );
}
else
{
FinVec = MakeFinVec( MinWire, Vfirst );
thePoint = BRep_Tool::Pnt( Vfirst );
}
PntSeq.Append( thePoint );
WireMap.Remove( MinWire );
}
TopExp::Vertices( theWire, Vfirst, Vlast );
PntSeq.Append( BRep_Tool::Pnt( Vfirst ) );
}
void BRepFill_Filling::Build()
{
GeomPlate_BuildPlateSurface thebuild( myDegree, myNbPtsOnCur, myNbIter,
myTol2d, myTol3d, myTolAng, myTolCurv, myAnisotropie );
myBuilder = thebuild;
TopoDS_Edge CurEdge;
TopoDS_Face CurFace;
Standard_Integer i, j;
//Creating array of points: extremities of wires
TColgp_SequenceOfPnt PntSeq;
//????????????
//Setting tollerance
for (i = 1; i <= myBoundary.Length(); i++)
{
TopoDS_Edge E (myBoundary(i).myEdge);
TopoDS_Vertex V1 (TopExp::FirstVertex( E ));
Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &V1.TShape());
if (TV1->Tolerance() > 0.001)
TV1->Tolerance( 0.001 );
TV1->Modified( Standard_True );
TopoDS_Vertex V2 (TopExp::LastVertex( E ));
Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &V2.TShape());
if (TV2->Tolerance() > 0.001)
TV2->Tolerance( 0.001 );
TV2->Modified( Standard_True );
}
//Building missing bounds
TopTools_MapOfShape EdgeMap, WireMap;
for (i = 1; i <= myBoundary.Length(); i++)
EdgeMap.Add( myBoundary(i).myEdge );
BuildWires( EdgeMap, WireMap );
FindExtremitiesOfHoles( WireMap, PntSeq );
//Searching for surfaces for missing bounds
for (j = 1; j <= myFreeConstraints.Length(); j++)
{
GeomAPI_ProjectPointOnSurf Projector;
Quantity_Parameter U1, V1, U2, V2;
CurFace = myFreeConstraints(j).myFace;
Handle( BRepAdaptor_HSurface ) HSurf = new BRepAdaptor_HSurface();
HSurf->ChangeSurface().Initialize( CurFace );
Handle( Geom_Surface ) CurSurface = BRep_Tool::Surface( HSurf->ChangeSurface().Face() );
//BRepTopAdaptor_FClass2d Classifier( CurFace, Precision::Confusion() );
for (i = 1; i <= PntSeq.Length(); i += 2)
{
Projector.Init( PntSeq.Value(i), CurSurface );
if (Projector.LowerDistance() > Precision::Confusion())
continue;
Projector.LowerDistanceParameters( U1, V1 );
/*
State = Classifier.Perform(gp_Pnt2d( U1, V1 ),
((HSurf->IsUPeriodic() || HSurf->IsVPeriodic())? Standard_True : Standard_False));
if (State == TopAbs_OUT || State == TopAbs_UNKNOWN)
continue;
*/
Projector.Init( PntSeq.Value(i+1), CurSurface );
if (Projector.LowerDistance() > Precision::Confusion())
continue;
Projector.LowerDistanceParameters( U2, V2 );
/*
State = Classifier.Perform(gp_Pnt2d( U2, V2 ),
((HSurf->IsUPeriodic() || HSurf->IsVPeriodic())? Standard_True : Standard_False));
if (State == TopAbs_OUT || State == TopAbs_UNKNOWN)
continue;
*/
//Making the constraint
TColgp_Array1OfPnt2d Points( 1, 2 );
Points(1) = gp_Pnt2d( U1, V1 );
Points(2) = gp_Pnt2d( U2, V2 );
Handle( Geom2d_BezierCurve ) Line2d = new Geom2d_BezierCurve( Points );
TopoDS_Edge E = BRepLib_MakeEdge( Line2d, CurSurface, Line2d->FirstParameter(), Line2d->LastParameter() );
Add( E, CurFace, myFreeConstraints(j).myOrder );
PntSeq.Remove( i, i+1 );
break;
} //for (i = 1; i <= PntSeq.Length(); i += 2)
} //for (j = 1; j <= myFreeConstraints.Length(); j++)
//Load initial surface to myBuilder if it is given
if (myIsInitFaceGiven)
{
Handle( BRepAdaptor_HSurface ) HSurfInit = new BRepAdaptor_HSurface();
HSurfInit->ChangeSurface().Initialize( myInitFace );
myBuilder.LoadInitSurface( BRep_Tool::Surface( HSurfInit->ChangeSurface().Face() ) );
}
//Adding constraints to myBuilder
AddConstraints( myBoundary );
myBuilder.SetNbBounds( myBoundary.Length() );
AddConstraints( myConstraints );
for (i = 1; i <= myPoints.Length(); i++)
myBuilder.Add( myPoints(i) );
myBuilder.Perform();
if (myBuilder.IsDone())
myIsDone = Standard_True;
else
{
myIsDone = Standard_False;
return;
}
Handle( GeomPlate_Surface ) GPlate = myBuilder.Surface();
Handle( Geom_BSplineSurface ) Surface;
// Approximation
Standard_Real dmax = 1.1 * myBuilder.G0Error(); //???????????
//Standard_Real dmax = myTol3d;
if (! myIsInitFaceGiven)
{
Standard_Real seuil; //?????
TColgp_SequenceOfXY S2d;
TColgp_SequenceOfXYZ S3d;
S2d.Clear();
S3d.Clear();
myBuilder.Disc2dContour(4,S2d);
myBuilder.Disc3dContour(4,0,S3d);
seuil = Max( myTol3d, 10*myBuilder.G0Error() ); //????????
GeomPlate_PlateG0Criterion Criterion( S2d, S3d, seuil );
GeomPlate_MakeApprox Approx( GPlate, Criterion, myTol3d, myMaxSegments, myMaxDeg );
Surface = Approx.Surface();
}
else
{
GeomPlate_MakeApprox Approx( GPlate, myTol3d, myMaxSegments, myMaxDeg, dmax, 0 ); //?????????????
//GeomConvert_ApproxSurface Approx( GPlate, myTol3d, GeomAbs_C1, GeomAbs_C1, myMaxDeg, myMaxDeg, myMaxSegments, 1 );
//Approx.Dump( cout );
Surface = Approx.Surface();
}
TopoDS_Wire W;
//Preparing EdgeMap for method BuildWires
EdgeMap.Clear();
WireMap.Clear();
PntSeq.Clear();
BRep_Builder B;
for (i = 1; i <= myBoundary.Length(); i++)
{
TopoDS_Edge E;
Handle( GeomPlate_CurveConstraint ) CC = myBuilder.CurveConstraint(i);
E = BRepLib_MakeEdge( CC->Curve2dOnSurf(),
Surface,
CC->FirstParameter(),
CC->LastParameter());
B.UpdateVertex( TopExp::FirstVertex(E), dmax );
B.UpdateVertex( TopExp::LastVertex(E), dmax );
BRepLib::BuildCurve3d( E );
EdgeMap.Add( E );
}
//Fixing the holes
TopTools_MapOfShape EdgeMap2;
TopTools_MapIteratorOfMapOfShape MapIt( EdgeMap );
for (; MapIt.More(); MapIt.Next())
EdgeMap2.Add( MapIt.Key() );
BuildWires( EdgeMap2, WireMap );
FindExtremitiesOfHoles( WireMap, PntSeq );
for (i = 1; i <= PntSeq.Length(); i += 2)
{
GeomAPI_ProjectPointOnSurf Projector;
Quantity_Parameter U1, V1, U2, V2;
Projector.Init( PntSeq.Value(i), Surface );
Projector.LowerDistanceParameters( U1, V1 );
Projector.Init( PntSeq.Value(i+1), Surface );
Projector.LowerDistanceParameters( U2, V2 );
//Making the edge on the resulting surface
TColgp_Array1OfPnt2d Points( 1, 2 );
Points(1) = gp_Pnt2d( U1, V1 );
Points(2) = gp_Pnt2d( U2, V2 );
Handle( Geom2d_BezierCurve ) Line2d = new Geom2d_BezierCurve( Points );
TopoDS_Edge E = BRepLib_MakeEdge( Line2d, Surface, Line2d->FirstParameter(), Line2d->LastParameter() );
B.UpdateVertex( TopExp::FirstVertex(E), dmax );
B.UpdateVertex( TopExp::LastVertex(E), dmax );
BRepLib::BuildCurve3d( E );
EdgeMap.Add( E );
}
WireMap.Clear();
BuildWires( EdgeMap, WireMap );
MapIt.Initialize( WireMap );
W = TopoDS::Wire( MapIt.Key() );
if (!(W.Closed()))
Standard_Failure::Raise("Wire is not closed");
myFace = BRepLib_MakeFace( Surface, W );
}
Standard_Boolean BRepFill_Filling::IsDone() const
{
return myIsDone;
}
TopoDS_Face BRepFill_Filling::Face() const
{
return myFace;
}
Standard_Real BRepFill_Filling::G0Error() const
{
return myBuilder.G0Error();
}
Standard_Real BRepFill_Filling::G1Error() const
{
return myBuilder.G1Error();
}
Standard_Real BRepFill_Filling::G2Error() const
{
return myBuilder.G2Error();
}
Standard_Real BRepFill_Filling::G0Error( const Standard_Integer Index )
{
return myBuilder.G0Error( Index );
}
Standard_Real BRepFill_Filling::G1Error( const Standard_Integer Index )
{
return myBuilder.G1Error( Index );
}
Standard_Real BRepFill_Filling::G2Error( const Standard_Integer Index )
{
return myBuilder.G2Error( Index );
}

View File

@@ -0,0 +1,78 @@
-- File: BRepFill_Generator.cdl
-- Created: Mon Mar 7 09:35:05 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
-- Modified: Thu Jul 2 16:47:35 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
-- add methods Generated and GeneratedShapes
---Copyright: Matra Datavision 1994
class Generator from BRepFill
---Purpose: Compute a topological surface ( a shell) using
-- generating wires. The face of the shell will be
-- ruled surfaces passing by the wires.
-- The wires must have the same number of edges.
uses
Wire from TopoDS,
Shell from TopoDS,
Shape from TopoDS,
SequenceOfShape from TopTools,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools
is
Create returns Generator from BRepFill;
AddWire( me : in out;
Wire : in Wire from TopoDS)
is static;
Perform( me : in out)
---Purpose: Compute the shell.
is static;
Shell(me)
---C++: return const&
---C++: inline
returns Shell from TopoDS
is static;
Generated (me )
---Purpose: Returns all the shapes created
---C++ : return const &
returns DataMapOfShapeListOfShape from TopTools
is static;
GeneratedShapes (me ;
SSection : Shape from TopoDS)
---Purpose: Returns the shapes created from a subshape
-- <SSection> of a section.
--
---C++ : return const &
returns ListOfShape from TopTools
is static;
fields
myWires : SequenceOfShape from TopTools;
myShell : Shell from TopoDS;
myMap : DataMapOfShapeListOfShape from TopTools;
end Generator;

View File

@@ -0,0 +1,970 @@
// File: BRepFill_Generator.cxx
// Created: Mon Mar 7 10:01:42 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
// Modified: Mon Feb 23 09:28:46 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// traitement des wires ponctuels
// Modified: Tue Mar 10 17:08:58 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// suite traitement des KPart, calcul d'une BezierCurve
// au lieu d'une extraction d'iso pour Edge3 et Edge4
// Modified: Mon Apr 6 15:47:44 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// correction KPart (PRO12929)
// Modified: Thu Apr 30 15:24:17 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// debug KPart
// Modified: Fri Jul 31 15:14:19 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// KPart semi-cone pointe en bas : calcul de Edge4
//
// ajout des methodes Generated et GeneratedShapes
// Modified: Mon Nov 23 12:22:04 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// CTS21701 : orientation de l'edge dans DetectKPart
#include <BRepFill_Generator.ixx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRep_Builder.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp_Explorer.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax3.hxx>
#include <gp_Circ.hxx>
#include <gp_Lin.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_Curve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <GeomFill_Generator.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <GeomFill.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Precision.hxx>
#include <BRepLib.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Geom_BSplineCurve.hxx>
#include <gp_Vec.hxx>
#include <GeomConvert.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRepTools.hxx>
//=======================================================================
//function : DetectKPart
//purpose :
//=======================================================================
Standard_Integer DetectKPart(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2)
{
// initialisations
Standard_Integer IType = 0;
// caracteristiques de la premiere edge
Standard_Real first1, last1, first2, last2, ff, ll;
TopLoc_Location loc;
TopoDS_Vertex V1, V2;
Handle(Geom_Curve) curv1, curv;
GeomAdaptor_Curve AdC1;
Standard_Boolean degen1 = BRep_Tool::Degenerated(Edge1);
// recherche de cas particulier
gp_Pnt pos1, pos;
Standard_Real dist;
#ifndef DEB
Standard_Real dist1 =0.;
#else
Standard_Real dist1;
#endif
gp_Ax1 axe1, axe;
if (degen1) {
IType = -2;
TopExp::Vertices(Edge1,V1,V2);
pos1 = BRep_Tool::Pnt(V1);
}
else {
curv1 = BRep_Tool::Curve(Edge1, loc, first1, last1);
curv1 =
Handle(Geom_Curve)::DownCast(curv1->Transformed(loc.Transformation()));
ff = first1;
ll = last1;
if (Edge1.Orientation() == TopAbs_REVERSED) {
curv1->Reverse();
first1 = curv1->ReversedParameter(ll);
last1 = curv1->ReversedParameter(ff);
}
AdC1.Load(curv1);
if (AdC1.GetType() == GeomAbs_Circle) {
// premiere section circulaire
IType = 1;
pos1 = AdC1.Circle().Location();
dist1 = AdC1.Circle().Radius();
axe1 = AdC1.Circle().Axis();
}
else if (AdC1.GetType() == GeomAbs_Line) {
// premiere section rectiligne
IType = 4;
pos1 = AdC1.Line().Location();
dist1 = AdC1.Value(first1).Distance(AdC1.Value(last1));
gp_Vec vec(AdC1.Value(first1),AdC1.Value(last1));
gp_Dir dir(vec);
axe1 = gp_Ax1(AdC1.Value(first1),dir);
}
else {
// premiere section quelconque
IType = 0;
}
}
if (IType!=0) {
Standard_Boolean degen2 = BRep_Tool::Degenerated(Edge2);
if (degen2) {
TopExp::Vertices(Edge2,V1,V2);
pos = BRep_Tool::Pnt(V1);
if (IType==1) {
// seul cas particulier avec une edge degeneree en bout : le cone
if (pos.IsEqual(pos1,Precision::Confusion())) {
// le sommet est confondu avec le centre du cercle
IType = 0;
}
else {
gp_Vec vec(pos1,pos);
gp_Dir dir(vec);
axe = gp_Ax1(pos1,dir);
if (axe.IsParallel(axe1,Precision::Angular())) {
// le sommet est bien sur l'axe du cercle
IType = 2;
}
else {
// sommet incorrect --> pas de cas particulier
IType = 0;
}
}
}
else if (IType != 4) { //not plane
// pas de cas particulier
IType = 0;
}
}
else {
curv = BRep_Tool::Curve(Edge2, loc, first2, last2);
curv =
Handle(Geom_Curve)::DownCast(curv->Transformed(loc.Transformation()));
ff = first2;
ll = last2;
if (Edge2.Orientation() == TopAbs_REVERSED) {
curv->Reverse();
first2 = curv->ReversedParameter(ll);
last2 = curv->ReversedParameter(ff);
}
GeomAdaptor_Curve AdC(curv);
if (IType>0 && IType<4) {
if (AdC.GetType() != GeomAbs_Circle) {
// section non circulaire --> pas de cas particulier
IType = 0;
}
else {
if (AdC.Circle().Axis()
.IsCoaxial(axe1,Precision::Angular(),Precision::Confusion())) {
// meme axe
if (Abs(AdC.Circle().Radius()-dist1)< Precision::Confusion()) {
// possibilite de cylindre ou de morceau de cylindre
Standard_Real h1 = Abs(last1-first1), h2 = Abs(last2-first2);
Standard_Boolean Same,
SameParametricLength = ( Abs(h1-h2) < Precision::PConfusion() );
Standard_Real m1=(first1+last1)/2., m2=(first2+last2)/2.;
gp_Pnt P1,P2;
gp_Vec DU;
AdC1.D1(m1,P1,DU);
AdC.D0(m2,P2);
Same = SameParametricLength
&& ( gp_Vec(P1,P2).IsNormal(DU,Precision::Angular()) ) ;
if (Same) {
// cylindre ou morceau de cylindre
IType = 1;
}
else {
// l'intervalle de definition n'est pas correct
IType = 0;
}
}
else {
// possibilite de tronc de cone
Standard_Real h1 = Abs(last1-first1), h2 = Abs(last2-first2);
Standard_Boolean Same,
SameParametricLength = ( Abs(h1-h2) < Precision::PConfusion() );
Standard_Real m1=(first1+last1)/2., m2=(first2+last2)/2.;
gp_Pnt P1,P2;
gp_Vec DU;
AdC1.D1(m1,P1,DU);
AdC.D0(m2,P2);
Same = SameParametricLength
&& ( gp_Vec(P1,P2).IsNormal(DU,Precision::Angular()) ) ;
if (Same) {
// tronc de cone
IType = 2;
}
else {
// l'intervalle de definition n'est pas correct
IType = 0;
}
}
if (AdC.Circle().Location().IsEqual(pos1,Precision::Confusion())) {
// les centres sont confondus
IType = 0;
}
}
else {
// axe different
if (AdC.Circle().Radius()==dist1) {
// tore ?
IType = 3;
}
else {
// rayon different --> pas de cas particulier
IType = 0;
}
}
}
}
else if (IType>=4) {
if (AdC.GetType() != GeomAbs_Line) {
// section non rectiligne --> pas de cas particulier
IType = 0;
}
else {
pos = AdC.Line().Location();
dist = AdC.Value(first2).Distance(AdC.Value(last2));
gp_Vec vec(AdC.Value(first2),AdC.Value(last2));
gp_Dir dir(vec);
axe = gp_Ax1(AdC.Value(first2),dir);
if (axe.IsParallel(axe1,Precision::Angular())) {
// droite parallele
if (Abs(dist-dist1)<Precision::Confusion()) {
gp_Dir dir(gp_Vec(AdC1.Value(first1),AdC.Value(first2)));
if (dir.IsNormal(gp_Dir(vec),Precision::Angular())) {
// plan
IType = 4;
}
else {
// extrusion ?
IType = 5;
}
}
else {
// longueur differente --> pas de cas particulier
IType = 0;
}
}
else {
// droite non parallele --> pas de cas particulier
IType = 0;
}
}
}
else if (IType==-2) {
if (AdC.GetType() == GeomAbs_Line)
IType = 4; //plane
else if (AdC.GetType() == GeomAbs_Circle)
{
// seul cas particulier avec une edge degeneree au debut : le cone
pos = AdC.Circle().Location();
axe = AdC.Circle().Axis();
if (pos1.IsEqual(pos,Precision::Confusion())) {
// le sommet est confondu avec le centre du cercle
IType = 0;
}
else {
gp_Vec vec(pos1,pos);
gp_Dir dir(vec);
axe1 = gp_Ax1(pos1,dir);
if (axe.IsParallel(axe1,Precision::Angular())) {
// le sommet est bien sur l'axe du cercle
IType = -2;
}
else {
// sommet incorrect --> pas de cas particulier
IType = 0;
}
}
}
else
IType = 0;
}
}
}
// tore et extrusion ne sont pas des cas part.
if (IType == 3 || IType == 5) IType = 0;
return IType;
}
//=======================================================================
//function : CreateKPart
//purpose :
//=======================================================================
void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
const Standard_Integer IType,
Handle(Geom_Surface)& Surf)
{
// find the dimension
TopoDS_Vertex V1, V2;
TopLoc_Location loc;
Standard_Real a1, b1, aa =0., bb =0.;
TopoDS_Vertex v1f,v1l,v2f,v2l;
// find characteristics of the first edge
Handle(Geom_Curve) C1;
Standard_Boolean degen1 = BRep_Tool::Degenerated(Edge1);
if(degen1) {
// cone avec arete degeneree au sommet
TopExp::Vertices(Edge1,v1f,v1l);
}
else {
C1 = BRep_Tool::Curve(Edge1, loc, a1, b1);
C1 = Handle(Geom_Curve)::DownCast(C1->Transformed(loc.Transformation()));
aa = a1;
bb = b1;
if (Edge1.Orientation() == TopAbs_REVERSED) {
C1->Reverse();
aa = C1->ReversedParameter(b1);
bb = C1->ReversedParameter(a1);
TopExp::Vertices(Edge1,v1l,v1f);
}
else {
TopExp::Vertices(Edge1,v1f,v1l);
}
}
// find characteristics of the second edge
Handle(Geom_Curve) C2;
Standard_Boolean degen2 = BRep_Tool::Degenerated(Edge2);
if(degen2) {
// cone avec arete degeneree au sommet
TopExp::Vertices(Edge2,v2f,v2l);
}
else {
C2 = BRep_Tool::Curve(Edge2, loc, a1, b1);
C2 = Handle(Geom_Curve)::DownCast(C2->Transformed(loc.Transformation()));
if (Edge2.Orientation() == TopAbs_REVERSED) {
C2->Reverse();
if (degen1) {
aa = a1;
bb = b1;
}
TopExp::Vertices(Edge2,v2l,v2f);
}
else {
if (degen1) {
aa = a1; //C2->ReversedParameter(b1);
bb = b1; //C2->ReversedParameter(a1);
}
TopExp::Vertices(Edge2,v2f,v2l);
}
}
// create the new surface
TopoDS_Shell shell;
TopoDS_Face face;
TopoDS_Wire W;
TopoDS_Edge edge1, edge2, edge3, edge4, couture;
BRep_Builder B;
B.MakeShell(shell);
TopoDS_Wire newW1, newW2;
BRep_Builder BW1, BW2;
BW1.MakeWire(newW1);
BW2.MakeWire(newW2);
// calculate the surface
Handle(Geom_Surface) surface;
Standard_Real V, Rad;
if (IType==1) {
// surface cylindrique
gp_Circ c1 = (Handle(Geom_Circle)::DownCast(C1))->Circ();
gp_Circ c2 = (Handle(Geom_Circle)::DownCast(C2))->Circ();
gp_Ax3 Ac1 = c1.Position();
V = gp_Vec( c1.Location(),c2.Location()).Dot(gp_Vec(Ac1.Direction()));
if ( V < 0.) {
Ac1.ZReverse();
V = -V;
}
Handle(Geom_CylindricalSurface) Cyl =
new Geom_CylindricalSurface( Ac1, c1.Radius());
surface = new Geom_RectangularTrimmedSurface
( Cyl, aa, bb, Min(0.,V), Max(0.,V) );
}
else if (IType==2) {
// surface conique
gp_Circ k1 = (Handle(Geom_Circle)::DownCast(C1))->Circ();
gp_Ax3 Ak1 = k1.Position();
if (degen2) {
V = gp_Vec( k1.Location(),BRep_Tool::Pnt(v2f))
.Dot(gp_Vec(Ak1.Direction()));
Rad = - k1.Radius();
}
else {
gp_Circ k2 = (Handle(Geom_Circle)::DownCast(C2))->Circ();
V = gp_Vec( k1.Location(),k2.Location()).Dot(gp_Vec(Ak1.Direction()));
Rad = k2.Radius() - k1.Radius();
}
if ( V < 0.) {
Ak1.ZReverse();
V = -V;
}
Standard_Real Ang = ATan( Rad / V);
Handle(Geom_ConicalSurface) Cone =
new Geom_ConicalSurface( Ak1, Ang, k1.Radius());
V /= Cos(Ang);
surface = new Geom_RectangularTrimmedSurface
( Cone, aa, bb, Min(0.,V), Max(0.,V) );
}
else if (IType==-2) {
// surface conique avec le sommet au debut (degen1 est vrai)
gp_Circ k2 = (Handle(Geom_Circle)::DownCast(C2))->Circ();
gp_Ax3 Ak2 = k2.Position();
Ak2.SetLocation(BRep_Tool::Pnt(v1f));
V = gp_Vec(BRep_Tool::Pnt(v1f),k2.Location())
.Dot(gp_Vec(Ak2.Direction()));
Rad = k2.Radius(); // - k2.Radius();
if ( V < 0.) {
Ak2.ZReverse();
V = -V;
}
Standard_Real Ang = ATan( Rad / V);
Handle(Geom_ConicalSurface) Cone =
new Geom_ConicalSurface( Ak2, Ang, 0.);
V /= Cos(Ang);
surface = new Geom_RectangularTrimmedSurface
( Cone, aa, bb, Min(0.,V), Max(0.,V) );
}
else if (IType==3) {
// surface torique ?
}
else if (IType==4) {
// surface plane
gp_Lin L1, L2, aLine;
if (!degen1)
{
L1 = (Handle(Geom_Line)::DownCast(C1))->Lin();
aLine = L1;
}
if (!degen2)
{
L2 = (Handle(Geom_Line)::DownCast(C2))->Lin();
aLine = L2;
}
gp_Pnt P1 = (degen1)? BRep_Tool::Pnt(v1f) : L1.Location();
gp_Pnt P2 = (degen2)? BRep_Tool::Pnt(v2f) : L2.Location();
gp_Vec P1P2( P1, P2 );
gp_Dir D1 = aLine.Direction();
gp_Ax3 Ax( aLine.Location(), gp_Dir(D1.Crossed(P1P2)), D1 );
Handle(Geom_Plane) Plan = new Geom_Plane(Ax);
V = P1P2.Dot( Ax.YDirection());
surface = Plan;
//surface = new Geom_RectangularTrimmedSurface
//( Plan, aa, bb, Min(0.,V), Max(0.,V) );
}
else if (IType==5) {
// surface d'extrusion ?
}
else {
// IType incorrect
}
Surf = surface;
}
//=======================================================================
//function : BRepFill_Generator
//purpose :
//=======================================================================
BRepFill_Generator::BRepFill_Generator()
{
}
//=======================================================================
//function : AddWire
//purpose :
//=======================================================================
void BRepFill_Generator::AddWire(const TopoDS_Wire& Wire)
{
myWires.Append( Wire);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepFill_Generator::Perform()
{
TopoDS_Shell Shell;
TopoDS_Face Face;
TopoDS_Shape S1, S2;
TopoDS_Edge Edge1, Edge2, Edge3, Edge4, Couture;
BRep_Builder B;
B.MakeShell(myShell);
Standard_Integer Nb = myWires.Length();
BRepTools_WireExplorer ex1,ex2;
Standard_Boolean wPoint1, wPoint2, uClosed, DegenFirst, DegenLast;
for ( Standard_Integer i = 1; i <= Nb-1; i++) {
TopoDS_Wire Wire1 = TopoDS::Wire(myWires( i ));
TopoDS_Wire Wire2 = TopoDS::Wire(myWires(i+1));
wPoint1 = Standard_False;
if (i==1) {
wPoint1 = Standard_True;
for(ex1.Init(Wire1); ex1.More(); ex1.Next()) {
wPoint1 = wPoint1 && (BRep_Tool::Degenerated(ex1.Current()));
}
DegenFirst = wPoint1;
TopoDS_Vertex V1, V2;
TopExp::Vertices(Wire1, V1, V2);
uClosed = V1.IsSame(V2);
}
wPoint2 = Standard_False;
if (i==Nb-1) {
wPoint2 = Standard_True;
for(ex2.Init(Wire2); ex2.More(); ex2.Next()) {
wPoint2 = wPoint2 && (BRep_Tool::Degenerated(ex2.Current()));
}
DegenLast = wPoint2;
}
ex1.Init(Wire1);
ex2.Init(Wire2);
TopTools_DataMapOfShapeShape Map;
Standard_Boolean tantque = ex1.More() && ex2.More();
while ( tantque ) {
TopoDS_Vertex V1f,V1l,V2f,V2l, Vf_toMap, Vl_toMap;
Standard_Boolean degen1
= BRep_Tool::Degenerated(TopoDS::Edge(ex1.Current()));
Standard_Boolean degen2
= BRep_Tool::Degenerated(TopoDS::Edge(ex2.Current()));
if ( degen1 ) {
TopoDS_Shape aLocalShape = ex1.Current().EmptyCopied();
Edge1 = TopoDS::Edge(aLocalShape);
// Edge1 = TopoDS::Edge(ex1.Current().EmptyCopied());
// aLocalShape = ex1.Current();
// TopExp::Vertices(TopoDS::Edge(aLocalShape),V1f,V1l);
TopExp::Vertices(TopoDS::Edge(ex1.Current()),V1f,V1l);
V1f.Orientation(TopAbs_FORWARD);
B.Add(Edge1,V1f);
V1l.Orientation(TopAbs_REVERSED);
B.Add(Edge1,V1l);
B.Range(Edge1,0,1);
}
else {
TopoDS_Shape aLocalShape = ex1.Current();
Edge1 = TopoDS::Edge(aLocalShape);
// Edge1 = TopoDS::Edge(ex1.Current());
}
if ( degen2 ) {
TopoDS_Shape aLocalShape = ex2.Current().EmptyCopied();
Edge2 = TopoDS::Edge(aLocalShape);
// Edge2 = TopoDS::Edge(ex2.Current().EmptyCopied());
TopExp::Vertices(TopoDS::Edge(ex2.Current()),V2f,V2l);
V2f.Orientation(TopAbs_FORWARD);
B.Add(Edge2,V2f);
V2l.Orientation(TopAbs_REVERSED);
B.Add(Edge2,V2l);
B.Range(Edge2,0,1);
}
else {
Edge2 = TopoDS::Edge(ex2.Current());
}
Standard_Boolean Periodic
= (Edge1.Closed() || degen1) && (Edge2.Closed() || degen2);
// ATTENTION : un wire non ponctuel ne doit pas
// contenir une edge ponctuelle
if (!wPoint1) ex1.Next();
if (!wPoint2) ex2.Next();
// initialisation des vertices
Handle(Geom_Surface) Surf;
Standard_Real f1=0, l1=1, f2=0, l2=1;
if (Edge1.Orientation() == TopAbs_REVERSED)
TopExp::Vertices(Edge1,V1l,V1f);
else
TopExp::Vertices(Edge1,V1f,V1l);
if (Edge2.Orientation() == TopAbs_REVERSED)
TopExp::Vertices(Edge2,V2l,V2f);
else
TopExp::Vertices(Edge2,V2f,V2l);
if (degen1)
{
Vf_toMap = V2f;
Vl_toMap = V2l;
}
else
{
Vf_toMap = V1f;
Vl_toMap = V1l;
}
if(Periodic) {
Standard_Boolean E1IsReallyClosed = BRepTools::Compare(V1f,V1l);
Standard_Boolean E2IsReallyClosed = BRepTools::Compare(V2f,V2l);
Periodic
= (E1IsReallyClosed || degen1) && (E2IsReallyClosed || degen2);
}
// traitement des KPart
Standard_Integer IType = DetectKPart(Edge1,Edge2);
if (IType==0) {
// pas de cas part
TopLoc_Location L,L1,L2;
Handle(Geom_Curve) C1, C2;
TColgp_Array1OfPnt Extremities(1,2);
if (degen1) {
Extremities(1) = BRep_Tool::Pnt(V1f);
Extremities(2) = BRep_Tool::Pnt(V1l);
C1 = new Geom_BezierCurve(Extremities);
}
else {
C1 = BRep_Tool::Curve(Edge1,L1,f1,l1);
}
if (degen2) {
Extremities(1) = BRep_Tool::Pnt(V2l);
Extremities(2) = BRep_Tool::Pnt(V2f);
C2 = new Geom_BezierCurve(Extremities);
}
else {
C2 = BRep_Tool::Curve(Edge2,L2,f2,l2);
}
// compute the location
Standard_Boolean SameLoc = Standard_False;
// transform and trim the curves
if (Abs(f1 - C1->FirstParameter()) > Precision::PConfusion() ||
Abs(l1 - C1->LastParameter()) > Precision::PConfusion() ) {
C1 = new Geom_TrimmedCurve(C1,f1,l1);
}
else {
C1 = Handle(Geom_Curve)::DownCast(C1->Copy());
}
if (!SameLoc) C1->Transform(L1.Transformation());
if (Edge1.Orientation() == TopAbs_REVERSED) {
C1->Reverse();
}
if (Abs(f2 - C2->FirstParameter()) > Precision::PConfusion() ||
Abs(l2 - C2->LastParameter()) > Precision::PConfusion() ) {
C2 = new Geom_TrimmedCurve(C2,f2,l2);
}
else {
C2 = Handle(Geom_Curve)::DownCast(C2->Copy());
}
if (!SameLoc) C2->Transform(L2.Transformation());
if (Edge2.Orientation() == TopAbs_REVERSED) {
C2->Reverse();
}
GeomFill_Generator Generator;
Generator.AddCurve( C1);
Generator.AddCurve( C2);
Generator.Perform( Precision::PConfusion());
Surf = Generator.Surface();
B.MakeFace(Face,Surf,Precision::Confusion());
}
else {
// cas particulier
CreateKPart(Edge1,Edge2,IType,Surf);
B.MakeFace(Face,Surf,Precision::Confusion());
}
// make the missing edges
Standard_Real first,last;
Surf->Bounds(f1,l1,f2,l2);
if ( Map.IsBound(Vf_toMap)) {
TopoDS_Shape aLocalShape = Map(Vf_toMap).Reversed();
Edge3 = TopoDS::Edge(aLocalShape);
// Edge3 = TopoDS::Edge(Map(V1f).Reversed());
}
else {
Handle(Geom_Curve) CC;
TColgp_Array1OfPnt Extremities(1,2);
if (IType==0) {
// cas general : Edge3 correspond a l'iso U=f1
CC = Surf->UIso(f1);
first=f2;
last=l2;
}
else {
// cas particulier : il faut calculer la courbe 3d
Extremities(1) = BRep_Tool::Pnt(V1f);
Extremities(2) = BRep_Tool::Pnt(V2f);
CC = new Geom_BezierCurve(Extremities);
first=0.;
last=1.;
}
B.MakeEdge(Edge3,CC,Precision::Confusion());
V1f.Orientation(TopAbs_FORWARD);
B.Add(Edge3,V1f);
V2f.Orientation(TopAbs_REVERSED);
B.Add(Edge3,V2f);
B.Range(Edge3,first,last);
Edge3.Reverse();
Map.Bind(Vf_toMap, Edge3);
}
Standard_Boolean CommonEdge = Standard_False;
if ( Map.IsBound(Vl_toMap) ) {
TopoDS_Shape aLocalShape = Map(Vl_toMap).Reversed();
const TopoDS_Edge CommonE = TopoDS::Edge(aLocalShape);
// const TopoDS_Edge CommonE = TopoDS::Edge(Map(V1l).Reversed());
TopoDS_Vertex V1, V2;
TopExp::Vertices(CommonE,V1,V2);
CommonEdge = V1.IsSame(V1l) && V2.IsSame(V2l);
}
if ( CommonEdge ) {
TopoDS_Shape aLocalShape = Map(Vl_toMap).Reversed();
Edge4 = TopoDS::Edge(aLocalShape);
// Edge4 = TopoDS::Edge(Map(V1l).Reversed());
}
else {
Handle(Geom_Curve) CC;
TColgp_Array1OfPnt Extremities(1,2);
if (IType==0) {
// cas general : Edge4 correspond a l'iso U=l1
CC = Surf->UIso(l1);
first=f2;
last=l2;
}
else {
// cas particulier : il faut calculer la courbe 3d
Extremities(1) = BRep_Tool::Pnt(V1l);
Extremities(2) = BRep_Tool::Pnt(V2l);
CC = new Geom_BezierCurve(Extremities);
first=0.;
last=1.;
}
B.MakeEdge(Edge4,CC,Precision::Confusion());
V1l.Orientation(TopAbs_FORWARD);
B.Add(Edge4,V1l);
V2l.Orientation(TopAbs_REVERSED);
B.Add(Edge4,V2l);
B.Range(Edge4,first,last);
Map.Bind(Vl_toMap, Edge4);
}
// make the wire
TopoDS_Wire W;
B.MakeWire(W);
if (! (degen1 && IType == 4))
B.Add(W,Edge1);
B.Add(W,Edge4);
if (! (degen2 && IType == 4))
B.Add(W,Edge2.Reversed());
B.Add(W,Edge3);
B.Add(Face,W);
B.Add(myShell,Face);
// complete myMap for edge1
if (! (degen1 && IType == 4))
{
TopTools_ListOfShape Empty;
if (!myMap.IsBound(Edge1)) myMap.Bind(Edge1,Empty);
myMap(Edge1).Append(Face);
}
// set the pcurves
Standard_Real T = Precision::Confusion();
if (IType != 4) //not plane
{
if ( Edge1.Orientation() == TopAbs_REVERSED ) {
B.UpdateEdge(Edge1,
new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(-1,0)),
Face,T);
B.Range(Edge1,Face,-l1,-f1);
}
else {
B.UpdateEdge(Edge1,
new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(1,0)),
Face,T);
B.Range(Edge1,Face,f1,l1);
}
if ( Edge2.Orientation() == TopAbs_REVERSED ) {
B.UpdateEdge(Edge2,
new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(-1,0)),
Face,T);
B.Range(Edge2,Face,-l1,-f1);
}
else {
B.UpdateEdge(Edge2,
new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(1,0)),
Face,T);
B.Range(Edge2,Face,f1,l1);
}
}
if (IType==0) {
if ( Periodic) {
B.UpdateEdge(Edge3,
new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),
new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),
Face,T);
}
else {
B.UpdateEdge(Edge3,
new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),
Face,T);
B.UpdateEdge(Edge4,
new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),
Face,T);
}
}
else {
// KPart
if ( Periodic) {
TColgp_Array1OfPnt2d Extrem1(1,2);
Extrem1(1).SetCoord(l1,f2);
Extrem1(2).SetCoord(l1,l2);
TColgp_Array1OfPnt2d Extrem2(1,2);
Extrem2(1).SetCoord(f1,f2);
Extrem2(2).SetCoord(f1,l2);
B.UpdateEdge(Edge3,
new Geom2d_BezierCurve(Extrem1),
new Geom2d_BezierCurve(Extrem2),
Face,T);
}
else if (IType != 4) { //not plane
TColgp_Array1OfPnt2d Extrem2(1,2);
Extrem2(1).SetCoord(f1,f2);
Extrem2(2).SetCoord(f1,l2);
B.UpdateEdge(Edge3,
new Geom2d_BezierCurve(Extrem2),
Face,T);
TColgp_Array1OfPnt2d Extrem1(1,2);
Extrem1(1).SetCoord(l1,f2);
Extrem1(2).SetCoord(l1,l2);
B.UpdateEdge(Edge4,
new Geom2d_BezierCurve(Extrem1),
Face,T);
}
}
// Set the non parameter flag;
B.SameParameter(Edge1,Standard_False);
B.SameParameter(Edge2,Standard_False);
B.SameParameter(Edge3,Standard_False);
B.SameParameter(Edge4,Standard_False);
B.SameRange(Edge1,Standard_False);
B.SameRange(Edge2,Standard_False);
B.SameRange(Edge3,Standard_False);
B.SameRange(Edge4,Standard_False);
tantque = ex1.More() && ex2.More();
if (wPoint1) tantque = ex2.More();
if (wPoint2) tantque = ex1.More();
}
}
BRepLib::SameParameter(myShell);
if (uClosed && DegenFirst && DegenLast)
myShell.Closed(Standard_True);
}
//=======================================================================
//function : GeneratedShapes
//purpose :
//=======================================================================
const TopTools_ListOfShape&
BRepFill_Generator::GeneratedShapes (const TopoDS_Shape& SSection) const
{
if (myMap.IsBound(SSection)) {
return myMap(SSection);
}
else {
static TopTools_ListOfShape Empty;
return Empty;
}
}
//=======================================================================
//function : Generated
//purpose :
//=================================================================== ====
const TopTools_DataMapOfShapeListOfShape& BRepFill_Generator::Generated() const
{
return myMap;
}

View File

@@ -0,0 +1,16 @@
// File: BRepFill_Generator.lxx
// Created: Mon Mar 7 10:00:22 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
//=======================================================================
//function : Shell
//purpose :
//=======================================================================
inline const TopoDS_Shell& BRepFill_Generator::Shell() const
{
return myShell;
}

View File

@@ -0,0 +1,164 @@
-- File: BRepFill_LocationLaw.cdl
-- Created: Wed Jan 14 14:14:49 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
deferred class LocationLaw from BRepFill inherits TShared from MMgt
---Purpose: Location Law on a Wire.
---Level: Advanced
uses
LocationLaw from GeomFill,
HArray1OfLocationLaw from GeomFill,
PipeError from GeomFill,
HArray1OfReal from TColStd,
Array1OfInteger from TColStd,
HArray1OfInteger from TColStd,
HArray1OfShape from TopTools,
Shape from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Vertex from TopoDS
raises
OutOfRange from Standard
is
Init (me : mutable; Path : Wire from TopoDS)
---Purpose: Initialize all the fields, this methode have to
-- be called by the constructors of Inherited class.
is protected;
GetStatus(me)
---Purpose: Return a error status, if the status is not PipeOk then
-- it exist a parameter tlike the law is not valuable for t.
returns PipeError from GeomFill;
TransformInG0Law(me : mutable)
---Purpose: Apply a linear transformation on each law, to have
-- continuity of the global law beetween the edges.
is virtual;
TransformInCompatibleLaw(me : mutable;
AngularTolerance : Real)
---Purpose: Apply a linear transformation on each law, to reduce
-- the dicontinuities of law at one rotation.
is virtual;
TangentIsMain(me : mutable)
---Purpose: To preseve if possible the Tangent in transformations
-- It is the default mode.
is protected;
NormalIsMain(me : mutable)
---Purpose: To preseve if possible the Normal in transformations
is protected;
BiNormalIsMain(me : mutable)
---Purpose: To preseve if possible the BiNormal in transformations
is protected;
DeleteTransform(me : mutable)
is static;
NbHoles(me: mutable; Tol : Real = 1.0e-7)
returns Integer;
Holes(me; Interval : out Array1OfInteger from TColStd);
NbLaw(me)
---Purpose: Return the number of elementary Law
returns Integer;
Law(me; Index : Integer)
---Purpose: Return the elementary Law of rank <Index>
-- <Index> have to be in [1, NbLaw()]
---C++: return const &
returns LocationLaw from GeomFill
raises OutOfRange;
Wire(me)
---Purpose: return the path
---C++: return const &
returns Wire from TopoDS;
Edge(me; Index : Integer)
---Purpose: Return the Edge of rank <Index> in the path
-- <Index> have to be in [1, NbLaw()]
---C++: return const &
returns Edge from TopoDS
raises OutOfRange;
Vertex(me; Index : Integer)
---Purpose: Return the vertex of rank <Index> in the path
-- <Index> have to be in [0, NbLaw()]
returns Vertex from TopoDS
raises OutOfRange;
PerformVertex(me; Index : Integer;
InputVertex : Vertex from TopoDS;
TolMin : Real;
OutputVertex : out Vertex;
Location : Integer = 0)
---Purpose: Compute <OutputVertex> like a transformation of
-- <InputVertex> the transformation is given by
-- evaluation of the location law in the vertex of
-- rank <Index>.
-- <Location> is used to manage discontinuities :
-- - -1 : The law before the vertex is used.
-- - 1 : The law after the vertex is used.
-- - 0 : Average of the both laws is used.
is static;
CurvilinearBounds(me; Index : Integer;
First, Last :out Real);
---Purpose:Return the Curvilinear Bounds of the <Index> Law
IsClosed(me) returns Boolean;
IsG1(me; Index : Integer;
SpatialTolerance : Real = 1.0e-7;
AngularTolerance : Real = 1.0e-4)
---Purpose: Compute the Law's continuity beetween 2 edges of the path
-- The result can be :
-- -1 : Case Not connex
-- 0 : It is connex (G0)
-- 1 : It is tangent (G1)
returns Integer;
D0(me:mutable; Abscissa :Real;
Section : in out Shape from TopoDS);
---Purpose: Apply the Law to a shape, for a given Curnilinear abscissa
Parameter(me:mutable; Abscissa :Real;
Index : out Integer;
Param : out Real);
---Purpose: Find the index Law and the parmaeter, for a given
-- Curnilinear abscissa
Abscissa(me:mutable; Index : Integer;
Param : Real)
---Purpose:Return the curvilinear abscissa corresponding to a point
-- of the path, defined by <Index> of Edge and a
-- parameter on the edge.
returns Real;
fields
myPath : Wire from TopoDS is protected;
myTol : Real is protected;
myLaws : HArray1OfLocationLaw from GeomFill is protected;
myLength : HArray1OfReal from TColStd is protected;
myEdges : HArray1OfShape from TopTools is protected;
myDisc : HArray1OfInteger from TColStd is protected;
myType : Integer;
end LocationLaw;

View File

@@ -0,0 +1,635 @@
// File: BRepFill_LocationLaw.cxx
// Created: Wed Jan 14 14:41:23 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_LocationLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <gp_Vec.hxx>
#include <gp_Mat.hxx>
#include <gp_XYZ.hxx>
#include <gp_Trsf.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Precision.hxx>
//=======================================================================
//function : Norm
//purpose : Norme d'une Matrice
//=======================================================================
static Standard_Real Norm(const gp_Mat& M) {
Standard_Real R, Norme;
gp_XYZ Coord;
Coord = M.Row(1);
Norme = Abs(Coord.X()) + Abs(Coord.Y())+ Abs(Coord.Z());
Coord = M.Row(2);
R = Abs(Coord.X()) + Abs(Coord.Y())+ Abs(Coord.Z());
if (R>Norme) Norme = R;
Coord = M.Row(3);
R = Abs(Coord.X()) + Abs(Coord.Y())+ Abs(Coord.Z());
if (R>Norme) Norme = R;
return Norme;
}
//=======================================================================
//function : ToG0
//purpose : Cacul une tranformation T tq T.M2 = M1
//=======================================================================
static void ToG0(const gp_Mat& M1, const gp_Mat& M2, gp_Mat& T) {
T = M2.Inverted();
T *= M1;
}
//=======================================================================
//function : BRepFill_LocationLaw
//purpose :
//=======================================================================
void BRepFill_LocationLaw::Init(const TopoDS_Wire& Path)
{
Standard_Integer NbEdge;
BRepTools_WireExplorer wexp;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
TopoDS_Edge E;
myPath = Path;
myTol = 1.e-4;
for (NbEdge=0, wexp.Init(myPath);
wexp.More(); wexp.Next())
// if (! B.Degenerated(wexp.Current())) NbEdge++;
if (! BRep_Tool::Degenerated(wexp.Current())) NbEdge++;
myLaws = new (GeomFill_HArray1OfLocationLaw)(1, NbEdge);
myLength = new (TColStd_HArray1OfReal) (1, NbEdge+1);
myLength->Init(-1.);
myLength->SetValue(1, 0.);
myEdges = new (TopTools_HArray1OfShape) (1, NbEdge);
myDisc.Nullify();
TangentIsMain();
}
//=======================================================================
//function : GetStatus
//purpose :
//=======================================================================
GeomFill_PipeError BRepFill_LocationLaw::GetStatus() const
{
Standard_Integer ii, N = myLaws->Length();
GeomFill_PipeError Status = GeomFill_PipeOk;
for (ii=1; ii<=N && (Status == GeomFill_PipeOk); ii++) {
Status = myLaws->Value(ii)->ErrorStatus();
}
return Status;
}
//=======================================================================
//function : TangentIsMain
//purpose :
//=======================================================================
void BRepFill_LocationLaw::TangentIsMain()
{
myType = 1;
}
//=======================================================================
//function : NormalIsMain
//purpose :
//=======================================================================
void BRepFill_LocationLaw::NormalIsMain()
{
myType = 2;
}
//=======================================================================
//function : BiNormalIsMain
//purpose :
//=======================================================================
void BRepFill_LocationLaw::BiNormalIsMain()
{
myType = 3;
}
//=======================================================================
//function : TransformInCompatibleLaw
//purpose : Mise en continuite des loi
//=======================================================================
void BRepFill_LocationLaw::TransformInCompatibleLaw(const Standard_Real TolAngular)
{
Standard_Real First, Last, Angle;
Standard_Integer ipath;
gp_Mat Trsf, M1, M2;
gp_Vec V, T1, T2, N1, N2;
gp_XYZ OZ(0, 0, 1);
myLaws->Value(1)->GetDomain(First, Last);
for (ipath=2; ipath<=myLaws->Length(); ipath++) {
myLaws->Value(ipath-1)->D0(Last, M1, V);
myLaws->Value(ipath)->GetDomain(First, Last);
myLaws->Value(ipath)->D0(First, M2, V);
T1.SetXYZ(M1.Column(3));
T2.SetXYZ(M2.Column(3));
N1.SetXYZ(M1.Column(1));
N2.SetXYZ(M2.Column(1));
if (T1.IsParallel(T2, TolAngular ) &&
!T1.IsOpposite(T2, TolAngular)) { // Correction G0
ToG0(M1, M2, Trsf);
}
else {
Standard_Real alpha;
gp_Vec cross(T1);
cross.Cross(T2);
alpha = T2.AngleWithRef(T1, cross);
gp_Ax1 axe(gp::Origin(), cross.XYZ());
N2.Rotate(axe, alpha);
#if DEB
if (N2.Dot(T1) > 1.e-9) {
cout << "Imprecision dans TransformInCompatibleLaw" << endl;
cout << "--- T1.R(N2) = " << N2.Dot(T1) << endl;
gp_Vec tt;
tt = T1;
tt.Rotate(axe, alpha);
cout << "--- T1.R(T2) = " << tt.Dot(T1) << endl;
cout << "--- R(N2).R(T2) = " << N2.Dot(tt) << endl;
}
#endif
Angle = N2.AngleWithRef(N1, T1);
Trsf.SetRotation(OZ, Angle);
}
myLaws->Value(ipath)->SetTrsf(Trsf);
}
}
//=======================================================================
//function : TransformInG0Law
//purpose : Mise en continuite des loi
//=======================================================================
void BRepFill_LocationLaw::TransformInG0Law()
{
Standard_Real First, Last;
Standard_Integer ipath;
gp_Mat M1, M2, aux;//,Trsf
gp_Vec V;
myLaws->Value(1)->GetDomain(First, Last);
for (ipath=2; ipath<=myLaws->Length(); ipath++) {
myLaws->Value(ipath-1)->D0(Last, M1, V);
myLaws->Value(ipath)->GetDomain(First, Last);
myLaws->Value(ipath)->D0(First, M2, V);
ToG0(M1, M2, aux);
myLaws->Value(ipath)->SetTrsf(aux);
}
// La loi est elle periodique ?
if (myPath.Closed()) {
myLaws->Value(myLaws->Length())->D0(Last, M1, V);
myLaws->Value(1)->GetDomain(First, Last);
myLaws->Value(1)->D0(First, M2, V);
}
}
//=======================================================================
//function : DeleteTransform
//purpose : Supprime la Mise en continuite des loi
//=======================================================================
void BRepFill_LocationLaw::DeleteTransform()
{
gp_Mat Id;
Id.SetIdentity();
for (Standard_Integer ii=1; ii<=myEdges->Length(); ii++) {
myLaws->ChangeValue(ii)->SetTrsf(Id);
}
myDisc.Nullify();
}
//=======================================================================
//function : NbHoles
//purpose : Rechecherche des "Trous"
//=======================================================================
Standard_Integer BRepFill_LocationLaw::NbHoles(const Standard_Real Tol)
{
if (myDisc.IsNull()) {
TColStd_SequenceOfInteger Seq;
Standard_Integer ii, NbDisc;
for (ii=2, NbDisc=-1; ii<=myLaws->Length()+1; ii++) {
if (IsG1(ii-1, Tol, 1.e-12) == -1) {
Seq.Append(ii);
}
}
NbDisc = Seq.Length();
if ( NbDisc > 0) {
myDisc = new (TColStd_HArray1OfInteger)(1, NbDisc);
for (ii=1; ii<=NbDisc; ii++)
myDisc->SetValue(ii, Seq(ii));
}
}
if (myDisc.IsNull()) return 0;
return myDisc->Length();
}
//=======================================================================
//function : Holes
//purpose :
//=======================================================================
void BRepFill_LocationLaw::Holes(TColStd_Array1OfInteger& Disc) const
{
if (!myDisc.IsNull()) {
for (Standard_Integer ii=1; ii<=myDisc->Length(); ii++)
Disc(ii) = myDisc->Value(ii);
}
}
//=======================================================================
//function : NbLaw
//purpose :
//=======================================================================
Standard_Integer BRepFill_LocationLaw::NbLaw() const
{
return myLaws->Length();
}
//=======================================================================
//function : Law
//purpose :
//=======================================================================
const Handle(GeomFill_LocationLaw)&
BRepFill_LocationLaw::Law(const Standard_Integer Index) const
{
return myLaws->Value(Index);
}
//=======================================================================
//function : Wire
//purpose :
//=======================================================================
const TopoDS_Wire& BRepFill_LocationLaw::Wire() const
{
return myPath;
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TopoDS_Edge& BRepFill_LocationLaw::Edge(const Standard_Integer Index) const
{
return TopoDS::Edge(myEdges->Value(Index));
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
TopoDS_Vertex BRepFill_LocationLaw::Vertex(const Standard_Integer Index) const
{
TopoDS_Edge E;
TopoDS_Vertex V;
if (Index <= myEdges->Length()) {
E = TopoDS::Edge(myEdges->Value(Index));
if (E.Orientation() == TopAbs_REVERSED)
V = TopExp::LastVertex(E);
else V = TopExp::FirstVertex(E);
}
else if (Index == myEdges->Length()+1) {
E = TopoDS::Edge(myEdges->Value(Index-1));
if (E.Orientation() == TopAbs_REVERSED)
V = TopExp::FirstVertex(E);
else V = TopExp::LastVertex(E);
}
return V;
}
//=======================================================================
//function : PerformVertex
//purpose : Calcul un vertex du balayage a partir d'un vertex d'une section
// et de l'indice de l'edge dans la trajectoire
//=======================================================================
void BRepFill_LocationLaw::PerformVertex(const Standard_Integer Index,
const TopoDS_Vertex& Input,
const Standard_Real TolMin,
TopoDS_Vertex& Output,
const Standard_Integer ILoc) const
{
BRep_Builder B;
Standard_Boolean IsBary = (ILoc == 0);
Standard_Real First, Last;
gp_Pnt P;
gp_Vec V1, V2;//, V;
gp_Mat M1, M2;
if (Index>0 && Index<myLaws->Length()) {
if (ILoc <=0) {
myLaws->Value(Index)->GetDomain(First, Last);
myLaws->Value(Index)->D0(Last, M1, V1);
}
if (ILoc >= 0) {
myLaws->Value(Index+1)->GetDomain(First, Last);
if (ILoc == 0)
myLaws->Value(Index+1)->D0(First, M2, V2);
else
myLaws->Value(Index+1)->D0(First, M1, V1);
}
}
if (Index == 0 || Index == myLaws->Length()) {
if (!myPath.Closed() || (IsG1(Index, TolMin) != 1)) {
IsBary = Standard_False;
if (Index == 0) {
myLaws->Value(1)->GetDomain(First, Last);
myLaws->Value(1)->D0(First, M1, V1);
}
else {
myLaws->Value(myLaws->Length())->GetDomain(First, Last);
myLaws->Value(myLaws->Length())->D0(Last, M1, V1);
}
}
else {
if (ILoc <=0) {
myLaws->Value(myLaws->Length())->GetDomain(First, Last);
myLaws->Value(myLaws->Length())->D0(Last, M1, V1);
}
if (ILoc >=0) {
myLaws->Value(1)->GetDomain(First, Last);
if (ILoc==0)
myLaws->Value(1)->D0(First, M2, V2);
else
myLaws->Value(1)->D0(First, M1, V1);
}
}
}
P = BRep_Tool::Pnt(Input);
if (IsBary) {
gp_XYZ P1(P.XYZ()), P2(P.XYZ());
P1 *= M1;
P1 += V1.XYZ();
P2 *= M2;
P2 += V2.XYZ();
P.ChangeCoord().SetLinearForm(0.5, P1, 0.5, P2);
P1 -= P2;
Standard_Real Tol = P1.Modulus()/2;
Tol += TolMin;
B.MakeVertex(Output, P, Tol);
}
else {
P.ChangeCoord() *= M1;
P.ChangeCoord() += V1.XYZ();
B.MakeVertex(Output, P, TolMin);
}
}
//=======================================================================
//function : CurvilinearBounds
//purpose :
//=======================================================================
void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
Standard_Real& First,
Standard_Real& Last) const
{
First = myLength->Value(Index);
Last = myLength->Value(Index+1);
if (Last<0) { //Il faut effectuer le calcul
Standard_Integer ii, NbE = myEdges->Length();
Standard_Real Length, f, l;
GCPnts_AbscissaPoint AbsC;
for (ii=1, Length=0.; ii<=NbE; ii++) {
myLaws->Value(ii)->GetDomain(f, l);
Length += AbsC.Length(myLaws->Value(ii)->GetCurve()->GetCurve(), myTol);
myLength->SetValue(ii+1, Length);
}
First = myLength->Value(Index);
Last = myLength->Value(Index+1);
}
}
Standard_Boolean BRepFill_LocationLaw::IsClosed() const
{
return myPath.Closed();
}
//=======================================================================
//function : IsG1
//purpose : Evalue la continuite de la loi en un vertex
//=======================================================================
Standard_Integer
BRepFill_LocationLaw::IsG1(const Standard_Integer Index,
const Standard_Real SpatialTolerance,
const Standard_Real AngularTolerance) const
{
gp_Vec V1, DV1, V2, DV2;
gp_Mat M1, M2, DM1, DM2;
Standard_Real First, Last, EpsNul = 1.e-12;
Standard_Real TolEps = SpatialTolerance;
#ifndef DEB
Standard_Boolean Ok_D1 = Standard_False;
#else
Standard_Boolean Ok_D1;
#endif
TopoDS_Vertex V;
TopoDS_Edge E;
TColgp_Array1OfPnt2d Bid1 (1,1);
TColgp_Array1OfVec2d Bid2 (1,1);
if (Index>0 && Index<myLaws->Length()) {
myLaws->Value(Index)->GetDomain(First, Last);
Ok_D1 = myLaws->Value(Index)->D1(Last, M1, V1, DM1, DV1,
Bid1, Bid2);
if (!Ok_D1) myLaws->Value(Index)->D0(Last, M1, V1);
myLaws->Value(Index+1)->GetDomain(First, Last);
if (Ok_D1)
Ok_D1 = myLaws->Value(Index+1)->D1(First, M2, V2, DM2, DV2,
Bid1, Bid2);
if (!Ok_D1) myLaws->Value(Index+1)->D0(First, M2, V2);
E = TopoDS::Edge(myEdges->Value(Index+1));
}
if (Index == 0 || Index == myLaws->Length()) {
if (!myPath.Closed()) return -1;
myLaws->Value(myLaws->Length())->GetDomain(First, Last);
Ok_D1 = myLaws->Value(myLaws->Length())->D1(Last, M1, V1, DM1, DV1,
Bid1, Bid2);
if (!Ok_D1) myLaws->Value(myLaws->Length())->D0(Last, M1, V1);
myLaws->Value(1)->GetDomain(First, Last);
if (Ok_D1)
myLaws->Value(1)->D1(First, M2, V2, DM2, DV2,
Bid1, Bid2);
if (!Ok_D1) myLaws->Value(1)->D0(First, M2, V2);
E = TopoDS::Edge(myEdges->Value(1));
}
if (E.Orientation() == TopAbs_REVERSED)
V = TopExp::LastVertex(E);
else
V = TopExp::FirstVertex(E);
TolEps += 2*BRep_Tool::Tolerance(V);
Standard_Boolean isG0 = Standard_True;
Standard_Boolean isG1 = Standard_True;
if ((V1-V2).Magnitude() > TolEps) isG0 = Standard_False;
if (Norm(M1-M2) > SpatialTolerance) isG0 = Standard_False;
if (!isG0) return -1;
if (!Ok_D1) return 0; // Pas de controle de la derive
if ( (DV1.Magnitude()>EpsNul) && (DV2.Magnitude()>EpsNul)
&& (DV1.Angle(DV2) > AngularTolerance) ) isG1 = Standard_False;
// Pour la suite, les test sont plutot empirique
Standard_Real Norm1 = Norm(DM1);
Standard_Real Norm2 = Norm(DM2);
// Si les 2 normes sont nulle c'est bon
if ((Norm1 > EpsNul) || (Norm2 > EpsNul)) {
// sinon on compare les matrice normalise
if ((Norm1 > EpsNul) && (Norm2 > EpsNul)) {
DM1 /= Norm1;
DM2 /= Norm2;
if (Norm(DM1 - DM2) > AngularTolerance) isG1 = Standard_False;
}
else isG1 = Standard_False; // 1 Null l'autre pas
}
if (isG1) return 1;
else return 0;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
void BRepFill_LocationLaw::Parameter(const Standard_Real Abcissa,
Standard_Integer& Index,
Standard_Real& U)
{
Standard_Integer iedge, NbE=myEdges->Length();
Standard_Boolean Trouve = Standard_False;
//Controle que les longueurs sont calcules
if (myLength->Value(NbE+1) < 0) {
Standard_Real f, l;
CurvilinearBounds(NbE, f, l);
}
// Recherche de l'interval
for (iedge=1; iedge<=NbE && !Trouve; ) {
if (myLength->Value(iedge+1) >= Abcissa) {
Trouve = Standard_True;
}
else iedge++;
}
if (Trouve) {
Standard_Real f, l;
const Handle(GeomFill_LocationLaw)& Law = myLaws->Value(iedge);
Law->GetDomain(f, l);
if (Abcissa == myLength->Value(iedge+1)) {
U = l;
}
else if (Abcissa == myLength->Value(iedge)) {
U = f;
}
else {
GCPnts_AbscissaPoint
AbsC(myTol,
myLaws->Value(iedge)->GetCurve()->GetCurve(),
Abcissa-myLength->Value(iedge), f);
U = AbsC.Parameter();
}
Index = iedge;
}
else {
Index = 0;
}
}
//=======================================================================
//function : D0
//purpose : Positionement d'une section, a une abscisse curviligne donnee
//=======================================================================
void BRepFill_LocationLaw::D0(const Standard_Real Abcissa,
TopoDS_Shape& W)
{
Standard_Real u;
Standard_Integer ind;
gp_Mat M;
gp_Vec V;
Parameter(Abcissa, ind, u);
if (ind != 0) {
// Positionement
myLaws->Value(ind)->D0(u, M, V);
gp_Trsf fila;
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
TopLoc_Location Loc(fila);
W.Location(Loc.Multiplied(W.Location()));
}
else {
W.Nullify();
#if DEB
cout << "BRepFill_LocationLaw::D0 : Attention positionement hors borne"
<< endl;
#endif
}
}
//=======================================================================
//function : Abscissa
//purpose : Calcul l'abscisse d'un point
//=======================================================================
Standard_Real BRepFill_LocationLaw::Abscissa(const Standard_Integer Index,
const Standard_Real Param)
{
GCPnts_AbscissaPoint AbsC;
Standard_Real Length = myLength->Value(Index);
if (Length < 0) {
Standard_Real bid;
CurvilinearBounds(Index, bid, Length);
}
Length += AbsC.Length(myLaws->Value(Index)->GetCurve()->GetCurve(),
myLaws->Value(Index)->GetCurve()->FirstParameter(),
Param, myTol);
return Length;
}

View File

@@ -0,0 +1,103 @@
-- File: BRepFill_MultiLine.cdl
-- Created: Mon Nov 14 15:01:03 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
private class MultiLine from BRepFill
---Purpose: Private class used to compute the 3d curve and the
-- two 2d curves resulting from the intersection of a
-- surface of linear extrusion( Bissec, Dz) and the 2
-- faces.
-- This 3 curves will have the same parametrization
-- as the Bissectrice.
-- This class is to be send to an approximation
-- routine.
uses
Face from TopoDS,
Edge from TopoDS,
Curve from Geom,
Curve from Geom2d,
Curve from Geom2dAdaptor,
Pnt from gp,
Pnt2d from gp,
Shape from GeomAbs
raises
DomainError from Standard
is
Create;
Create( Face1, Face2 : Face from TopoDS;
Edge1, Edge2 : Edge from TopoDS;
Inv1 , Inv2 : Boolean from Standard;
Bissec : Curve from Geom2d );
IsParticularCase(me)
returns Boolean from Standard
---Purpose: Search if the Projection of the Bissectrice on the
-- faces needs an approximation or not.
-- Returns true if the approximation is not needed.
is static;
Continuity (me) returns Shape from GeomAbs
---Purpose: Returns the continuity betwwen the two faces
-- seShape from GeomAbsparated by myBis.
is static;
Curves(me; Curve : in out Curve from Geom;
PCurve1 : in out Curve from Geom2d;
PCurve2 : in out Curve from Geom2d)
raises
DomainError from Standard
---Purpose: raises if IsParticularCase is <False>.
is static;
FirstParameter(me)
---Purpose: returns the first parameter of the Bissectrice.
returns Real from Standard is static;
LastParameter(me)
---Purpose: returns the last parameter of the Bissectrice.
returns Real from Standard is static;
Value ( me; U : Real from Standard)
---Purpose: Returns the current point on the 3d curve
returns Pnt from gp is static;
ValueOnF1(me; U : Real from Standard)
---Purpose: returns the current point on the PCurve of the
-- first face
returns Pnt2d from gp is static;
ValueOnF2(me; U : Real from Standard)
---Purpose: returns the current point on the PCurve of the
-- first face
returns Pnt2d from gp is static;
Value3dOnF1OnF2(me;
U : Real from Standard;
P3d : in out Pnt from gp;
PF1 : in out Pnt2d from gp;
PF2 : in out Pnt2d from gp)
is static;
fields
myFace1 : Face from TopoDS;
myFace2 : Face from TopoDS;
myU1 : Curve from Geom2dAdaptor;
myV1 : Curve from Geom2dAdaptor;
myU2 : Curve from Geom2dAdaptor;
myV2 : Curve from Geom2dAdaptor;
myIsoU1 : Boolean from Standard;
myIsoU2 : Boolean from Standard;
myBis : Curve from Geom2dAdaptor;
myKPart : Integer from Standard;
myCont : Shape from GeomAbs;
end MultiLine;

View File

@@ -0,0 +1,761 @@
// File: BRepFill_MultiLine.cxx
// Created: Mon Nov 14 15:32:23 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_MultiLine.ixx>
#include <BRepIntCurveSurface_Inter.hxx>
#include <gp.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax3.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <Precision.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom2d_Line.hxx>
#include <GeomProjLib.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <Standard_ConstructionError.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <ElCLib.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAbs_SurfaceType.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>
#endif
#ifdef DEB
static Standard_Boolean AffichCurve = Standard_False;
static Standard_Integer NbProj = 1;
#endif
//POP pour NT
#include <stdio.h>
//=======================================================================
//function : isIsoU
//purpose :
//=======================================================================
static Standard_Boolean isIsoU(const TopoDS_Face& Face,
const TopoDS_Edge& Edge )
{
Handle(Geom2d_Curve) C;
Handle(Geom2d_Line) Li;
Standard_Real f,l;
C = BRep_Tool::CurveOnSurface(Edge,Face, f, l);
if ( C.IsNull()) {
Standard_ConstructionError::Raise ("BRepFill_MultiLine : Edge without PCurve");
}
gp_Dir2d D = C->DN(f,1);
if (Abs(D.Dot(gp::DX2d())) < Abs(D.Dot(gp::DY2d())))
return Standard_True;
else
return Standard_False;
}
//=======================================================================
//function : BRepFill_MultiLine
//purpose :
//=======================================================================
BRepFill_MultiLine::BRepFill_MultiLine()
{
}
//=======================================================================
//function : BRepFill_MultiLine
//purpose :
//=======================================================================
BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1,
const TopoDS_Face& Face2,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
const Standard_Boolean Inv1,
const Standard_Boolean Inv2,
const Handle(Geom2d_Curve)& Bissec) :
myFace1(Face1 ),
myFace2(Face2 ),
myBis (Bissec),
myKPart(0)
{
// eval if myedges are IsoU or not
myIsoU1 = isIsoU(Face1, Edge1);
myIsoU2 = isIsoU(Face2, Edge2);
// eval myU1, myV1, myU2, myV2;
Handle(Geom_Plane) RefPlane;
Handle(Geom_Plane) BasisPlane = new Geom_Plane(0.,0.,1.,0.);
TopLoc_Location L;
TopExp_Explorer Exp;
Standard_Real Umin,Vmin,Umax,Vmax,U,V;
gp_Pnt2d P1,P2;
gp_Vec DZ;
gp_Pnt P;
// Result on Face1
Standard_Boolean First = Standard_True;
for (Exp.Init(myFace1,TopAbs_EDGE);Exp.More(); Exp.Next()) {
TopoDS_Edge CurEdge = TopoDS::Edge(Exp.Current());
BRep_Tool::UVPoints(CurEdge,myFace1,P1,P2);
if ( First) {
First = Standard_False;
Umin = Min(P1.X(),P2.X());
Umax = Max(P1.X(),P2.X());
Vmin = Min(P1.Y(),P2.Y());
Vmax = Max(P1.Y(),P2.Y());
}
else {
U = Min(P1.X(),P2.X());
Umin = Min(Umin,U);
U = Max(P1.X(),P2.X());
Umax = Max(Umax,U);
V = Min(P1.Y(),P2.Y());
Vmin = Min(Vmin,V);
V = Max(P1.Y(),P2.Y());
Vmax = Max(Vmax,V);
}
}
// recuperons les isos dans leur domaine de restriction.
Handle(Geom_Curve) UU1, UU2, VV1, VV2;
Handle(Geom_Surface) S;
S = BRep_Tool::Surface(myFace1,L);
if (!L.IsIdentity())
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
if ( myIsoU1) {
if (!BRep_Tool::Degenerated(Edge1) && !Inv1) {
UU1 = S->UIso(Umin);
GeomAdaptor_Curve Dummy(UU1);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU1 = S->UIso(Umax);
}
}
else {
UU1 = S->UIso(Umax);
GeomAdaptor_Curve Dummy(UU1);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU1 = S->UIso(Umin);
}
}
VV1 = S->VIso(Vmin);
}
else {
if (!BRep_Tool::Degenerated(Edge1) && !Inv1) {
UU1 = S->VIso(Vmin);
GeomAdaptor_Curve Dummy(UU1);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU1 = S->VIso(Vmax);
}
}
else {
UU1 = S->VIso(Vmax);
GeomAdaptor_Curve Dummy(UU1);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU1 = S->VIso(Vmin);
}
}
VV1 = S->UIso(Umin);
}
if ( myIsoU1) {
Standard_Real dummyUmin = Umin, dummyUmax = Umax;
Umin = Vmin;
Umax = Vmax;
Vmin = dummyUmin;
Vmax = dummyUmax;
}
// essai dub
GeomAdaptor_Surface GAS1(S);
GeomAbs_SurfaceType Type1 = GAS1.GetType();
if ( UU1->IsPeriodic()) {
ElCLib::AdjustPeriodic(UU1->FirstParameter(),
UU1->LastParameter(),
Precision::PConfusion(),
Umin, Umax);
}
if ( VV1->IsPeriodic()) {
ElCLib::AdjustPeriodic(VV1->FirstParameter(),
VV1->LastParameter(),
Precision::PConfusion(),
Vmin, Vmax);
}
if (GAS1.GetType() == GeomAbs_Sphere) {
if (myIsoU1)
ElCLib::AdjustPeriodic(-PI/2.,PI/2.,
Precision::PConfusion(),
Umin, Umax);
else
ElCLib::AdjustPeriodic(-PI/2.,PI/2.,
Precision::PConfusion(),
Vmin, Vmax);
}
// fin essai dub
myU1 = Geom2dAdaptor_Curve(GeomProjLib::Curve2d(UU1, BasisPlane),
Umin, Umax);
UU1->D1(Umin, P, DZ);
RefPlane = new Geom_Plane(gp_Ax3(P,DZ,gp::DZ()));
myV1 = Geom2dAdaptor_Curve(GeomProjLib::Curve2d(VV1, RefPlane),
Vmin, Vmax);
First = Standard_True;
for (Exp.Init(myFace2,TopAbs_EDGE);Exp.More(); Exp.Next()) {
TopoDS_Edge CurEdge = TopoDS::Edge(Exp.Current());
BRep_Tool::UVPoints(CurEdge,myFace2,P1,P2);
if ( First) {
First = Standard_False;
Umin = Min(P1.X(),P2.X());
Umax = Max(P1.X(),P2.X());
Vmin = Min(P1.Y(),P2.Y());
Vmax = Max(P1.Y(),P2.Y());
}
else {
U = Min(P1.X(),P2.X());
Umin = Min(Umin,U);
U = Max(P1.X(),P2.X());
Umax = Max(Umax,U);
V = Min(P1.Y(),P2.Y());
Vmin = Min(Vmin,V);
V = Max(P1.Y(),P2.Y());
Vmax = Max(Vmax,V);
}
}
// recuperons les isos dans leur domaine de restriction.
S = BRep_Tool::Surface(myFace2,L);
if (!L.IsIdentity())
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
if ( myIsoU2) {
if (!BRep_Tool::Degenerated(Edge2) && !Inv2) {
UU2 = S->UIso(Umin);
GeomAdaptor_Curve Dummy(UU2);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU2 = S->UIso(Umax);
}
}
else {
UU2 = S->UIso(Umax);
GeomAdaptor_Curve Dummy(UU2);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU2 = S->UIso(Umin);
}
}
VV2 = S->VIso(Vmin);
}
else {
if (!BRep_Tool::Degenerated(Edge2) && !Inv2) {
UU2 = S->VIso(Vmin);
GeomAdaptor_Curve Dummy(UU2);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU2 = S->VIso(Vmax);
}
}
else {
UU2 = S->VIso(Vmax);
GeomAdaptor_Curve Dummy(UU2);
if (Dummy.GetType() == GeomAbs_Circle &&
Dummy.Circle().Radius() < Precision::Confusion()) {
UU2 = S->VIso(Vmin);
}
}
VV2 = S->UIso(Umin);
}
if ( myIsoU2) {
Standard_Real dummyUmin = Umin, dummyUmax = Umax;
Umin = Vmin;
Umax = Vmax;
Vmin = dummyUmin;
Vmax = dummyUmax;
}
// essai dub
GeomAdaptor_Surface GAS2(S);
GeomAbs_SurfaceType Type2 = GAS2.GetType();
if ( UU2->IsPeriodic()) {
ElCLib::AdjustPeriodic(UU2->FirstParameter(),
UU2->LastParameter(),
Precision::PConfusion(),
Umin, Umax);
}
if ( VV2->IsPeriodic()) {
ElCLib::AdjustPeriodic(VV2->FirstParameter(),
VV2->LastParameter(),
Precision::PConfusion(),
Vmin, Vmax);
}
if (GAS2.GetType() == GeomAbs_Sphere) {
if (myIsoU2)
ElCLib::AdjustPeriodic(-PI/2.,PI/2.,
Precision::PConfusion(),
Umin, Umax);
else
ElCLib::AdjustPeriodic(-PI/2.,PI/2.,
Precision::PConfusion(),
Vmin, Vmax);
}
// fin essai dub
myU2 = Geom2dAdaptor_Curve(GeomProjLib::Curve2d(UU2, BasisPlane),
Umin, Umax);
UU2->D1(Umin, P, DZ);
RefPlane = new Geom_Plane(gp_Ax3(P,DZ,gp::DZ()));
myV2 = Geom2dAdaptor_Curve(GeomProjLib::Curve2d(VV2, RefPlane),
Vmin, Vmax);
// eval if in a particular case.
// Cas Particulier si :
// 1) - Bissec droite
// - Bissec orthogonale a l`element de la base.
// ==> Iso sur les 2 faces.
// 2) - Bissec droite
// - les 2 surfaces sont des plans.
myCont = GeomAbs_C0;
if ( myBis.GetType() == GeomAbs_Line) {
Standard_Real DeltaU = myBis.LastParameter() - myBis.FirstParameter();
gp_Pnt2d P1 = ValueOnF1(myBis.FirstParameter() + 0.1*DeltaU);
gp_Pnt2d P2 = ValueOnF1(myBis.FirstParameter() + 0.9*DeltaU);
if ( myIsoU1) {
if ( Abs(P1.Y() - P2.Y()) < Precision::Confusion())
myKPart = 1;
}
else {
if ( Abs(P1.X() - P2.X()) < Precision::Confusion())
myKPart = 1;
}
if ( myKPart == 1)
myCont = GeomAbs_G1;
if ( (Type1 == GeomAbs_Plane) && (Type2 == GeomAbs_Plane)) {
myKPart = 2;
}
}
}
//=======================================================================
//function : IsParticularCase
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLine::IsParticularCase() const
{
return ( myKPart != 0);
}
//=======================================================================
//function : Curves
//purpose :
//=======================================================================
void BRepFill_MultiLine::Curves(Handle(Geom_Curve)& Curve,
Handle(Geom2d_Curve)& PCurve1,
Handle(Geom2d_Curve)& PCurve2) const
{
if ( myKPart == 1) {
gp_Pnt2d P1,P2,PMil;
Standard_Real f,l;
P1 = ValueOnF1(myBis.FirstParameter());
P2 = ValueOnF1(myBis.LastParameter());
// on recherche la valeur de l iso avec le point milieu
// les bouts pouvant etre des points degeneres.
PMil = ValueOnF1(0.5*(myBis.FirstParameter() + myBis.LastParameter()));
TopLoc_Location L;
Handle(Geom_Surface) S = BRep_Tool::Surface(myFace1,L);
if (!L.IsIdentity())
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
Standard_Boolean Sens;
if ( !myIsoU1) {
Curve = S->UIso(PMil.X());
Sens = P1.Y() < P2.Y();
if ( Sens)
Curve = new Geom_TrimmedCurve(Curve, P1.Y(), P2.Y(), Sens);
else
Curve = new Geom_TrimmedCurve(Curve, P2.Y(), P1.Y(), Sens);
f = Curve->FirstParameter();
l = Curve->LastParameter();
if ( Sens)
PCurve1 = new Geom2d_Line(gp_Pnt2d(PMil.X(),P1.Y() - f), gp::DY2d());
else
PCurve1 = new Geom2d_Line(gp_Pnt2d(PMil.X(),P1.Y() + f),-gp::DY2d());
PCurve1 = new Geom2d_TrimmedCurve( PCurve1 ,f ,l);
}
else {
Curve = S->VIso(PMil.Y());
Sens = P1.X() < P2.X();
if (Sens)
Curve = new Geom_TrimmedCurve(Curve, P1.X(), P2.X(), Sens);
else
Curve = new Geom_TrimmedCurve(Curve, P2.X(), P1.X(), Sens);
f = Curve->FirstParameter();
l = Curve->LastParameter();
if ( Sens)
PCurve1 = new Geom2d_Line(gp_Pnt2d(P1.X() - f,PMil.Y()), gp::DX2d());
else
PCurve1 = new Geom2d_Line(gp_Pnt2d(P1.X() + f,PMil.Y()), -gp::DX2d());
PCurve1 = new Geom2d_TrimmedCurve( PCurve1 ,f ,l);
}
P1 = ValueOnF2(myBis.FirstParameter());
P2 = ValueOnF2(myBis.LastParameter());
PMil = ValueOnF2(0.5*(myBis.FirstParameter() + myBis.LastParameter()));
if (!myIsoU2) {
Sens = P1.Y() < P2.Y();
if ( Sens)
PCurve2 = new Geom2d_Line(gp_Pnt2d(PMil.X(),(P1.Y() - f)), gp::DY2d());
else
PCurve2 = new Geom2d_Line(gp_Pnt2d(PMil.X(),(P1.Y() + f)), -gp::DY2d());
}
else {
Sens = P1.X() < P2.X();
if ( Sens)
PCurve2 = new Geom2d_Line(gp_Pnt2d(P1.X() - f ,PMil.Y()), gp::DX2d());
else
PCurve2 = new Geom2d_Line(gp_Pnt2d(P1.X() + f ,PMil.Y()), -gp::DX2d());
}
PCurve2 = new Geom2d_TrimmedCurve( PCurve2 ,f ,l);
}
else if ( myKPart == 2) {
TopLoc_Location L;
Handle(Geom_Surface) S = BRep_Tool::Surface(myFace1,L);
if (!L.IsIdentity())
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
Handle(Geom_Plane) Plane = Handle(Geom_Plane)::DownCast(S);
// eval the 3d curve corresponding to the bissectrice.
gp_Pnt2d P = myBis.Line().Location();
gp_Dir2d D = myBis.Line().Direction();
Handle(Geom_Line) Line = new Geom_Line(gp_Pnt(P.X(),P.Y(),0.),
gp_Dir(D.X(),D.Y(),0.) );
Handle(Geom_TrimmedCurve) TLine =
new Geom_TrimmedCurve(Line, myBis.FirstParameter(),
myBis.LastParameter());
Curve = GeomProjLib::ProjectOnPlane(TLine, Plane,
gp::DZ(), Standard_False);
#ifdef DRAW
if ( AffichCurve) {
//POP pour NT
// char name[100];
char* name = new char[100];
sprintf(name,"C2_%d",NbProj);
DrawTrSurf::Set(name,TLine);
sprintf(name,"C3_%d",NbProj);
DrawTrSurf::Set(name,Curve);
sprintf(name,"SS_%d",NbProj);
DrawTrSurf::Set(name,Plane);
NbProj++;
}
#endif
// eval PCurve1
PCurve1 = GeomProjLib::Curve2d(Curve,Plane);
// eval PCurve2
S = BRep_Tool::Surface(myFace2,L);
if (!L.IsIdentity())
S = Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
Plane = Handle(Geom_Plane)::DownCast(S);
PCurve2 = GeomProjLib::Curve2d(Curve,Plane);
}
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real BRepFill_MultiLine::FirstParameter() const
{
return myBis.FirstParameter();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real BRepFill_MultiLine::LastParameter() const
{
return myBis.LastParameter();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt BRepFill_MultiLine::Value(const Standard_Real U) const
{
Handle(Geom_Surface) S;
TopLoc_Location L;
S = BRep_Tool::Surface(myFace1,L);
gp_Pnt2d P2d = ValueOnF1(U);
gp_Pnt P3d = S->Value(P2d.X(), P2d.Y());
P3d.Transform(L.Transformation());
return P3d;
}
//=======================================================================
//function : ValueOnFace
//purpose :
//=======================================================================
static gp_Pnt2d ValueOnFace(const Standard_Real U,
const Geom2dAdaptor_Curve& TheBis,
const Geom2dAdaptor_Curve& TheU,
const Geom2dAdaptor_Curve& TheV,
const Standard_Boolean IsIsoU)
{
gp_Pnt2d P = TheBis.Value(U);
Geom2dAPI_ProjectPointOnCurve Ext(P,TheU.Curve(),
TheU.FirstParameter(),
TheU.LastParameter());
#ifdef DRAW
if (AffichCurve) {
char* TheUname = "TheU";
char* PP1name = "PP1";
DrawTrSurf::Set(TheUname,TheU.Curve());
DrawTrSurf::Set(PP1name,P);
// DrawTrSurf::Set("TheU",TheU.Curve());
// DrawTrSurf::Set("PP1",P);
}
#endif
Standard_Real UU =0., Dist = Precision::Infinite(), D1, D2;
if ( !Ext.NbPoints() == 0 ) {
UU = Ext.LowerDistanceParameter();
Dist = Ext.LowerDistance();
}
// Controle avec les `bouts`
D1 = P.Distance(TheU.Value(TheU.FirstParameter()));
D2 = P.Distance(TheU.Value(TheU.LastParameter()));
if (D1 < Dist || D2 < Dist) {
if ( Abs( D1 - D2) < Precision::Confusion()) {
if ( TheU.GetType() == GeomAbs_Circle) {
gp_Vec2d Axis = TheU.Circle().XAxis().Direction();
gp_Vec2d D12d = TheBis.DN(TheBis.FirstParameter(),1);
Standard_Real Ang = Axis.Angle(D12d);
if ( !TheU.Circle().IsDirect()) Ang = -Ang;
UU = ElCLib::InPeriod( Ang, TheU.FirstParameter(),
TheU.FirstParameter() + 2*PI);
Dist = TheU.Circle().Radius();
}
else {
#ifdef DEB
cout << "MultiLine : D1 = D2 and the Curve is not a circle" << endl;
cout << " ---> ValueOnFace failed at parameter U = " << U << endl;
#endif
Standard_ConstructionError::Raise("BRepFill_MultiLine: ValueOnFace");
}
}
else if ( D1 < D2) {
Dist = D1;
UU = TheU.FirstParameter();
}
else {
Dist = D2;
UU = TheU.LastParameter();
}
}
Standard_Real Tol = Precision::Confusion();
Standard_Real VV;
gp_Pnt2d PF = TheV.Value(TheV.FirstParameter());
gp_Pnt2d PL = TheV.Value(TheV.LastParameter());
if (Abs(Dist - Abs(PF.Y())) < Tol) {
VV = TheV.FirstParameter();
}
else if (Abs(Dist - Abs(PL.Y())) < Tol) {
VV = TheV.LastParameter();
}
else {
// test si la courbe est du cote `Y negatif`.
if ( Min( PF.Y(),PL.Y()) < -Tol) Dist = -Dist;
Handle(Geom2d_Line) Line
= new Geom2d_Line(gp_Pnt2d(0., Dist), gp::DX2d());
#ifdef DRAW
if (AffichCurve) {
static Standard_CString aTheV = "TheV" ;
DrawTrSurf::Set(aTheV,TheV.Curve());
static Standard_CString aLINF1 = "LINF1" ;
DrawTrSurf::Set(aLINF1,Line);
}
#endif
Geom2dAdaptor_Curve Cu1 = TheV;
Geom2dAdaptor_Curve Cu2( Line);
Standard_Real TolConf = 0.;
Geom2dInt_GInter Intersector(Cu1,Cu2,TolConf,Tol);
if ( !Intersector.IsDone()) {
#ifdef DEB
cout << "Intersector not done" << endl;
cout << " ---> ValueonFace failed at parameter U = " << U << endl;
#endif
return gp_Pnt2d(0.,0.);
}
else {
if ( Intersector.NbPoints() > 0) {
VV = Intersector.Point(1).ParamOnFirst();
}
else if ( Intersector.NbSegments() > 0) {
IntRes2d_IntersectionSegment Seg = Intersector.Segment(1);
Standard_Real VS1 = Seg.FirstPoint().ParamOnFirst();
Standard_Real VS2 = Seg.LastPoint().ParamOnFirst();
gp_Pnt2d PS1 = TheV.Value(VS1);
gp_Pnt2d PS2 = TheV.Value(VS2);
Standard_Real Alp = (Dist - PS1.Y())/(PS2.Y() - PS1.Y());
VV = Alp*(VS2 - VS1) + VS1;
}
else {
#ifdef DEB
cout << "Intersector done, but no points found" << endl;
cout << " ---> ValueonFace failed at parameter U = " << U << endl;
#endif
if (Abs(Dist - PL.Y()) < Abs(Dist - PF.Y()))
VV = TheV.LastParameter();
else
VV = TheV.FirstParameter();
}
}
}
if ( IsIsoU)
return gp_Pnt2d(VV,UU);
else
return gp_Pnt2d(UU,VV);
}
//=======================================================================
//function : ValueOnF1
//purpose :
//=======================================================================
gp_Pnt2d BRepFill_MultiLine::ValueOnF1(const Standard_Real U) const
{
return ValueOnFace(U,myBis,myU1,myV1,myIsoU1);
}
//=======================================================================
//function : ValueOnF2
//purpose :
//=======================================================================
gp_Pnt2d BRepFill_MultiLine::ValueOnF2(const Standard_Real U) const
{
return ValueOnFace(U,myBis,myU2,myV2,myIsoU2);
}
//=======================================================================
//function : Value3dOnF1OnF2
//purpose :
//=======================================================================
void BRepFill_MultiLine::Value3dOnF1OnF2(const Standard_Real U,
gp_Pnt& P3d,
gp_Pnt2d& PF1,
gp_Pnt2d& PF2)
const
{
PF1 = ValueOnFace(U,myBis,myU1,myV1,myIsoU1);
PF2 = ValueOnFace(U,myBis,myU2,myV2,myIsoU2);
Handle(Geom_Surface) S;
TopLoc_Location L;
S = BRep_Tool::Surface(myFace1,L);
P3d = S->Value(PF1.X(), PF1.Y());
P3d.Transform(L.Transformation());
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape BRepFill_MultiLine::Continuity() const
{
return myCont;
}

View File

@@ -0,0 +1,95 @@
-- File: BRepFill_MultiLineTool.cdl
-- Created: Mon Nov 14 15:01:41 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
private class MultiLineTool from BRepFill
---Purpose: private class used to instantiate the continuous
-- approximations routines.
uses
Pnt from gp,
Pnt2d from gp,
Vec from gp,
Vec2d from gp,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
Array1OfVec from TColgp,
Array1OfVec2d from TColgp,
MultiLine from BRepFill
is
FirstParameter(myclass; ML: MultiLine from BRepFill)
---Purpose: returns the first parameter of the Line.
returns Real from Standard;
LastParameter(myclass; ML: MultiLine from BRepFill)
---Purpose: returns the last parameter of the Line.
returns Real from Standard;
NbP2d(myclass; ML: MultiLine from BRepFill)
---Purpose: Returns the number of 2d points of a MLine
returns Integer from Standard;
NbP3d(myclass; ML: MultiLine from BRepFill)
---Purpose: Returns the number of 3d points of a MLine.
returns Integer from Standard;
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt: out Array1OfPnt from TColgp);
---Purpose: returns the 3d points of the multipoint <MPointIndex>
-- when only 3d points exist.
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt2d: out Array1OfPnt2d from TColgp);
---Purpose: returns the 2d points of the multipoint <MPointIndex>
-- when only 2d points exist.
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt : out Array1OfPnt from TColgp;
tabPt2d: out Array1OfPnt2d from TColgp);
---Purpose: returns the 3d and 2d points of the multipoint
-- <MPointIndex>.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV: out Array1OfVec from TColgp)
returns Boolean from Standard;
---Purpose: returns the 3d derivative values of the multipoint
-- <MPointIndex> when only 3d points exist.
-- returns False if the derivative cannot be computed.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV2d: out Array1OfVec2d from TColgp)
returns Boolean from Standard;
---Purpose: returns the 2d derivative values of the multipoint
-- <MPointIndex> only when 2d points exist.
-- returns False if the derivative cannot be computed.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV : out Array1OfVec from TColgp;
tabV2d: out Array1OfVec2d from TColgp)
returns Boolean from Standard;
---Purpose: returns the 3d and 2d derivative values of the
-- multipoint <MPointIndex>.
-- returns False if the derivative cannot be computed.
end MultiLineTool;

View File

@@ -0,0 +1,137 @@
// File: BRepFill_MultiLineTool.cxx
// Created: Mon Nov 14 15:24:57 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_MultiLineTool.ixx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real BRepFill_MultiLineTool::FirstParameter
(const BRepFill_MultiLine& ML)
{
return ML.FirstParameter();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real BRepFill_MultiLineTool::LastParameter
(const BRepFill_MultiLine& ML)
{
return ML.LastParameter();
}
//=======================================================================
//function : NbP2d
//purpose :
//=======================================================================
Standard_Integer BRepFill_MultiLineTool::NbP2d
(const BRepFill_MultiLine&)
{
return 2;
}
//=======================================================================
//function : NbP3d
//purpose :
//=======================================================================
Standard_Integer BRepFill_MultiLineTool::NbP3d(const BRepFill_MultiLine&)
{
return 1;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine& ,
const Standard_Real,
TColgp_Array1OfPnt&)
{
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfPnt2d&)
{
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine& ML,
const Standard_Real U,
TColgp_Array1OfPnt& tabPt,
TColgp_Array1OfPnt2d& tabPt2d)
{
tabPt(1) = ML.Value(U);
tabPt2d(1) = ML.ValueOnF1(U);
tabPt2d(2) = ML.ValueOnF2(U);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec&)
{
return Standard_False;
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec2d&)
{
return Standard_False;
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec&,
TColgp_Array1OfVec2d&)
{
return Standard_False;
}

View File

@@ -0,0 +1,85 @@
-- File: BRepFill_NSections.cdl
-- Created: Tue Dec 29 17:00:36 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
---Copyright: Matra Datavision 1998
class NSections from BRepFill inherits SectionLaw from BRepFill
---Purpose: Build Section Law, with N Sections
--
---Level: Advanced
uses
SectionLaw from GeomFill,
HArray1OfSectionLaw from GeomFill,
BSplineSurface from Geom,
HArray2OfShape from TopTools,
SequenceOfReal from TColStd,
SequenceOfShape from TopTools,
Shape from GeomAbs,
Vertex from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Shape from TopoDS,
Function from Law
is
Create (S:SequenceOfShape from TopTools;
Build : Boolean = Standard_True)
---Purpose: Construct
returns NSections from BRepFill;
Create (S : SequenceOfShape from TopTools;
P : SequenceOfReal from TColStd;
VF,VL : Real;
Build : Boolean = Standard_True)
---Purpose: Construct
returns NSections from BRepFill;
IsVertex(me)
---Purpose: Say if the input shape is a vertex.
returns Boolean
is redefined;
IsConstant(me)
---Purpose: Say if the Law is Constant.
returns Boolean
is redefined;
ConcatenedLaw(me)
---Purpose: Give the law build on a concatened section
returns SectionLaw from GeomFill
is redefined;
Continuity(me; Index : Integer;
TolAngular : Real)
returns Shape from GeomAbs
is redefined;
VertexTol(me; Index : Integer;
Param : Real)
returns Real
is redefined;
Vertex(me; Index : Integer;
Param : Real)
returns Vertex from TopoDS
is redefined;
D0(me:mutable; Param : Real;
S : out Shape from TopoDS)
is redefined;
Init(me : mutable; P : SequenceOfReal from TColStd;
B : Boolean from Standard ) is private;
fields
VFirst, VLast : Real;
myShapes: SequenceOfShape from TopTools;
myParams: SequenceOfReal from TColStd;
myEdges: HArray2OfShape from TopTools;
mySurface: BSplineSurface from Geom;
end NSections;

View File

@@ -0,0 +1,823 @@
// File: BRepFill_NSections.cxx
// Created: Tue Dec 29 17:01:25 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
#include <stdio.h>
#include <BRepFill_NSections.ixx>
#include <BRepFill.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepLProp.hxx>
#include <BRepLib_MakeWire.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Conic.hxx>
#include <GeomFill_UniformSection.hxx>
#include <GeomFill_EvolvedSection.hxx>
#include <GeomFill_HArray1OfSectionLaw.hxx>
#include <GeomFill_NSections.hxx>
#include <TColGeom_SequenceOfCurve.hxx>
#include <GeomFill_SectionGenerator.hxx>
#include <GeomFill_Line.hxx>
#include <GeomFill_AppSurf.hxx>
#include <GeomConvert.hxx>
#include <GeomConvert_ApproxCurve.hxx>
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
#include <BSplCLib.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Geom_BezierCurve.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <Precision.hxx>
#ifdef DEB
static Standard_Boolean Affich = 0;
#endif
#ifdef DRAW
#include <DrawTrSurf.hxx>
#include <DBRep.hxx>
#endif
//=======================================================================
//function : totalsurf
//purpose :
//=======================================================================
static Handle(Geom_BSplineSurface) totalsurf(const TopTools_Array2OfShape& shapes,
const Standard_Integer NbSects,
const Standard_Integer NbEdges,
const TColStd_SequenceOfReal& params,
const Standard_Boolean w1Point,
const Standard_Boolean w2Point,
const Standard_Boolean uClosed,
const Standard_Boolean vClosed,
const Standard_Real myPres3d)
{
Standard_Integer i,j,jdeb=1,jfin=NbSects;
TopoDS_Edge edge;
TopLoc_Location loc;
Standard_Real first, last;
TopoDS_Vertex vf,vl;
GeomFill_SectionGenerator section;
Handle(Geom_BSplineSurface) surface;
Handle(Geom_BSplineCurve) BS, BS1;
Handle(Geom_TrimmedCurve) curvTrim;
Handle(Geom_BSplineCurve) curvBS;
if (w1Point) {
jdeb++;
edge = TopoDS::Edge(shapes.Value(1,1));
TopExp::Vertices(edge,vl,vf);
TColgp_Array1OfPnt Extremities(1,2);
Extremities(1) = BRep_Tool::Pnt(vf);
Extremities(2) = BRep_Tool::Pnt(vl);
TColStd_Array1OfReal Bounds(1,2);
Bounds(1) = 0.;
Bounds(2) = 1.;
Standard_Real Deg = 1;
TColStd_Array1OfInteger Mult(1,2);
Mult(1) = (Standard_Integer) Deg+1;
Mult(2) = (Standard_Integer) Deg+1;
Handle(Geom_BSplineCurve) BSPoint
= new Geom_BSplineCurve(Extremities,Bounds,Mult,(Standard_Integer ) Deg);
section.AddCurve(BSPoint);
}
if (w2Point) {
jfin--;
}
for (j=jdeb; j<=jfin; j++) {
// cas des sections bouclantes
if (j==jfin && vClosed) {
section.AddCurve(BS1);
}
else {
// read the first edge to initialise CompBS;
edge = TopoDS::Edge(shapes.Value(1,j));
if (BRep_Tool::Degenerated(edge)) {
// edge degeneree : construction d'une courbe ponctuelle
TopExp::Vertices(edge,vl,vf);
TColgp_Array1OfPnt Extremities(1,2);
Extremities(1) = BRep_Tool::Pnt(vf);
Extremities(2) = BRep_Tool::Pnt(vl);
Handle(Geom_Curve) curv = new Geom_BezierCurve(Extremities);
curvTrim = new Geom_TrimmedCurve(curv,
curv->FirstParameter(),
curv->LastParameter());
}
else {
// recuperation de la courbe sur l'edge
Handle(Geom_Curve) curv = BRep_Tool::Curve(edge, loc, first, last);
curvTrim = new Geom_TrimmedCurve(curv, first, last);
curvTrim->Transform(loc.Transformation());
}
if (edge.Orientation() == TopAbs_REVERSED) {
curvTrim->Reverse();
}
// transformation en BSpline reparametree sur [i-1,i]
curvBS = Handle(Geom_BSplineCurve)::DownCast(curvTrim);
if (curvBS.IsNull()) {
Handle(Geom_Curve) theCurve = curvTrim->BasisCurve();
if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic)))
{
GeomConvert_ApproxCurve appr(curvTrim, Precision::Confusion(), GeomAbs_C1, 16, 14);
if (appr.HasResult())
curvBS = appr.Curve();
}
if (curvBS.IsNull())
curvBS = GeomConvert::CurveToBSplineCurve(curvTrim);
}
TColStd_Array1OfReal BSK(1,curvBS->NbKnots());
curvBS->Knots(BSK);
BSplCLib::Reparametrize(0.,1.,BSK);
curvBS->SetKnots(BSK);
// initialisation
GeomConvert_CompCurveToBSplineCurve CompBS(curvBS);
for (i=2; i<=NbEdges; i++) {
// read the edge
edge = TopoDS::Edge(shapes.Value(i,j));
if (BRep_Tool::Degenerated(edge)) {
// edge degeneree : construction d'une courbe ponctuelle
TopExp::Vertices(edge,vl,vf);
TColgp_Array1OfPnt Extremities(1,2);
Extremities(1) = BRep_Tool::Pnt(vf);
Extremities(2) = BRep_Tool::Pnt(vl);
Handle(Geom_Curve) curv = new Geom_BezierCurve(Extremities);
curvTrim = new Geom_TrimmedCurve(curv,
curv->FirstParameter(),
curv->LastParameter());
}
else {
// recuperation de la courbe sur l'edge
Handle(Geom_Curve) curv = BRep_Tool::Curve(edge, loc, first, last);
curvTrim = new Geom_TrimmedCurve(curv, first, last);
curvTrim->Transform(loc.Transformation());
}
if (edge.Orientation() == TopAbs_REVERSED) {
curvTrim->Reverse();
}
// transformation en BSpline reparametree sur [i-1,i]
curvBS = Handle(Geom_BSplineCurve)::DownCast(curvTrim);
if (curvBS.IsNull()) {
Handle(Geom_Curve) theCurve = curvTrim->BasisCurve();
if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic)))
{
GeomConvert_ApproxCurve appr(curvTrim, Precision::Confusion(), GeomAbs_C1, 16, 14);
if (appr.HasResult())
curvBS = appr.Curve();
}
if (curvBS.IsNull())
curvBS = GeomConvert::CurveToBSplineCurve(curvTrim);
}
TColStd_Array1OfReal BSK(1,curvBS->NbKnots());
curvBS->Knots(BSK);
BSplCLib::Reparametrize(i-1,i,BSK);
curvBS->SetKnots(BSK);
// concatenation
TopoDS_Vertex ComV;
Standard_Real epsV;
Standard_Boolean Bof =
TopExp::CommonVertex(TopoDS::Edge(shapes.Value(i-1,j)), edge, ComV);
if (Bof) epsV = BRep_Tool::Tolerance(ComV);
else epsV = Precision::Confusion();
Bof = CompBS.Add(curvBS, epsV, Standard_True, Standard_False, 1);
if (!Bof) Bof = CompBS.Add(curvBS, 200*epsV,
Standard_True, Standard_False, 1);
}
// recuperation de la section finale
BS = CompBS.BSplineCurve();
section.AddCurve(BS);
// cas des sections bouclantes
if (j==jdeb && vClosed) {
BS1 = BS;
}
}
}
if (w2Point) {
edge = TopoDS::Edge(shapes.Value(NbEdges,NbSects));
TopExp::Vertices(edge,vl,vf);
TColgp_Array1OfPnt Extremities(1,2);
Extremities(1) = BRep_Tool::Pnt(vf);
Extremities(2) = BRep_Tool::Pnt(vl);
TColStd_Array1OfReal Bounds(1,2);
Bounds(1) = 0.;
Bounds(2) = 1.;
Standard_Real Deg = 1;
TColStd_Array1OfInteger Mult(1,2);
Mult(1) = (Standard_Integer) Deg+1;
Mult(2) = (Standard_Integer) Deg+1;
Handle(Geom_BSplineCurve) BSPoint
= new Geom_BSplineCurve(Extremities,Bounds,Mult,(Standard_Integer ) Deg);
section.AddCurve(BSPoint);
}
Handle(TColStd_HArray1OfReal) HPar
= new TColStd_HArray1OfReal(1,params.Length());
for (i=1; i<=params.Length(); i++) {
HPar->SetValue(i,params(i));
}
section.SetParam(HPar);
section.Perform(Precision::PConfusion());
Handle(GeomFill_Line) line = new GeomFill_Line(NbSects);
Standard_Integer nbIt = 0, degmin = 2, degmax = 6;
Standard_Boolean knownP = Standard_True;
GeomFill_AppSurf anApprox(degmin, degmax, myPres3d, myPres3d, nbIt, knownP);
Standard_Boolean SpApprox = Standard_True;
anApprox.Perform(line, section, SpApprox);
Standard_Boolean uperiodic = uClosed;
Standard_Boolean vperiodic = vClosed;
Standard_Integer nup = anApprox.SurfPoles().ColLength(),
nvp = anApprox.SurfPoles().RowLength();
TColStd_Array1OfInteger Umults(1,anApprox.SurfUKnots().Length());
Umults = anApprox.SurfUMults();
TColStd_Array1OfInteger Vmults(1,anApprox.SurfVKnots().Length());
Vmults = anApprox.SurfVMults();
if (uperiodic) {
Standard_Integer nbuk = anApprox.SurfUKnots().Length();
Umults(1) --;
Umults(nbuk) --;
nup --;
}
if (vperiodic) {
Standard_Integer nbvk = anApprox.SurfVKnots().Length();
Vmults(1) --;
Vmults(nbvk) --;
nvp --;
}
TColgp_Array2OfPnt poles (1, nup, 1, nvp);
TColStd_Array2OfReal weights(1, nup, 1, nvp);
for (j = 1; j <= nvp; j++) {
for (i = 1; i <= nup; i++) {
poles(i, j) = anApprox.SurfPoles()(i,j);
weights(i, j) = anApprox.SurfWeights()(i,j);
}
}
// To create non-rational surface if possible
Standard_Real TolEps = 1.e-13;
Standard_Boolean Vrational = Standard_False, Urational = Standard_False;
for (j = 1; j <= weights.UpperCol(); j++)
if (!Vrational)
for (i = 1; i <= weights.UpperRow()-1; i++)
{
//Standard_Real signeddelta = weights(i,j) - weights(i+1,j);
Standard_Real delta = Abs( weights(i,j) - weights(i+1,j) );
// Standard_Real eps = Epsilon( Abs(weights(i,j)) );
if (delta > TolEps/* || delta > 3.*eps*/)
{
Vrational = Standard_True;
break;
}
}
for (i = 1; i <= weights.UpperRow(); i++)
if (!Urational)
for (j = 1; j <= weights.UpperCol()-1; j++)
{
//Standard_Real signeddelta = weights(i,j) - weights(i,j+1);
Standard_Real delta = Abs( weights(i,j) - weights(i,j+1) );
// Standard_Real eps = Epsilon( Abs(weights(i,j)) );
if (delta > TolEps/* || delta > 3.*eps*/)
{
Urational = Standard_True;
break;
}
}
if (!Vrational && !Urational)
{
Standard_Real theWeight = weights(1,1);
for (i = 1; i <= weights.UpperRow(); i++)
for (j = 1; j <= weights.UpperCol(); j++)
weights(i,j) = theWeight;
}
surface =
new Geom_BSplineSurface(poles, weights,
anApprox.SurfUKnots(), anApprox.SurfVKnots(),
Umults, Vmults,
anApprox.UDegree(), anApprox.VDegree(),
uperiodic, vperiodic);
return surface;
}
//=======================================================================
//function : Create
//purpose : WSeq
//=======================================================================
BRepFill_NSections::BRepFill_NSections(const TopTools_SequenceOfShape& S,
const Standard_Boolean Build)
{
myShapes = S;
VFirst = 0.;
VLast = 1.;
TColStd_SequenceOfReal par;
par.Clear();
for (Standard_Integer i=1;i<=S.Length();i++) {
par.Append(i-1);
}
myParams = par;
Init(par,Build);
}
//=======================================================================
//function : Create
//purpose : WSeq + Param
//=======================================================================
BRepFill_NSections::BRepFill_NSections(const TopTools_SequenceOfShape& S,
const TColStd_SequenceOfReal & P,
const Standard_Real VF,
const Standard_Real VL,
const Standard_Boolean Build)
{
#ifdef DEB
if ( Affich) {
#ifdef DRAW
Standard_Integer NBSECT = 0;
for (Standard_Integer i=1;i<=S.Length();i++) {
NBSECT++;
char name[256];
sprintf(name,"WIRE_%d",NBSECT);
DBRep::Set(name,TopoDS::Wire(S.Value(i)));
}
#endif
}
#endif
Standard_Boolean ok = Standard_True;
for (Standard_Integer iseq=1;iseq<P.Length();iseq++) {
ok = ok && (P.Value(iseq)<P.Value(iseq+1));
}
if (ok) {
myParams = P;
myShapes = S;
VFirst = VF;
VLast = VL;
Init(P,Build);
}
}
//=======================================================================
//function : Init
//purpose : On cree une table de GeomFill_SectionLaw
//=======================================================================
void BRepFill_NSections::Init(const TColStd_SequenceOfReal & P,
const Standard_Boolean Build)
{
BRepTools_WireExplorer wexp;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
TopoDS_Edge E;
Standard_Integer ii, NbEdge, jj, NbSects = P.Length();
Standard_Integer ideb = 1, ifin = NbSects;
Standard_Boolean wClosed, w1Point = Standard_True,
w2Point = Standard_True;
Standard_Real First, Last;
TopoDS_Wire W;
// On regarde si les wires debut et fin sont ponctuels
W = TopoDS::Wire(myShapes(1));
for (wexp.Init(W); wexp.More(); wexp.Next())
// w1Point = w1Point && B.Degenerated(wexp.Current());
w1Point = w1Point && BRep_Tool::Degenerated(wexp.Current());
if (w1Point) ideb++;
W = TopoDS::Wire(myShapes(NbSects));
for (wexp.Init(W); wexp.More(); wexp.Next())
// w2Point = w2Point && B.Degenerated(wexp.Current());
w2Point = w2Point && BRep_Tool::Degenerated(wexp.Current());
if (w2Point) ifin--;
// On regarde si les wires debut et fin sont identiques
vclosed = myShapes(1).IsSame(myShapes(NbSects));
// On compte le nombre d'aretes non degenerees
W = TopoDS::Wire(myShapes(ideb));
for (NbEdge=0, wexp.Init(W); wexp.More(); wexp.Next())
// if (! B.Degenerated(wexp.Current())) NbEdge++;
if (! BRep_Tool::Degenerated(wexp.Current())) NbEdge++;
myEdges = new (TopTools_HArray2OfShape) (1, NbEdge, 1, NbSects);
// On Remplit les tables
uclosed = Standard_True;
for (jj=ideb;jj<=ifin;jj++){
W = TopoDS::Wire(myShapes(jj));
for (ii=1, wexp.Init(W); ii<=NbEdge ; wexp.Next(), ii++) {
E = wexp.Current();
// if ( ! B.Degenerated(E)) {
if ( ! BRep_Tool::Degenerated(E)) {
myEdges->SetValue(ii,jj, E);
}
}
// La loi est elle fermee en U ?
wClosed = W.Closed();
if (!wClosed) {
// le flag n'etant pas tres sur, on fait une verif
TopoDS_Edge Edge1, Edge2;
TopoDS_Vertex V1,V2;
Edge1 = TopoDS::Edge (myEdges->Value(NbEdge,jj));
Edge2 = TopoDS::Edge (myEdges->Value(1,jj));
if ( Edge1.Orientation() == TopAbs_REVERSED) {
V1 = TopExp::FirstVertex(Edge1);
}
else {
V1 = TopExp::LastVertex(Edge1);
}
if ( Edge2.Orientation() == TopAbs_REVERSED) {
V2 = TopExp::LastVertex(Edge2);
}
else {
V2 = TopExp::FirstVertex(Edge2);
}
if (V1.IsSame(V2)) {
wClosed = Standard_True;
}
else {
BRepAdaptor_Curve Curve1(Edge1);
BRepAdaptor_Curve Curve2(Edge2);
Standard_Real U1 = BRep_Tool::Parameter(V1,Edge1);
Standard_Real U2 = BRep_Tool::Parameter(V2,Edge2);
Standard_Real Eps = BRep_Tool::Tolerance(V2) +
BRep_Tool::Tolerance(V1);
wClosed = Curve1.Value(U1).IsEqual(Curve2.Value(U2), Eps);
}
}
if (!wClosed) uclosed = Standard_False;
}
// sections en bout ponctuelles
if (w1Point) {
W = TopoDS::Wire(myShapes(1));
wexp.Init(W);
E = wexp.Current();
for (ii=1; ii<=NbEdge ; ii++) {
myEdges->SetValue(ii, 1, E);
}
}
if (w2Point) {
W = TopoDS::Wire(myShapes(NbSects));
wexp.Init(W);
E = wexp.Current();
for (ii=1; ii<=NbEdge ; ii++) {
myEdges->SetValue(ii, NbSects, E);
}
}
myLaws = new (GeomFill_HArray1OfSectionLaw) (1, NbEdge);
Standard_Real tol = Precision::Confusion();
mySurface = totalsurf(myEdges->Array2(),myShapes.Length(),NbEdge,
myParams,w1Point,w2Point,uclosed,vclosed,tol);
// On augmente le degre pour que le positionnement D2
// sur les GeomFill_NSections soit correct
// cf commentaires dans GeomFill_NSections
if (mySurface->VDegree()<2) {
mySurface->IncreaseDegree(mySurface->UDegree(),2);
}
#ifdef DRAW
if ( Affich) {
char* name = new char[100];
sprintf(name,"Ref_Surf");
DrawTrSurf::Set(name,mySurface);
}
#endif
// On Remplit les tables
if (Build) {
for (ii=1; ii<=NbEdge ; ii++) {
TColGeom_SequenceOfCurve NC;
NC.Clear();
for (jj=1;jj<=NbSects;jj++) {
E = TopoDS::Edge (myEdges->Value(ii,jj));
Handle(Geom_Curve) C;
// if (B.Degenerated(E)) {
if (BRep_Tool::Degenerated(E)) {
TopoDS_Vertex vf,vl;
TopExp::Vertices(E,vl,vf);
TColgp_Array1OfPnt Extremities(1,2);
Extremities(1) = BRep_Tool::Pnt(vf);
Extremities(2) = BRep_Tool::Pnt(vl);
TColStd_Array1OfReal Bounds(1,2);
Bounds(1) = 0.;
Bounds(2) = 1.;
TColStd_Array1OfInteger Mult(1,2);
Mult(1) = 2;
Mult(2) = 2;
Handle(Geom_BSplineCurve) BSPoint
= new Geom_BSplineCurve(Extremities,Bounds,Mult,1);
C = BSPoint;
}
else {
C = BRep_Tool::Curve(E,First,Last);
if (E.Orientation() == TopAbs_REVERSED) {
Standard_Real aux;
Handle(Geom_Curve) CBis;
CBis = C->Reversed(); // Pour eviter de deteriorer la topologie
aux = C->ReversedParameter(First);
First = C->ReversedParameter(Last);
Last = aux;
C = CBis;
}
if ((ii>1) || (!E.Closed()) ) { // On trimme C
Handle(Geom_TrimmedCurve) TC =
new (Geom_TrimmedCurve) (C,First, Last);
C = TC;
}
// sinon On garde l'integrite de la courbe
}
NC.Append(C);
}
Standard_Real Ufirst = ii-1;
Standard_Real Ulast = ii;
myLaws->ChangeValue(ii) = new (GeomFill_NSections)(NC,myParams,
Ufirst,Ulast,
VFirst,VLast,
mySurface);
}
}
}
//=======================================================================
//function : IsVertex
//purpose :
//=======================================================================
Standard_Boolean BRepFill_NSections::IsVertex() const
{
return Standard_False;
}
//=======================================================================
//function : IsConstant
//purpose :
//=======================================================================
Standard_Boolean BRepFill_NSections::IsConstant() const
{
return Standard_False;
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
TopoDS_Vertex
BRepFill_NSections::Vertex(const Standard_Integer Index,
const Standard_Real Param) const
{
BRep_Builder B;
TopoDS_Vertex V;
B.MakeVertex(V);
gp_Pnt P;
if (Index <= myEdges->ColLength()) {
Handle(Geom_BSplineCurve) Curve
= Handle(Geom_BSplineCurve)::DownCast(myLaws->Value(Index)->
BSplineSurface()->VIso(Param));
Standard_Real first = Curve ->FirstParameter();
Curve->D0(first, P);
B.UpdateVertex(V, P, Precision::Confusion());
}
else if (Index == myEdges->ColLength()+1) {
Handle(Geom_BSplineCurve) Curve
= Handle(Geom_BSplineCurve)::DownCast(myLaws->Value(Index-1)->
BSplineSurface()->VIso(Param));
Standard_Real last = Curve ->LastParameter();
Curve->D0(last, P);
B.UpdateVertex(V, P, Precision::Confusion());
}
return V;
}
///=======================================================================
//function : VertexTol
//purpose : Evalue le trou entre 2 edges de la section
//=======================================================================
Standard_Real BRepFill_NSections::VertexTol(const Standard_Integer Index,
const Standard_Real Param) const
{
Standard_Real Tol = Precision::Confusion();
Standard_Integer I1, I2;
if ( (Index==0) || (Index==myEdges->ColLength()) ) {
if (!uclosed) return Tol; //Le moins faux possible
I1 = myEdges->ColLength();
I2 = 1;
}
else {
I1 = Index;
I2 = I1 +1;
}
Handle(GeomFill_SectionLaw) Loi;
Standard_Integer NbPoles, NbKnots, Degree;
Handle(TColgp_HArray1OfPnt) Poles;
Handle(TColStd_HArray1OfReal) Knots, Weigth;
Handle(TColStd_HArray1OfInteger) Mults;
Handle(Geom_BSplineCurve) BS;
gp_Pnt PFirst;
Loi = myLaws->Value(I1);
Loi->SectionShape( NbPoles, NbKnots, Degree);
Poles = new (TColgp_HArray1OfPnt) (1, NbPoles);
Weigth = new (TColStd_HArray1OfReal) (1, NbPoles);
Loi->D0(Param, Poles->ChangeArray1(), Weigth->ChangeArray1());
Knots = new (TColStd_HArray1OfReal) (1, NbKnots);
Loi->Knots(Knots->ChangeArray1());
Mults = new (TColStd_HArray1OfInteger) (1, NbKnots);
Loi->Mults(Mults->ChangeArray1());
BS = new (Geom_BSplineCurve) (Poles->Array1(),
Weigth->Array1(),
Knots->Array1(),
Mults->Array1(),
Degree,
Loi->IsUPeriodic());
PFirst = BS->Value( Knots->Value(Knots->Length()) );
Loi = myLaws->Value(I2);
Loi->SectionShape( NbPoles, NbKnots, Degree);
Poles = new (TColgp_HArray1OfPnt) (1, NbPoles);
Weigth = new (TColStd_HArray1OfReal) (1, NbPoles);
Loi->D0(Param, Poles->ChangeArray1(), Weigth->ChangeArray1());
Knots = new (TColStd_HArray1OfReal) (1, NbKnots);
Loi->Knots(Knots->ChangeArray1());
Mults = new (TColStd_HArray1OfInteger) (1, NbKnots);
Loi->Mults(Mults->ChangeArray1());
BS = new (Geom_BSplineCurve) (Poles->Array1(),
Weigth->Array1(),
Knots->Array1(),
Mults->Array1(),
Degree,
Loi->IsUPeriodic());
Tol += PFirst.Distance(BS->Value( Knots->Value(1)));
return Tol;
}
//=======================================================================
//function : ConcatenedLaw
//purpose :
//=======================================================================
Handle(GeomFill_SectionLaw) BRepFill_NSections::ConcatenedLaw() const
{
Handle(GeomFill_SectionLaw) Law;
if (myLaws->Length() == 1)
return myLaws->Value(1);
else {
Standard_Real Ufirst, Ulast, Vfirst, Vlast;
mySurface->Bounds(Ufirst, Ulast, Vfirst, Vlast);
TColGeom_SequenceOfCurve NCompo;
NCompo.Clear();
for (Standard_Integer jj=1; jj<=myShapes.Length(); jj++) {
NCompo.Append(mySurface->VIso(myParams(jj)));
}
Law = new (GeomFill_NSections)(NCompo, myParams,
Ufirst, Ulast,
Vfirst, Vlast,
mySurface);
}
return Law;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape BRepFill_NSections::Continuity(const Standard_Integer Index,
const Standard_Real TolAngular) const
{
Standard_Integer jj;
GeomAbs_Shape cont_jj;
#ifndef DEB
GeomAbs_Shape cont = GeomAbs_C0;
#else
GeomAbs_Shape cont;
#endif
for (jj=1; jj<=myShapes.Length(); jj++) {
TopoDS_Edge Edge1, Edge2;
if ( (Index==0) || (Index==myEdges->ColLength()) ) {
if (!uclosed) return GeomAbs_C0; //Le moins faux possible
Edge1 = TopoDS::Edge (myEdges->Value(myEdges->ColLength(),jj));
Edge2 = TopoDS::Edge (myEdges->Value(1,jj));
}
else {
Edge1 = TopoDS::Edge (myEdges->Value(Index,jj));
Edge2 = TopoDS::Edge (myEdges->Value(Index+1,jj));
}
TopoDS_Vertex V1,V2;
if ( Edge1.Orientation() == TopAbs_REVERSED) {
V1 = TopExp::FirstVertex(Edge1);
}
else {
V1 = TopExp::LastVertex(Edge1);
}
if ( Edge2.Orientation() == TopAbs_REVERSED) {
V2 = TopExp::LastVertex(Edge2);
}
else {
V2 = TopExp::FirstVertex(Edge2);
}
if (BRep_Tool::Degenerated(Edge1) || BRep_Tool::Degenerated(Edge2))
cont_jj = GeomAbs_CN;
else
{
Standard_Real U1 = BRep_Tool::Parameter(V1,Edge1);
Standard_Real U2 = BRep_Tool::Parameter(V2,Edge2);
BRepAdaptor_Curve Curve1(Edge1);
BRepAdaptor_Curve Curve2(Edge2);
Standard_Real Eps = BRep_Tool::Tolerance(V2) +
BRep_Tool::Tolerance(V1);
cont_jj = BRepLProp::Continuity(Curve1,Curve2,U1,U2, Eps, TolAngular);
}
if (jj==1) cont = cont_jj;
if (cont>cont_jj) cont = cont_jj;
}
return cont;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void BRepFill_NSections::D0(const Standard_Real V, TopoDS_Shape& S)
{
TopoDS_Wire W;
BRepLib_MakeWire MW;
Standard_Integer ii, NbEdge = myLaws->Length();
for (ii=1; ii<=NbEdge ; ii++) {
Handle(Geom_BSplineCurve) Curve
= Handle(Geom_BSplineCurve)::DownCast(myLaws->Value(ii)->BSplineSurface()->VIso(V));
Standard_Real first = Curve ->FirstParameter(),
last = Curve ->LastParameter();
TopoDS_Edge E = BRepLib_MakeEdge(Curve,first,last);
MW.Add(E);
}
TopAbs_Orientation Orien = TopAbs_FORWARD;
TopoDS_Shape aLocalShape = MW.Wire().Oriented(Orien);
S = TopoDS::Wire(aLocalShape);
// S = TopoDS::Wire(MW.Wire().Oriented(Orien));
}

View File

@@ -0,0 +1,55 @@
-- File: BRepFill_OffsetAncestors.cdl
-- Created: Fri Sep 1 10:01:30 1995
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1995
class OffsetAncestors from BRepFill
---Purpose: this class is used to find the generating shapes
-- of an OffsetWire.
uses
OffsetWire from BRepFill,
Shape from TopoDS,
Edge from TopoDS,
DataMapOfShapeShape from TopTools
raises
NotDone from StdFail
is
Create returns OffsetAncestors from BRepFill;
Create ( Paral : in out OffsetWire from BRepFill)
returns OffsetAncestors from BRepFill;
Perform ( me : in out; Paral : in out OffsetWire from BRepFill)
is static;
IsDone( me)
returns Boolean from Standard
is static;
HasAncestor (me; S1 : Edge from TopoDS)
returns Boolean from Standard
is static;
Ancestor (me ; S1 : Edge from TopoDS)
---Purpose: may return a Null Shape if S1 is not a subShape
-- of <Paral>;
---C++: return const &
returns Shape from TopoDS
raises
NotDone from StdFail
---Purpose: if Perform is not done.
is static;
fields
myIsPerform : Boolean from Standard;
myMap : DataMapOfShapeShape from TopTools;
end OffsetAncestors;

View File

@@ -0,0 +1,98 @@
// File: BRepFill_OffsetAncestors.cxx
// Created: Fri Sep 1 14:32:44 1995
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_OffsetAncestors.ixx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
//=======================================================================
//function : BRepFill_OffsetAncestors
//purpose :
//=======================================================================
BRepFill_OffsetAncestors::BRepFill_OffsetAncestors()
:myIsPerform(Standard_False)
{
}
//=======================================================================
//function : BRepFill_OffsetAncestors
//purpose :
//=======================================================================
BRepFill_OffsetAncestors::BRepFill_OffsetAncestors
(BRepFill_OffsetWire& Paral)
{
Perform(Paral);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepFill_OffsetAncestors::Perform(BRepFill_OffsetWire& Paral)
{
TopoDS_Face Spine = Paral.Spine();
TopExp_Explorer Exp;
TopTools_ListIteratorOfListOfShape it;
// on itere sur les edges.
for ( Exp.Init(Spine, TopAbs_EDGE); Exp.More(); Exp.Next()) {
for (it.Initialize(Paral.GeneratedShapes(Exp.Current()));
it.More(); it.Next()) {
myMap.Bind( it.Value(), Exp.Current());
}
}
// on itere sur les vertex.
for ( Exp.Init(Spine, TopAbs_VERTEX); Exp.More(); Exp.Next()) {
for (it.Initialize(Paral.GeneratedShapes(Exp.Current()));
it.More(); it.Next()) {
myMap.Bind( it.Value(), Exp.Current());
}
}
myIsPerform = Standard_True;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepFill_OffsetAncestors::IsDone() const
{
return myIsPerform;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepFill_OffsetAncestors:: HasAncestor(const TopoDS_Edge& S1)
const
{
return myMap.IsBound(S1);
}
//=======================================================================
//function : TopoDS_Shape&
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_OffsetAncestors::Ancestor(const TopoDS_Edge& S1)
const
{
StdFail_NotDone_Raise_if( !myIsPerform, "");
return myMap(S1);
}

View File

@@ -0,0 +1,130 @@
-- File: BRepFill_OffsetWire.cdl
-- Created: Wed Apr 19 14:28:26 1995
-- Author: Yves FRICAUD
-- <yfr@stylox>
---Copyright: Matra Datavision 1995
class OffsetWire from BRepFill
---Purpose: Constructs a Offset Wire to a spine (wire or face)
-- on the left of spine.
uses
Face from TopoDS,
Shape from TopoDS,
JoinType from GeomAbs,
ListOfShape from TopTools,
DataMapOfShapeShape from TopTools,
DataMapOfOrientedShapeListOfShape from BRepFill,
BisectingLocus from BRepMAT2d,
LinkTopoBilo from BRepMAT2d
raises
ConstructionError from Standard,
NoSuchObject from Standard
is
Create returns OffsetWire from BRepFill;
Create ( Spine : Face from TopoDS;
Join : JoinType from GeomAbs = GeomAbs_Arc)
returns OffsetWire from BRepFill;
Init ( me : in out;
Spine : Face from TopoDS;
Join : JoinType from GeomAbs = GeomAbs_Arc)
---Purpose: Initialize the evaluation of Offseting.
raises
ConstructionError from Standard
is static;
Perform (me : in out;
Offset : Real from Standard;
Alt : Real from Standard = 0.0)
---Purpose: Performs an OffsetWire at an altitude <Alt> from
-- the face ( According to the orientation of the
-- face)
raises
ConstructionError from Standard
is static;
PerformWithBiLo (me : in out;
WSP : Face from TopoDS;
Offset : Real from Standard;
Locus : BisectingLocus from BRepMAT2d;
Link : in out LinkTopoBilo from BRepMAT2d;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Alt : Real from Standard = 0.0)
---Purpose: Performs an OffsetWire
raises
ConstructionError from Standard
is static;
IsDone ( me)
returns Boolean from Standard
is static;
Spine(me)
returns Face from TopoDS
---C++: return const &
is static;
Shape(me) returns Shape from TopoDS
---Purpose: returns the generated shape.
---C++ : return const &
is static;
GeneratedShapes (me : in out ; SpineShape : Shape from TopoDS)
---Purpose: Returns the shapes created from a subshape
-- <SpineShape> of the spine.
-- Returns the last computed Offset.
--
---C++ : return const &
returns ListOfShape from TopTools
is static;
JoinType (me) returns JoinType from GeomAbs
is static;
Generated (me : in out )
---C++: return &
returns DataMapOfOrientedShapeListOfShape from BRepFill
is static private;
PrepareSpine (me : in out)
---Purpose: Prepare the spine as follow
-- - Cut the spine-Edges at the extrema of curvature and
-- at the inflexion points.
is static private;
Add(me : in out; Other : OffsetWire from BRepFill)
---Purpose: Add the OffsetWire <Other> to <me> and update <myMap>
is static private;
MakeWires (me : in out)
---Purpose: Constructs the wires with the trimmed offset edges.
is static private;
FixHoles (me : in out)
---Purpose: Fix holes between open wires where it is possible
is static private;
fields
mySpine : Face from TopoDS;
myWorkSpine : Face from TopoDS;
myOffset : Real from Standard; -- >0 ;
myShape : Shape from TopoDS;
myIsDone : Boolean from Standard;
myJoinType : JoinType from GeomAbs;
myMap : DataMapOfOrientedShapeListOfShape from BRepFill;
myBilo : BisectingLocus from BRepMAT2d;
myLink : LinkTopoBilo from BRepMAT2d;
myMapSpine : DataMapOfShapeShape from TopTools;
myCallGen : Boolean from Standard;
end OffsetWire;

File diff suppressed because it is too large Load Diff

153
src/BRepFill/BRepFill_Pipe.cdl Executable file
View File

@@ -0,0 +1,153 @@
-- File: BRepFill_Pipe.cdl
-- Created: Tue Jun 7 15:35:09 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
class Pipe from BRepFill
---Purpose: Create a shape by sweeping a shape (the profile)
-- along a wire (the spine).
--
-- For each edge or vertex from the spine the user
-- may ask for the shape generated from each subshape
-- of the profile.
uses
HArray2OfShape from TopTools,
LocationLaw from BRepFill,
Shape from TopoDS,
Face from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
Pnt from gp,
Trsf from gp
raises
DomainError from Standard,
NotDone from StdFail
is
Create returns Pipe from BRepFill;
Create ( Spine : Wire from TopoDS;
Profile : Shape from TopoDS;
GeneratePartCase : Boolean from Standard = Standard_False)
returns Pipe from BRepFill;
Perform (me : in out; Spine : Wire from TopoDS;
Profile : Shape from TopoDS;
GeneratePartCase : Boolean from Standard = Standard_False)
is static;
Spine(me) returns Shape from TopoDS
---C++ : return const &
is static;
Profile(me) returns Shape from TopoDS
---C++ : return const &
is static;
Shape(me) returns Shape from TopoDS
---C++ : return const &
is static;
FirstShape(me) returns Shape from TopoDS
---C++ : return const &
is static;
LastShape(me) returns Shape from TopoDS
---C++ : return const &
is static;
Face(me : in out; ESpine, EProfile : Edge from TopoDS)
returns Face from TopoDS
---Purpose: Returns the face created from an edge of the spine
-- and an edge of the profile.
raises
DomainError from Standard
---Purpose: if the edges are not in the spine or the profile
is static;
Edge(me : in out; ESpine : Edge from TopoDS; VProfile : Vertex from TopoDS)
returns Edge from TopoDS
---Purpose: Returns the edge created from an edge of the spine
-- and a vertex of the profile.
raises
DomainError from Standard
---Purpose: if the edge or the vertex are not in the spine or
-- the profile.
is static;
Section(me; VSpine : Vertex from TopoDS)
returns Shape from TopoDS
---Purpose: Returns the shape created from the profile at the
-- position of the vertex VSpine.
raises
DomainError from Standard
---Purpose: if the vertex is not in the Spine
is static;
PipeLine(me; Point : Pnt from gp)
---Purpose: Create a Wire by sweeping the Point along the <spine>
returns Wire from TopoDS
raises
DomainError from Standard
---Purpose: if the <Spine> is undefined
is static;
--
-- Private methods
--
MakeShape(me : in out; S : Shape from TopoDS;
FirstShape, LastShape : Shape from TopoDS)
returns Shape from TopoDS
---Purpose: Auxiliary recursive method used to build the
-- result.
is static private;
FindEdge(me; S : Shape from TopoDS;
E : Edge from TopoDS;
Init : in out Integer)
---Purpose: Auxiliary recursive method used to find the edge's index
returns Integer
is static private;
FindVertex(me; S : Shape from TopoDS;
V : Vertex from TopoDS;
Init : in out Integer)
returns Integer
is static private;
DefineRealSegmax(me : in out)
is static private;
fields
mySpine : Wire from TopoDS;
myProfile : Shape from TopoDS;
myShape : Shape from TopoDS;
myTrsf : Trsf from gp;
myLoc : LocationLaw from BRepFill;
mySections: HArray2OfShape from TopTools;
myFaces : HArray2OfShape from TopTools;
myEdges : HArray2OfShape from TopTools;
myFirst : Shape from TopoDS;
myLast : Shape from TopoDS;
myDegmax : Integer from Standard;
mySegmax : Integer from Standard;
end Pipe;

759
src/BRepFill/BRepFill_Pipe.cxx Executable file
View File

@@ -0,0 +1,759 @@
// File: BRepFill_Pipe.cxx
// Created: Tue Jun 7 16:31:15 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_Pipe.ixx>
#include <Standard_ErrorHandler.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <GeomFill_CorrectedFrenet.hxx>
#include <GeomFill_CurveAndTrihedron.hxx>
#include <BRepFill_SectionPlacement.hxx>
#include <BRepFill_ShapeLaw.hxx>
#include <BRepFill_Edge3DLaw.hxx>
#include <BRepFill_Sweep.hxx>
#include <GeomAbs_Shape.hxx>
#include <TopExp.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <Precision.hxx>
#include <Standard_NotImplemented.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#ifdef DRAW
#include <DBRep.hxx>
static Standard_Boolean Affich = 0;
#endif
//=======================================================================
//function : BRepFill_Pipe
//purpose :
//=======================================================================
BRepFill_Pipe::BRepFill_Pipe()
{
myDegmax = 10;
mySegmax = 100;
}
//=======================================================================
//function : BRepFill_Pipe
//purpose :
//=======================================================================
BRepFill_Pipe::BRepFill_Pipe(const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const Standard_Boolean KPart)
{
myDegmax = 10;
mySegmax = 100;
Perform(Spine, Profile, KPart);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
const TopoDS_Shape& Profile,
const Standard_Boolean KPart)
{
mySections.Nullify();
myFaces.Nullify();
myEdges.Nullify();
mySpine = Spine;
myProfile = Profile;
DefineRealSegmax();
BRepTools_WireExplorer wexp;
TopoDS_Shape TheProf;
Handle(GeomFill_CorrectedFrenet) TLaw =
new (GeomFill_CorrectedFrenet) ();
Handle(GeomFill_CurveAndTrihedron) Loc =
new (GeomFill_CurveAndTrihedron) (TLaw);
myLoc = new (BRepFill_Edge3DLaw) (mySpine, Loc);
if (myLoc->NbLaw() == 0) {
return; // Cas degenere
}
myLoc->TransformInG0Law(); // Mise en continuite
BRepFill_SectionPlacement Place(myLoc, Profile);
myTrsf = Place.Transformation();
TopLoc_Location Loc2(myTrsf), Loc1;
Loc1 = Profile.Location();
TopoDS_Shape aux;
TheProf = myProfile;
TheProf.Location(Loc2.Multiplied(Loc1));
// Construit les Shape First && Last
Handle(GeomFill_LocationLaw) law;
gp_Mat M;
gp_Vec V;
gp_Trsf fila;
Standard_Real first, last;
myLoc->Law(1)->GetDomain(first, last);
myLoc->Law(1)->D0(first, M, V);
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
fila.Multiply(myTrsf);
TopLoc_Location LocFirst(fila);
myFirst = myProfile;
if ( ! LocFirst.IsIdentity()) {
myFirst.Location( LocFirst.Multiplied(myProfile.Location()) );
}
myLoc->Law(myLoc->NbLaw())->GetDomain(first, last);
myLoc->Law(myLoc->NbLaw())->D0(last,M, V);
// try { // Pas joli mais il n'y as pas d'autre moyens de tester SetValues
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
fila.Multiply(myTrsf);
TopLoc_Location LocLast(fila);
if (! myLoc->IsClosed() || LocFirst != LocLast) {
myLast = myProfile;
if ( ! LocLast.IsIdentity()) {
myLast.Location(LocLast.Multiplied(myProfile.Location()) );
}
}
else {
myLast = myFirst;
}
#if DRAW
if (Affich) {
DBRep::Set("theprof", TheProf);
DBRep::Set("thefirst", myFirst);
DBRep::Set("thelast" , myLast);
}
#endif
myShape = MakeShape(TheProf, myFirst, myLast);
}
//=======================================================================
//function : Spine
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_Pipe::Spine() const
{
return mySpine;
}
//=======================================================================
//function : Profile
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_Pipe::Profile() const
{
return myProfile;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_Pipe::Shape() const
{
return myShape;
}
//=======================================================================
//function : FirstShape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_Pipe::FirstShape() const
{
return myFirst;
}
//=======================================================================
//function : LastShape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepFill_Pipe::LastShape() const
{
return myLast;
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
TopoDS_Face BRepFill_Pipe::Face(const TopoDS_Edge& ESpine,
const TopoDS_Edge& EProfile)
{
TopoDS_Face theFace;
if ( BRep_Tool::Degenerated(EProfile))
return theFace;
Standard_Integer ii, ispin = 0, iprof = 0, count = 0;
// *************************************************
// Search if EProfile is an edge of myProfile
// *************************************************
iprof = FindEdge(myProfile, EProfile, count);
if (!iprof) Standard_DomainError::Raise(
"BRepFill_Pipe::Face : Edge not in the Profile");
// *************************************************
// Search if ESpine is an edge of mySpine and find
// the index of the corresponding Filler
// *************************************************
for (ii=1; ii<=myLoc->NbLaw() && (!ispin); ii++)
if (ESpine.IsSame(myLoc->Edge(ii))) ispin = ii;
if (!ispin) Standard_DomainError::Raise(
"BRepFill_Pipe::Edge : Edge not in the Spine");
theFace = TopoDS::Face(myFaces->Value(iprof, ispin));
return theFace;
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
TopoDS_Edge BRepFill_Pipe::Edge(const TopoDS_Edge& ESpine,
const TopoDS_Vertex& VProfile)
{
Standard_Integer ii, ispin = 0, iprof = 0, count = 0;;
// *************************************************
// Search if VProfile is a Vertex of myProfile
// *************************************************
iprof = FindVertex(myProfile, VProfile, count);
if (!iprof) Standard_DomainError::Raise(
"BRepFill_Pipe::Edge : Vertex not in the Profile");
// *************************************************
// Search if ESpine is an edge of mySpine and find
// the index of the corresponding Filler
// *************************************************
for (ii=1; ii<=myLoc->NbLaw() && (!ispin); ii++)
if (ESpine.IsSame(myLoc->Edge(ii))) ispin = ii;
if (!ispin) Standard_DomainError::Raise(
"BRepFill_Pipe::Edge : Edge not in the Spine");
// *************************************************
// Generate the corresponding Shape
// *************************************************
TopoDS_Edge theEdge;
theEdge = TopoDS::Edge(myEdges->Value(iprof, ispin));
return theEdge;
}
//=======================================================================
//function : Section
//purpose :
//=======================================================================
TopoDS_Shape BRepFill_Pipe::Section(const TopoDS_Vertex& VSpine) const
{
TopoDS_Iterator it, itv;
Standard_Integer ii, ispin = 0;
TopoDS_Shape curSect = myProfile;
// *************************************************
// Search if ESpine is an edge of mySpine and find
// the index of the corresponding Filler
// *************************************************
// iterate on all the edges of mySpine
for (ii=1; ii<=myLoc->NbLaw()+1 && (!ispin); ii++)
if (VSpine.IsSame(myLoc->Vertex(ii))) ispin = ii;
if (!ispin) Standard_DomainError::Raise(
"BRepFill_Pipe::Section : Vertex not in the Spine");
BRep_Builder B;
TopoDS_Compound Comp;
B.MakeCompound(Comp);
for (ii=1; ii<=mySections->ColLength(); ii++)
B.Add(Comp, mySections->Value(ii, ispin));
return Comp;
}
//=======================================================================
//function : PipeLine
//purpose : Construit un wire par balayage d'un point
//=======================================================================
TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point) const
{
// Postionnement
gp_Pnt P;
P = Point;
P.Transform(myTrsf);
BRepLib_MakeVertex MkV(P);
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (MkV.Vertex());
// Balayage
BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
MkSw.Build( BRepFill_Modified, GeomFill_Location, GeomAbs_C2, myDegmax, mySegmax );
TopoDS_Shape aLocalShape = MkSw.Shape();
return TopoDS::Wire(aLocalShape);
// return TopoDS::Wire(MkSw.Shape());
}
//=======================================================================
//function : MakeShape
//purpose :
//=======================================================================
TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& LastShape)
{
TopoDS_Shape result;
BRep_Builder B;
Standard_Boolean explode = Standard_False;
TopoDS_Shape TheS, TheFirst, TheLast;
Standard_Integer InitialLength = 0;
TheS = S;
TheFirst = FirstShape;
TheLast = LastShape;
if (! myFaces.IsNull()) InitialLength = myFaces->ColLength();
// there are two kinds of generation
// 1. generate with S from each Filler (Vertex, Edge)
// 2. call MakeShape recursively on the subshapes of S
//
// explode is True in the second case
// create the result empty
switch (S.ShapeType()) {
case TopAbs_VERTEX :
{
B.MakeWire(TopoDS::Wire(result));
break;
}
case TopAbs_EDGE :
{
TopoDS_Wire W;
B.MakeShell(TopoDS::Shell(result));
B.MakeWire(W);
B.Add(W, S);
W.Closed(S.Closed());
TheS = W;
if (!FirstShape.IsNull()) {
B.MakeWire(W);
B.Add(W, FirstShape);
W.Closed(FirstShape.Closed());
TheFirst = W;
}
if (!LastShape.IsNull()) {
B.MakeWire(W);
B.Add(W, LastShape);
W.Closed(LastShape.Closed());
TheLast = W;
}
break;
}
case TopAbs_WIRE :
B.MakeShell(TopoDS::Shell(result));
break;
case TopAbs_FACE :
{
B.MakeShell(TopoDS::Shell(result));
explode = Standard_True;
if ( !mySpine.Closed() && !TheFirst.IsNull()) {
B.Add(result, TheFirst.Reversed());
}
break;
}
case TopAbs_SHELL :
{
B.MakeCompSolid(TopoDS::CompSolid(result));
explode = Standard_True;
break;
}
case TopAbs_SOLID :
case TopAbs_COMPSOLID :
Standard_DomainError::Raise("BRepFill_Pipe::SOLID or COMPSOLID");
break;
case TopAbs_COMPOUND :
{
B.MakeCompound(TopoDS::Compound(result));
explode = Standard_True;
break;
}
#ifndef DEB
default:
break;
#endif
}
if (explode) {
// add the subshapes
TopoDS_Iterator itFirst, itLast;
TopoDS_Shape first, last;
if (!TheFirst.IsNull()) itFirst.Initialize(TheFirst);
if (!TheLast.IsNull()) itLast.Initialize(TheLast);
for (TopoDS_Iterator it(S); it.More(); it.Next()) {
if (!TheFirst.IsNull()) first = itFirst.Value();
if (!TheLast.IsNull()) last = itLast.Value();
if (TheS.ShapeType() == TopAbs_FACE )
MakeShape(it.Value(), first, last);
else
B.Add(result,MakeShape(it.Value(), first, last));
if (!TheFirst.IsNull()) itFirst.Next();
if (!TheLast.IsNull()) itLast.Next();
}
}
else {
if (TheS.ShapeType() == TopAbs_VERTEX ) {
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (TopoDS::Vertex(TheS));
BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
MkSw.Build( BRepFill_Modified, GeomFill_Location, GeomAbs_C2, myDegmax, mySegmax );
result = MkSw.Shape();
}
if (TheS.ShapeType() == TopAbs_WIRE ) {
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (TopoDS::Wire(TheS));
BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
MkSw.SetBounds(TopoDS::Wire(TheFirst),
TopoDS::Wire(TheLast));
MkSw.Build( BRepFill_Modified, GeomFill_Location, GeomAbs_C2, myDegmax, mySegmax );
result = MkSw.Shape();
// Reperage des elements
if (mySections.IsNull()) {
myFaces = MkSw.SubShape();
mySections = MkSw.Sections();
myEdges = MkSw.InterFaces();
}
else {
Handle(TopTools_HArray2OfShape) Aux, Somme;
Standard_Integer length;
Standard_Integer ii, jj, kk;
Aux = MkSw.SubShape();
length = Aux->ColLength() + myFaces->ColLength();
Somme = new (TopTools_HArray2OfShape) (1, length, 1,
Aux->RowLength());
for (jj=1; jj<=myFaces->RowLength(); jj++) {
for (ii=1; ii<=myFaces->ColLength(); ii++)
Somme->SetValue(ii, jj, myFaces->Value(ii, jj));
for (kk=1, ii=myFaces->ColLength()+1;
kk <=Aux->ColLength(); kk++, ii++)
Somme->SetValue(ii, jj, Aux->Value(kk, jj));
}
myFaces = Somme;
Aux = MkSw.Sections();
length = Aux->ColLength() + mySections->ColLength();
Somme = new (TopTools_HArray2OfShape) (1, length, 1,
Aux->RowLength());
for (jj=1; jj<=mySections->RowLength(); jj++) {
for (ii=1; ii<=mySections->ColLength(); ii++)
Somme->SetValue(ii, jj, mySections->Value(ii, jj));
for (kk=1, ii=mySections->ColLength()+1;
kk <=Aux->ColLength(); kk++, ii++)
Somme->SetValue(ii, jj, Aux->Value(kk, jj));
}
mySections = Somme;
Aux = MkSw.InterFaces();
length = Aux->ColLength() + myEdges->ColLength();
Somme = new (TopTools_HArray2OfShape) (1, length, 1,
Aux->RowLength());
for (jj=1; jj<=myEdges->RowLength(); jj++) {
for (ii=1; ii<=myEdges->ColLength(); ii++)
Somme->SetValue(ii, jj, myEdges->Value(ii, jj));
for (kk=1, ii=myEdges->ColLength()+1;
kk <=Aux->ColLength(); kk++, ii++)
Somme->SetValue(ii, jj, Aux->Value(kk, jj));
}
myEdges = Somme;
}
}
}
if ( TheS.ShapeType() == TopAbs_FACE ) {
Standard_Integer ii, jj;
TopoDS_Face F;
for (ii=InitialLength+1; ii<=myFaces->ColLength(); ii++) {
for (jj=1; jj<=myFaces->RowLength(); jj++) {
F = TopoDS::Face(myFaces->Value(ii, jj));
if (!F.IsNull()) B.Add(result, F);
}
}
if ( !mySpine.Closed()) {
// if Spine is not closed
// add the last face of the solid
B.Add(result, TopoDS::Face(TheLast));
}
TopoDS_Solid solid;
BRep_Builder BS;
BS.MakeSolid(solid);
result.Closed(Standard_True);
BS.Add(solid,TopoDS::Shell(result));
BRepClass3d_SolidClassifier SC(solid);
SC.PerformInfinitePoint(Precision::Confusion());
if ( SC.State() == TopAbs_IN) {
BS.MakeSolid(solid);
TopoDS_Shape aLocalShape = result.Reversed();
BS.Add(solid,TopoDS::Shell(aLocalShape));
// BS.Add(solid,TopoDS::Shell(result.Reversed()));
}
return solid;
}
else {
return result;
}
return result;
}
//=======================================================================
//function : FindEdge
//purpose : Recherche le numero de bande correspondant a une edge du
// profil.
//=======================================================================
Standard_Integer BRepFill_Pipe::FindEdge(const TopoDS_Shape& S,
const TopoDS_Edge& E,
Standard_Integer& InitialLength) const
{
Standard_Integer result = 0;
switch (S.ShapeType()) {
case TopAbs_EDGE :
{
InitialLength++;
if (S.IsSame(E)) result = InitialLength;
break;
}
case TopAbs_WIRE :
{
Standard_Integer ii = InitialLength+1;
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (TopoDS::Wire(S), Standard_False);
InitialLength += Section->NbLaw();
for (; (ii<=InitialLength) && (!result); ii++) {
if (E.IsSame(Section->Edge(ii)) ) result = ii;
}
break;
}
case TopAbs_FACE :
case TopAbs_SHELL :
case TopAbs_COMPOUND :
{
for (TopoDS_Iterator it(S); it.More() && (!result); it.Next())
result = FindEdge(it.Value(), E, InitialLength );
break;
}
case TopAbs_SOLID :
case TopAbs_COMPSOLID :
Standard_DomainError::Raise("BRepFill_Pipe::SOLID or COMPSOLID");
break;
#ifndef DEB
default:
break;
#endif
}
return result;
}
//=======================================================================
//function : FindVertex
//purpose : Recherche le numero de bande correspondant a une edge du
// profil.
//=======================================================================
Standard_Integer BRepFill_Pipe::FindVertex(const TopoDS_Shape& S,
const TopoDS_Vertex& V,
Standard_Integer& InitialLength) const
{
Standard_Integer result = 0;
switch (S.ShapeType()) {
case TopAbs_VERTEX :
{
InitialLength++;
if (S.IsSame(V)) result = InitialLength;
break;
}
case TopAbs_EDGE :
{
TopoDS_Vertex VF, VL;
TopExp::Vertices(TopoDS::Edge(S), VF, VL);
if (S.Orientation() == TopAbs_REVERSED) {
TopoDS_Vertex aux;
aux = VF; VF = VL; VL = aux;
}
if (VF.IsSame(V)) result = InitialLength+1;
else if (VL.IsSame(V)) result = InitialLength+2;
InitialLength += 2;
break;
}
case TopAbs_WIRE :
{
Standard_Integer ii = InitialLength+1;
Handle(BRepFill_ShapeLaw) Section =
new (BRepFill_ShapeLaw) (TopoDS::Wire(S), Standard_False);
InitialLength += Section->NbLaw()+1;
for (; (ii<=InitialLength) && (!result); ii++) {
if (V.IsSame(Section->Vertex(ii, 0.)) ) result = ii;
}
break;
}
case TopAbs_FACE :
case TopAbs_SHELL :
case TopAbs_COMPOUND :
{
for (TopoDS_Iterator it(S); it.More() && (!result); it.Next())
result = FindVertex(it.Value(), V, InitialLength);
break;
}
case TopAbs_SOLID :
case TopAbs_COMPSOLID :
Standard_DomainError::Raise("BRepFill_Pipe::SOLID or COMPSOLID");
break;
#ifndef DEB
default:
break;
#endif
}
return result;
}
//=======================================================================
//function : DefineRealSegmax
//purpose : Defines the real number of segments
// required in the case of bspline spine
//=======================================================================
void BRepFill_Pipe::DefineRealSegmax()
{
Standard_Integer RealSegmax = 0;
TopoDS_Iterator iter(mySpine);
for (; iter.More(); iter.Next())
{
TopoDS_Edge E = TopoDS::Edge(iter.Value());
Standard_Real first, last;
Handle(Geom_Curve) C = BRep_Tool::Curve( E, first, last );
if (C.IsNull())
continue;
while (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve) ||
C->DynamicType() == STANDARD_TYPE(Geom_OffsetCurve))
{
if (C->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve))
C = (*((Handle(Geom_TrimmedCurve)*)&C))->BasisCurve();
if (C->DynamicType() == STANDARD_TYPE(Geom_OffsetCurve))
C = (*((Handle(Geom_OffsetCurve)*)&C))->BasisCurve();
}
if (C->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve))
{
const Handle(Geom_BSplineCurve)& BC = *((Handle(Geom_BSplineCurve)*)&C);
Standard_Integer NbKnots = BC->NbKnots();
Standard_Integer RealNbKnots = NbKnots;
if (first > BC->FirstParameter())
{
Standard_Integer I1, I2;
BC->LocateU( first, Precision::PConfusion(), I1, I2 );
RealNbKnots -= I1-1;
}
if (last < BC->LastParameter())
{
Standard_Integer I1, I2;
BC->LocateU( last, Precision::PConfusion(), I1, I2 );
RealNbKnots -= NbKnots-I2;
}
RealSegmax += RealNbKnots-1;
}
}
if (mySegmax < RealSegmax)
mySegmax = RealSegmax;
}

View File

@@ -0,0 +1,272 @@
-- File: BRepFill_PipeShell.cdl
-- Created: Wed Jul 22 09:10:50 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class PipeShell from BRepFill inherits TShared from MMgt
---Purpose: Perform general sweeping construction
uses
Dir from gp,
Ax2 from gp,
Function from Law,
ListOfShape from TopTools,
HArray2OfShape from TopTools,
Shape from TopoDS,
Wire from TopoDS,
Vertex from TopoDS,
TransitionStyle from BRepFill,
Trihedron from GeomFill,
PipeError from GeomFill,
LocationLaw from BRepFill,
SectionLaw from BRepFill,
Section from BRepFill,
Sweep from BRepFill,
DataMapOfShapeListOfShape from TopTools,
SequenceOfSection from BRepFill
raises
DomainError from Standard,
NotDone from StdFail
is
Create( Spine : Wire from TopoDS)
---Level: Public
returns PipeShell from BRepFill;
-- =================================
-- Methodes Set
-- =================================
---Purpose: Set an sweep's mode
-- If no mode are setted, the mode use in MakePipe is used
---See Also: GeomFill_IsCorrectedFrenet
Set(me : mutable; Frenet : Boolean = Standard_False);
---Purpose: Set an Frenet or an CorrectedFrenet trihedron
-- to perform the sweeping
---Level: Public
---See Also:GeomFill_IsCorrectedFrenet
Set(me : mutable; Axe : Ax2 from gp);
---Purpose: Set an fixed trihedron to perform the sweeping
-- all sections will be parallel.
---Level: Public
---See Also: GeomFill_IsFixed
Set(me : mutable; BiNormal : Dir from gp);
---Purpose: Set an fixed BiNormal direction to perform
-- the sweeping
---Level: Public
---See Also: GeomFill_IsConstantNormal
Set(me : mutable; SpineSupport : Shape from TopoDS)
---Purpose: Set support to the spine to define the BiNormal
-- at the spine, like the normal the surfaces.
-- Warning: To be effective, Each edge of the <spine> must
-- have an representaion on one face of<SpineSupport>
---Level: Public
---See Also: GeomFill_IsDarboux
returns Boolean;
Set(me : mutable;
AuxiliarySpine : Wire from TopoDS;
CurvilinearEquivalence : Boolean = Standard_True;
KeepContact : Boolean = Standard_False );
---Purpose: Set an auxiliary spine to define the Normal
-- For each Point of the Spine P, an Point Q is evalued
-- on <AuxiliarySpine>
-- If <CurvilinearEquivalence>
-- Q split <AuxiliarySpine> with the same length ratio
-- than P split <Spline>.
-- Else the plan define by P and the tangent to the <Spine>
-- intersect <AuxiliarySpine> in Q.
-- If <KeepContact> the Normal is defined to assume like the sweeped
-- section is in contact to the <AuxiliarySpine>
-- Else the Normal is defined by the vector PQ.
---Level: Public
-- =================================
-- Methodes to define section(s)
-- =================================
---Purpose: Give section to sweep.
-- Possibilities are :
-- - Give one or sevral profile
-- - Give one profile and an homotetic law.
-- - Automatic compute of correspondance beetween profile, and section
-- on the sweeped shape
-- - correspondance beetween profile, and section on the sweeped shape
-- defined by a vertex of the spine
-- -"WithCorrection" The profile is rotated to have a Normal --
-- parallel to the trihedron's normal and have tangent
-- perpendicular to the trihedron's tangent.
Add(me:mutable;
Profile : Shape from TopoDS;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False );
---Purpose: Set an section. The corespondance with the spine, will
-- be automaticaly performed.
---Level: Public
Add(me:mutable;
Profile : Shape from TopoDS;
Location : Vertex from TopoDS;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False)
---Purpose: Set an section. The corespondance with the spine, is
-- given by <Location>
---Level: Public
raises DomainError; -- if the <Spine> do not contain <Location>
SetLaw(me :mutable;
Profile : Shape from TopoDS;
L : Function from Law;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False);
---Purpose: Set an section and an homotetic law.
-- The homotetie's centers is given by point on the <Spine>.
---Level: Public
SetLaw(me :mutable;
Profile : Shape from TopoDS;
L : Function from Law;
Location : Vertex from TopoDS;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False);
---Purpose: Set an section and an homotetic law.
-- The homotetie center is given by point on the <Spine>
---Level: Public
Delete(me : mutable; Profile : Shape from TopoDS);
---Purpose: Delete an section.
---Level: Public
-- ========================================
-- Methodes to perform and read shape
-- ========================================
IsReady(me)
---Purpose: Say if <me> is ready to build the shape
-- return False if <me> do not have section definition
returns Boolean;
GetStatus(me)
---Purpose: Get a status, when Simulate or Build failed.
returns PipeError from GeomFill;
SetTolerance(me : mutable;
Tol3d : Real = 1.0e-4;
BoundTol : Real = 1.0e-4;
TolAngular : Real = 1.0e-2);
SetTransition(me : mutable;
Mode :TransitionStyle from BRepFill
= BRepFill_Modified;
Angmin : Real = 1.0e-2;
Angmax : Real = 6.0)
---Purpose: Set the Transition Mode to manage discontinuities
-- on the sweep.
---Level: Public
is static;
Simulate(me : mutable;
NumberOfSection : Integer;
Sections : out ListOfShape from TopTools)
---Purpose: Perform simulation of the sweep :
-- Somes Section are returned.
---Level: Public
raises NotDone; -- If <me> it is not Ready
Build(me : mutable)
---Purpose: Builds the resulting shape (redefined from MakeShape).
---Level: Public
returns Boolean
raises NotDone -- If <me> it is not Ready
is static;
MakeSolid(me : mutable)
---Purpose: Transform the sweeping Shell in Solid.
-- If the section are not closed returns False
---Level: Public
returns Boolean
raises NotDone; -- If <me> is not Builded;
Shape (me)
---Purpose: Returns the result Shape.
---C++: return const &
---Level: Public
returns Shape from TopoDS
is static;
FirstShape (me)
---Purpose: Returns the TopoDS Shape of the bottom of the sweep.
---C++: return const &
---Level: Public
returns Shape from TopoDS
is static;
LastShape (me)
---Purpose: Returns the TopoDS Shape of the top of the sweep.
---C++: return const &
---Level: Public
returns Shape from TopoDS
is static;
Generated (me: mutable;
S : Shape from TopoDS;
L : out ListOfShape from TopTools)
---Purpose: Returns the list of shapes generated from the
-- shape <S>.
---Level: Public
is static;
Prepare(me: mutable) is private;
Place(me : mutable;
Sec : Section from BRepFill;
W : out Wire from TopoDS;
param : out Real from Standard) is private;
ResetLoc(me : mutable) is private;
BuildHistory(me: mutable; theSweep: Sweep from BRepFill)
is private;
fields
mySpine : Wire from TopoDS;
myFirst : Shape from TopoDS;
myLast : Shape from TopoDS;
myShape : Shape from TopoDS;
mySeq : SequenceOfSection from BRepFill;
myGenMap : DataMapOfShapeListOfShape from TopTools;
myTol3d : Real;
myBoundTol : Real;
myTolAngular : Real;
angmin, angmax : Real;
myLaw : Function from Law;
myLocation : LocationLaw from BRepFill;
mySection : SectionLaw from BRepFill;
myFaces : HArray2OfShape from TopTools;
myTrihedron : Trihedron from GeomFill;
myTransition : TransitionStyle from BRepFill;
myStatus : PipeError from GeomFill;
end PipeShell;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
-- File: BRepFill_Section.cdl
-- Created: Wed Jul 22 10:18:13 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
private class Section from BRepFill
---Purpose: To store section definition
uses
Shape from TopoDS,
Wire from TopoDS,
Vertex from TopoDS
is
Create returns Section from BRepFill;
Create (Profile : Shape from TopoDS;
V : Vertex from TopoDS;
WithContact : Boolean ;
WithCorrection : Boolean)
returns Section from BRepFill;
Set(me : in out; IsLaw : Boolean);
Wire(me)
---C++: return const &
---C++: inline
returns Wire from TopoDS;
Vertex(me)
---C++: return const &
---C++: inline
returns Vertex from TopoDS;
IsLaw(me)
---C++: inline
returns Boolean;
WithContact(me)
---C++: inline
returns Boolean;
WithCorrection(me)
---C++: inline
returns Boolean;
fields
wire : Wire from TopoDS;
vertex : Vertex from TopoDS;
islaw : Boolean;
contact : Boolean;
correction:Boolean;
end Section;

View File

@@ -0,0 +1,52 @@
// File: BRepFill_Section.cxx
// Created: Wed Jul 22 10:50:48 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_Section.ixx>
#include <TopoDS.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Edge.hxx>
BRepFill_Section::BRepFill_Section() :islaw(0), contact(0), correction(0)
{
}
BRepFill_Section::BRepFill_Section(const TopoDS_Shape& Profile,
const TopoDS_Vertex& V,
const Standard_Boolean WithContact,
const Standard_Boolean WithCorrection)
: vertex(V),
islaw(0),contact(WithContact),
correction(WithCorrection)
{
if (Profile.ShapeType() == TopAbs_WIRE)
wire = TopoDS::Wire(Profile);
else if (Profile.ShapeType() == TopAbs_VERTEX)
{
TopoDS_Vertex aVertex = TopoDS::Vertex(Profile);
BRep_Builder BB;
TopoDS_Edge DegEdge;
BB.MakeEdge( DegEdge );
BB.Add( DegEdge, aVertex.Oriented(TopAbs_FORWARD) );
BB.Add( DegEdge, aVertex.Oriented(TopAbs_REVERSED) );
BB.Degenerated( DegEdge, Standard_True );
DegEdge.Closed( Standard_True );
BB.MakeWire( wire );
BB.Add( wire, DegEdge );
wire.Closed( Standard_True );
}
else
Standard_Failure::Raise("BRepFill_Section: bad shape type of section");
}
void BRepFill_Section::Set(const Standard_Boolean IsLaw)
{
islaw = IsLaw;
}

View File

@@ -0,0 +1,31 @@
// File: BRepFill_Section.lxx
// Created: Wed Jul 22 10:51:47 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
inline const TopoDS_Wire& BRepFill_Section::Wire() const
{
return wire;
}
inline const TopoDS_Vertex& BRepFill_Section::Vertex() const
{
return vertex;
}
inline Standard_Boolean BRepFill_Section::IsLaw() const
{
return islaw;
}
inline Standard_Boolean BRepFill_Section::WithContact() const
{
return contact;
}
inline Standard_Boolean BRepFill_Section::WithCorrection() const
{
return correction;
}

View File

@@ -0,0 +1,77 @@
-- File: BRepFill_SectionLaw.cdl
-- Created: Wed Jan 7 12:07:03 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
deferred class SectionLaw from BRepFill inherits TShared from MMgt
---Purpose: Build Section Law, with an Vertex, or an Wire
---Level: Advanced
uses
SectionLaw from GeomFill,
HArray1OfSectionLaw from GeomFill,
Shape from GeomAbs,
Shape from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
WireExplorer from BRepTools
is
NbLaw(me) returns Integer;
Law(me; Index : Integer)
---C++: return const &
returns SectionLaw from GeomFill;
IsConstant(me) returns Boolean
is deferred;
IsUClosed(me) returns Boolean;
IsVClosed(me) returns Boolean;
IsVertex(me)
---Purpose: Say if the input sahpe is a vertex.
returns Boolean
is deferred;
ConcatenedLaw(me)
returns SectionLaw from GeomFill
is deferred;
Continuity(me; Index : Integer;
TolAngular : Real)
returns Shape from GeomAbs
is deferred;
VertexTol(me; Index : Integer;
Param : Real)
returns Real
is deferred;
Vertex(me; Index : Integer;
Param : Real)
returns Vertex from TopoDS
is deferred;
D0(me:mutable; U : Real;
S : out Shape from TopoDS)
is deferred;
Init(me: mutable; W : Wire from TopoDS);
CurrentEdge(me : mutable)
returns Edge from TopoDS;
fields
myLaws : HArray1OfSectionLaw from GeomFill is protected;
uclosed : Boolean from Standard is protected;
vclosed : Boolean from Standard is protected;
myIterator : WireExplorer from BRepTools;
end SectionLaw;

View File

@@ -0,0 +1,104 @@
// File: BRepFill_SectionLaw.cxx
// Created: Wed Jan 7 13:40:00 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_SectionLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepLProp.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomFill_UniformSection.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Precision.hxx>
//=======================================================================
//function : NbLaw
//purpose : Donne le nombre de loi elementaire (ou Geometrique)
//=======================================================================
Standard_Integer BRepFill_SectionLaw::NbLaw() const
{
return myLaws->Length();
}
//=======================================================================
//function : Law
//purpose :
//=======================================================================
const Handle(GeomFill_SectionLaw)&
BRepFill_SectionLaw::Law(const Standard_Integer Index) const
{
return myLaws->Value(Index);
}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean BRepFill_SectionLaw::IsUClosed() const
{
return uclosed;
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean BRepFill_SectionLaw::IsVClosed() const
{
return vclosed;
}
//=======================================================================
//function : Init
//purpose : Prepare le parcour d'un wire
//=======================================================================
void BRepFill_SectionLaw::Init(const TopoDS_Wire& W)
{
myIterator.Init(W);
}
//=======================================================================
//function :
//purpose : Parcourt d'un wire en sautant les Edges degenere
//=======================================================================
TopoDS_Edge BRepFill_SectionLaw::CurrentEdge()
{
TopoDS_Edge E;
// Class BRep_Tool without fields and without Constructor :
// BRep_Tool B;
Standard_Boolean Suivant = Standard_False;
if (myIterator.More()) {
E = myIterator.Current();
// Suivant = (B.Degenerated(E));
Suivant = (BRep_Tool::Degenerated(E));
}
while (Suivant) {
myIterator.Next();
E = myIterator.Current();
// Suivant = (B.Degenerated(E) && myIterator.More());
Suivant = (BRep_Tool::Degenerated(E) && myIterator.More());
}
if (myIterator.More()) myIterator.Next();
return E;
}

View File

@@ -0,0 +1,52 @@
-- File: BRepFill_SectionPlacement.cdl
-- Created: Wed Feb 11 16:11:25 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
private class SectionPlacement from BRepFill
---Purpose: Place a shape in a local axis coordinate
uses
LocationLaw from BRepFill,
Shape from TopoDS,
Trsf from gp
is
Create(Law : LocationLaw from BRepFill;
Section : Shape from TopoDS;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False)
---Purpose: Automatic placement
returns SectionPlacement from BRepFill;
Create(Law : LocationLaw from BRepFill;
Section : Shape from TopoDS;
Vertex : Shape from TopoDS;
WithContact : Boolean = Standard_False;
WithCorrection : Boolean = Standard_False)
---Purpose: Placement on vertex
returns SectionPlacement from BRepFill;
Perform(me:in out;
WithContact : Boolean;
WithCorrection : Boolean;
Vertex : Shape from TopoDS)
is private;
Transformation(me)
---C++: return const &
returns Trsf from gp;
AbscissaOnPath(me:in out)
returns Real;
fields
myLaw : LocationLaw from BRepFill;
mySection : Shape from TopoDS;
myTrsf : Trsf from gp;
myParam : Real;
myIndex : Integer;
end SectionPlacement;

View File

@@ -0,0 +1,353 @@
// File: BRepFill_SectionPlacement.cxx
// Created: Wed Feb 11 16:23:18 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_SectionPlacement.ixx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepAdaptor_HCompCurve.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepExtrema_SupportType.hxx>
#include <Geom_Curve.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Line.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomFill_SectionPlacement.hxx>
#include <GeomFill_LocationLaw.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_NotImplemented.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Precision.hxx>
#if DEB
static Standard_Boolean myDebug = Standard_False;
#endif
static Standard_Real SearchParam(const Handle(BRepFill_LocationLaw)& Law,
const Standard_Integer Ind,
const TopoDS_Vertex& TheV)
{
Standard_Real t;
TopoDS_Edge E;
E = Law->Edge(Ind);
t = BRep_Tool::Parameter(TheV, E);
if (E.Orientation() == TopAbs_REVERSED) {
Standard_Real f, l, Lf, Ll;
Handle(Geom_Curve) C;
C = BRep_Tool::Curve(E,f,l);
Lf = Law->Law(Ind)->GetCurve()->FirstParameter();
Ll = Law->Law(Ind)->GetCurve()->LastParameter();
t = Ll - (t-f)*(Ll-Lf)/(l-f);
}
return t;
}
BRepFill_SectionPlacement::
BRepFill_SectionPlacement(const Handle(BRepFill_LocationLaw)& Law,
const TopoDS_Shape& Section,
const Standard_Boolean WithContact,
const Standard_Boolean WithCorrection) :
myLaw(Law), mySection(Section)
{
TopoDS_Vertex VNull;
VNull.Nullify();
Perform(WithContact, WithCorrection, VNull);
}
BRepFill_SectionPlacement::
BRepFill_SectionPlacement(const Handle(BRepFill_LocationLaw)& Law,
const TopoDS_Shape& Section,
const TopoDS_Shape& Vertex,
const Standard_Boolean WithContact,
const Standard_Boolean WithCorrection) :
myLaw(Law), mySection(Section)
{
Perform(WithContact, WithCorrection, Vertex);
}
void BRepFill_SectionPlacement::Perform(const Standard_Boolean WithContact,
const Standard_Boolean WithCorrection,
const TopoDS_Shape& Vertex)
{
TopoDS_Vertex TheV;
TheV = TopoDS::Vertex(Vertex);
Standard_Integer ii;
Standard_Integer Ind1 = 0, Ind2 = 0;
Standard_Boolean Bof, isVertex = Standard_False;
Standard_Real First, Last;
TopExp_Explorer Ex;
TopoDS_Edge E;
TopoDS_Vertex V;
Handle(Geom_Curve) C;
Handle(Geom_TrimmedCurve) TC;
// modified by NIZHNY-OCC629 Thu Jul 24 14:11:45 2003
Standard_Boolean isFound = Standard_False;
Ex.Init(mySection, TopAbs_EDGE);
for(; Ex.More(); Ex.Next()) {
E = TopoDS::Edge(Ex.Current());
// avoid null, degenerated edges
if( E.IsNull() || BRep_Tool::Degenerated(E) ) continue;
C = BRep_Tool::Curve(E, First, Last);
if( C.IsNull() ) continue;
isFound = Standard_True;
break;
}
if( !isFound )
isVertex = Standard_True;
else
{
TC = new (Geom_TrimmedCurve)(C, First, Last);
Ex.Next();
if( Ex.More() ) {
Standard_Real tolrac, epsV, tol = Precision::Confusion();
GeomConvert_CompCurveToBSplineCurve Conv(TC);
for (; Ex.More(); Ex.Next()) {
E = TopoDS::Edge(Ex.Current());
// avoid null, degenerated edges
if( E.IsNull() || BRep_Tool::Degenerated(E) ) continue;
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E,VFirst, VLast);
epsV = Max(BRep_Tool::Tolerance(VFirst), BRep_Tool::Tolerance(VLast));
C = BRep_Tool::Curve(E, First, Last);
if( C.IsNull() ) continue;
TC = new (Geom_TrimmedCurve)(C, First, Last);
tolrac = Min(tol,epsV);
Bof = Conv.Add(TC, tolrac);
if (!Bof) {
tolrac = Max(tol,epsV);
Bof = Conv.Add(TC, tolrac);
}
}
C = Conv.BSplineCurve();
}
else C = TC; // On garde l'unique courbe
}
// modified by NIZHNY-629 Fri Jul 25 11:10:27 2003 b
// // section ponctuelle
// Ex.Init(mySection, TopAbs_EDGE);
// Standard_Boolean isPonctual = Standard_False;
// if (Ex.More()) {
// E = TopoDS::Edge(Ex.Current());
// isPonctual = BRep_Tool::Degenerated(E);
// }
// Ex.Init(mySection, TopAbs_EDGE);
// if (Ex.More()&&!isPonctual) {
// E = TopoDS::Edge(Ex.Current());
// C = BRep_Tool::Curve(E, First, Last);
// TC = new (Geom_TrimmedCurve)(C, First, Last);
// Ex.Next();
// if (Ex.More()) { // On essai d'avoir un echantillon representatif
// Standard_Real tolrac, epsV, tol = Precision::Confusion();
// GeomConvert_CompCurveToBSplineCurve Conv(TC);
// for (; Ex.More(); Ex.Next()) {
// E = TopoDS::Edge(Ex.Current());
// TopoDS_Vertex VFirst, VLast;
// TopExp::Vertices(E,VFirst, VLast);
// epsV = Max(BRep_Tool::Tolerance(VFirst), BRep_Tool::Tolerance(VLast));
// C = BRep_Tool::Curve(E, First, Last);
// TC = new (Geom_TrimmedCurve)(C, First, Last);
// tolrac = Min(tol,epsV);
// Bof = Conv.Add(TC, tolrac);
// if (!Bof) {
// tolrac = Max(tol,epsV);
// Bof = Conv.Add(TC, tolrac);
// }
// }
// C = Conv.BSplineCurve();
// }
// else C = TC; // On garde l'unique courbe
// }
// else {
// // Localisation par distance Shape/Shape
// Standard_Real Tpos;
// BRepExtrema_DistShapeShape Ext(mySection, myLaw->Wire());
// if (! Ext.IsDone())
// Standard_ConstructionError::Raise("Distance Vertex/Spine");
// if (Ext.SupportTypeShape2(1) == BRepExtrema_IsOnEdge) {
// TopoDS_Shape sbis = Ext.SupportOnShape2(1);
// E = TopoDS::Edge(sbis);
// Ext.ParOnEdgeS2(1, Tpos);
// }
// else {
// TopoDS_Vertex Vf, Vl,V;
// TopoDS_Shape sbis = Ext.SupportOnShape2(1);
// V = TopoDS::Vertex(sbis);
// for (ii=1, Ind1=0 ; ii<=myLaw->NbLaw(); ii++) {
// E = myLaw->Edge(ii);
// TopExp::Vertices(E, Vf, Vl);
// if ((V.IsSame(Vf)) || (V.IsSame(Vl))) {
// if (Ind1 == 0) Ind1 = ii;
// else Ind2 = ii;
// }
// }
// // On invente une section
// gp_Dir D(0, 0, 1);
// gp_Pnt Origine, PV;
// Origine = BRep_Tool::Pnt(V);
// Standard_Real length;
// if (Ext.SupportTypeShape1(1) == BRepExtrema_IsVertex) {
// TopoDS_Shape aLocalShape = Ext.SupportOnShape1(1);
// PV = BRep_Tool::Pnt(TopoDS::Vertex(aLocalShape));
// // PV = BRep_Tool::Pnt(TopoDS::Vertex(Ext.SupportOnShape1(1)));
// }
// else {
// PV = BRep_Tool::Pnt(TopoDS::Vertex(mySection));
// }
// length = Origine.Distance(PV);
// if (length > Precision::Confusion()) {
// gp_Vec theVec(Origine, PV);
// D.SetXYZ(theVec.XYZ());
// }
// else length = 10*Precision::Confusion();
// Handle(Geom_Line) CL = new (Geom_Line) (Origine, D);
// TC = new (Geom_TrimmedCurve)(CL, 0., length);
// C = TC;
// isVertex = Standard_True;
// }
// }
// // Recherche du Vertex de positionnement
// if (!TheV.IsNull()) {
// Standard_Integer NbV = myLaw->NbLaw()+1;
// for (ii=1, Ind1=0; ii<=NbV && (!Ind1); ii++)
// if (TheV.IsSame(myLaw->Vertex(ii))) Ind1 = ii;
// if (Ind1 != 0) {
// Ind2 =0;
// isVertex = Standard_True;
// if (Ind1==1) {
// if (myLaw->IsClosed()) Ind2 = NbV-1;
// }
// else {
// Ind1--;
// if (Ind1 < NbV-1)
// Ind2 = Ind1+1;
// }
// }
// else {
// TheV.Nullify(); // On oublie cette option...
// }
// }
// modified by NIZHNY-629 Fri Jul 25 11:11:06 2003 e
// Construction
Handle(Geom_Geometry) theSection = C;
if (isVertex)
{
Ex.Init(mySection, TopAbs_VERTEX);
TopoDS_Vertex theVertex = TopoDS::Vertex(Ex.Current());
gp_Pnt thePoint = BRep_Tool::Pnt(theVertex);
theSection = new Geom_CartesianPoint(thePoint);
}
GeomFill_SectionPlacement Place(myLaw->Law(1), theSection);
// Dans le cas generale : Localisation via une concatenation de la spine
TColStd_Array1OfReal SuperKnot(1, myLaw->NbLaw()+1);
TColStd_Array1OfInteger Index(1, myLaw->NbLaw());
for (ii=1; ii<=myLaw->NbLaw(); ii++) {
SuperKnot(ii+1) = Index(ii) = ii;
}
SuperKnot(1) = 0;
Handle(BRepAdaptor_HCompCurve) adpPath =
new (BRepAdaptor_HCompCurve) (myLaw->Wire());
Place.Perform(adpPath, Precision::Confusion());
Standard_Real theParam = Place.ParameterOnPath(),
eps = Precision::PConfusion();
#if DEB
if (myDebug) {
gp_Pnt P_Path;
P_Path = adpPath->Value(theParam);
cout << "Point on Path" << P_Path.X() << ", "
<< P_Path.Y() << ", " << P_Path.Z() << ", " << endl;
}
#endif
for (ii=1, Bof=Standard_True; ii<=myLaw->NbLaw() && Bof; ii++) {
Bof = !((SuperKnot(ii)-eps<=theParam) &&
(SuperKnot(ii+1)+eps>= theParam));
if (!Bof) {
Ind1 = ii;
if ( (Abs(theParam-SuperKnot(ii))<eps) && (ii>1) ) Ind2 = ii-1;
else if ((Abs(theParam-SuperKnot(ii+1))<eps) &&
(ii<myLaw->NbLaw()) ) Ind2 = ii+1;
}
}
if (Bof) Standard_ConstructionError::Raise("Interval non trouve !!");
Ind1 = Index(Ind1);
if (Ind2) Ind2 = Index(Ind2);
// Positionnement sur l'edge (ou les 2 Edges) localisee(s)
Standard_Real Angle;
Place.SetLocation(myLaw->Law(Ind1));
if(TheV.IsNull())
Place.Perform(Precision::Confusion());
else {
Place.Perform(SearchParam(myLaw, Ind1, TheV),
Precision::Confusion());
}
myTrsf = Place.Transformation(WithContact, WithCorrection);
myIndex = Ind1;
myParam = Place.ParameterOnPath();
Angle = Place.Angle();
if (Ind2) {
Place.SetLocation(myLaw->Law(Ind2));
if (TheV.IsNull())
Place.Perform(Precision::Confusion());
else {
if (Ind1 == Ind2) TheV.Reverse();
Place.Perform(SearchParam(myLaw, Ind2,TheV),
Precision::Confusion());
}
if (Place.Angle() > Angle) {
myTrsf = Place.Transformation(WithContact, WithCorrection);
myIndex = Ind2;
myParam = Place.ParameterOnPath();
}
}
}
const gp_Trsf& BRepFill_SectionPlacement::Transformation() const
{
return myTrsf;
}
Standard_Real BRepFill_SectionPlacement::AbscissaOnPath()
{
return myLaw->Abscissa(myIndex, myParam);
}

View File

@@ -0,0 +1,87 @@
-- File: BRepFill_ShapeLaw.cdl
-- Created: Mon Aug 17 10:17:21 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class ShapeLaw from BRepFill inherits SectionLaw from BRepFill
---Purpose: Build Section Law, with an Vertex, or an Wire
---Level: Advanced
uses
SectionLaw from GeomFill,
HArray1OfSectionLaw from GeomFill,
HArray1OfShape from TopTools,
Shape from GeomAbs,
Vertex from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
Shape from TopoDS,
Function from Law
is
Create (V: Vertex from TopoDS;
Build : Boolean = Standard_True )
---Purpose: Construct an constant Law
returns ShapeLaw from BRepFill;
Create (W:Wire from TopoDS;
Build : Boolean = Standard_True)
---Purpose: Construct an constant Law
returns ShapeLaw from BRepFill;
Create (W: Wire from TopoDS;
L: Function from Law;
Build : Boolean = Standard_True)
---Purpose: Construct an evolutive Law
returns ShapeLaw from BRepFill;
IsVertex(me)
---Purpose: Say if the input shape is a vertex.
returns Boolean
is redefined;
IsConstant(me)
---Purpose: Say if the Law is Constant.
returns Boolean
is redefined;
ConcatenedLaw(me)
---Purpose: Give the law build on a concaneted section
returns SectionLaw from GeomFill
is redefined;
Continuity(me; Index : Integer;
TolAngular : Real)
returns Shape from GeomAbs
is redefined;
VertexTol(me; Index : Integer;
Param : Real)
returns Real
is redefined;
Vertex(me; Index : Integer;
Param : Real)
returns Vertex from TopoDS
is redefined;
D0(me:mutable; Param : Real;
S : out Shape from TopoDS)
is redefined;
Edge(me; Index : Integer)
---C++: return const &
---C++: inline
returns Edge from TopoDS;
Init(me : mutable; B : Boolean) is private;
fields
myShape: Shape from TopoDS;
myEdges: HArray1OfShape from TopTools;
TheLaw : Function from Law;
vertex : Boolean from Standard is protected;
end ShapeLaw;

View File

@@ -0,0 +1,440 @@
// File: BRepFill_ShapeLaw.cxx
// Created: Mon Aug 17 10:30:37 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <BRepFill_ShapeLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepLProp.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomFill_UniformSection.hxx>
#include <GeomFill_EvolvedSection.hxx>
#include <GeomFill_HArray1OfSectionLaw.hxx>
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Precision.hxx>
//=======================================================================
//function : Create
//purpose : On traite le cas du Vertex en construisant, une line,
// ayant le vertex pour origine
//=======================================================================
BRepFill_ShapeLaw::BRepFill_ShapeLaw(const TopoDS_Vertex& V,
const Standard_Boolean Build)
: vertex(Standard_True),
myShape(V)
{
TheLaw.Nullify();
uclosed = Standard_False;
vclosed = Standard_True; // loi constante
myEdges = new (TopTools_HArray1OfShape) (1, 1);
myEdges->SetValue(1, V);
if (Build) {
myLaws = new (GeomFill_HArray1OfSectionLaw) (1, 1);
// gp_Pnt Origine;
gp_Dir D(1,0,0); //Suivant la normal
Handle(Geom_Line) L = new (Geom_Line)(BRep_Tool::Pnt(V), D);
Standard_Real Last = 2*BRep_Tool::Tolerance(V)+Precision::PConfusion();
Handle(Geom_TrimmedCurve) TC = new (Geom_TrimmedCurve) (L, 0, Last);
myLaws->ChangeValue(1) =
new (GeomFill_UniformSection)(TC);
}
}
//=======================================================================
//function : Create
//purpose : Wire
//=======================================================================
BRepFill_ShapeLaw::BRepFill_ShapeLaw(const TopoDS_Wire& W,
const Standard_Boolean Build)
: vertex(Standard_False),
myShape(W)
{
TheLaw.Nullify();
Init(Build);
}
//=======================================================================
//function : Create
//purpose : Wire evolutif
//=======================================================================
BRepFill_ShapeLaw::BRepFill_ShapeLaw(const TopoDS_Wire& W,
const Handle(Law_Function)& L,
const Standard_Boolean Build)
: vertex(Standard_False),
myShape(W)
{
TheLaw = L;
Init(Build);
}
//=======================================================================
//function : Init
//purpose : Cas du wire : On cree une table de GeomFill_SectionLaw
//=======================================================================
void BRepFill_ShapeLaw::Init(const Standard_Boolean Build)
{
vclosed = Standard_True;
BRepTools_WireExplorer wexp;
TopoDS_Edge E;
Standard_Integer NbEdge,ii;
Standard_Real First, Last;
TopoDS_Wire W;
W = TopoDS::Wire(myShape);
for (NbEdge=0, wexp.Init(W); wexp.More(); wexp.Next()) {
E = wexp.Current();
if( !E.IsNull() && !BRep_Tool::Degenerated(E)) {
Handle(Geom_Curve) C = BRep_Tool::Curve(E,First,Last);
if( !C.IsNull() ) {
NbEdge++;
}
}
}
myLaws = new GeomFill_HArray1OfSectionLaw (1, NbEdge);
myEdges = new TopTools_HArray1OfShape (1, NbEdge);
ii = 1;
for(wexp.Init(W); wexp.More(); wexp.Next()) {
E = wexp.Current();
if ( !E.IsNull() && !BRep_Tool::Degenerated(wexp.Current())) {
Handle(Geom_Curve) C = BRep_Tool::Curve(E,First,Last);
if( !C.IsNull() ) {
myEdges->SetValue(ii, E);
if(Build) {
//Handle(Geom_Curve) C = BRep_Tool::Curve(E,First,Last);
if (E.Orientation() == TopAbs_REVERSED) {
Standard_Real aux;
Handle(Geom_Curve) CBis;
CBis = C->Reversed(); // Pour eviter de deteriorer la topologie
aux = C->ReversedParameter(First);
First = C->ReversedParameter(Last);
Last = aux;
C = CBis;
}
Standard_Boolean IsReallyClosed = E.Closed();
//IFV - some checking when closed flag is wrong
if(IsReallyClosed) {
TopoDS_Vertex V1, V2;
TopExp::Vertices(E, V1, V2);
if(V1.IsNull() || V2.IsNull()) {
IsReallyClosed = Standard_False;
}
else {
IsReallyClosed = V1.IsSame(V2);
}
}
if ((ii>1) || !IsReallyClosed ) { // On trimme C
Handle(Geom_TrimmedCurve) TC = new Geom_TrimmedCurve(C,First, Last);
C = TC;
}
// sinon On garde l'integrite de la courbe
if (TheLaw.IsNull()) {
myLaws->ChangeValue(ii) = new GeomFill_UniformSection(C);
}
else {
myLaws->ChangeValue(ii) = new GeomFill_EvolvedSection(C, TheLaw);
}
}
ii++;
}
}
}
// cout << "new law" << endl;
// La loi est elle ferme en U ?
uclosed = W.Closed();
if (!uclosed) {
// le flag n'etant pas tres sur, on fait une verif
TopoDS_Edge Edge1, Edge2;
TopoDS_Vertex V1,V2;
Edge1 = TopoDS::Edge (myEdges->Value(myEdges->Length()));
Edge2 = TopoDS::Edge (myEdges->Value(1));
if( Edge1.Orientation() == TopAbs_REVERSED) {
V1 = TopExp::FirstVertex(Edge1);
}
else {
V1 = TopExp::LastVertex(Edge1);
}
if ( Edge2.Orientation() == TopAbs_REVERSED) {
V2 = TopExp::LastVertex(Edge2);
}
else {
V2 = TopExp::FirstVertex(Edge2);
}
if (V1.IsSame(V2)) {
uclosed = Standard_True;
}
else {
BRepAdaptor_Curve Curve1(Edge1);
BRepAdaptor_Curve Curve2(Edge2);
Standard_Real U1 = BRep_Tool::Parameter(V1,Edge1);
Standard_Real U2 = BRep_Tool::Parameter(V2,Edge2);
Standard_Real Eps = BRep_Tool::Tolerance(V2) +
BRep_Tool::Tolerance(V1);
uclosed = Curve1.Value(U1).IsEqual(Curve2.Value(U2), Eps);
}
}
}
//=======================================================================
//function : IsVertex
//purpose :
//=======================================================================
Standard_Boolean BRepFill_ShapeLaw::IsVertex() const
{
return vertex;
}
//=======================================================================
//function : IsConstant
//purpose :
//=======================================================================
Standard_Boolean BRepFill_ShapeLaw::IsConstant() const
{
return TheLaw.IsNull();
}
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
TopoDS_Vertex
BRepFill_ShapeLaw::Vertex(const Standard_Integer Index,
const Standard_Real Param) const
{
TopoDS_Edge E;
TopoDS_Vertex V;
if (Index <= myEdges->Length()) {
E = TopoDS::Edge(myEdges->Value(Index));
if (E.Orientation() == TopAbs_REVERSED)
V = TopExp::LastVertex(E);
else V = TopExp::FirstVertex(E);
}
else if (Index == myEdges->Length()+1) {
E = TopoDS::Edge(myEdges->Value(Index-1));
if (E.Orientation() == TopAbs_REVERSED)
V = TopExp::FirstVertex(E);
else V = TopExp::LastVertex(E);
}
if (!TheLaw.IsNull()) {
gp_Trsf T;
T.SetScale(gp_Pnt(0, 0, 0), TheLaw->Value(Param));
TopLoc_Location L(T);
V.Move(L);
}
return V;
}
///=======================================================================
//function : VertexTol
//purpose : Evalue le trou entre 2 edges de la section
//=======================================================================
Standard_Real BRepFill_ShapeLaw::VertexTol(const Standard_Integer Index,
const Standard_Real Param) const
{
Standard_Real Tol = Precision::Confusion();
Standard_Integer I1, I2;
if ( (Index==0) || (Index==myEdges->Length()) ) {
if (!uclosed) return Tol; //Le moins faux possible
I1 = myEdges->Length();
I2 = 1;
}
else {
I1 = Index;
I2 = I1 +1;
}
Handle(GeomFill_SectionLaw) Loi;
Standard_Integer NbPoles, NbKnots, Degree;
Handle(TColgp_HArray1OfPnt) Poles;
Handle(TColStd_HArray1OfReal) Knots, Weigth;
Handle(TColStd_HArray1OfInteger) Mults;
Handle(Geom_BSplineCurve) BS;
gp_Pnt PFirst;
Loi = myLaws->Value(I1);
Loi->SectionShape( NbPoles, NbKnots, Degree);
Poles = new (TColgp_HArray1OfPnt) (1, NbPoles);
Weigth = new (TColStd_HArray1OfReal) (1, NbPoles);
Loi->D0(Param, Poles->ChangeArray1(), Weigth->ChangeArray1());
Knots = new (TColStd_HArray1OfReal) (1, NbKnots);
Loi->Knots(Knots->ChangeArray1());
Mults = new (TColStd_HArray1OfInteger) (1, NbKnots);
Loi->Mults(Mults->ChangeArray1());
BS = new (Geom_BSplineCurve) (Poles->Array1(),
Weigth->Array1(),
Knots->Array1(),
Mults->Array1(),
Degree,
Loi->IsUPeriodic());
PFirst = BS->Value( Knots->Value(Knots->Length()) );
Loi = myLaws->Value(I2);
Loi->SectionShape( NbPoles, NbKnots, Degree);
Poles = new (TColgp_HArray1OfPnt) (1, NbPoles);
Weigth = new (TColStd_HArray1OfReal) (1, NbPoles);
Loi->D0(Param, Poles->ChangeArray1(), Weigth->ChangeArray1());
Knots = new (TColStd_HArray1OfReal) (1, NbKnots);
Loi->Knots(Knots->ChangeArray1());
Mults = new (TColStd_HArray1OfInteger) (1, NbKnots);
Loi->Mults(Mults->ChangeArray1());
BS = new (Geom_BSplineCurve) (Poles->Array1(),
Weigth->Array1(),
Knots->Array1(),
Mults->Array1(),
Degree,
Loi->IsUPeriodic());
Tol += PFirst.Distance(BS->Value( Knots->Value(1)));
return Tol;
}
//=======================================================================
//function : ConcatenedLaw
//purpose :
//=======================================================================
Handle(GeomFill_SectionLaw) BRepFill_ShapeLaw::ConcatenedLaw() const
{
Handle(GeomFill_SectionLaw) Law;
if (myLaws->Length() == 1)
return myLaws->Value(1);
else {
TopoDS_Wire W;
TopoDS_Vertex V;
W = TopoDS::Wire(myShape);
if(!W.IsNull()) {
// Concatenation des aretes
Standard_Integer ii;
Standard_Real epsV, f, l;
Standard_Boolean Bof;
Handle(Geom_Curve) Composite;
Handle(Geom_TrimmedCurve) TC;
Composite = BRep_Tool::Curve(Edge(1), f, l);
TC = new (Geom_TrimmedCurve)(Composite, f, l);
GeomConvert_CompCurveToBSplineCurve Concat(TC);
for (ii=2, Bof=Standard_True; ii<=myEdges->Length() && Bof; ii++){
Composite = BRep_Tool::Curve(Edge(ii),f, l);
TC = new (Geom_TrimmedCurve)(Composite, f, l);
Bof = TopExp::CommonVertex(Edge(ii-1), Edge(ii), V);
if (Bof) {epsV = BRep_Tool::Tolerance(V);}
else epsV = 10*Precision::PConfusion();
Bof = Concat.Add(TC, epsV, Standard_True,
Standard_False, 20);
if (!Bof) Bof = Concat.Add(TC, 200*epsV,
Standard_True, Standard_False, 20);
#if DEB
if (!Bof)
cout << "BRepFill_ShapeLaw::ConcatenedLaw INCOMPLET !!!"
<< endl;
#endif
}
Composite = Concat.BSplineCurve();
if (TheLaw.IsNull()) {
Law = new (GeomFill_UniformSection)(Composite);
}
else {
Law = new (GeomFill_EvolvedSection)(Composite, TheLaw);
}
}
}
return Law;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape BRepFill_ShapeLaw::Continuity(const Standard_Integer Index,
const Standard_Real TolAngular) const
{
TopoDS_Edge Edge1, Edge2;
if ( (Index==0) || (Index==myEdges->Length()) ) {
if (!uclosed) return GeomAbs_C0; //Le moins faux possible
Edge1 = TopoDS::Edge (myEdges->Value(myEdges->Length()));
Edge2 = TopoDS::Edge (myEdges->Value(1));
}
else {
Edge1 = TopoDS::Edge (myEdges->Value(Index));
Edge2 = TopoDS::Edge (myEdges->Value(Index+1));
}
TopoDS_Vertex V1,V2;
if ( Edge1.Orientation() == TopAbs_REVERSED) {
V1 = TopExp::FirstVertex(Edge1);
}
else {
V1 = TopExp::LastVertex(Edge1);
}
if ( Edge2.Orientation() == TopAbs_REVERSED) {
V2 = TopExp::LastVertex(Edge2);
}
else {
V2 = TopExp::FirstVertex(Edge2);
}
Standard_Real U1 = BRep_Tool::Parameter(V1,Edge1);
Standard_Real U2 = BRep_Tool::Parameter(V2,Edge2);
BRepAdaptor_Curve Curve1(Edge1);
BRepAdaptor_Curve Curve2(Edge2);
Standard_Real Eps = BRep_Tool::Tolerance(V2) +
BRep_Tool::Tolerance(V1);
GeomAbs_Shape cont;
cont = BRepLProp::Continuity(Curve1,Curve2,U1,U2, Eps, TolAngular);
return cont;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void BRepFill_ShapeLaw::D0(const Standard_Real U, TopoDS_Shape& S)
{
S = myShape;
if (!TheLaw.IsNull()) {
gp_Trsf T;
T.SetScale(gp_Pnt(0, 0, 0), TheLaw->Value(U));
TopLoc_Location L(T);
S.Move(L);
}
}

View File

@@ -0,0 +1,17 @@
// File: BRepFill_ShapeLaw.lxx
// Created: Mon Aug 24 16:26:52 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <TopoDS.hxx>
#include <TopTools_HArray1OfShape.hxx>
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
inline const TopoDS_Edge&
BRepFill_ShapeLaw::Edge(const Standard_Integer Index) const
{
return TopoDS::Edge(myEdges->Value(Index));
}

170
src/BRepFill/BRepFill_Sweep.cdl Executable file
View File

@@ -0,0 +1,170 @@
-- File: BRepFill_Sweep.cdl
-- Created: Fri Nov 21 14:07:48 1997
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1997
class Sweep from BRepFill
---Purpose: Topological Sweep Algorithm
---Level: Advanced
uses
SectionLaw from BRepFill,
LocationLaw from BRepFill,
ApproxStyle from GeomFill,
TransitionStyle from BRepFill,
HCurve from Adaptor3d,
Shape from GeomAbs,
HArray2OfShape from TopTools,
ListOfShape from TopTools,
DataMapOfShapeShape from TopTools,
Wire from TopoDS,
Shape from TopoDS,
Trsf from gp
raises
NotDone,
OutOfRange,
ConstructionError
is
Create(Section : SectionLaw from BRepFill;
Location : LocationLaw from BRepFill;
WithKPart: Boolean)
returns Sweep from BRepFill;
SetBounds(me : in out;
FirstShape, LastShape : Wire from TopoDS);
SetTolerance(me : in out;
Tol3d : Real;
BoundTol : Real = 1.0;
Tol2d : Real = 1.0e-5;
TolAngular : Real = 1.0e-2);
---Purpose: Set Approximation Tolerance
-- Tol3d : Tolerance to surface approximation
-- Tol2d : Tolerance used to perform curve approximation
-- Normaly the 2d curve are approximated with a
-- tolerance given by the resolution on support surfaces,
-- but if this tolerance is too large Tol2d is used.
-- TolAngular : Tolerance (in radian) to control the angle
-- beetween tangents on the section law and
-- tangent of iso-v on approximed surface
SetAngularControl(me: in out;
AngleMin : Real = 0.01;
AngleMax : Real = 6.0)
---Purpose: Tolerance To controle Corner management.
--
-- If the discontinuity is lesser than <AngleMin> in radian The
-- Transition Performed will be alway "Modified"
--
-- If the discontinuity is greater than <AngleMax> in radian The
-- Transition "Round" replace the Transition "Right"
is static;
Build(me : in out;
Transition : TransitionStyle = BRepFill_Modified;
Approx : ApproxStyle = GeomFill_Location;
Continuity : Shape from GeomAbs = GeomAbs_C2;
Degmax : Integer = 11;
Segmax : Integer = 30);
---Purpose: Build the Sweeep Surface
-- Transition define Transition strategy
-- Approx define Approximation Strategy
-- - GeomFill_Section : The composed Function Location X Section
-- is directly approximed.
-- - GeomFill_Location : The location law is approximed, and the
-- SweepSurface is bulid algebric composition
-- of approximed location law and section law
-- This option is Ok, if Section.Surface() methode
-- is effective.
-- Continuity : The continuity in v waiting on the surface
-- Degmax : The maximum degree in v requiered on the surface
-- Segmax : The maximum number of span in v requiered on
-- the surface.
CorrectApproxParameters(me: in out)
returns Boolean is private;
BuildWire(me : in out;
Transition : TransitionStyle)
returns Boolean is private;
BuildShell(me : in out;
Transition : TransitionStyle;
Vf, Vl : Integer;
ExtendFirst : Real = 0.0;
ExtendLast : Real = 0.0)
returns Boolean is private;
IsDone(me)
---Purpose: Say if the Shape is Build.
returns Boolean;
Shape(me)
---Purpose: returns the Sweeping Shape
returns Shape from TopoDS;
ErrorOnSurface(me)
---Purpose: Get the Approximation error.
returns Real;
SubShape(me)
returns HArray2OfShape from TopTools;
InterFaces(me)
returns HArray2OfShape from TopTools;
Sections(me)
returns HArray2OfShape from TopTools;
PerformCorner(me : in out; Index : Integer;
Transition : TransitionStyle;
Bounds : HArray2OfShape from TopTools)
is private;
EvalExtrapol(me; Index : Integer;
Transition : TransitionStyle)
returns Real
is private;
MergeVertex(me;
V1 : Shape from TopoDS;
V2 : in out Shape from TopoDS)
returns Boolean is private;
UpdateVertex(me; Ipath, Isec : Integer;
Error, Param : Real;
V : in out Shape from TopoDS)
is private;
fields
isDone : Boolean;
KPart : Boolean;
myTol3d : Real;
myBoundTol : Real;
myTol2d : Real;
myTolAngular : Real;
myAngMin : Real;
myAngMax : Real;
myApproxStyle : ApproxStyle from GeomFill;
myContinuity : Shape from GeomAbs;
myDegmax : Integer;
mySegmax : Integer;
myShape : Shape from TopoDS;
myLoc : LocationLaw from BRepFill;
mySec : SectionLaw from BRepFill;
myUEdges : HArray2OfShape from TopTools;
myVEdges : HArray2OfShape from TopTools;
myVEdgesModified : DataMapOfShapeShape from TopTools;
myFaces : HArray2OfShape from TopTools;
myAuxShape : ListOfShape from TopTools;
Error : Real;
FirstShape,
LastShape : Wire from TopoDS;
end Sweep;

3072
src/BRepFill/BRepFill_Sweep.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
-- File: BRepFill_TrimEdgeTool.cdl
-- Created: Mon Apr 24 16:15:45 1995
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1995
private class TrimEdgeTool from BRepFill
---Purpose:
uses
Bisec from Bisector,
Edge from TopoDS,
Pnt2d from gp,
Curve from Geom2d,
Geometry from Geom2d,
SequenceOfPnt from TColgp,
Curve from Geom2dAdaptor
is
Create
returns TrimEdgeTool from BRepFill;
Create( Bisec : Bisec from Bisector;
S1, S2 : Geometry from Geom2d;
Offset : Real from Standard)
returns TrimEdgeTool from BRepFill;
IntersectWith( me : in out;
Edge1 , Edge2 : Edge from TopoDS;
Params : in out SequenceOfPnt from TColgp)
is static;
AddOrConfuse ( me ;
Start : Boolean from Standard;
Edge1 , Edge2 : Edge from TopoDS;
Params : in out SequenceOfPnt from TColgp)
is static;
IsInside( me; P : Pnt2d from gp)
returns Boolean from Standard
is static;
fields
isPoint1 : Boolean from Standard;
isPoint2 : Boolean from Standard;
myP1 : Pnt2d from gp;
myP2 : Pnt2d from gp;
myC1 : Curve from Geom2d;
myC2 : Curve from Geom2d;
myOffset : Real from Standard;
myBisec : Bisec from Bisector;
myBis : Curve from Geom2dAdaptor;
end TrimEdgeTool;

View File

@@ -0,0 +1,615 @@
// File: BRepFill_TrimEdgeTool.cxx
// Created: Mon Apr 24 16:40:33 1995
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <BRepFill_TrimEdgeTool.ixx>
#include <BRep_Tool.hxx>
#include <Bisector_BisecAna.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom_Curve.hxx>
#include <GeomProjLib.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <gp_Pnt.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <Precision.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <StdFail_NotDone.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>
#include <DBRep.hxx>
static Standard_Boolean Affich = Standard_False;
#endif
//=======================================================================
//function : SimpleExpression
//purpose :
//=======================================================================
static void SimpleExpression (const Bisector_Bisec& B,
Handle(Geom2d_Curve)& Bis)
{
Bis = B.Value();
Handle(Standard_Type) BT = Bis->DynamicType();
if (BT == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Handle(Geom2d_TrimmedCurve) TrBis
= Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
Handle(Geom2d_Curve) BasBis = TrBis->BasisCurve();
BT = BasBis->DynamicType();
if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
Bis = new Geom2d_TrimmedCurve (Bis,
TrBis->FirstParameter(),
TrBis->LastParameter());
}
}
}
//=======================================================================
//function : BRepFill_TrimEdgeTool
//purpose :
//=======================================================================
BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool()
{
}
//=======================================================================
//function : BRepFill_TrimEdgeTool
//purpose :
//=======================================================================
BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool
(const Bisector_Bisec& Bisec,
const Handle(Geom2d_Geometry)& S1,
const Handle(Geom2d_Geometry)& S2,
const Standard_Real Offset) :
myOffset(Offset),
myBisec(Bisec)
{
isPoint1 = (S1->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
isPoint2 = (S2->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
// recuperation des geometries des shapes.
// Standard_Real f,l;
if (isPoint1) {
myP1 = Handle(Geom2d_Point)::DownCast(S1)->Pnt2d();
}
else {
myC1 = Handle(Geom2d_Curve)::DownCast(S1);
#ifdef DRAW
if ( Affich) {
//POP pour NT
char* myC1name = "myC1";
DrawTrSurf::Set(myC1name,myC1);
// DrawTrSurf::Set("myC1",myC1);
}
#endif
}
if (isPoint2) {
myP2 = Handle(Geom2d_Point)::DownCast(S2)->Pnt2d();
}
else {
myC2 = Handle(Geom2d_Curve)::DownCast(S2);
#ifdef DRAW
if ( Affich) {
char* myC2name = "myC2";
DrawTrSurf::Set(myC2name,myC2);
// DrawTrSurf::Set("myC2",myC2);
}
#endif
}
// recuperer l expression simple de la bisectrice
Handle(Geom2d_Curve) Bis;
SimpleExpression(myBisec, Bis);
myBis = Geom2dAdaptor_Curve(Bis);
#ifdef DRAW
if ( Affich) {
char* myBisname = "myBis";
DrawTrSurf::Set(myBisname,Bis);
}
#endif
}
//=======================================================================
//function : Bubble
//purpose : Ordonne la sequence de point en x croissant.
//=======================================================================
static void Bubble(TColgp_SequenceOfPnt& Seq)
{
Standard_Boolean Invert = Standard_True;
Standard_Integer NbPoints = Seq.Length();
while (Invert) {
Invert = Standard_False;
for ( Standard_Integer i = 1; i < NbPoints; i++) {
gp_Pnt P1 = Seq.Value(i);
gp_Pnt P2 = Seq.Value(i+1);
if (P2.X()<P1.X()) {
Seq.Exchange(i,i+1);
Invert = Standard_True;
}
}
}
}
//=======================================================================
//function : EvalParameters (lbr le 8 juillet, je duplique pour modifier)
//purpose :
//=======================================================================
static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params)
{
Geom2dInt_GInter Intersector;
Standard_Real Tol = Precision::Intersection();
// Standard_Real TolC = 1.e-9;
Geom2dAdaptor_Curve CBis(Bis);
Geom2dAdaptor_Curve CAC (AC);
if(AC.GetType() != GeomAbs_Circle || AC.GetType() != GeomAbs_Line) {
Tol *= 100.;
}
//Intersector = Geom2dInt_GInter(CBis, CAC, TolC, Tol);
Intersector = Geom2dInt_GInter(CAC, CBis, Tol, Tol);
Standard_Integer NbPoints, NbSegments;
Standard_Real U1, U2;
gp_Pnt P;
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
if (NbPoints > 0) {
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
U1 = Intersector.Point(i).ParamOnSecond();
U2 = Intersector.Point(i).ParamOnFirst();
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
NbSegments = Intersector.NbSegments();
if (NbSegments > 0) {
IntRes2d_IntersectionSegment Seg;
for ( Standard_Integer i = 1; i <= NbSegments; i++) {
Seg = Intersector.Segment(i);
U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
}
else {
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
}
// Ordonne la sequence en param croissant sur la bissectrice.
Bubble( Params);
}
static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params,
const Standard_Real Tol)
{
Geom2dInt_GInter Intersector;
Standard_Real TolC = Tol;
Geom2dAdaptor_Curve CBis(Bis);
Geom2dAdaptor_Curve CAC (AC);
Intersector = Geom2dInt_GInter(CAC, CBis, TolC, Tol);
Standard_Integer NbPoints, NbSegments;
Standard_Real U1, U2;
gp_Pnt P;
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
if (NbPoints > 0) {
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
U1 = Intersector.Point(i).ParamOnSecond();
U2 = Intersector.Point(i).ParamOnFirst();
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
NbSegments = Intersector.NbSegments();
if (NbSegments > 0) {
IntRes2d_IntersectionSegment Seg;
for ( Standard_Integer i = 1; i <= NbSegments; i++) {
Seg = Intersector.Segment(i);
U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
}
else {
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
}
// Ordonne la sequence en param croissant sur la bissectrice.
Bubble( Params);
}
//=======================================================================
//function : IntersectWith
//purpose :
//=======================================================================
void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
{
Params.Clear();
// recuperer les courbes associees aux edges.
TopLoc_Location L;
Standard_Real f,l;
Handle(Geom_Surface) Surf;
Handle(Geom2d_Curve) C1;
BRep_Tool::CurveOnSurface(Edge1,C1,Surf,L,f,l);
Geom2dAdaptor_Curve AC1(C1,f,l);
Handle(Geom2d_Curve) C2;
BRep_Tool::CurveOnSurface(Edge2,C2,Surf,L,f,l);
Geom2dAdaptor_Curve AC2(C2,f,l);
#ifdef DRAW
if ( Affich) {
f = AC1.FirstParameter();
l = AC1.LastParameter();
char* CURVE1name = "CURVE1";
DrawTrSurf::Set(CURVE1name, new Geom2d_TrimmedCurve(C1,f,l));
f = AC2.FirstParameter();
l = AC2.LastParameter();
char* CURVE2name = "CURVE2";
DrawTrSurf::Set(CURVE2name, new Geom2d_TrimmedCurve(C2,f,l));
f = myBis.FirstParameter();
l = myBis.LastParameter();
char* bisname = "BIS";
DrawTrSurf::Set(bisname, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
char* Edge1name = "E1";
DBRep::Set(Edge1name, Edge1);
char* Edge2name = "E2";
DBRep::Set(Edge2name, Edge2);
}
#endif
// Calcul intersection
TColgp_SequenceOfPnt Points2;
gp_Pnt PSeq;
EvalParameters (myBis,AC1,Params);
EvalParameters (myBis,AC2,Points2);
Standard_Integer SeanceDeRattrapage=0;
Standard_Real TolInit= 1.e-9;
Standard_Integer nn = 7;
if(AC1.GetType() != GeomAbs_Circle ||
AC1.GetType() != GeomAbs_Line ||
AC2.GetType() != GeomAbs_Circle ||
AC2.GetType() != GeomAbs_Line ) {
TolInit = 1.e-8;
nn = 6;
}
while ( SeanceDeRattrapage < nn // TolInit <= 0.01
&& ( Points2.Length() != Params.Length() ||
(Points2.Length() == 0 && Params.Length() == 0) ) ) {
#ifdef DEB
cout << "BRepFill_TrimEdgeTool: incoherent intersection. On essaie avec une tol plus grande" << endl;
#endif
Params.Clear();
Points2.Clear();
TolInit*=10.0;
EvalParametersBis(myBis,AC1,Params,TolInit);
EvalParametersBis(myBis,AC2,Points2,TolInit);
SeanceDeRattrapage++;
}
#ifdef DEB
if(SeanceDeRattrapage != 0) cout << "SeanceDeRattrapage = " << SeanceDeRattrapage << endl;
if(SeanceDeRattrapage == nn) {
cout << "BRepFill_TrimEdgeTool: incoherent intersection" << endl;
}
#endif
if(Params.Length() == 0 && Points2.Length() == 1) {
//cout << "Params.Length() == 0 && Points2.Length() == 1" << endl;
Standard_Real dmin;
Standard_Real tBis = Points2(1).X();
gp_Pnt2d PBis = myBis.Value(tBis);
Standard_Real t = AC1.FirstParameter();
gp_Pnt2d PC = AC1.Value(t);
dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.);
Params.Append(P);
t = AC1.LastParameter();
PC = AC1.Value(t);
if(dmin > PC.SquareDistance(PBis)) {
P.SetY(t);
Params.SetValue(1,P);
}
}
else if(Params.Length() == 1 && Points2.Length() == 0) {
//cout << "Params.Length() == 1 && Points2.Length() == 0" << endl;
Standard_Real dmin;
Standard_Real tBis = Params(1).X();
gp_Pnt2d PBis = myBis.Value(tBis);
Standard_Real t = AC2.FirstParameter();
gp_Pnt2d PC = AC2.Value(t);
dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.);
Points2.Append(P);
t = AC2.LastParameter();
PC = AC2.Value(t);
if(dmin > PC.SquareDistance(PBis)) {
P.SetY(t);
Points2.SetValue(1,P);
}
}
// petite manip destinee a eliminer les intersections incoherentes:
// on ne renvoie que les intersections communes ( meme parametre sur
// la bissectrice.).
// La tolerance pourra eventuellement etre reglee.
gp_Pnt P1,P2;
Standard_Real Tol = 4 * 100 * Precision::PConfusion();
Standard_Integer i = 1;
Standard_Integer NbPoints = Params.Length();
if(NbPoints == 1 && Points2.Length() == 1) {
//cout << "NbPoints == 1 && Points2.Length() == 1" << endl;
for ( i = 1; i <= NbPoints; i++) {
PSeq = Params(i);
PSeq.SetZ((Points2.Value(i)).Y());
Params.SetValue(i,PSeq);
}
return;
}
i = 1;
while ( i <= Min( Params.Length(), Points2.Length())) {
P1 = Params(i);
P2 = Points2(i);
Standard_Real P1xP2x=Abs( P1.X() - P2.X());
if ( P1xP2x > Tol ) {
#ifdef DEB
cout << "BRepFill_TrimEdgeTool: Pas le meme parametre sur la bissectrice" << endl;
#endif
if(P1xP2x>TolInit) {
#ifdef DEB
cout << "BRepFill_TrimEdgeTool: On continue quand meme" << endl;
#endif
i++;
}
else {
if ( P1.X() < P2.X()) Params.Remove(i);
else Points2.Remove(i);
}
}
else i++;
}
if ( Params.Length() > Points2.Length()) {
Params.Remove(Points2.Length()+1, Params.Length());
}
else if ( Params.Length() < Points2.Length()) {
Points2.Remove(Params.Length()+1, Points2.Length());
}
NbPoints = Params.Length();
for ( i = 1; i <= NbPoints; i++) {
PSeq = Params(i);
PSeq.SetZ((Points2.Value(i)).Y());
Params.SetValue(i,PSeq);
}
}
//=======================================================================
//function : AddOrConfuse
//purpose : le premier ou le dernier point de la bissectrice est sur la
// parallele si on ne l a pas trouve dans les intersections on
// le projette sur les paralleles et on l ajoute dans les params
//=======================================================================
void BRepFill_TrimEdgeTool::AddOrConfuse(const Standard_Boolean Start,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
const
{
Standard_Boolean ToProj = Standard_True;
gp_Pnt2d PBis;
Standard_Real Tol = 10*Precision::Confusion();
// recuperer les courbes associees aux edges.
TopLoc_Location L;
Standard_Real f,l;
Handle(Geom_Surface) Surf;
Handle(Geom2d_Curve) C1;
BRep_Tool::CurveOnSurface(Edge1,C1,Surf,L,f,l);
Geom2dAdaptor_Curve AC1(C1,f,l);
if (Start) PBis = myBis.Value(myBis.FirstParameter());
else PBis = myBis.Value(myBis.LastParameter ());
// Test si le bout de la bissectrice est dans l ensemble des points d intersection.
if (!Params.IsEmpty()) {
gp_Pnt2d P;
if (Start) P = AC1.Value(Params.First().Y());
else P = AC1.Value(Params.Last ().Y());
ToProj = !PBis.IsEqual(P,Tol);
}
if (ToProj) {
#ifdef DEB
cout << " projection extremite bissectrice sur parallele."<<endl;
#endif
// Projection du point sur les paralleles et ajout dans Params
Standard_Real f2,l2;
Handle(Geom2d_Curve) C2;
BRep_Tool::CurveOnSurface(Edge2,C2,Surf,L,f2,l2);
Geom2dAPI_ProjectPointOnCurve Projector1(PBis,C1,f,l);
Geom2dAPI_ProjectPointOnCurve Projector2(PBis,C2,f2,l2);
if (Projector1.NbPoints() == 0) {
#ifdef DEB
cout << "Echec projection dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (!Projector1.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB
cout <<" Mauvaisesolution dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (Projector2.NbPoints() == 0) {
#ifdef DEB
cout << "Echec projection dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (!Projector2.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB
cout <<" Mauvaisesolution dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
gp_Pnt PInt (0,
Projector1.LowerDistanceParameter(),
Projector2.LowerDistanceParameter());
if (Start) {
PInt.SetX (myBis.FirstParameter());
Params.Prepend(PInt);
}
else {
PInt.SetX (myBis.LastParameter());
Params.Append(PInt);
}
}
}
//=======================================================================
//function : IsInside
//purpose :
//=======================================================================
Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
{
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
// Standard_Real Dist;
Standard_Real Dist = RealLast();
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
if (isPoint1)
Dist = P.Distance(myP1);
else if (isPoint2)
Dist = P.Distance(myP2);
else {
Geom2dAPI_ProjectPointOnCurve Projector(P,myC1);
if (Projector.NbPoints() > 0) {
Dist = Projector.LowerDistance();
}
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
// else {
// gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
// gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
// Dist = Min (P.Distance(PF),P.Distance(PL));
// }
// Check of distances between P and first and last point of the first curve
// should be performed in any case, despite of the results of projection.
gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
Standard_Real aDistMin = Min (P.Distance(PF),P.Distance(PL));
if (Dist > aDistMin)
Dist = aDistMin;
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
}
// return (Dist < Abs(myOffset);
// return (Dist < Abs(myOffset) + Precision::Confusion());
return (Dist < Abs(myOffset) - Precision::Confusion());
}

View File

@@ -0,0 +1,58 @@
-- File: BRepFill_TrimShellCorner.cdl
-- Created: Tue Oct 21 17:43:29 2003
-- Author: Mikhail KLOKOV
-- <mkk@kurox>
---Copyright: Matra Datavision 2003
class TrimShellCorner from BRepFill
uses
Ax2 from gp,
Shape from TopoDS,
Wire from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
HArray2OfShape from TopTools,
DataMapOfShapeListOfShape from TopTools
is
Create(theFaces : HArray2OfShape from TopTools;
theAxeOfBisPlane : Ax2 from gp;
theSecPlane : Face from TopoDS)
returns TrimShellCorner from BRepFill;
Create(theFaces : HArray2OfShape from TopTools;
theAxeOfBisPlane : Ax2 from gp;
theSpine : Wire from TopoDS;
theSecPlane : Face from TopoDS)
returns TrimShellCorner from BRepFill;
SetSpine(me: in out; theSpine: Wire from TopoDS);
AddBounds(me : in out; Bounds : HArray2OfShape from TopTools);
AddUEdges(me : in out; theUEdges : HArray2OfShape from TopTools);
Perform(me : in out);
IsDone(me) returns Boolean from Standard;
HasSection(me) returns Boolean from Standard;
Modified(me:in out; S : Shape from TopoDS;
theModified: out ListOfShape from TopTools);
fields
myAxeOfBisPlane : Ax2 from gp;
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
mySpine : Wire from TopoDS;
mySecPln : Face from TopoDS;
myBounds : HArray2OfShape from TopTools;
myUEdges : HArray2OfShape from TopTools;
myFaces : HArray2OfShape from TopTools;
myDone : Boolean from Standard;
myHasSection: Boolean from Standard;
myHistMap: DataMapOfShapeListOfShape from TopTools;
end TrimShellCorner from BRepFill;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
-- File: BRepFill_TrimSurfaceTool.cdl
-- Created: Fri Oct 21 11:45:39 1994
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1994
private class TrimSurfaceTool from BRepFill
---Purpose:
uses
Curve from Geom2d,
Curve from Geom,
Pnt2d from gp,
Face from TopoDS,
Edge from TopoDS,
SequenceOfPnt from TColgp,
Shape from GeomAbs
raises
NoSuchObject from Standard
is
Create(Bis : Curve from Geom2d;
Face1 : Face from TopoDS;
Face2 : Face from TopoDS;
Edge1 : Edge from TopoDS;
Edge2 : Edge from TopoDS;
Inv1 : Boolean from Standard;
Inv2 : Boolean from Standard)
returns TrimSurfaceTool from BRepFill;
IntersectWith(me; EdgeOnF1 : in Edge from TopoDS;
EdgeOnF2 : in Edge from TopoDS;
Points : in out SequenceOfPnt from TColgp )
---Purpose: Intersect <Bis> with the projection of the edges
-- <EdgeOnFi> and returns the intersecting parameters
-- on Bis and on the edges
-- P.X() : Parameter on Bis
-- P.Y() : Parameter on EdgeOnF1
-- P.Z() : Parameter on EdgeOnF2
raises
NoSuchObject from Standard
---Purpose: raises if <Edge> is not a edge of Face1 or Face2.
is static;
IsOnFace(me; Point : Pnt2d from gp)
returns Boolean from Standard
---Purpose: returns True if the Line (P, DZ) intersect the Faces
is static;
ProjOn(me; Point : Pnt2d from gp;
Edge : Edge from TopoDS)
returns Real from Standard
---Purpose: returns the parameter of the point <Point> on the
-- Edge <Edge>, assuming that the point is on the edge.
is static;
Project(me;
U1, U2 : Real from Standard;
Curve : out Curve from Geom;
PCurve1, PCurve2 : out Curve from Geom2d;
myCont : out Shape from GeomAbs)
---Purpose:
is static;
fields
myFace1 : Face from TopoDS;
myFace2 : Face from TopoDS;
myEdge1 : Edge from TopoDS;
myEdge2 : Edge from TopoDS;
myInv1 : Boolean from Standard;
myInv2 : Boolean from Standard;
myBis : Curve from Geom2d;
end TrimSurfaceTool;

View File

@@ -0,0 +1,514 @@
// File: BRepFill_TrimSurfaceTool.cxx
// Created: Fri Oct 21 14:56:32 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <stdio.h>
#include <BRepFill_TrimSurfaceTool.ixx>
#include <Precision.hxx>
#include <Adaptor3d_SurfaceOfRevolution.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <BRepFill_ComputeCLine.hxx>
#include <BRepFill_MultiLine.hxx>
#include <BRepIntCurveSurface_Inter.hxx>
#include <BRepFill_ApproxSeewing.hxx>
#include <BRep_Tool.hxx>
#include <ElCLib.hxx>
#include <BSplCLib.hxx>
#include <PLib.hxx>
#include <gp.hxx>
#include <gp_Sphere.hxx>
#include <gp_Cone.hxx>
#include <gp_Torus.hxx>
#include <gp_Cylinder.hxx>
#include <Geom2dInt_GInter.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomProjLib.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <Precision.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_NotImplemented.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TopAbs_State.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>
#include <DBRep.hxx>
#endif
#ifdef DEB
static Standard_Boolean Affich = Standard_False;
static Standard_Integer NBCALL = 1;
#endif
//=======================================================================
//function : BRepFill_TrimSurfaceTool
//purpose : Initialisation avec les deux face voisines
// Edge1 et Edge2 sont les edges paralleles correspondant
// a une iso minimum sur F1 et F2 respectivement.
// ie Edge1 est Umin ou VMin sur F1.
// Inv1 et Inv2 indique si Edge1 et Edge2 sont des
// parallleles retournees.
//=======================================================================
BRepFill_TrimSurfaceTool::BRepFill_TrimSurfaceTool
(const Handle(Geom2d_Curve)& Bis,
const TopoDS_Face& Face1,
const TopoDS_Face& Face2,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
const Standard_Boolean Inv1,
const Standard_Boolean Inv2 ) :
myFace1(Face1),
myFace2(Face2),
myEdge1(Edge1),
myEdge2(Edge2),
myInv1(Inv1),
myInv2(Inv2),
myBis (Bis)
{
#ifdef DEB
if ( Affich) {
cout << " ---------->TrimSurfaceTool : NBCALL = " << NBCALL << endl;
#ifdef DRAW
char name[256];
sprintf(name,"FACE1_%d",NBCALL);
DBRep::Set(name,myFace1);
sprintf(name,"FACE2_%d",NBCALL);
DBRep::Set(name,myFace2);
sprintf(name,"EDGE1_%d",NBCALL);
DBRep::Set(name,myEdge1);
sprintf(name,"EDGE2_%d",NBCALL);
DBRep::Set(name,myEdge2);
sprintf(name,"BISSEC_%d",NBCALL);
DrawTrSurf::Set(name,myBis);
#endif
NBCALL++;
}
#endif
}
//=======================================================================
//function : Bubble
//purpose : Ordonne la sequence de point en x croissant.
//=======================================================================
static void Bubble(TColgp_SequenceOfPnt& Seq)
{
Standard_Boolean Invert = Standard_True;
Standard_Integer NbPoints = Seq.Length();
while (Invert) {
Invert = Standard_False;
for ( Standard_Integer i = 1; i < NbPoints; i++) {
gp_Pnt P1 = Seq.Value(i);
gp_Pnt P2 = Seq.Value(i+1);
if (P2.X()<P1.X()) {
Seq.Exchange(i,i+1);
Invert = Standard_True;
}
}
}
}
//=======================================================================
//function : EvalPhase
//purpose :
//=======================================================================
static Standard_Real EvalPhase(const TopoDS_Edge& Edge,
const TopoDS_Face& Face,
const GeomAdaptor_Surface& GAS,
const gp_Ax3& Axis)
{
gp_Pnt2d PE1,PE2,PF1,PF2;
Standard_Real VDeg;
#ifndef DEB
Standard_Real V = 0.;
#else
Standard_Real V;
#endif
BRep_Tool::UVPoints(Edge,Face,PE1,PE2);
VDeg = PE1.Y();
TopExp_Explorer Exp(Face,TopAbs_EDGE);
for (; Exp.More(); Exp.Next()) {
if ( !TopoDS::Edge(Exp.Current()).IsSame(Edge)) {
BRep_Tool::UVPoints(TopoDS::Edge(Exp.Current()),Face,PF1,PF2);
V = ( Abs(PF1.Y() - VDeg) > Abs(PF2.Y() - VDeg)) ? PF1.Y() : PF2.Y();
break;
}
}
gp_Pnt P = GAS.Value(0., V);
if ( gp_Vec(Axis.Location(), P).Dot(Axis.XDirection()) < 0.)
return PI;
else
return 0.;
}
//=======================================================================
//function : EvalParameters
//purpose :
//=======================================================================
static void EvalParameters(const TopoDS_Edge& Edge,
const TopoDS_Face& Face,
const Handle(Geom2d_Curve)& Bis ,
TColgp_SequenceOfPnt& Seq )
{
Standard_Boolean Degener = BRep_Tool::Degenerated(Edge);
// recuperer les courbes 3d associees aux edges.
TopLoc_Location L;
Standard_Real f,l;
Handle(Geom_TrimmedCurve) CT;
Handle(Geom_Plane) Plane = new Geom_Plane(0,0,1,0);
Geom2dInt_GInter Intersector;
Standard_Integer NbPoints, NbSegments;
Standard_Real U1, U2;
gp_Pnt P;//,PSeq;
// Standard_Real Tol = Precision::Intersection();
// modified by NIZHNY-EAP Wed Dec 22 15:00:51 1999 ___BEGIN___
Standard_Real Tol = 1.e-6; // BRepFill_Precision();
Standard_Real TolC = 0.;
if ( !Degener) {
Handle(Geom_Curve) C = BRep_Tool::Curve(Edge,L,f,l);
CT = new Geom_TrimmedCurve(C,f,l);
CT->Transform(L.Transformation());
// projection de ces courbes 3d dans le plan xOy
Handle(Geom2d_Curve) C2d = GeomProjLib::Curve2d(CT,Plane);
Geom2dAdaptor_Curve AC(C2d);
Geom2dAdaptor_Curve ABis(Bis);
Intersector = Geom2dInt_GInter(ABis, AC, TolC, Tol);
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
if (NbPoints < 1) {
// try to elongate curves and enlarge tolerance
// don't do it rightaway from the beginning in order not to get
// extra solutions those would cause *Exception*: incoherent intersection
GeomAbs_CurveType CType = AC.GetType(), BisType = ABis.GetType();
Standard_Boolean canElongateC = !(CType == GeomAbs_BezierCurve ||
CType == GeomAbs_BSplineCurve ||
CType == GeomAbs_OtherCurve);
Standard_Boolean canElongateBis = !(BisType == GeomAbs_BezierCurve ||
BisType == GeomAbs_BSplineCurve ||
BisType == GeomAbs_OtherCurve);
Handle(Geom2d_TrimmedCurve) TBis = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
Handle(Geom2d_TrimmedCurve) TC2d = Handle(Geom2d_TrimmedCurve)::DownCast(C2d);
if (canElongateC) {
TC2d->SetTrim(TC2d->FirstParameter() - Tol, TC2d->LastParameter() + Tol);
AC.Load(TC2d);
}
if (canElongateBis) {
TBis->SetTrim(TBis->FirstParameter() - Tol, TBis->LastParameter() + Tol);
ABis.Load(TBis);
}
Intersector = Geom2dInt_GInter(ABis, AC, TolC, Tol*10);
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
}
// modified by NIZHNY-EAP Wed Dec 22 15:00:56 1999 ___END___
if (NbPoints > 0) {
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
U1 = Intersector.Point(i).ParamOnFirst();
U2 = Intersector.Point(i).ParamOnSecond();
P = gp_Pnt(U1,U2,0.);
Seq.Append(P);
}
}
NbSegments = Intersector.NbSegments();
if (NbSegments > 0) {
#ifdef DEB
cout << " IntersectWith : " << NbSegments
<< " Segments d`intersection" << endl;
#endif
IntRes2d_IntersectionSegment Seg;
for ( Standard_Integer i = 1; i <= NbSegments; i++) {
Seg = Intersector.Segment(i);
U1 = Seg.FirstPoint().ParamOnFirst();
U1 += Seg.LastPoint().ParamOnFirst();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnSecond();
U2 += Seg.LastPoint().ParamOnSecond();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Seq.Append(P);
}
}
// Ordonne la sequence en param croissant sur la bissectrice.
Bubble( Seq);
// modified by NIZHNY-EAP Fri Dec 24 18:47:24 1999 ___BEGIN___
// Remove double points
gp_Pnt P1, P2;
for ( Standard_Integer i = 1; i < NbPoints; i++) {
P1 = Seq.Value(i);
P2 = Seq.Value(i+1);
if ( P2.X()-P1.X() < Tol ) {
// cout<<"REMOVE "<<P1.X()<<endl;
Seq.Remove(i--);
NbPoints--;
}
}
// modified by NIZHNY-EAP Fri Dec 24 18:47:28 1999 ___END___
}
else {
// l`edge est degenere : on recupere le point et on cherche s`il est sur
// la bissectrice.
gp_Pnt P3d = BRep_Tool::Pnt( TopExp::FirstVertex(Edge));
gp_Pnt2d P2d( P3d.X(), P3d.Y());
Standard_Real UBis = Bis->FirstParameter();
gp_Pnt2d PBis = Bis->Value( UBis);
// modified by NIZHNY-EAP Wed Jan 12 11:41:30 2000 ___BEGIN___
// inside gp_Pnt2d::Distance
// Infinite * Infinite => Exception: DefaultNumericError
// Case encounered: UBis < Precision::Infinite()
// but PBis.X() > Precision::Infinite()
if (Precision::IsPositiveInfinite(Abs(PBis.X())) ||
Precision::IsPositiveInfinite(Abs(PBis.Y())) ||
PBis.Distance(P2d) > Tol) {
// modified by NIZHNY-EAP Wed Jan 12 11:41:40 2000 ___END___
UBis = Bis->LastParameter();
if (UBis >= Precision::Infinite()) return;
PBis = Bis->Value( UBis);
if ( PBis.Distance(P2d) > Tol) return;
}
// eval parametre intersection.
Handle(Geom_Surface) GS = BRep_Tool::Surface(Face);
GeomAdaptor_Surface GAS(GS);
gp_Ax3 Axis;
Standard_Real Phase = 0.;
switch ( GAS.GetType()) {
case GeomAbs_Sphere:
Axis = GAS.Sphere().Position(); break;
case GeomAbs_Cone: {
//----------------------------------------------------------
// si myFace1 n est pas du meme cote de l apex que le point
// de parametre 0 0 sur le cone => phase = PI.
//----------------------------------------------------------
Axis = GAS.Cone().Position();
Phase = EvalPhase(Edge,Face,GAS,Axis);
break;
}
case GeomAbs_Torus:
Axis = GAS.Torus().Position(); break;
case GeomAbs_Cylinder:
Axis = GAS.Cylinder().Position(); break;
case GeomAbs_SurfaceOfRevolution: {
//----------------------------------------------------------
// si myFace1 n est pas du meme cote de l apex que le point
// de parametre 0 0 sur le cone => phase = PI.
//----------------------------------------------------------
Handle(Geom_SurfaceOfRevolution) GSRev =
Handle(Geom_SurfaceOfRevolution)::DownCast(GS);
Handle(GeomAdaptor_HCurve) HC =
new GeomAdaptor_HCurve(GSRev->BasisCurve());
Adaptor3d_SurfaceOfRevolution ASRev(HC,GAS.AxeOfRevolution());
Axis = ASRev.Axis();
Phase = EvalPhase(Edge,Face,GAS,Axis);
break;
}
default:
Standard_NotImplemented::Raise(" BRepFill_TrimSurfaceTool");
}
gp_Vec2d D12d = Bis->DN(UBis,1);
gp_Vec D1( D12d.X(), D12d.Y(), 0.);
Standard_Real U = Axis.XDirection().
AngleWithRef(D1,Axis.XDirection()^Axis.YDirection());
U += Phase;
if ( U < 0.) U += 2*PI;
P = gp_Pnt(Bis->FirstParameter(), U, 0.);
Seq.Append(P);
}
}
//=======================================================================
//function : IntersectWith
//purpose :
//=======================================================================
void BRepFill_TrimSurfaceTool::IntersectWith
(const TopoDS_Edge& EdgeOnF1,
const TopoDS_Edge& EdgeOnF2,
TColgp_SequenceOfPnt& Points )
const
{
Points.Clear();
TColgp_SequenceOfPnt Points2;
EvalParameters(EdgeOnF1, myFace1, myBis, Points);
EvalParameters(EdgeOnF2, myFace2, myBis, Points2);
StdFail_NotDone_Raise_if
( Points.Length() != Points2.Length(),
"BRepFill_TrimSurfaceTool::IntersectWith: incoherent intersection");
gp_Pnt PSeq;
Standard_Integer NbPoints = Points.Length();
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
PSeq = Points(i);
PSeq.SetZ((Points2.Value(i)).Y());
Points.SetValue(i,PSeq);
// cout<<"BisPar "<<PSeq.X()<<endl;
}
}
//=======================================================================
//function : IsOnFace
//purpose :
//=======================================================================
Standard_Boolean BRepFill_TrimSurfaceTool::IsOnFace
(const gp_Pnt2d& Point) const
{
gp_Pnt P( Point.X(), Point.Y(), 0.);
gp_Lin Line( P, gp::DZ());
BRepIntCurveSurface_Inter Inter;
// eval if is on face 1
// modified by NIZHNY-EAP Fri Jan 21 09:49:09 2000 ___BEGIN___
Inter.Init(myFace1, Line, 1e-6);//Precision::PConfusion());
if (Inter.More()) return Standard_True;
// eval if is on face 2
Inter.Init(myFace2, Line, 1e-6);//Precision::PConfusion());
return Inter.More();
// modified by NIZHNY-EAP Fri Jan 21 09:49:14 2000 ___END___
}
//=======================================================================
//function : ProjOn
//purpose :
//=======================================================================
Standard_Real BRepFill_TrimSurfaceTool::ProjOn(const gp_Pnt2d& Point,
const TopoDS_Edge& Edge) const
{
TopLoc_Location L;
Standard_Real f,l;
Handle(Geom_Curve) C1 = BRep_Tool::Curve(Edge,L,f,l);
Handle(Geom_TrimmedCurve) CT = new Geom_TrimmedCurve(C1,f,l);
CT->Transform(L.Transformation());
// projection de ces courbes 3d dans le plan xOy
Handle(Geom_Plane) Plane = new Geom_Plane(0,0,1,0);
Handle(Geom2d_Curve) C2d = GeomProjLib::Curve2d(CT,Plane);
// eval the projection of the point on the curve.
Geom2dAPI_ProjectPointOnCurve Projector(Point, C2d);
#ifdef DEB
Standard_Real Dist =
#endif
Projector.LowerDistance();
#ifdef DEB
if ( Dist > Precision::Confusion() ) {
cout << " *** WARNING TrimSurfaceTool: *** " << endl;
cout << " --> le point n'est pas sur l'edge" <<endl;
cout << " distance = " << Dist << endl;
}
#endif
Standard_Real U = Projector.LowerDistanceParameter();
return U;
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
void BRepFill_TrimSurfaceTool::Project
(const Standard_Real U1,
const Standard_Real U2,
Handle(Geom_Curve)& Curve,
Handle(Geom2d_Curve)& PCurve1,
Handle(Geom2d_Curve)& PCurve2,
GeomAbs_Shape& Cont) const
{
Standard_Integer Deg1, Deg2;
Deg1 = Deg2 = 8;
Handle(Geom2d_TrimmedCurve) CT =
new Geom2d_TrimmedCurve(myBis,U1,U2);
BRepFill_MultiLine ML(myFace1,myFace2,
myEdge1,myEdge2,myInv1,myInv2,CT);
Cont = ML.Continuity();
if ( ML.IsParticularCase()) {
ML.Curves(Curve,PCurve1,PCurve2);
}
else {
BRepFill_ApproxSeewing AppSeew(ML);
Curve = AppSeew.Curve();
PCurve1 = AppSeew.CurveOnF1();
PCurve2 = AppSeew.CurveOnF2();
}
}