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:
306
src/BRepLib/BRepLib.cdl
Executable file
306
src/BRepLib/BRepLib.cdl
Executable file
@@ -0,0 +1,306 @@
|
||||
-- File: BRepLib.cdl
|
||||
-- Created: Wed Dec 15 15:34:04 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@zerox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
package BRepLib
|
||||
|
||||
---Purpose: The BRepLib package provides general utilities for
|
||||
-- BRep.
|
||||
--
|
||||
-- * FindSurface : Class to compute a surface through
|
||||
-- a set of edges.
|
||||
--
|
||||
-- * Compute missing 3d curve on an edge.
|
||||
|
||||
uses
|
||||
Standard,
|
||||
StdFail,
|
||||
gp,
|
||||
Geom,
|
||||
GeomAbs,
|
||||
Geom2d,
|
||||
TopoDS,
|
||||
TopLoc,
|
||||
TopTools,
|
||||
TopAbs
|
||||
|
||||
is
|
||||
|
||||
enumeration EdgeError is
|
||||
---Purpose: Errors that can occur at edge construction.
|
||||
EdgeDone, -- no error
|
||||
PointProjectionFailed,
|
||||
ParameterOutOfRange,
|
||||
DifferentPointsOnClosedCurve,
|
||||
PointWithInfiniteParameter,
|
||||
DifferentsPointAndParameter,
|
||||
LineThroughIdenticPoints
|
||||
end EdgeError;
|
||||
|
||||
|
||||
enumeration WireError is
|
||||
---Purpose: Errors that can occur at wire construction.
|
||||
WireDone, -- no error
|
||||
EmptyWire,
|
||||
DisconnectedWire,
|
||||
NonManifoldWire
|
||||
|
||||
end WireError;
|
||||
|
||||
|
||||
enumeration FaceError is
|
||||
---Purpose: Errors that can occur at face construction.
|
||||
FaceDone, -- no error
|
||||
NoFace, -- not initialised
|
||||
NotPlanar,
|
||||
CurveProjectionFailed,
|
||||
ParametersOutOfRange
|
||||
|
||||
end FaceError;
|
||||
|
||||
|
||||
enumeration ShellError is
|
||||
---Purpose: Errors that can occur at shell construction.
|
||||
|
||||
ShellDone, -- no error
|
||||
EmptyShell,
|
||||
DisconnectedShell,
|
||||
ShellParametersOutOfRange
|
||||
|
||||
end ShellError;
|
||||
|
||||
enumeration ShapeModification is
|
||||
---Purpose: Modification type after a topologic operation.
|
||||
|
||||
Preserved, -- no modification
|
||||
Deleted,
|
||||
Trimmed,
|
||||
Merged,
|
||||
BoundaryModified
|
||||
|
||||
end ShapeModification;
|
||||
|
||||
deferred class Command;
|
||||
---Purpose: Root class for all BRepBuilderAPI commands.
|
||||
|
||||
deferred class MakeShape;
|
||||
---Purpose: Root class for all shape constructions.
|
||||
|
||||
--
|
||||
-- Construction of topology from geometry
|
||||
--
|
||||
|
||||
class MakeVertex;
|
||||
|
||||
class MakeEdge;
|
||||
|
||||
class MakeEdge2d;
|
||||
|
||||
class MakePolygon;
|
||||
|
||||
class MakeFace;
|
||||
|
||||
--
|
||||
-- Construction of composite topologies
|
||||
--
|
||||
|
||||
class MakeWire;
|
||||
|
||||
class MakeShell;
|
||||
|
||||
class MakeSolid;
|
||||
|
||||
|
||||
|
||||
|
||||
--- END of API commands.
|
||||
|
||||
|
||||
|
||||
|
||||
class FindSurface;
|
||||
---Purpose: Find a surface in a set of edges.
|
||||
|
||||
class FuseEdges;
|
||||
---Purpose:
|
||||
|
||||
|
||||
--
|
||||
-- Default precison methods.
|
||||
-- The default precision is initialized with Precision::Confusion()
|
||||
--
|
||||
|
||||
Precision(P : Real);
|
||||
---Purpose: Sets the default precision. The current Precision
|
||||
-- is returned.
|
||||
---Level: Public
|
||||
|
||||
Precision returns Real;
|
||||
---Purpose: Returns the default precision.
|
||||
---Level: Public
|
||||
|
||||
|
||||
--
|
||||
-- Default plane for 2d edges.
|
||||
--
|
||||
|
||||
Plane(P : Plane from Geom);
|
||||
---Purpose: Sets the current plane to P.
|
||||
---Level: Public
|
||||
|
||||
Plane returns Plane from Geom;
|
||||
---Purpose: Returns the current plane.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
|
||||
|
||||
|
||||
CheckSameRange(E : Edge from TopoDS ;
|
||||
Confusion : Real from Standard = 1.0e-12)
|
||||
returns Boolean;
|
||||
|
||||
---Purpose: checks if the Edge is same range IGNORING
|
||||
-- the same range flag of the edge
|
||||
-- Confusion argument is to compare real numbers
|
||||
-- idenpendently of any model space tolerance
|
||||
--
|
||||
|
||||
|
||||
SameRange(E : Edge from TopoDS ;
|
||||
Tolerance : Real from Standard = 1.0e-5) ;
|
||||
---Purpose: will make all the curve representation have
|
||||
-- the same range domain for the parameters.
|
||||
-- This will IGNORE the same range flag value
|
||||
-- to proceed.
|
||||
-- If there is a 3D curve there it will the
|
||||
-- range of that curve. If not the first curve representation
|
||||
-- encountered in the list will give its range to
|
||||
-- the all the other curves.
|
||||
|
||||
BuildCurve3d(E : Edge from TopoDS ;
|
||||
Tolerance : Real from Standard = 1.0e-5 ;
|
||||
Continuity : Shape from GeomAbs = GeomAbs_C1;
|
||||
MaxDegree : Integer = 14;
|
||||
MaxSegment : Integer = 0 --30
|
||||
) returns Boolean;
|
||||
---Purpose: Computes the 3d curve for the edge <E> if it does
|
||||
-- not exist. Returns True if the curve was computed
|
||||
-- or existed. Returns False if there is no planar
|
||||
-- pcurve.
|
||||
-- <MaxSegment> >= 30 in approximation
|
||||
|
||||
BuildCurves3d(S : Shape from TopoDS ;
|
||||
Tolerance : Real from Standard;
|
||||
Continuity : Shape from GeomAbs = GeomAbs_C1;
|
||||
MaxDegree : Integer = 14;
|
||||
MaxSegment : Integer = 0 --30
|
||||
) returns Boolean;
|
||||
|
||||
---Purpose: Computes the 3d curves for all the edges of <S>
|
||||
-- return False if one of the computation failed.
|
||||
-- <MaxSegment> >= 30 in approximation
|
||||
|
||||
BuildCurves3d(S : Shape from TopoDS)
|
||||
returns Boolean;
|
||||
|
||||
---Purpose: Computes the 3d curves for all the edges of <S>
|
||||
-- return False if one of the computation failed.
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
UpdateEdgeTol( E : Edge from TopoDS ;
|
||||
MinToleranceRequest : Real from Standard ;
|
||||
MaxToleranceToCheck : Real from Standard)
|
||||
---Purpose: Checks if the edge has a Tolerance smaller than -- --
|
||||
-- -- -- MaxToleranceToCheck if so it will compute the
|
||||
-- radius of -- the cylindrical pipe surface that
|
||||
-- MinToleranceRequest is the minimum tolerance before it
|
||||
-- is usefull to start testing. Usually it should be arround
|
||||
-- 10e-5
|
||||
-- contains all -- the curve represenation of the edge
|
||||
-- returns True if the Edge tolerance had to be updated
|
||||
returns Boolean ;
|
||||
|
||||
|
||||
UpdateEdgeTolerance(S : Shape from TopoDS;
|
||||
MinToleranceRequest : Real from Standard ;
|
||||
MaxToleranceToCheck : Real from Standard)
|
||||
|
||||
---Purpose: -- Checks all the edges of the shape whose -- -- --
|
||||
-- Tolerance is smaller than MaxToleranceToCheck --
|
||||
-- Returns True if at least one edge was updated --
|
||||
-- MinToleranceRequest is the minimum tolerance before
|
||||
-- -- it -- is usefull to start testing. Usually it
|
||||
-- should be arround -- 10e-5--
|
||||
--
|
||||
-- Warning :The method is very slow as it checks all.
|
||||
-- Use only in interfaces or processing assimilate batch
|
||||
--
|
||||
|
||||
returns Boolean ;
|
||||
|
||||
SameParameter(E: Edge from TopoDS;
|
||||
Tolerance : Real from Standard = 1.0e-5);
|
||||
---Purpose: Computes new 2d curve(s) for the edge <E> to have
|
||||
-- the same parameter as the 3d curve.
|
||||
-- The algorithm is not done if the flag SameParameter
|
||||
-- was True on the Edge.
|
||||
|
||||
|
||||
|
||||
SameParameter(S: Shape from TopoDS ;
|
||||
Tolerance : Real from Standard = 1.0e-5;
|
||||
forced : Boolean from Standard = Standard_False);
|
||||
---Purpose: Computes new 2d curve(s) for all the edges of <S>
|
||||
-- to have the same parameter as the 3d curve.
|
||||
-- The algorithm is not done if the flag SameParameter
|
||||
-- was True on an Edge.
|
||||
|
||||
UpdateTolerances(S: Shape from TopoDS;
|
||||
verifyFaceTolerance : Boolean from Standard = Standard_False);
|
||||
---Purpose: Replaces tolerance of FACE EDGE VERTEX by the
|
||||
-- tolerance Max of their connected handling shapes.
|
||||
-- It is not necessary to use this call after
|
||||
-- SameParameter. (called in)
|
||||
|
||||
OrientClosedSolid(solid : in out Solid from TopoDS)
|
||||
---Purpose: Orients the solid forward and the shell with the
|
||||
-- orientation to have matter in the solid. Returns
|
||||
-- False if the solid is unOrientable (open or incoherent)
|
||||
returns Boolean;
|
||||
|
||||
|
||||
EncodeRegularity(S : Shape from TopoDS;
|
||||
TolAng : Real from Standard = 1.0e-10);
|
||||
---Purpose: Encodes the Regularity of edges on a Shape.
|
||||
-- Warning: <TolAng> is an angular tolerance, expressed in Rad.
|
||||
-- Warning: If the edges's regularity are coded before, nothing
|
||||
-- is done.
|
||||
|
||||
EncodeRegularity(S : in out Edge from TopoDS;
|
||||
F1, F2 : Face from TopoDS;
|
||||
TolAng : Real from Standard = 1.0e-10);
|
||||
---Purpose: Encodes the Regularity beetween <F1> and <F2> by <E>
|
||||
-- Warning: <TolAng> is an angular tolerance, expressed in Rad.
|
||||
-- Warning: If the edge's regularity is coded before, nothing
|
||||
-- is done.
|
||||
|
||||
SortFaces (S : Shape from TopoDS;
|
||||
LF : in out ListOfShape from TopTools);
|
||||
---Purpose: Sorts in LF the Faces of S on the complexity of
|
||||
-- their surfaces
|
||||
-- (Plane,Cylinder,Cone,Sphere,Torus,other)
|
||||
|
||||
ReverseSortFaces (S : Shape from TopoDS;
|
||||
LF : in out ListOfShape from TopTools);
|
||||
---Purpose: Sorts in LF the Faces of S on the reverse
|
||||
-- complexity of their surfaces
|
||||
-- (other,Torus,Sphere,Cone,Cylinder,Plane)
|
||||
|
||||
end BRepLib;
|
1775
src/BRepLib/BRepLib.cxx
Executable file
1775
src/BRepLib/BRepLib.cxx
Executable file
File diff suppressed because it is too large
Load Diff
57
src/BRepLib/BRepLib_Command.cdl
Executable file
57
src/BRepLib/BRepLib_Command.cdl
Executable file
@@ -0,0 +1,57 @@
|
||||
-- File: BRepLib_Command.cdl
|
||||
-- Created: Wed Jul 21 19:53:17 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
|
||||
deferred class Command from BRepLib
|
||||
|
||||
---Purpose: Root class for all commands in BRepLib.
|
||||
--
|
||||
-- Provides :
|
||||
--
|
||||
-- * Managements of the notDone flag.
|
||||
--
|
||||
-- * Catching of exceptions (not implemented).
|
||||
--
|
||||
-- * Logging (not implemented).
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
Delete(me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~BRepLib_Command(){Delete() ; }"
|
||||
|
||||
Initialize;
|
||||
---Purpose: Set done to False.
|
||||
|
||||
IsDone(me) returns Boolean
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Done(me : in out)
|
||||
---Purpose: Set done to true.
|
||||
---Level: Public
|
||||
is static protected;
|
||||
|
||||
NotDone(me : in out)
|
||||
---Purpose: Set done to false.
|
||||
---Level: Public
|
||||
is static protected;
|
||||
|
||||
|
||||
|
||||
Check(me)
|
||||
---Purpose: Raises NotDone if done is false.
|
||||
---Level: Public
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
fields
|
||||
myDone : Boolean;
|
||||
|
||||
end Command;
|
68
src/BRepLib/BRepLib_Command.cxx
Executable file
68
src/BRepLib/BRepLib_Command.cxx
Executable file
@@ -0,0 +1,68 @@
|
||||
// File: BRepLib_Command.cxx
|
||||
// Created: Fri Jul 23 15:51:38 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
|
||||
#include <BRepLib_Command.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_Command
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_Command::BRepLib_Command() :
|
||||
myDone(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
void BRepLib_Command::Delete()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepLib_Command::IsDone()const
|
||||
{
|
||||
return myDone;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Check
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_Command::Check()const
|
||||
{
|
||||
if (!myDone)
|
||||
StdFail_NotDone::Raise("BRep_API: command not done");
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Done
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_Command::Done()
|
||||
{
|
||||
myDone = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NotDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_Command::NotDone()
|
||||
{
|
||||
myDone = Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
93
src/BRepLib/BRepLib_FindSurface.cdl
Executable file
93
src/BRepLib/BRepLib_FindSurface.cdl
Executable file
@@ -0,0 +1,93 @@
|
||||
-- File: BRepLib_FindSurface.cdl
|
||||
-- Created: Fri Jul 22 11:31:40 1994
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@bravox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
|
||||
class FindSurface from BRepLib
|
||||
|
||||
---Purpose: Provides an algorithm to find a Surface through a
|
||||
-- set of edges.
|
||||
--
|
||||
-- The edges of the shape given as argument are
|
||||
-- explored if they are not coplanar at the required
|
||||
-- tolerance the method Found returns false.
|
||||
--
|
||||
-- If a null tolerance is given the max of the edges
|
||||
-- tolerances is used.
|
||||
--
|
||||
-- The method Tolerance returns the true distance of
|
||||
-- the edges to the Surface.
|
||||
--
|
||||
-- The method Surface returns the Surface if found.
|
||||
--
|
||||
-- The method Existed returns returns True if the
|
||||
-- Surface was already attached to some of the edges.
|
||||
--
|
||||
-- When Existed returns True the Surface may have a
|
||||
-- location given by the Location method.
|
||||
|
||||
uses
|
||||
|
||||
Shape from TopoDS,
|
||||
Location from TopLoc,
|
||||
Surface from Geom
|
||||
|
||||
raises
|
||||
|
||||
NoSuchObject from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns FindSurface from BRepLib;
|
||||
|
||||
Create (S : Shape from TopoDS;
|
||||
Tol : Real from Standard = -1;
|
||||
OnlyPlane : Boolean from Standard = Standard_False)
|
||||
---Purpose: Computes the Surface from the edges of <S> with the
|
||||
-- given tolerance.
|
||||
-- if <OnlyPlane> is true, the computed surface will be
|
||||
-- a plane. If it is not possible to find a plane, the
|
||||
-- flag NotDone will be set.
|
||||
returns FindSurface from BRepLib;
|
||||
|
||||
Init (me : in out;
|
||||
S : Shape from TopoDS;
|
||||
Tol : Real from Standard = -1;
|
||||
OnlyPlane : Boolean from Standard = Standard_False)
|
||||
---Purpose: Computes the Surface from the edges of <S> with the
|
||||
-- given tolerance.
|
||||
-- if <OnlyPlane> is true, the computed surface will be
|
||||
-- a plane. If it is not possible to find a plane, the
|
||||
-- flag NotDone will be set.
|
||||
is static;
|
||||
|
||||
Found(me) returns Boolean
|
||||
is static;
|
||||
|
||||
Surface(me) returns mutable Surface from Geom
|
||||
is static;
|
||||
|
||||
Tolerance(me) returns Real
|
||||
is static;
|
||||
|
||||
ToleranceReached(me) returns Real
|
||||
is static;
|
||||
|
||||
Existed(me) returns Boolean
|
||||
is static;
|
||||
|
||||
Location(me) returns Location from TopLoc
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
mySurface : Surface from Geom;
|
||||
myTolerance : Real;
|
||||
myTolReached : Real;
|
||||
isExisted : Boolean;
|
||||
myLocation : Location from TopLoc;
|
||||
|
||||
end FindSurface;
|
431
src/BRepLib/BRepLib_FindSurface.cxx
Executable file
431
src/BRepLib/BRepLib_FindSurface.cxx
Executable file
@@ -0,0 +1,431 @@
|
||||
// File: BRepLib_FindSurface.cxx
|
||||
// Created: Fri Jul 22 14:03:07 1994
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
#include <BRepLib_FindSurface.ixx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_Gauss.hxx>
|
||||
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Elips.hxx>
|
||||
#include <gp_Hypr.hxx>
|
||||
#include <gp_Parab.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <TColgp_SequenceOfPnt.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
|
||||
#include <GeomLib.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Controle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
|
||||
const Handle(Geom_Plane)& thePlane)
|
||||
{
|
||||
Standard_Real dfMaxDist=0.;
|
||||
Standard_Real a,b,c,d, dist;
|
||||
Standard_Integer ii;
|
||||
thePlane->Coefficients(a,b,c,d);
|
||||
for (ii=1; ii<=thePoints.Length(); ii++) {
|
||||
const gp_XYZ& xyz = thePoints(ii).XYZ();
|
||||
dist = Abs(a*xyz.X() + b*xyz.Y() + c*xyz.Z() + d);
|
||||
if (dist > dfMaxDist)
|
||||
dfMaxDist = dist;
|
||||
}
|
||||
|
||||
return dfMaxDist;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_FindSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepLib_FindSurface::BRepLib_FindSurface()
|
||||
{
|
||||
}
|
||||
//=======================================================================
|
||||
//function : BRepLib_FindSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean OnlyPlane)
|
||||
{
|
||||
Init(S,Tol,OnlyPlane);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean OnlyPlane)
|
||||
{
|
||||
myTolerance = Tol;
|
||||
myTolReached = 0.;
|
||||
isExisted = Standard_False;
|
||||
myLocation.Identity();
|
||||
mySurface.Nullify();
|
||||
|
||||
// compute the tolerance
|
||||
TopExp_Explorer ex;
|
||||
|
||||
for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
Standard_Real t = BRep_Tool::Tolerance(TopoDS::Edge(ex.Current()));
|
||||
if (t > myTolerance) myTolerance = t;
|
||||
}
|
||||
|
||||
// search an existing surface
|
||||
ex.Init(S,TopAbs_EDGE);
|
||||
if (!ex.More()) return; // no edges ....
|
||||
|
||||
TopoDS_Edge E = TopoDS::Edge(ex.Current());
|
||||
Standard_Real f,l,ff,ll;
|
||||
Handle(Geom2d_Curve) PC,PPC;
|
||||
Handle(Geom_Surface) SS;
|
||||
TopLoc_Location L;
|
||||
Standard_Integer i = 0,j;
|
||||
|
||||
// iterate on the surfaces of the first edge
|
||||
while ( Standard_True) {
|
||||
i++;
|
||||
BRep_Tool::CurveOnSurface(E,PC,mySurface,myLocation,f,l,i);
|
||||
if (mySurface.IsNull()) {
|
||||
break;
|
||||
}
|
||||
// check the other edges
|
||||
for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
if (!E.IsSame(ex.Current())) {
|
||||
j = 0;
|
||||
while (Standard_True) {
|
||||
j++;
|
||||
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),
|
||||
PPC,SS,L,ff,ll,j);
|
||||
if (SS.IsNull()) {
|
||||
break;
|
||||
}
|
||||
if (SS == mySurface) {
|
||||
break;
|
||||
}
|
||||
SS.Nullify();
|
||||
}
|
||||
|
||||
if (SS.IsNull()) {
|
||||
mySurface.Nullify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if OnlyPlane, eval if mySurface is a plane.
|
||||
if ( OnlyPlane && !mySurface.IsNull() )
|
||||
mySurface = Handle(Geom_Plane)::DownCast(mySurface);
|
||||
|
||||
if (!mySurface.IsNull()) break;
|
||||
}
|
||||
|
||||
if (!mySurface.IsNull()) {
|
||||
isExisted = Standard_True;
|
||||
return;
|
||||
}
|
||||
//
|
||||
// no existing surface, search a plane
|
||||
// 07/02/02 akm vvv : (OCC157) changed algorithm
|
||||
// 1. Collect the points along all edges of the shape
|
||||
// For each point calculate the WEIGHT = sum of
|
||||
// distances from neighboring points (_only_ same edge)
|
||||
// 2. Minimizing the weighed sum of squared deviations
|
||||
// compute coefficients of the sought plane.
|
||||
|
||||
TColgp_SequenceOfPnt aPoints;
|
||||
TColStd_SequenceOfReal aWeight;
|
||||
|
||||
// ======================= Step #1
|
||||
for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
|
||||
{
|
||||
BRepAdaptor_Curve c(TopoDS::Edge(ex.Current()));
|
||||
|
||||
Standard_Real dfUf = c.FirstParameter();
|
||||
Standard_Real dfUl = c.LastParameter();
|
||||
if (IsEqual(dfUf,dfUl)) {
|
||||
// Degenerate
|
||||
continue;
|
||||
}
|
||||
Standard_Integer iNbPoints=0;
|
||||
|
||||
// Add the points with weights to the sequences
|
||||
switch (c.GetType())
|
||||
{
|
||||
case GeomAbs_BezierCurve:
|
||||
{
|
||||
// Put all poles for bezier
|
||||
Handle(Geom_BezierCurve) GC = c.Bezier();
|
||||
Standard_Integer iNbPol = GC->NbPoles();
|
||||
if ( iNbPol < 2)
|
||||
// Degenerate
|
||||
continue;
|
||||
else
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
|
||||
GC->Poles(aPoles->ChangeArray1());
|
||||
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
|
||||
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
|
||||
{
|
||||
if (iPol<iNbPol)
|
||||
{
|
||||
aPoleNext = aPoles->Value(iPol+1);
|
||||
dfDistNext = aPolePrev.Distance(aPoleNext);
|
||||
}
|
||||
else
|
||||
dfDistNext = 0.;
|
||||
aPoints.Append (aPolePrev);
|
||||
aWeight.Append (dfDistPrev+dfDistNext);
|
||||
dfDistPrev = dfDistNext;
|
||||
aPolePrev = aPoleNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GeomAbs_BSplineCurve:
|
||||
{
|
||||
// Put all poles for bspline
|
||||
Handle(Geom_BSplineCurve) GC = c.BSpline();
|
||||
Standard_Integer iNbPol = GC->NbPoles();
|
||||
if ( iNbPol < 2)
|
||||
// Degenerate
|
||||
continue;
|
||||
else
|
||||
{
|
||||
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
|
||||
GC->Poles(aPoles->ChangeArray1());
|
||||
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
|
||||
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
|
||||
{
|
||||
if (iPol<iNbPol)
|
||||
{
|
||||
aPoleNext = aPoles->Value(iPol+1);
|
||||
dfDistNext = aPolePrev.Distance(aPoleNext);
|
||||
}
|
||||
else
|
||||
dfDistNext = 0.;
|
||||
aPoints.Append (aPolePrev);
|
||||
aWeight.Append (dfDistPrev+dfDistNext);
|
||||
dfDistPrev = dfDistNext;
|
||||
aPolePrev = aPoleNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GeomAbs_Line:
|
||||
case GeomAbs_Circle:
|
||||
case GeomAbs_Ellipse:
|
||||
case GeomAbs_Hyperbola:
|
||||
case GeomAbs_Parabola:
|
||||
if (c.GetType() == GeomAbs_Line)
|
||||
// Two points on straight segment
|
||||
iNbPoints=2;
|
||||
else
|
||||
// Four points on otheranalitical curves
|
||||
iNbPoints=4;
|
||||
default:
|
||||
{
|
||||
// Put some points on other curves
|
||||
if (iNbPoints==0)
|
||||
iNbPoints = 15 + c.NbIntervals(GeomAbs_C3);
|
||||
Standard_Real dfDelta = (dfUl-dfUf)/(iNbPoints-1);
|
||||
Standard_Integer iPoint;
|
||||
Standard_Real dfU;
|
||||
gp_Pnt aPointPrev = c.Value(dfUf), aPointNext;
|
||||
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||
for (iPoint=1, dfU=dfUf+dfDelta;
|
||||
iPoint<=iNbPoints;
|
||||
iPoint++, dfU+=dfDelta)
|
||||
{
|
||||
if (iPoint<iNbPoints)
|
||||
{
|
||||
aPointNext = c.Value(dfU);
|
||||
dfDistNext = aPointPrev.Distance(aPointNext);
|
||||
}
|
||||
else
|
||||
dfDistNext = 0.;
|
||||
aPoints.Append (aPointPrev);
|
||||
aWeight.Append (dfDistPrev+dfDistNext);
|
||||
dfDistPrev = dfDistNext;
|
||||
aPointPrev = aPointNext;
|
||||
}
|
||||
} // default:
|
||||
} // switch (c.GetType()) ...
|
||||
} // for (ex.Init(S,TopAbs_EDGE); ex.More() && control; ex.Next()) ...
|
||||
|
||||
if (aPoints.Length() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ======================= Step #2
|
||||
myLocation.Identity();
|
||||
Standard_Integer iPoint;
|
||||
math_Matrix aMat (1,3,1,3, 0.);
|
||||
math_Vector aVec (1,3, 0.);
|
||||
// Find the barycenter and normalize weights
|
||||
Standard_Real dfMaxWeight=0.;
|
||||
gp_XYZ aBaryCenter(0.,0.,0.);
|
||||
Standard_Real dfSumWeight=0.;
|
||||
for (iPoint=1; iPoint<=aPoints.Length(); iPoint++) {
|
||||
Standard_Real dfW = aWeight(iPoint);
|
||||
aBaryCenter += dfW*aPoints(iPoint).XYZ();
|
||||
dfSumWeight += dfW;
|
||||
if (dfW > dfMaxWeight) {
|
||||
dfMaxWeight = dfW;
|
||||
}
|
||||
}
|
||||
aBaryCenter /= dfSumWeight;
|
||||
|
||||
// Fill the matrix and the right vector
|
||||
for (iPoint=1; iPoint<=aPoints.Length(); iPoint++) {
|
||||
gp_XYZ p=aPoints(iPoint).XYZ()-aBaryCenter;
|
||||
Standard_Real w=aWeight(iPoint)/dfMaxWeight;
|
||||
aMat(1,1)+=w*p.X()*p.X();
|
||||
aMat(1,2)+=w*p.X()*p.Y();
|
||||
aMat(1,3)+=w*p.X()*p.Z();
|
||||
aMat(2,1)+=w*p.Y()*p.X();
|
||||
aMat(2,2)+=w*p.Y()*p.Y();
|
||||
aMat(2,3)+=w*p.Y()*p.Z();
|
||||
aMat(3,1)+=w*p.Z()*p.X();
|
||||
aMat(3,2)+=w*p.Z()*p.Y();
|
||||
aMat(3,3)+=w*p.Z()*p.Z();
|
||||
aVec(1) -= w*p.X();
|
||||
aVec(2) -= w*p.Y();
|
||||
aVec(3) -= w*p.Z();
|
||||
}
|
||||
|
||||
// Solve the system of equations to get plane coefficients
|
||||
math_Gauss aSolver(aMat);
|
||||
Standard_Boolean isSolved = aSolver.IsDone();
|
||||
//
|
||||
// let us be more tolerant (occ415)
|
||||
Standard_Real dfDist = RealLast();
|
||||
Handle(Geom_Plane) aPlane;
|
||||
//
|
||||
if (isSolved) {
|
||||
aSolver.Solve(aVec);
|
||||
if (aVec.Norm2()<gp::Resolution()) {
|
||||
isSolved = Standard_False;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (isSolved) {
|
||||
aPlane = new Geom_Plane(aBaryCenter,gp_Dir(aVec(1),aVec(2),aVec(3)));
|
||||
dfDist = Controle (aPoints, aPlane);
|
||||
}
|
||||
//
|
||||
if (!isSolved || myTolerance < dfDist) {
|
||||
gp_Pnt aFirstPnt=aPoints(1);
|
||||
for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) {
|
||||
gp_Vec aDir(aFirstPnt,aPoints(iPoint));
|
||||
Standard_Real dfSide=aDir.Magnitude();
|
||||
if (dfSide<myTolerance) {
|
||||
continue; // degeneration
|
||||
}
|
||||
for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
|
||||
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
|
||||
if (aCross.Magnitude() > dfSide*myTolerance) {
|
||||
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aFirstPnt, aCross);
|
||||
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
|
||||
if (dfDist2 < myTolerance) {
|
||||
myTolReached = dfDist2;
|
||||
mySurface = aPlane2;
|
||||
return;
|
||||
}
|
||||
if (dfDist2 < dfDist) {
|
||||
dfDist = dfDist2;
|
||||
aPlane = aPlane2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
//XXf
|
||||
//static Standard_Real weakness = 5.0;
|
||||
Standard_Real weakness = 5.0;
|
||||
//XXf
|
||||
if(dfDist <= myTolerance || dfDist < myTolerance*weakness && Tol<0) {
|
||||
//XXf
|
||||
//myTolReached = dfDist;
|
||||
//XXt
|
||||
mySurface = aPlane;
|
||||
}
|
||||
//XXf
|
||||
myTolReached = dfDist;
|
||||
//XXt
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Found
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepLib_FindSurface::Found() const
|
||||
{
|
||||
return !mySurface.IsNull();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom_Surface) BRepLib_FindSurface::Surface() const
|
||||
{
|
||||
return mySurface;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Tolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real BRepLib_FindSurface::Tolerance() const
|
||||
{
|
||||
return myTolerance;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ToleranceReached
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real BRepLib_FindSurface::ToleranceReached() const
|
||||
{
|
||||
return myTolReached;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Existed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepLib_FindSurface::Existed() const
|
||||
{
|
||||
return isExisted;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Location
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopLoc_Location BRepLib_FindSurface::Location() const
|
||||
{
|
||||
return myLocation;
|
||||
}
|
140
src/BRepLib/BRepLib_FuseEdges.cdl
Executable file
140
src/BRepLib/BRepLib_FuseEdges.cdl
Executable file
@@ -0,0 +1,140 @@
|
||||
-- File: BRepLib_FuseEdges.cdl
|
||||
-- Created: Mon Sep 10 10:36:48 2007
|
||||
-- Author: Igor FEOKTISTOV
|
||||
-- <ifv@philipox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2007
|
||||
|
||||
|
||||
class FuseEdges from BRepLib
|
||||
|
||||
---Purpose: This class can detect vertices in a face that can
|
||||
-- be considered useless and then perform the fuse of
|
||||
-- the edges and remove the useless vertices. By
|
||||
-- useles vertices, we mean :
|
||||
-- * vertices that have exactly two connex edges
|
||||
-- * the edges connex to the vertex must have
|
||||
-- exactly the same 2 connex faces .
|
||||
-- * The edges connex to the vertex must have the
|
||||
-- same geometric support.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Edge from TopoDS,
|
||||
ShapeEnum from TopAbs,
|
||||
MapOfShape from TopTools,
|
||||
ListOfShape from TopTools,
|
||||
DataMapOfIntegerListOfShape from TopTools,
|
||||
DataMapOfIntegerShape from TopTools,
|
||||
DataMapOfShapeShape from TopTools,
|
||||
IndexedDataMapOfShapeListOfShape from TopTools,
|
||||
IndexedMapOfShape from TopTools
|
||||
|
||||
raises
|
||||
ConstructionError from Standard,
|
||||
NullObject from Standard
|
||||
|
||||
is
|
||||
Create (theShape : Shape from TopoDS;
|
||||
PerformNow : Boolean from Standard = Standard_False)
|
||||
returns FuseEdges from BRepLib
|
||||
raises NullObject from Standard;
|
||||
---Purpose: Initialise members and build construction of map
|
||||
-- of ancestors.
|
||||
|
||||
AvoidEdges (me : in out; theMapEdg : IndexedMapOfShape from TopTools);
|
||||
---Purpose: set edges to avoid being fused
|
||||
|
||||
-- Modified by IFV 19.04.07
|
||||
SetConcatBSpl(me : in out; theConcatBSpl : Boolean from Standard = Standard_True);
|
||||
---Purpose: set mode to enable concatenation G1 BSpline edges in one
|
||||
-- End Modified by IFV 19.04.07
|
||||
|
||||
Edges (me : in out ; theMapLstEdg : in out DataMapOfIntegerListOfShape from TopTools);
|
||||
---Purpose: returns all the list of edges to be fused
|
||||
-- each list of the map represent a set of connex edges
|
||||
-- that can be fused.
|
||||
|
||||
ResultEdges (me : in out ; theMapEdg : in out DataMapOfIntegerShape from TopTools);
|
||||
---Purpose: returns all the fused edges. each integer entry in
|
||||
-- the map corresponds to the integer in the
|
||||
-- DataMapOfIntegerListOfShape we get in method
|
||||
-- Edges. That is to say, to the list of edges in
|
||||
-- theMapLstEdg(i) corresponds the resulting edge theMapEdge(i)
|
||||
--
|
||||
|
||||
|
||||
Faces (me: in out; theMapFac : in out DataMapOfShapeShape from TopTools);
|
||||
---Purpose: returns the map of modified faces.
|
||||
|
||||
Shape (me : in out)
|
||||
returns Shape from TopoDS
|
||||
raises NullObject from Standard;
|
||||
---Purpose: returns myShape modified with the list of internal
|
||||
-- edges removed from it.
|
||||
---C++: return &
|
||||
|
||||
NbVertices (me : in out)
|
||||
returns Integer from Standard
|
||||
raises NullObject from Standard;
|
||||
---Purpose: returns the number of vertices candidate to be removed
|
||||
---C++: return const
|
||||
|
||||
Perform (me : in out);
|
||||
---Purpose: Using map of list of connex edges, fuse each list to
|
||||
-- one edge and then update myShape
|
||||
|
||||
|
||||
BuildAncestors (me; S: Shape from TopoDS; TS: ShapeEnum from TopAbs;
|
||||
TA: ShapeEnum from TopAbs; M: in out IndexedDataMapOfShapeListOfShape from TopTools)
|
||||
---Purpose: build a map of shapes and ancestors, like
|
||||
-- TopExp.MapShapesAndAncestors, but we remove duplicate
|
||||
-- shapes in list of shapes.
|
||||
is private;
|
||||
|
||||
BuildListEdges (me : in out)
|
||||
---Purpose: Build the all the lists of edges that are to be fused
|
||||
is private;
|
||||
|
||||
BuildListResultEdges (me : in out)
|
||||
---Purpose: Build result fused edges according to the list
|
||||
-- builtin BuildLisEdges
|
||||
is private;
|
||||
|
||||
BuildListConnexEdge (me : in out; theEdge : Shape from TopoDS; theMapUniq : in out MapOfShape from TopTools;
|
||||
theLstEdg : in out ListOfShape from TopTools)
|
||||
is private;
|
||||
|
||||
NextConnexEdge (me; theVertex : Vertex from TopoDS; theEdge : Shape from TopoDS;
|
||||
theEdgeConnex : in out Shape from TopoDS)
|
||||
returns Boolean from Standard
|
||||
is private;
|
||||
|
||||
SameSupport (me; E1 : Edge from TopoDS; E2 :Edge from TopoDS)
|
||||
returns Boolean from Standard
|
||||
is private;
|
||||
|
||||
UpdatePCurve (me; theOldEdge : Edge from TopoDS;
|
||||
theNewEdge : in out Edge from TopoDS;
|
||||
theLstEdg : ListOfShape from TopTools)
|
||||
returns Boolean from Standard
|
||||
is private;
|
||||
|
||||
|
||||
fields
|
||||
myShape : Shape from TopoDS;
|
||||
myShapeDone : Boolean from Standard;
|
||||
myEdgesDone : Boolean from Standard;
|
||||
myResultEdgesDone : Boolean from Standard;
|
||||
myMapVerLstEdg : IndexedDataMapOfShapeListOfShape from TopTools;
|
||||
myMapEdgLstFac : IndexedDataMapOfShapeListOfShape from TopTools;
|
||||
myMapLstEdg : DataMapOfIntegerListOfShape from TopTools;
|
||||
myMapEdg : DataMapOfIntegerShape from TopTools;
|
||||
myMapFaces : DataMapOfShapeShape from TopTools;
|
||||
myNbConnexEdge : Integer from Standard;
|
||||
myAvoidEdg : IndexedMapOfShape from TopTools;
|
||||
-- Modified by IFV 19.04.07
|
||||
myConcatBSpl : Boolean from Standard; -- to enable concatenation of G1 BSpline
|
||||
-- edges
|
||||
|
||||
end FuseEdges;
|
1218
src/BRepLib/BRepLib_FuseEdges.cxx
Executable file
1218
src/BRepLib/BRepLib_FuseEdges.cxx
Executable file
File diff suppressed because it is too large
Load Diff
348
src/BRepLib/BRepLib_MakeEdge.cdl
Executable file
348
src/BRepLib/BRepLib_MakeEdge.cdl
Executable file
@@ -0,0 +1,348 @@
|
||||
-- File: BRepLib_MakeEdge.cdl
|
||||
-- Created: Tue Jul 6 18:57:30 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class MakeEdge from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methods to build edges.
|
||||
--
|
||||
-- The methods have the following syntax, where
|
||||
-- TheCurve is one of Lin, Circ, ...
|
||||
--
|
||||
-- Create(C : TheCurve)
|
||||
--
|
||||
-- Makes an edge on the whole curve. Add vertices
|
||||
-- on finite curves.
|
||||
--
|
||||
-- Create(C : TheCurve; p1,p2 : Real)
|
||||
--
|
||||
-- Make an edge on the curve between parameters p1
|
||||
-- and p2. if p2 < p1 the edge will be REVERSED. If
|
||||
-- p1 or p2 is infinite the curve will be open in
|
||||
-- that direction. Vertices are created for finite
|
||||
-- values of p1 and p2.
|
||||
--
|
||||
-- Create(C : TheCurve; P1, P2 : Pnt from gp)
|
||||
--
|
||||
-- Make an edge on the curve between the points P1
|
||||
-- and P2. The points are projected on the curve
|
||||
-- and the previous method is used. An error is
|
||||
-- raised if the points are not on the curve.
|
||||
--
|
||||
-- Create(C : TheCurve; V1, V2 : Vertex from TopoDS)
|
||||
--
|
||||
-- Make an edge on the curve between the vertices
|
||||
-- V1 and V2. Same as the previous but no vertices
|
||||
-- are created. If a vertex is Null the curve will
|
||||
-- be open in this direction.
|
||||
|
||||
uses
|
||||
EdgeError from BRepLib,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Pnt from gp,
|
||||
Lin from gp,
|
||||
Circ from gp,
|
||||
Elips from gp,
|
||||
Hypr from gp,
|
||||
Parab from gp,
|
||||
Curve from Geom2d,
|
||||
Curve from Geom,
|
||||
Surface from Geom
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Points
|
||||
----------------------------------------
|
||||
|
||||
Create(V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(P1, P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Lin
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Lin from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Lin from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Lin from gp; P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Lin from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Circ
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Circ from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Circ from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Circ from gp; P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Circ from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Elips
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Elips from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Elips from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Elips from gp; P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Elips from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Hypr
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Hypr from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Hypr from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Hypr from gp; P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Hypr from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Parab
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Parab from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Parab from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Parab from gp; P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Parab from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Curve
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Curve from Geom)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom;
|
||||
P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom;
|
||||
P1,P2 : Pnt from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 :Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Curve and surface
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom;
|
||||
P1,P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom;
|
||||
P1,P2 : Pnt from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; S : Surface from Geom;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 :Real)
|
||||
---Level: Public
|
||||
returns MakeEdge from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------
|
||||
|
||||
Init(me : in out; C : Curve from Geom)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom;
|
||||
P1, P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom;
|
||||
P1, P2 : Pnt from gp;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom;
|
||||
P1, P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom;
|
||||
P1, P2 : Pnt from gp;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d; S : Surface from Geom;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Results
|
||||
----------------------------------------
|
||||
|
||||
Error(me) returns EdgeError from BRepLib
|
||||
---Purpose: Returns the error description when NotDone.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Edge(me) returns Edge from TopoDS
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Edge() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Vertex1(me) returns Vertex from TopoDS
|
||||
---Purpose: Returns the first vertex of the edge. May be Null.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Vertex2(me) returns Vertex from TopoDS
|
||||
---Purpose: Returns the second vertex of the edge. May be Null.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myError : EdgeError from BRepLib;
|
||||
myVertex1 : Vertex from TopoDS;
|
||||
myVertex2 : Vertex from TopoDS;
|
||||
|
||||
end MakeEdge;
|
1230
src/BRepLib/BRepLib_MakeEdge.cxx
Executable file
1230
src/BRepLib/BRepLib_MakeEdge.cxx
Executable file
File diff suppressed because it is too large
Load Diff
279
src/BRepLib/BRepLib_MakeEdge2d.cdl
Executable file
279
src/BRepLib/BRepLib_MakeEdge2d.cdl
Executable file
@@ -0,0 +1,279 @@
|
||||
-- File: BRepLib_MakeEdge2d.cdl
|
||||
-- Created: Wed Jan 4 11:09:52 1995
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@fuegox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class MakeEdge2d from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methods to build edges.
|
||||
--
|
||||
-- The methods have the following syntax, where
|
||||
-- TheCurve is one of Lin2d, Circ2d, ...
|
||||
--
|
||||
-- Create(C : TheCurve)
|
||||
--
|
||||
-- Makes an edge on the whole curve. Add vertices
|
||||
-- on finite curves.
|
||||
--
|
||||
-- Create(C : TheCurve; p1,p2 : Real)
|
||||
--
|
||||
-- Make an edge on the curve between parameters p1
|
||||
-- and p2. if p2 < p1 the edge will be REVERSED. If
|
||||
-- p1 or p2 is infinite the curve will be open in
|
||||
-- that direction. Vertices are created for finite
|
||||
-- values of p1 and p2.
|
||||
--
|
||||
-- Create(C : TheCurve; P1, P2 : Pnt2d from gp)
|
||||
--
|
||||
-- Make an edge on the curve between the points P1
|
||||
-- and P2. The points are projected on the curve
|
||||
-- and the previous method is used. An error is
|
||||
-- raised if the points are not on the curve.
|
||||
--
|
||||
-- Create(C : TheCurve; V1, V2 : Vertex from TopoDS)
|
||||
--
|
||||
-- Make an edge on the curve between the vertices
|
||||
-- V1 and V2. Same as the previous but no vertices
|
||||
-- are created. If a vertex is Null the curve will
|
||||
-- be open in this direction.
|
||||
|
||||
uses
|
||||
EdgeError from BRepLib,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Pnt2d from gp,
|
||||
Lin2d from gp,
|
||||
Circ2d from gp,
|
||||
Elips2d from gp,
|
||||
Hypr2d from gp,
|
||||
Parab2d from gp,
|
||||
Curve from Geom2d
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
----------------------------------------
|
||||
-- Points
|
||||
----------------------------------------
|
||||
|
||||
Create(V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(P1, P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Lin
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Lin2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Lin2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Lin2d from gp; P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Lin2d from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Circ
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Circ2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Circ2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Circ2d from gp; P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Circ2d from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Elips
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Elips2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Elips2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Elips2d from gp; P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Elips2d from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Hypr
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Hypr2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Hypr2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Hypr2d from gp; P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Hypr2d from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Parab
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Parab2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Parab2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Parab2d from gp; P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Parab2d from gp; V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Curve
|
||||
----------------------------------------
|
||||
|
||||
Create(L : Curve from Geom2d)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d;
|
||||
P1,P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d;
|
||||
P1,P2 : Pnt2d from gp; p1,p2 : Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
Create(L : Curve from Geom2d;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 :Real)
|
||||
---Level: Public
|
||||
returns MakeEdge2d from BRepLib;
|
||||
|
||||
----------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d;
|
||||
P1, P2 : Pnt2d from gp)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d;
|
||||
V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d;
|
||||
P1, P2 : Pnt2d from gp;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; C : Curve from Geom2d;
|
||||
V1, V2 : Vertex from TopoDS;
|
||||
p1, p2 : Real)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Results
|
||||
----------------------------------------
|
||||
|
||||
Error(me)
|
||||
returns EdgeError from BRepLib
|
||||
---Purpose: Returns the error description when NotDone.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Edge(me) returns Edge from TopoDS
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Edge() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Vertex1(me) returns Vertex from TopoDS
|
||||
---Purpose: Returns the first vertex of the edge. May be Null.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Vertex2(me) returns Vertex from TopoDS
|
||||
---Purpose: Returns the second vertex of the edge. May be Null.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myError : EdgeError from BRepLib;
|
||||
myVertex1 : Vertex from TopoDS;
|
||||
myVertex2 : Vertex from TopoDS;
|
||||
|
||||
end MakeEdge2d;
|
762
src/BRepLib/BRepLib_MakeEdge2d.cxx
Executable file
762
src/BRepLib/BRepLib_MakeEdge2d.cxx
Executable file
@@ -0,0 +1,762 @@
|
||||
// File: BRepLib_MakeEdge2d.cxx
|
||||
// Created: Wed Jan 4 11:13:56 1995
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@fuegox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeEdge2d.ixx>
|
||||
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Ellipse.hxx>
|
||||
#include <Geom2d_Parabola.hxx>
|
||||
#include <Geom2d_Hyperbola.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Extrema_ExtPC2d.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose : make a 3d point on the current plane
|
||||
//=======================================================================
|
||||
|
||||
static gp_Pnt Point(const gp_Pnt2d& P)
|
||||
{
|
||||
return BRepLib::Plane()->Value(P.X(),P.Y());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose : project a vertex on the current plane
|
||||
//=======================================================================
|
||||
|
||||
static gp_Pnt2d Project(const TopoDS_Vertex& Ve)
|
||||
{
|
||||
gp_Pnt P = BRep_Tool::Pnt(Ve);
|
||||
Standard_Real U,V;
|
||||
ElSLib::Parameters(BRepLib::Plane()->Pln(),P,U,V);
|
||||
return gp_Pnt2d(U,V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Project
|
||||
//purpose : project a vertex on a curve
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean Project(const Handle(Geom2d_Curve)& C,
|
||||
const TopoDS_Vertex& V,
|
||||
Standard_Real& p)
|
||||
{
|
||||
gp_Pnt2d P = Project(V);
|
||||
Geom2dAdaptor_Curve AC(C);
|
||||
if (AC.GetType() == GeomAbs_Line) {
|
||||
p = ElCLib::LineParameter(AC.Line().Position(),P);
|
||||
}
|
||||
else if (AC.GetType() == GeomAbs_Circle) {
|
||||
p = ElCLib::CircleParameter(AC.Circle().Position(),P);
|
||||
}
|
||||
else {
|
||||
Extrema_ExtPC2d extrema(P,AC);
|
||||
if (extrema.IsDone()) {
|
||||
Standard_Integer i,n = extrema.NbExt();
|
||||
|
||||
Standard_Real d2 = RealLast();
|
||||
for (i = 1; i <= n; i++) {
|
||||
//OCC16852:if (extrema.IsMin(i)) {
|
||||
const Standard_Real dd2 = extrema.SquareDistance(i);
|
||||
if (dd2 < d2) {
|
||||
d2 = dd2;
|
||||
p = extrema.Point(i).Parameter();
|
||||
}
|
||||
//OCC16852:}
|
||||
}
|
||||
}
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
gp_Pnt2d P1 = Project(V1);
|
||||
gp_Pnt2d P2 = Project(V2);
|
||||
Standard_Real l = P1.Distance(P2);
|
||||
if (l <= gp::Resolution()) {
|
||||
myError = BRepLib_LineThroughIdenticPoints;
|
||||
return;
|
||||
}
|
||||
gp_Lin2d L(P1,gp_Vec2d(P1,P2));
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL,V1,V2,0,l);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Standard_Real l = P1.Distance(P2);
|
||||
if (l <= gp::Resolution()) {
|
||||
myError = BRepLib_LineThroughIdenticPoints;
|
||||
return;
|
||||
}
|
||||
gp_Lin2d L(P1,gp_Vec2d(P1,P2));
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL,P1,P2,0,l);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Lin2d& L)
|
||||
{
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Lin2d& L,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Lin2d& L,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Lin2d& L,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Handle(Geom2d_Line) GL = new Geom2d_Line(L);
|
||||
Init(GL,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Circ2d& C)
|
||||
{
|
||||
Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
|
||||
Init(GC);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Circ2d& C,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
|
||||
Init(GC,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Circ2d& C,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
|
||||
Init(GC,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Circ2d& C,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
|
||||
Init(GC,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Elips2d& E)
|
||||
{
|
||||
Handle(Geom2d_Ellipse) GE = new Geom2d_Ellipse(E);
|
||||
Init(GE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Elips2d& E,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Handle(Geom2d_Ellipse) GE = new Geom2d_Ellipse(E);
|
||||
Init(GE,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Elips2d& E,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Handle(Geom2d_Ellipse) GE = new Geom2d_Ellipse(E);
|
||||
Init(GE,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Elips2d& E,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Handle(Geom2d_Ellipse) GE = new Geom2d_Ellipse(E);
|
||||
Init(GE,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Hypr2d& H)
|
||||
{
|
||||
Handle(Geom2d_Hyperbola) GH = new Geom2d_Hyperbola(H);
|
||||
Init(GH);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Hypr2d& H,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Handle(Geom2d_Hyperbola) GH = new Geom2d_Hyperbola(H);
|
||||
Init(GH,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Hypr2d& H,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Handle(Geom2d_Hyperbola) GH = new Geom2d_Hyperbola(H);
|
||||
Init(GH,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Hypr2d& H,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Handle(Geom2d_Hyperbola) GH = new Geom2d_Hyperbola(H);
|
||||
Init(GH,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Parab2d& P)
|
||||
{
|
||||
Handle(Geom2d_Parabola) GP = new Geom2d_Parabola(P);
|
||||
Init(GP);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Parab2d& P,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Handle(Geom2d_Parabola) GP = new Geom2d_Parabola(P);
|
||||
Init(GP,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Parab2d& P,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Handle(Geom2d_Parabola) GP = new Geom2d_Parabola(P);
|
||||
Init(GP,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const gp_Parab2d& P,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Handle(Geom2d_Parabola) GP = new Geom2d_Parabola(P);
|
||||
Init(GP,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L)
|
||||
{
|
||||
Init(L);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Init(L,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
Init(L,P1,P2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Init(L,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Init(L,P1,P2,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeEdge2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::BRepLib_MakeEdge2d(const Handle(Geom2d_Curve)& L,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
Init(L,V1,V2,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& C)
|
||||
{
|
||||
Init(C,C->FirstParameter(),C->LastParameter());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& C,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
// BRep_Builder B;
|
||||
|
||||
TopoDS_Vertex V1,V2;
|
||||
Init(C,V1,V2,p1,p2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& C,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2)
|
||||
{
|
||||
BRep_Builder B;
|
||||
TopoDS_Vertex V1,V2;
|
||||
B.MakeVertex(V1,Point(P1),Precision::Confusion());
|
||||
if (P1.Distance(P2) < Precision::Confusion())
|
||||
V2 = V1;
|
||||
else
|
||||
B.MakeVertex(V2,Point(P2),Precision::Confusion());
|
||||
Init(C,V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& C,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
// try projecting the vertices on the curve
|
||||
|
||||
Standard_Real p1,p2;
|
||||
|
||||
if (V1.IsNull())
|
||||
p1 = C->FirstParameter();
|
||||
else
|
||||
if (!Project(C,V1,p1)) {
|
||||
myError = BRepLib_PointProjectionFailed;
|
||||
return;
|
||||
}
|
||||
if (V2.IsNull())
|
||||
p2 = C->LastParameter();
|
||||
else
|
||||
if (!Project(C,V2,p2)) {
|
||||
myError = BRepLib_PointProjectionFailed;
|
||||
return;
|
||||
}
|
||||
|
||||
Init(C,V1,V2,p1,p2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& C,
|
||||
const gp_Pnt2d& P1,
|
||||
const gp_Pnt2d& P2,
|
||||
const Standard_Real p1,
|
||||
const Standard_Real p2)
|
||||
{
|
||||
BRep_Builder B;
|
||||
|
||||
TopoDS_Vertex V1,V2;
|
||||
B.MakeVertex(V1,Point(P1),Precision::Confusion());
|
||||
if (P1.Distance(P2) < Precision::Confusion())
|
||||
V2 = V1;
|
||||
else
|
||||
B.MakeVertex(V2,Point(P2),Precision::Confusion());
|
||||
|
||||
|
||||
Init(C,V1,V2,p1,p2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : this one really makes the job ...
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeEdge2d::Init(const Handle(Geom2d_Curve)& CC,
|
||||
const TopoDS_Vertex& VV1,
|
||||
const TopoDS_Vertex& VV2,
|
||||
const Standard_Real pp1,
|
||||
const Standard_Real pp2)
|
||||
{
|
||||
// kill trimmed curves
|
||||
Handle(Geom2d_Curve) C = CC;
|
||||
Handle(Geom2d_TrimmedCurve) CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
|
||||
while (!CT.IsNull()) {
|
||||
C = CT->BasisCurve();
|
||||
CT = Handle(Geom2d_TrimmedCurve)::DownCast(C);
|
||||
}
|
||||
|
||||
// check parameters
|
||||
Standard_Real p1 = pp1;
|
||||
Standard_Real p2 = pp2;
|
||||
Standard_Real cf = C->FirstParameter();
|
||||
Standard_Real cl = C->LastParameter();
|
||||
Standard_Real epsilon = Precision::Confusion();
|
||||
Standard_Boolean periodic = C->IsPeriodic();
|
||||
|
||||
|
||||
TopoDS_Vertex V1,V2;
|
||||
if (periodic) {
|
||||
// adjust in period
|
||||
ElCLib::AdjustPeriodic(cf,cl,epsilon,p1,p2);
|
||||
V1 = VV1;
|
||||
V2 = VV2;
|
||||
}
|
||||
else {
|
||||
// reordonate
|
||||
if (p1 < p2) {
|
||||
V1 = VV1;
|
||||
V2 = VV2;
|
||||
}
|
||||
else {
|
||||
V2 = VV1;
|
||||
V1 = VV2;
|
||||
Standard_Real x = p1;
|
||||
p1 = p2;
|
||||
p2 = x;
|
||||
}
|
||||
|
||||
// check range
|
||||
if ((cf - p1 > epsilon) || (p2 - cl > epsilon)) {
|
||||
myError = BRepLib_ParameterOutOfRange;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// compute points on the curve
|
||||
Standard_Boolean p1inf = Precision::IsNegativeInfinite(p1);
|
||||
Standard_Boolean p2inf = Precision::IsPositiveInfinite(p2);
|
||||
gp_Pnt2d P1,P2;
|
||||
if (!p1inf) P1 = C->Value(p1);
|
||||
if (!p2inf) P2 = C->Value(p2);
|
||||
|
||||
Standard_Real preci = Precision::Confusion();
|
||||
BRep_Builder B;
|
||||
|
||||
// check for closed curve
|
||||
Standard_Boolean closed = Standard_False;
|
||||
if (!p1inf && !p2inf)
|
||||
closed = (P1.Distance(P2) <= preci);
|
||||
|
||||
// check if the vertices are on the curve
|
||||
if (closed) {
|
||||
if (V1.IsNull() && V2.IsNull()) {
|
||||
B.MakeVertex(V1,Point(P1),preci);
|
||||
V2 = V1;
|
||||
}
|
||||
else if (V1.IsNull())
|
||||
V1 = V2;
|
||||
else if (V2.IsNull())
|
||||
V2 = V1;
|
||||
else {
|
||||
if (!V1.IsSame(V2)) {
|
||||
myError = BRepLib_DifferentPointsOnClosedCurve;
|
||||
return;
|
||||
}
|
||||
else if (Point(P1).Distance(BRep_Tool::Pnt(V1)) > preci) {
|
||||
myError = BRepLib_DifferentPointsOnClosedCurve;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else { // not closed
|
||||
|
||||
if (p1inf) {
|
||||
if (!V1.IsNull()) {
|
||||
myError = BRepLib_PointWithInfiniteParameter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gp_Pnt P = Point(P1);
|
||||
if (V1.IsNull()) {
|
||||
B.MakeVertex(V1,P,preci);
|
||||
}
|
||||
#if 0
|
||||
// desctivate control (RLE) for speed in sketcher
|
||||
else if (P.Distance(BRep_Tool::Pnt(V1)) > preci) {
|
||||
myError = BRepLib_DifferentsPointAndParameter;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (p2inf) {
|
||||
if (!V2.IsNull()) {
|
||||
myError = BRepLib_PointWithInfiniteParameter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gp_Pnt P = Point(P2);
|
||||
if (V2.IsNull()) {
|
||||
B.MakeVertex(V2,P,preci);
|
||||
}
|
||||
#if 0
|
||||
// desctivate control (RLE) for speed in sketcher
|
||||
else if (P.Distance(BRep_Tool::Pnt(V2)) > preci){
|
||||
myError = BRepLib_DifferentsPointAndParameter;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
V1.Orientation(TopAbs_FORWARD);
|
||||
V2.Orientation(TopAbs_REVERSED);
|
||||
myVertex1 = V1;
|
||||
myVertex2 = V2;
|
||||
|
||||
TopoDS_Edge& E = TopoDS::Edge(myShape);
|
||||
B.MakeEdge(E);
|
||||
B.UpdateEdge(E,C,BRepLib::Plane(),TopLoc_Location(),preci);
|
||||
if (!V1.IsNull()) {
|
||||
B.Add(E,V1);
|
||||
}
|
||||
if (!V2.IsNull()) {
|
||||
B.Add(E,V2);
|
||||
}
|
||||
B.Range(E,p1,p2);
|
||||
Done();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Error
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_EdgeError BRepLib_MakeEdge2d::Error() const
|
||||
{
|
||||
return myError;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Edge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Edge& BRepLib_MakeEdge2d::Edge()const
|
||||
{
|
||||
return TopoDS::Edge(Shape());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakeEdge2d::Vertex1()const
|
||||
{
|
||||
Check();
|
||||
return myVertex1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakeEdge2d::Vertex2()const
|
||||
{
|
||||
Check();
|
||||
return myVertex2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeEdge2d::operator TopoDS_Edge() const
|
||||
{
|
||||
return Edge();
|
||||
}
|
249
src/BRepLib/BRepLib_MakeFace.cdl
Executable file
249
src/BRepLib/BRepLib_MakeFace.cdl
Executable file
@@ -0,0 +1,249 @@
|
||||
-- File: BRepLib_MakeFace.cdl
|
||||
-- Created: Mon Jul 12 11:35:23 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
class MakeFace from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methods to build faces.
|
||||
--
|
||||
-- A face may be built :
|
||||
--
|
||||
-- * From a surface.
|
||||
--
|
||||
-- - Elementary surface from gp.
|
||||
--
|
||||
-- - Surface from Geom.
|
||||
--
|
||||
-- * From a surface and U,V values.
|
||||
--
|
||||
-- * From a wire.
|
||||
--
|
||||
-- - Find the surface automatically if possible.
|
||||
--
|
||||
-- * From a surface and a wire.
|
||||
--
|
||||
-- - A flag Inside is given, when this flag is True
|
||||
-- the wire is oriented to bound a finite area on
|
||||
-- the surface.
|
||||
--
|
||||
-- * From a face and a wire.
|
||||
--
|
||||
-- - The new wire is a perforation.
|
||||
|
||||
uses
|
||||
Pln from gp,
|
||||
Cylinder from gp,
|
||||
Cone from gp,
|
||||
Sphere from gp,
|
||||
Torus from gp,
|
||||
Surface from Geom,
|
||||
Face from TopoDS,
|
||||
Wire from TopoDS,
|
||||
FaceError from BRepLib
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Purpose: Not done.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(F : Face from TopoDS)
|
||||
---Purpose: Load a face. Usefull to add wires.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From a surface
|
||||
----------------------------------------------
|
||||
|
||||
Create(P : Pln from gp)
|
||||
---Purpose: Make a face from a plane.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cylinder from gp)
|
||||
---Purpose: Make a face from a cylinder.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cone from gp)
|
||||
---Purpose: Make a face from a cone.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Sphere from gp)
|
||||
---Purpose: Make a face from a sphere.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Torus from gp)
|
||||
---Purpose: Make a face from a torus.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Surface from Geom)
|
||||
---Purpose: Make a face from a Surface.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From a surface and U,V values
|
||||
----------------------------------------------
|
||||
|
||||
Create(P : Pln from gp; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a plane.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cylinder from gp; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a cylinder.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cone from gp; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a cone.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Sphere from gp; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a sphere.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Torus from gp; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a torus.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Surface from Geom; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Make a face from a Surface.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From a wire
|
||||
----------------------------------------------
|
||||
|
||||
Create(W : Wire from TopoDS;
|
||||
OnlyPlane : Boolean from Standard = Standard_False)
|
||||
---Purpose: Find a surface from the wire and make a face.
|
||||
-- if <OnlyPlane> is true, the computed surface will be
|
||||
-- a plane. If it is not possible to find a plane, the
|
||||
-- flag NotDone will be set.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From a surface and a wire
|
||||
----------------------------------------------
|
||||
|
||||
Create(P : Pln from gp; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a plane and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cylinder from gp; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a cylinder and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Cone from gp; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a cone and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Sphere from gp; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a sphere and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(C : Torus from gp; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a torus and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
Create(S : Surface from Geom; W : Wire from TopoDS;
|
||||
Inside : Boolean = Standard_True)
|
||||
---Purpose: Make a face from a Surface and a wire.
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From face and wire.
|
||||
----------------------------------------------
|
||||
|
||||
Create(F : Face from TopoDS; W : Wire from TopoDS)
|
||||
---Purpose: Adds the wire <W> in the face <F>
|
||||
---Level: Public
|
||||
returns MakeFace from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------------
|
||||
|
||||
Init(me : in out; F : Face from TopoDS)
|
||||
---Purpose: Load the face.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; S : Surface from Geom; Bound : Boolean = Standard_True)
|
||||
---Purpose: Creates the face from the surface. If Bound is
|
||||
-- True a wire is made from the natural bounds.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax : Real)
|
||||
---Purpose: Creates the face from the surface and the min-max
|
||||
-- values.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Add(me : in out; W : Wire from TopoDS)
|
||||
---Purpose: Adds the wire <W> in the current face.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
----------------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------------
|
||||
|
||||
CheckInside(me : in out)
|
||||
---Purpose: Reorient the current face if the boundary is not
|
||||
-- finite.
|
||||
---Level: Public
|
||||
is static private;
|
||||
|
||||
----------------------------------------------
|
||||
-- Results
|
||||
----------------------------------------------
|
||||
|
||||
Error(me) returns FaceError from BRepLib
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Face(me) returns Face from TopoDS
|
||||
---Purpose: Returns the new face.
|
||||
--
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Face() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
fields
|
||||
myError : FaceError from BRepLib;
|
||||
|
||||
end MakeFace;
|
825
src/BRepLib/BRepLib_MakeFace.cxx
Executable file
825
src/BRepLib/BRepLib_MakeFace.cxx
Executable file
@@ -0,0 +1,825 @@
|
||||
// File: BRepLib_MakeFace.cxx
|
||||
// Created: Fri Jul 23 15:51:48 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeFace.ixx>
|
||||
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
|
||||
#include <Geom2d_Line.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#include <BRepTopAdaptor_FClass2d.hxx>
|
||||
#include <TopAbs_State.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
|
||||
#include <BRepLib_FindSurface.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace() :
|
||||
myError(BRepLib_NoFace)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Face& F)
|
||||
{
|
||||
Init(F);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P)
|
||||
{
|
||||
Handle(Geom_Plane) GP = new Geom_Plane(P);
|
||||
Init(GP);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C)
|
||||
{
|
||||
Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
|
||||
Init(GC);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C)
|
||||
{
|
||||
Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
|
||||
Init(GC);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S)
|
||||
{
|
||||
Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
|
||||
Init(GS);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T)
|
||||
{
|
||||
Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
|
||||
Init(GT);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S)
|
||||
{
|
||||
Init(S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Handle(Geom_Plane) GP = new Geom_Plane(P);
|
||||
Init(GP,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
|
||||
Init(GC,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
|
||||
Init(GC,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
|
||||
Init(GS,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
|
||||
Init(GT,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax)
|
||||
{
|
||||
Init(S,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
|
||||
const Standard_Boolean OnlyPlane)
|
||||
|
||||
{
|
||||
// Find a surface through the wire
|
||||
BRepLib_FindSurface FS(W, -1, OnlyPlane);
|
||||
if (!FS.Found()) {
|
||||
myError = BRepLib_NotPlanar;
|
||||
return;
|
||||
}
|
||||
|
||||
// build the face and add the wire
|
||||
BRep_Builder B;
|
||||
myError = BRepLib_FaceDone;
|
||||
|
||||
Standard_Real tol = Max(1.2*FS.ToleranceReached(), FS.Tolerance());
|
||||
|
||||
B.MakeFace(TopoDS::Face(myShape),FS.Surface(),FS.Location(),tol);
|
||||
Add(W);
|
||||
|
||||
BRepLib::UpdateTolerances(myShape);
|
||||
|
||||
CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Pln& P,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Handle(Geom_Plane) Pl = new Geom_Plane(P);
|
||||
Init(Pl,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cylinder& C,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Handle(Geom_CylindricalSurface) GC = new Geom_CylindricalSurface(C);
|
||||
Init(GC,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Cone& C,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Handle(Geom_ConicalSurface) GC = new Geom_ConicalSurface(C);
|
||||
Init(GC,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Sphere& S,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Handle(Geom_SphericalSurface) GS = new Geom_SphericalSurface(S);
|
||||
Init(GS,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const gp_Torus& T,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Handle(Geom_ToroidalSurface) GT = new Geom_ToroidalSurface(T);
|
||||
Init(GT,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const Handle(Geom_Surface)& S,
|
||||
const TopoDS_Wire& W,
|
||||
const Standard_Boolean Inside)
|
||||
{
|
||||
Init(S,Standard_False);
|
||||
Add(W);
|
||||
if (Inside) CheckInside();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Face& F,
|
||||
const TopoDS_Wire& W)
|
||||
{
|
||||
Init(F);
|
||||
Add(W);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeFace::Init(const TopoDS_Face& F)
|
||||
{
|
||||
// copy the face
|
||||
myShape = F.EmptyCopied();
|
||||
myError = BRepLib_FaceDone;
|
||||
|
||||
BRep_Builder B;
|
||||
TopoDS_Iterator It(F);
|
||||
while (It.More()) {
|
||||
B.Add(myShape,It.Value());
|
||||
It.Next();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeFace::Init(const Handle(Geom_Surface)& S,
|
||||
const Standard_Boolean Bound)
|
||||
{
|
||||
myError = BRepLib_FaceDone;
|
||||
if (Bound) {
|
||||
Standard_Real UMin,UMax,VMin,VMax;
|
||||
S->Bounds(UMin,UMax,VMin,VMax);
|
||||
Init(S,UMin,UMax,VMin,VMax);
|
||||
}
|
||||
else {
|
||||
BRep_Builder B;
|
||||
B.MakeFace(TopoDS::Face(myShape),S,Precision::Confusion());
|
||||
}
|
||||
BRep_Builder B;
|
||||
B.NaturalRestriction(TopoDS::Face(myShape),Standard_True);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDegenerated
|
||||
//purpose : fonction statique qui verifie qu'une courbe n'est pas reduite
|
||||
// a un point, pour ainsi coder l'edge Degenere.
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean IsDegenerated(const Handle(Geom_Curve)& C,
|
||||
const Standard_Real tol)
|
||||
{
|
||||
GeomAdaptor_Curve AC(C);
|
||||
|
||||
GeomAbs_CurveType Type = AC.GetType();
|
||||
if (Type == GeomAbs_Circle) {
|
||||
gp_Circ Circ = AC.Circle();
|
||||
return (Circ.Radius() < tol);
|
||||
}
|
||||
else if (Type == GeomAbs_BSplineCurve) {
|
||||
Handle(Geom_BSplineCurve) BS = AC.BSpline();
|
||||
Standard_Integer NbPoles = BS->NbPoles();
|
||||
Standard_Real tol2 = tol*tol;
|
||||
gp_Pnt P1,P2;
|
||||
P1 = BS->Pole(1);
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
P2 = BS->Pole(i);
|
||||
if (P1.SquareDistance(P2) > tol2) return Standard_False;
|
||||
// P1 = P2;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
else if (Type == GeomAbs_BezierCurve) {
|
||||
Handle(Geom_BezierCurve) BZ = AC.Bezier();
|
||||
Standard_Integer NbPoles = BZ->NbPoles();
|
||||
Standard_Real tol2 = tol*tol;
|
||||
gp_Pnt P1,P2;
|
||||
P1 = BZ->Pole(1);
|
||||
for (Standard_Integer i = 2; i <= NbPoles; i++) {
|
||||
P2 = BZ->Pole(i);
|
||||
if (P1.SquareDistance(P2) > tol2) return Standard_False;
|
||||
// P1 = P2;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeFace::Init(const Handle(Geom_Surface)& SS,
|
||||
const Standard_Real Um,
|
||||
const Standard_Real UM,
|
||||
const Standard_Real Vm,
|
||||
const Standard_Real VM)
|
||||
{
|
||||
myError = BRepLib_FaceDone;
|
||||
|
||||
Standard_Real UMin = Um;
|
||||
Standard_Real UMax = UM;
|
||||
Standard_Real VMin = Vm;
|
||||
Standard_Real VMax = VM;
|
||||
|
||||
Standard_Real umin,umax,vmin,vmax,T;
|
||||
|
||||
Handle(Geom_Surface) S = SS;
|
||||
Handle(Geom_RectangularTrimmedSurface) RS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
|
||||
if (!RS.IsNull())
|
||||
S = RS->BasisSurface();
|
||||
|
||||
|
||||
Standard_Boolean OffsetSurface =
|
||||
(S->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface));
|
||||
|
||||
// adjust periodical surface or reordonate
|
||||
// check if the values are in the natural range
|
||||
Standard_Real epsilon = Precision::PConfusion();
|
||||
|
||||
S->Bounds(umin,umax,vmin,vmax);
|
||||
|
||||
if (OffsetSurface) {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast(S);
|
||||
Handle(Geom_Surface) Base = OS->BasisSurface();
|
||||
|
||||
if (Base->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
|
||||
if (Precision::IsInfinite(umin) || Precision::IsInfinite(umax))
|
||||
S = new Geom_RectangularTrimmedSurface(OS, UMin, UMax, VMin, VMax);
|
||||
else
|
||||
S = new Geom_RectangularTrimmedSurface(OS, VMin, VMax, Standard_False);
|
||||
} else if (Base->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfRevolution)) {
|
||||
if (Precision::IsInfinite(vmin) || Precision::IsInfinite(vmax))
|
||||
S = new Geom_RectangularTrimmedSurface(OS, VMin, VMax, Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
if (S->IsUPeriodic()) {
|
||||
ElCLib::AdjustPeriodic(umin,umax,epsilon,UMin,UMax);
|
||||
}
|
||||
else if (UMin > UMax) {
|
||||
T = UMin;
|
||||
UMin = UMax;
|
||||
UMax = T;
|
||||
if ((umin - UMin > epsilon) || (UMax - umax > epsilon)) {
|
||||
myError = BRepLib_ParametersOutOfRange;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (S->IsVPeriodic()) {
|
||||
ElCLib::AdjustPeriodic(vmin,vmax,epsilon,VMin,VMax);
|
||||
}
|
||||
else if (VMin > VMax) {
|
||||
T = VMin;
|
||||
VMin = VMax;
|
||||
VMax = T;
|
||||
if ((vmin - VMin > epsilon) || (VMax - vmax > epsilon)) {
|
||||
myError = BRepLib_ParametersOutOfRange;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// compute infinite flags
|
||||
Standard_Boolean umininf = Precision::IsNegativeInfinite(UMin);
|
||||
Standard_Boolean umaxinf = Precision::IsPositiveInfinite(UMax);
|
||||
Standard_Boolean vmininf = Precision::IsNegativeInfinite(VMin);
|
||||
Standard_Boolean vmaxinf = Precision::IsPositiveInfinite(VMax);
|
||||
|
||||
// closed flag
|
||||
Standard_Boolean uclosed =
|
||||
S->IsUClosed() &&
|
||||
Abs(UMin - umin) < epsilon &&
|
||||
Abs(UMax - umax) < epsilon;
|
||||
|
||||
Standard_Boolean vclosed =
|
||||
S->IsVClosed() &&
|
||||
Abs(VMin - vmin) < epsilon &&
|
||||
Abs(VMax - vmax) < epsilon;
|
||||
|
||||
|
||||
// compute 3d curves and degenerate flag
|
||||
Standard_Real tol = Precision::Confusion();
|
||||
Handle(Geom_Curve) Cumin,Cumax,Cvmin,Cvmax;
|
||||
Standard_Boolean Dumin,Dumax,Dvmin,Dvmax;
|
||||
Dumin = Dumax = Dvmin = Dvmax = Standard_False;
|
||||
|
||||
if (!umininf) {
|
||||
Cumin = S->UIso(UMin);
|
||||
Dumin = IsDegenerated(Cumin,tol);
|
||||
}
|
||||
if (!umaxinf) {
|
||||
Cumax = S->UIso(UMax);
|
||||
Dumax = IsDegenerated(Cumax,tol);
|
||||
}
|
||||
if (!vmininf) {
|
||||
Cvmin = S->VIso(VMin);
|
||||
Dvmin = IsDegenerated(Cvmin,tol);
|
||||
}
|
||||
if (!vmaxinf) {
|
||||
Cvmax = S->VIso(VMax);
|
||||
Dvmax = IsDegenerated(Cvmax,tol);
|
||||
}
|
||||
|
||||
// compute vertices
|
||||
BRep_Builder B;
|
||||
|
||||
TopoDS_Vertex V00,V10,V11,V01;
|
||||
|
||||
if (!umininf) {
|
||||
if (!vmininf) B.MakeVertex(V00,S->Value(UMin,VMin),tol);
|
||||
if (!vmaxinf) B.MakeVertex(V01,S->Value(UMin,VMax),tol);
|
||||
}
|
||||
if (!umaxinf) {
|
||||
if (!vmininf) B.MakeVertex(V10,S->Value(UMax,VMin),tol);
|
||||
if (!vmaxinf) B.MakeVertex(V11,S->Value(UMax,VMax),tol);
|
||||
}
|
||||
|
||||
if (uclosed) {
|
||||
V10 = V00;
|
||||
V11 = V01;
|
||||
}
|
||||
|
||||
if (vclosed) {
|
||||
V01 = V00;
|
||||
V11 = V10;
|
||||
}
|
||||
|
||||
if (Dumin) V00 = V01;
|
||||
if (Dumax) V10 = V11;
|
||||
if (Dvmin) V00 = V10;
|
||||
if (Dvmax) V01 = V11;
|
||||
|
||||
// make the lines
|
||||
Handle(Geom2d_Line) Lumin,Lumax,Lvmin,Lvmax;
|
||||
if (!umininf)
|
||||
Lumin = new Geom2d_Line(gp_Pnt2d(UMin,0),gp_Dir2d(0,1));
|
||||
if (!umaxinf)
|
||||
Lumax = new Geom2d_Line(gp_Pnt2d(UMax,0),gp_Dir2d(0,1));
|
||||
if (!vmininf)
|
||||
Lvmin = new Geom2d_Line(gp_Pnt2d(0,VMin),gp_Dir2d(1,0));
|
||||
if (!vmaxinf)
|
||||
Lvmax = new Geom2d_Line(gp_Pnt2d(0,VMax),gp_Dir2d(1,0));
|
||||
|
||||
// make the face
|
||||
TopoDS_Face& F = TopoDS::Face(myShape);
|
||||
B.MakeFace(F,S,tol);
|
||||
|
||||
// make the edges
|
||||
TopoDS_Edge eumin,eumax,evmin,evmax;
|
||||
|
||||
if (!umininf) {
|
||||
if (!Dumin)
|
||||
B.MakeEdge(eumin,Cumin,tol);
|
||||
else
|
||||
B.MakeEdge(eumin);
|
||||
if (uclosed)
|
||||
B.UpdateEdge(eumin,Lumax,Lumin,F,tol);
|
||||
else
|
||||
B.UpdateEdge(eumin,Lumin,F,tol);
|
||||
B.Degenerated(eumin,Dumin);
|
||||
if (!vmininf) {
|
||||
V00.Orientation(TopAbs_FORWARD);
|
||||
B.Add(eumin,V00);
|
||||
}
|
||||
if (!vmaxinf) {
|
||||
V01.Orientation(TopAbs_REVERSED);
|
||||
B.Add(eumin,V01);
|
||||
}
|
||||
B.Range(eumin,VMin,VMax);
|
||||
}
|
||||
|
||||
if (!umaxinf) {
|
||||
if (uclosed)
|
||||
eumax = eumin;
|
||||
else {
|
||||
if (!Dumax)
|
||||
B.MakeEdge(eumax,Cumax,tol);
|
||||
else
|
||||
B.MakeEdge(eumax);
|
||||
B.UpdateEdge(eumax,Lumax,F,tol);
|
||||
B.Degenerated(eumax,Dumax);
|
||||
if (!vmininf) {
|
||||
V10.Orientation(TopAbs_FORWARD);
|
||||
B.Add(eumax,V10);
|
||||
}
|
||||
if (!vmaxinf) {
|
||||
V11.Orientation(TopAbs_REVERSED);
|
||||
B.Add(eumax,V11);
|
||||
}
|
||||
B.Range(eumax,VMin,VMax);
|
||||
}
|
||||
}
|
||||
|
||||
if (!vmininf) {
|
||||
if (!Dvmin)
|
||||
B.MakeEdge(evmin,Cvmin,tol);
|
||||
else
|
||||
B.MakeEdge(evmin);
|
||||
if (vclosed)
|
||||
B.UpdateEdge(evmin,Lvmin,Lvmax,F,tol);
|
||||
else
|
||||
B.UpdateEdge(evmin,Lvmin,F,tol);
|
||||
B.Degenerated(evmin,Dvmin);
|
||||
if (!umininf) {
|
||||
V00.Orientation(TopAbs_FORWARD);
|
||||
B.Add(evmin,V00);
|
||||
}
|
||||
if (!umaxinf) {
|
||||
V10.Orientation(TopAbs_REVERSED);
|
||||
B.Add(evmin,V10);
|
||||
}
|
||||
B.Range(evmin,UMin,UMax);
|
||||
}
|
||||
|
||||
if (!vmaxinf) {
|
||||
if (vclosed)
|
||||
evmax = evmin;
|
||||
else {
|
||||
if (!Dvmax)
|
||||
B.MakeEdge(evmax,Cvmax,tol);
|
||||
else
|
||||
B.MakeEdge(evmax);
|
||||
B.UpdateEdge(evmax,Lvmax,F,tol);
|
||||
B.Degenerated(evmax,Dvmax);
|
||||
if (!umininf) {
|
||||
V01.Orientation(TopAbs_FORWARD);
|
||||
B.Add(evmax,V01);
|
||||
}
|
||||
if (!umaxinf) {
|
||||
V11.Orientation(TopAbs_REVERSED);
|
||||
B.Add(evmax,V11);
|
||||
}
|
||||
B.Range(evmax,UMin,UMax);
|
||||
}
|
||||
}
|
||||
|
||||
// make the wires and add them to the face
|
||||
eumin.Orientation(TopAbs_REVERSED);
|
||||
evmax.Orientation(TopAbs_REVERSED);
|
||||
|
||||
TopoDS_Wire W;
|
||||
|
||||
if (!umininf && !umaxinf && vmininf && vmaxinf) {
|
||||
// two wires in u
|
||||
B.MakeWire(W);
|
||||
B.Add(W,eumin);
|
||||
B.Add(F,W);
|
||||
B.MakeWire(W);
|
||||
B.Add(W,eumax);
|
||||
B.Add(F,W);
|
||||
F.Closed(uclosed);
|
||||
}
|
||||
|
||||
else if (umininf && umaxinf && !vmininf && !vmaxinf) {
|
||||
// two wires in v
|
||||
B.MakeWire(W);
|
||||
B.Add(W,evmin);
|
||||
B.Add(F,W);
|
||||
B.MakeWire(W);
|
||||
B.Add(W,evmax);
|
||||
B.Add(F,W);
|
||||
F.Closed(vclosed);
|
||||
}
|
||||
|
||||
else if (!umininf || !umaxinf || !vmininf || !vmaxinf) {
|
||||
// one wire
|
||||
B.MakeWire(W);
|
||||
if (!umininf) B.Add(W,eumin);
|
||||
if (!vmininf) B.Add(W,evmin);
|
||||
if (!umaxinf) B.Add(W,eumax);
|
||||
if (!vmaxinf) B.Add(W,evmax);
|
||||
B.Add(F,W);
|
||||
W.Closed(!umininf && !umaxinf && !vmininf && !vmaxinf);
|
||||
F.Closed(uclosed && vclosed);
|
||||
}
|
||||
|
||||
if (OffsetSurface) {
|
||||
// Les Isos sont Approximees a Precision::Approximation()
|
||||
// et on code Precision::Confusion() dans l'arete.
|
||||
// ==> Un petit passage dans SamePrameter pour regler les tolerances.
|
||||
BRepLib::SameParameter( F, tol, Standard_True);
|
||||
}
|
||||
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeFace::Add(const TopoDS_Wire& W)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.Add(myShape,W);
|
||||
B.NaturalRestriction(TopoDS::Face(myShape),Standard_False);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Face
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Face& BRepLib_MakeFace::Face()const
|
||||
{
|
||||
return TopoDS::Face(myShape);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeFace::operator TopoDS_Face() const
|
||||
{
|
||||
return Face();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Error
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_FaceError BRepLib_MakeFace::Error() const
|
||||
{
|
||||
return myError;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckInside
|
||||
//purpose : Reverses the current face if not a bounded area
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeFace::CheckInside()
|
||||
{
|
||||
// compute the area and return the face if the area is negative
|
||||
TopoDS_Face F = TopoDS::Face(myShape);
|
||||
BRepTopAdaptor_FClass2d FClass(F,0.);
|
||||
if ( FClass.PerformInfinitePoint() == TopAbs_IN) {
|
||||
BRep_Builder B;
|
||||
TopoDS_Shape S = myShape.EmptyCopied();
|
||||
TopoDS_Iterator it(myShape);
|
||||
while (it.More()) {
|
||||
B.Add(S,it.Value().Reversed());
|
||||
it.Next();
|
||||
}
|
||||
myShape = S;
|
||||
}
|
||||
}
|
123
src/BRepLib/BRepLib_MakePolygon.cdl
Executable file
123
src/BRepLib/BRepLib_MakePolygon.cdl
Executable file
@@ -0,0 +1,123 @@
|
||||
-- File: BRepLib_MakePolygon.cdl
|
||||
-- Created: Thu Jul 29 11:39:48 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
class MakePolygon from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Class to build polygonal wires.
|
||||
--
|
||||
-- A polygonal wire may be build from
|
||||
--
|
||||
-- - 2,4,3 points.
|
||||
--
|
||||
-- - 2,3,4 vertices.
|
||||
--
|
||||
-- - any number of points.
|
||||
--
|
||||
-- - any number of vertices.
|
||||
--
|
||||
--
|
||||
-- When a point or vertex is added to the polygon if
|
||||
-- it is identic to the previous point no edge is
|
||||
-- built. The method added can be used to test it.
|
||||
|
||||
uses
|
||||
Wire from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Pnt from gp
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
Create
|
||||
returns MakePolygon from BRepLib;
|
||||
---Purpose: Creates an empty MakePolygon.
|
||||
---Level: Public
|
||||
|
||||
Create(P1, P2 : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
Create(P1, P2, P3 : Pnt from gp;
|
||||
Close : Boolean = Standard_False)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
Create(P1, P2, P3, P4 : Pnt from gp;
|
||||
Close : Boolean = Standard_False)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
Create(V1, V2 : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
Create(V1, V2, V3 : Vertex from TopoDS;
|
||||
Close : Boolean = Standard_False)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
Create(V1, V2, V3, V4 : Vertex from TopoDS;
|
||||
Close : Boolean = Standard_False)
|
||||
---Level: Public
|
||||
returns MakePolygon from BRepLib;
|
||||
|
||||
|
||||
Add(me : in out; P : Pnt from gp)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Add(me : in out; V : Vertex from TopoDS)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Added(me) returns Boolean
|
||||
---Purpose: Returns True if the last vertex or point was
|
||||
-- succesfully added.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Close(me : in out)
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
FirstVertex(me) returns Vertex from TopoDS
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
LastVertex(me) returns Vertex from TopoDS
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Edge(me) returns Edge from TopoDS
|
||||
---Purpose: Returns the last edge added to the polygon.
|
||||
--
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Edge() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Wire(me) returns Wire from TopoDS
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Wire() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myFirstVertex : Vertex from TopoDS;
|
||||
myLastVertex : Vertex from TopoDS;
|
||||
myEdge : Edge from TopoDS;
|
||||
|
||||
end MakePolygon;
|
285
src/BRepLib/BRepLib_MakePolygon.cxx
Executable file
285
src/BRepLib/BRepLib_MakePolygon.cxx
Executable file
@@ -0,0 +1,285 @@
|
||||
// File: BRepLib_MakePolygon.cxx
|
||||
// Created: Thu Jul 29 17:17:23 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@phylox>
|
||||
|
||||
|
||||
#include <BRepLib_MakePolygon.ixx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLib_MakeEdge.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const gp_Pnt& P1, const gp_Pnt& P2)
|
||||
{
|
||||
Add(P1);
|
||||
Add(P2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const gp_Pnt& P1,
|
||||
const gp_Pnt& P2,
|
||||
const gp_Pnt& P3,
|
||||
const Standard_Boolean Cl)
|
||||
{
|
||||
Add(P1);
|
||||
Add(P2);
|
||||
Add(P3);
|
||||
if (Cl) Close();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const gp_Pnt& P1,
|
||||
const gp_Pnt& P2,
|
||||
const gp_Pnt& P3,
|
||||
const gp_Pnt& P4,
|
||||
const Standard_Boolean Cl)
|
||||
{
|
||||
Add(P1);
|
||||
Add(P2);
|
||||
Add(P3);
|
||||
Add(P4);
|
||||
if (Cl) Close();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2)
|
||||
{
|
||||
Add(V1);
|
||||
Add(V2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2,
|
||||
const TopoDS_Vertex& V3,
|
||||
const Standard_Boolean Cl)
|
||||
{
|
||||
Add(V1);
|
||||
Add(V2);
|
||||
Add(V3);
|
||||
if (Cl) Close();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakePolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::BRepLib_MakePolygon(const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2,
|
||||
const TopoDS_Vertex& V3,
|
||||
const TopoDS_Vertex& V4,
|
||||
const Standard_Boolean Cl)
|
||||
{
|
||||
Add(V1);
|
||||
Add(V2);
|
||||
Add(V3);
|
||||
Add(V4);
|
||||
if (Cl) Close();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakePolygon::Add(const gp_Pnt& P)
|
||||
{
|
||||
BRep_Builder B;
|
||||
TopoDS_Vertex V;
|
||||
B.MakeVertex(V,P,Precision::Confusion());
|
||||
Add(V);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakePolygon::Add(const TopoDS_Vertex& V)
|
||||
{
|
||||
if (myFirstVertex.IsNull()) {
|
||||
myFirstVertex = V;
|
||||
}
|
||||
else {
|
||||
myEdge.Nullify();
|
||||
BRep_Builder B;
|
||||
TopoDS_Vertex last;
|
||||
|
||||
Standard_Boolean second = myLastVertex.IsNull();
|
||||
if (second) {
|
||||
last = myFirstVertex;
|
||||
myLastVertex = V;
|
||||
B.MakeWire(TopoDS::Wire(myShape));
|
||||
myShape.Closed(Standard_False);
|
||||
myShape.Orientable(Standard_True);
|
||||
}
|
||||
else {
|
||||
last = myLastVertex;
|
||||
if (BRepTools::Compare(V,myFirstVertex)) {
|
||||
myLastVertex = myFirstVertex;
|
||||
myShape.Closed(Standard_True);
|
||||
}
|
||||
else
|
||||
myLastVertex = V;
|
||||
}
|
||||
|
||||
BRepLib_MakeEdge ME(last,myLastVertex);
|
||||
if (ME.IsDone()) {
|
||||
myEdge = ME;
|
||||
B.Add(myShape,myEdge);
|
||||
Done();
|
||||
}
|
||||
else {
|
||||
// restore the previous last vertex
|
||||
if (second)
|
||||
myLastVertex.Nullify();
|
||||
else
|
||||
myLastVertex = last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Added
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepLib_MakePolygon::Added()const
|
||||
{
|
||||
return !myEdge.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Close
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakePolygon::Close()
|
||||
{
|
||||
if (myFirstVertex.IsNull() || myLastVertex.IsNull())
|
||||
return;
|
||||
|
||||
// check not already closed
|
||||
if (myShape.Closed())
|
||||
return;
|
||||
|
||||
// build the last edge
|
||||
BRep_Builder B;
|
||||
myEdge.Nullify();
|
||||
BRepLib_MakeEdge ME(myLastVertex,myFirstVertex);
|
||||
if (ME.IsDone()) {
|
||||
myEdge = ME;
|
||||
B.Add(myShape,myEdge);
|
||||
myShape.Closed(Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FirstVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakePolygon::FirstVertex()const
|
||||
{
|
||||
return myFirstVertex;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LastVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakePolygon::LastVertex()const
|
||||
{
|
||||
return myLastVertex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Edge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Edge& BRepLib_MakePolygon::Edge()const
|
||||
{
|
||||
return myEdge;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Wire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Wire& BRepLib_MakePolygon::Wire()const
|
||||
{
|
||||
return TopoDS::Wire(Shape());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::operator TopoDS_Edge() const
|
||||
{
|
||||
return Edge();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakePolygon::operator TopoDS_Wire() const
|
||||
{
|
||||
return Wire();
|
||||
}
|
||||
|
||||
|
||||
|
103
src/BRepLib/BRepLib_MakeShape.cdl
Executable file
103
src/BRepLib/BRepLib_MakeShape.cdl
Executable file
@@ -0,0 +1,103 @@
|
||||
-- File: BRepLib_MakeShape.cdl
|
||||
-- Created: Wed Jul 21 18:15:13 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@nonox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
deferred class MakeShape from BRepLib inherits Command from BRepLib
|
||||
|
||||
---Purpose: This is the root class for all shape
|
||||
-- constructions. It stores the result.
|
||||
--
|
||||
-- It provides deferred methods to trace the history
|
||||
-- of sub-shapes.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Face from TopoDS,
|
||||
Edge from TopoDS,
|
||||
ShapeModification from BRepLib,
|
||||
ListOfShape from TopTools
|
||||
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
Initialize;
|
||||
|
||||
Build(me : in out);
|
||||
---Purpose: This is called by Shape(). It does nothing but
|
||||
-- may be redefined.
|
||||
---Level: Public
|
||||
|
||||
Shape(me) returns Shape from TopoDS
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Shape() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
--- the following methods do nothing and must be redefined
|
||||
--- for faces creations.
|
||||
|
||||
FaceStatus(me; F: Face from TopoDS)
|
||||
---Purpose: returns the status of the Face after
|
||||
-- the shape creation.
|
||||
---Level: Public
|
||||
returns ShapeModification from BRepLib
|
||||
is virtual;
|
||||
|
||||
|
||||
HasDescendants(me; F: Face from TopoDS)
|
||||
---Purpose: Returns True if the Face generates new topology.
|
||||
---Level: Public
|
||||
returns Boolean from Standard
|
||||
is virtual;
|
||||
|
||||
|
||||
DescendantFaces(me: in out; F: Face from TopoDS)
|
||||
---Purpose: returns the list of generated Faces.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
returns ListOfShape from TopTools
|
||||
is virtual;
|
||||
|
||||
|
||||
NbSurfaces(me)
|
||||
---Purpose: returns the number of surfaces
|
||||
-- after the shape creation.
|
||||
---Level: Public
|
||||
returns Integer from Standard
|
||||
is virtual;
|
||||
|
||||
|
||||
NewFaces(me: in out; I: Integer from Standard)
|
||||
---Purpose: Return the faces created for surface I.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
returns ListOfShape from TopTools
|
||||
is virtual;
|
||||
|
||||
|
||||
FacesFromEdges(me: in out; E: Edge from TopoDS)
|
||||
---Purpose: returns a list of the created faces
|
||||
-- from the edge <E>.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
returns ListOfShape from TopTools
|
||||
is virtual;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myShape : Shape from TopoDS is protected;
|
||||
myGenFaces: ListOfShape from TopTools is protected;
|
||||
myNewFaces: ListOfShape from TopTools is protected;
|
||||
myEdgFaces: ListOfShape from TopTools is protected;
|
||||
|
||||
end MakeShape;
|
121
src/BRepLib/BRepLib_MakeShape.cxx
Executable file
121
src/BRepLib/BRepLib_MakeShape.cxx
Executable file
@@ -0,0 +1,121 @@
|
||||
// File: BRepLib_MakeShape.cxx
|
||||
// Created: Fri Jul 23 15:51:51 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeShape.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShape::BRepLib_MakeShape()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeShape::Build()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Shape& BRepLib_MakeShape::Shape() const
|
||||
{
|
||||
if (!IsDone()) {
|
||||
// the following is const cast away
|
||||
((BRepLib_MakeShape*) (void*) this)->Build();
|
||||
Check();
|
||||
}
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShape::operator TopoDS_Shape() const
|
||||
{
|
||||
return Shape();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasDescendants
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepLib_MakeShape::HasDescendants(const TopoDS_Face&)const
|
||||
{
|
||||
return (Standard_True);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FaceStatus
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_ShapeModification BRepLib_MakeShape::FaceStatus
|
||||
(const TopoDS_Face&) const
|
||||
{
|
||||
BRepLib_ShapeModification myStatus = BRepLib_Trimmed;
|
||||
return myStatus;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GeneratedFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepLib_MakeShape::DescendantFaces
|
||||
(const TopoDS_Face&)
|
||||
{
|
||||
return myGenFaces;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSurfaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepLib_MakeShape::NbSurfaces() const
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepLib_MakeShape::NewFaces(const Standard_Integer)
|
||||
{
|
||||
return myNewFaces;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FacesFromEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_ListOfShape& BRepLib_MakeShape::FacesFromEdges
|
||||
(const TopoDS_Edge&)
|
||||
{
|
||||
return myEdgFaces;
|
||||
}
|
82
src/BRepLib/BRepLib_MakeShell.cdl
Executable file
82
src/BRepLib/BRepLib_MakeShell.cdl
Executable file
@@ -0,0 +1,82 @@
|
||||
-- File: BRepLib_MakeShell.cdl
|
||||
-- Created: Wed Jan 4 11:11:36 1995
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@fuegox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
|
||||
class MakeShell from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methos to build shells.
|
||||
--
|
||||
-- Build a shell from a set of faces.
|
||||
-- Build untied shell from a non C2 surface
|
||||
-- splitting it into C2-continuous parts.
|
||||
|
||||
uses
|
||||
|
||||
Surface from Geom,
|
||||
Shell from TopoDS,
|
||||
Face from TopoDS,
|
||||
ShellError from BRepLib
|
||||
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
Create
|
||||
---Purpose: Not done.
|
||||
---Level: Public
|
||||
returns MakeShell from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From a set of face
|
||||
----------------------------------------------
|
||||
|
||||
----------------------------------------------
|
||||
-- From a surface
|
||||
----------------------------------------------
|
||||
|
||||
Create(S : Surface from Geom;
|
||||
Segment : Boolean from Standard = Standard_False)
|
||||
---Level: Public
|
||||
returns MakeShell from BRepLib;
|
||||
|
||||
Create(S : Surface from Geom; UMin, UMax, VMin, VMax : Real;
|
||||
Segment : Boolean from Standard = Standard_False)
|
||||
---Level: Public
|
||||
returns MakeShell from BRepLib;
|
||||
|
||||
Init(me : in out; S : Surface from Geom; UMin, UMax, VMin, VMax : Real;
|
||||
Segment : Boolean from Standard = Standard_False)
|
||||
---Purpose: Creates the shell from the surface and the min-max
|
||||
-- values.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
-- Results
|
||||
----------------------------------------------
|
||||
|
||||
Error(me) returns ShellError from BRepLib
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Shell(me) returns Shell from TopoDS
|
||||
---Purpose: Returns the new Shell.
|
||||
--
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Shell() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
fields
|
||||
myError : ShellError from BRepLib;
|
||||
|
||||
end MakeShell;
|
385
src/BRepLib/BRepLib_MakeShell.cxx
Executable file
385
src/BRepLib/BRepLib_MakeShell.cxx
Executable file
@@ -0,0 +1,385 @@
|
||||
// File: BRepLib_MakeShell.cxx
|
||||
// Created: Wed Jan 4 13:37:46 1995
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@fuegox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeShell.ixx>
|
||||
|
||||
#include <BRepLib.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <TColGeom2d_Array1OfCurve.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopTools_Array1OfShape.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeShell
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShell::BRepLib_MakeShell() :
|
||||
myError(BRepLib_EmptyShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeShell
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShell::BRepLib_MakeShell(const Handle(Geom_Surface)& S,
|
||||
const Standard_Boolean Segment)
|
||||
{
|
||||
Standard_Real UMin,UMax,VMin,VMax;
|
||||
S->Bounds(UMin,UMax,VMin,VMax);
|
||||
Init(S,UMin,UMax,VMin,VMax,Segment);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeShell
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShell::BRepLib_MakeShell(const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax,
|
||||
const Standard_Boolean Segment)
|
||||
{
|
||||
Init(S,UMin,UMax,VMin,VMax,Segment);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeShell::Init(const Handle(Geom_Surface)& S,
|
||||
const Standard_Real UMin,
|
||||
const Standard_Real UMax,
|
||||
const Standard_Real VMin,
|
||||
const Standard_Real VMax,
|
||||
const Standard_Boolean Segment)
|
||||
{
|
||||
Handle(Geom_Surface) BS = S;
|
||||
if ( S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
|
||||
BS = RTS->BasisSurface();
|
||||
}
|
||||
myError = BRepLib_EmptyShell;
|
||||
Standard_Real tol = Precision::Confusion();
|
||||
|
||||
// Make a shell from a surface
|
||||
GeomAdaptor_Surface GS(BS,UMin,UMax,VMin,VMax);
|
||||
|
||||
Standard_Integer nu = GS.NbUIntervals(GeomAbs_C2);
|
||||
Standard_Integer nv = GS.NbVIntervals(GeomAbs_C2);
|
||||
|
||||
Standard_Boolean uperiodic = GS.IsUPeriodic();
|
||||
Standard_Boolean vperiodic = GS.IsVPeriodic();
|
||||
|
||||
if (nu == 0 || nv == 0) return;
|
||||
|
||||
// arrays of parameters and pcurves
|
||||
TColStd_Array1OfReal upars(1,nu+1);
|
||||
TColStd_Array1OfReal vpars(1,nv+1);
|
||||
TColGeom2d_Array1OfCurve uisos(1,nu+1);
|
||||
TColGeom2d_Array1OfCurve visos(1,nv+1);
|
||||
|
||||
Standard_Integer iu,iv;
|
||||
|
||||
GS.UIntervals(upars,GeomAbs_C2);
|
||||
gp_Dir2d dv(0,1);
|
||||
for (iu = 1; iu <= nu+1; iu++) {
|
||||
Standard_Real u = upars(iu);
|
||||
if (!Precision::IsInfinite(u))
|
||||
uisos(iu) = new Geom2d_Line(gp_Pnt2d(u,0.),dv);
|
||||
}
|
||||
|
||||
GS.VIntervals(vpars,GeomAbs_C2);
|
||||
gp_Dir2d du(1,0);
|
||||
for (iv = 1; iv <= nv+1 ; iv++) {
|
||||
Standard_Real v = vpars(iv);
|
||||
if (!Precision::IsInfinite(v))
|
||||
visos(iv) = new Geom2d_Line(gp_Pnt2d(0.,v),du);
|
||||
}
|
||||
|
||||
// create row by row
|
||||
|
||||
// create the shell
|
||||
BRep_Builder B;
|
||||
B.MakeShell(TopoDS::Shell(myShape));
|
||||
|
||||
// arrays of edges and vertices for each row
|
||||
TopTools_Array1OfShape botedges(1,nu);
|
||||
TopTools_Array1OfShape botvertices(1,nu+1);
|
||||
|
||||
// copies of the first ones for periodic case
|
||||
TopTools_Array1OfShape fbotedges(1,nu);
|
||||
TopTools_Array1OfShape fbotvertices(1,nu+1);
|
||||
|
||||
TopoDS_Face F;
|
||||
TopoDS_Wire W;
|
||||
TopoDS_Edge eleft,eright,etop,ebot,feleft;
|
||||
TopoDS_Vertex vlb,vlt,vrb,vrt,fvlt;
|
||||
|
||||
|
||||
// init the botedges and botvertices
|
||||
if (!Precision::IsInfinite(vpars(1))) {
|
||||
if (!Precision::IsInfinite(upars(1)))
|
||||
B.MakeVertex(vrt,S->Value(upars(1),vpars(1)),tol);
|
||||
fbotvertices(1) = botvertices(1) = vrt;
|
||||
|
||||
for (iu = 1; iu <= nu; iu++) {
|
||||
vlt = vrt;
|
||||
|
||||
if (uperiodic && iu == nu)
|
||||
vrt = TopoDS::Vertex(botvertices(1));
|
||||
else if (!Precision::IsInfinite(upars(iu+1)))
|
||||
B.MakeVertex(vrt,S->Value(upars(iu+1),vpars(1)),tol);
|
||||
|
||||
fbotvertices(iu+1) = botvertices(iu+1) = vrt;
|
||||
B.MakeEdge(etop);
|
||||
if (!vlt.IsNull()) {
|
||||
vlt.Orientation(TopAbs_FORWARD);
|
||||
B.Add(etop,vlt);
|
||||
}
|
||||
if (!vrt.IsNull()) {
|
||||
vrt.Orientation(TopAbs_REVERSED);
|
||||
B.Add(etop,vrt);
|
||||
}
|
||||
fbotedges(iu) = botedges(iu) = etop;
|
||||
}
|
||||
}
|
||||
|
||||
for (iv = 1; iv <= nv; iv++) {
|
||||
|
||||
// compute the first edge and vertices of the line
|
||||
vrb = TopoDS::Vertex(botvertices(1));
|
||||
|
||||
if (vperiodic && iv == nv) {
|
||||
vrt = TopoDS::Vertex(fbotvertices(1));
|
||||
}
|
||||
else {
|
||||
vrt.Nullify();
|
||||
if (!Precision::IsInfinite(vpars(iv+1))) {
|
||||
if (!Precision::IsInfinite(upars(1)))
|
||||
B.MakeVertex(vrt,S->Value(upars(1),vpars(iv+1)),tol);
|
||||
}
|
||||
}
|
||||
|
||||
eright.Nullify();
|
||||
if (!Precision::IsInfinite(upars(1))) {
|
||||
B.MakeEdge(eright);
|
||||
if (!vrb.IsNull()) {
|
||||
vrb.Orientation(TopAbs_FORWARD);
|
||||
B.Add(eright,vrb);
|
||||
}
|
||||
if (!vrt.IsNull()) {
|
||||
vrt.Orientation(TopAbs_REVERSED);
|
||||
B.Add(eright,vrt);
|
||||
}
|
||||
}
|
||||
|
||||
fvlt = vrt;
|
||||
feleft = eright;
|
||||
|
||||
|
||||
// make the row of faces
|
||||
|
||||
for (iu = 1; iu <= nu; iu++) {
|
||||
|
||||
// create the face at iu, iv
|
||||
|
||||
// the surface
|
||||
Handle(Geom_Surface) SS = Handle(Geom_Surface)::DownCast(BS->Copy());
|
||||
if (GS.GetType() == GeomAbs_BSplineSurface && Segment) {
|
||||
Handle(Geom_BSplineSurface)::DownCast(SS)
|
||||
->Segment(upars(iu),upars(iu+1),
|
||||
vpars(iv),vpars(iv+1) );
|
||||
}
|
||||
B.MakeFace(F,SS,tol);
|
||||
|
||||
// the wire
|
||||
|
||||
B.MakeWire(W);
|
||||
|
||||
// the vertices
|
||||
|
||||
vlb = vrb;
|
||||
vrb = TopoDS::Vertex(botvertices(iu+1));
|
||||
vlt = vrt;
|
||||
|
||||
if (uperiodic && iu == nu)
|
||||
vrt = fvlt;
|
||||
else {
|
||||
vrt.Nullify();
|
||||
if (!Precision::IsInfinite(vpars(iv+1))) {
|
||||
if (!Precision::IsInfinite(upars(iu+1)))
|
||||
B.MakeVertex(vrt,S->Value(upars(iu+1),vpars(iv+1)),tol);
|
||||
}
|
||||
}
|
||||
|
||||
botvertices(iu) = vlt;
|
||||
botvertices(iu+1) = vrt;
|
||||
|
||||
// the edges
|
||||
|
||||
eleft = eright;
|
||||
|
||||
if (uperiodic && iu == nu)
|
||||
eright = feleft;
|
||||
else {
|
||||
eright.Nullify();
|
||||
if (!Precision::IsInfinite(upars(iu+1))) {
|
||||
B.MakeEdge(eright);
|
||||
if (!vrb.IsNull()) {
|
||||
vrb.Orientation(TopAbs_FORWARD);
|
||||
B.Add(eright,vrb);
|
||||
}
|
||||
if (!vrt.IsNull()) {
|
||||
vrt.Orientation(TopAbs_REVERSED);
|
||||
B.Add(eright,vrt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( uperiodic && nu == 1) {
|
||||
if (!eleft.IsNull() && !eright.IsNull()) {
|
||||
B.UpdateEdge(eleft,uisos(2),uisos(1),F,tol);
|
||||
B.Range(eleft,F,vpars(iv),vpars(iv+1));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!eleft.IsNull()) {
|
||||
B.UpdateEdge(eleft,uisos(iu),F,tol);
|
||||
B.Range(eleft,F,vpars(iv),vpars(iv+1));
|
||||
}
|
||||
if (!eright.IsNull()) {
|
||||
B.UpdateEdge(eright,uisos(iu+1),F,tol);
|
||||
B.Range(eright,F,vpars(iv),vpars(iv+1));
|
||||
}
|
||||
}
|
||||
|
||||
ebot = TopoDS::Edge(botedges(iu));
|
||||
|
||||
if (vperiodic && iv == nv)
|
||||
etop = TopoDS::Edge(fbotedges(iu));
|
||||
else {
|
||||
etop.Nullify();
|
||||
if (!Precision::IsInfinite(vpars(iv+1))) {
|
||||
B.MakeEdge(etop);
|
||||
if (!vlt.IsNull()) {
|
||||
vlt.Orientation(TopAbs_FORWARD);
|
||||
B.Add(etop,vlt);
|
||||
}
|
||||
if (!vrt.IsNull()) {
|
||||
vrt.Orientation(TopAbs_REVERSED);
|
||||
B.Add(etop,vrt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( vperiodic && nv == 1) {
|
||||
if (!ebot.IsNull() && !etop.IsNull()) {
|
||||
B.UpdateEdge(ebot,visos(1),visos(2),F,tol);
|
||||
B.Range(ebot,F,vpars(iv),vpars(iv+1));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!ebot.IsNull()) {
|
||||
B.UpdateEdge(ebot,visos(iv),F,tol);
|
||||
B.Range(ebot,F,upars(iu),upars(iu+1));
|
||||
}
|
||||
if (!etop.IsNull()) {
|
||||
B.UpdateEdge(etop,visos(iv+1),F,tol);
|
||||
B.Range(etop,F,upars(iu),upars(iu+1));
|
||||
}
|
||||
}
|
||||
|
||||
botedges(iu) = etop;
|
||||
|
||||
if (!eleft.IsNull()) {
|
||||
eleft.Orientation(TopAbs_REVERSED);
|
||||
B.Add(W,eleft);
|
||||
}
|
||||
if (!ebot.IsNull()) {
|
||||
ebot.Orientation(TopAbs_FORWARD);
|
||||
B.Add(W,ebot);
|
||||
}
|
||||
if (!eright.IsNull()) {
|
||||
eright.Orientation(TopAbs_FORWARD);
|
||||
B.Add(W,eright);
|
||||
}
|
||||
if (!etop.IsNull()) {
|
||||
etop.Orientation(TopAbs_REVERSED);
|
||||
B.Add(W,etop);
|
||||
}
|
||||
|
||||
B.Add(F,W);
|
||||
B.Add(myShape,F);
|
||||
}
|
||||
}
|
||||
|
||||
// codage des courbes 3d et regularites.
|
||||
BRepLib::BuildCurves3d(myShape,tol);
|
||||
BRepLib::EncodeRegularity(myShape);
|
||||
|
||||
myError = BRepLib_ShellDone;
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Error
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_ShellError BRepLib_MakeShell::Error() const
|
||||
{
|
||||
return myError;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TopoDS_Shell&
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Shell& BRepLib_MakeShell::Shell() const
|
||||
{
|
||||
return TopoDS::Shell(myShape);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TopoDS_Shell
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeShell::operator TopoDS_Shell() const
|
||||
{
|
||||
return Shell();
|
||||
}
|
||||
|
||||
|
112
src/BRepLib/BRepLib_MakeSolid.cdl
Executable file
112
src/BRepLib/BRepLib_MakeSolid.cdl
Executable file
@@ -0,0 +1,112 @@
|
||||
-- File: BRepLib_MakeSolid.cdl
|
||||
-- Created: Wed Jan 4 11:12:48 1995
|
||||
-- Author: Bruno DUMORTIER
|
||||
-- <dub@fuegox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
class MakeSolid from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Makes a solid from compsolid or shells.
|
||||
|
||||
uses
|
||||
Solid from TopoDS,
|
||||
CompSolid from TopoDS,
|
||||
Shell from TopoDS,
|
||||
Face from TopoDS,
|
||||
ListOfShape from TopTools,
|
||||
ShapeModification from BRepLib
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Level: Public
|
||||
---Purpose: Solid covers whole space.
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From CompSolid
|
||||
----------------------------------------------
|
||||
|
||||
Create(S : CompSolid from TopoDS)
|
||||
---Purpose: Make a solid from a CompSolid.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
-- From shells
|
||||
----------------------------------------------
|
||||
|
||||
Create(S : Shell from TopoDS)
|
||||
---Purpose: Make a solid from a shell.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
|
||||
Create(S1,S2 : Shell from TopoDS)
|
||||
---Purpose: Make a solid from two shells.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
Create(S1,S2,S3 : Shell from TopoDS)
|
||||
---Purpose: Make a solid from three shells.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
-- From solid and shells
|
||||
----------------------------------------------
|
||||
|
||||
Create(So : Solid from TopoDS)
|
||||
---Purpose: Make a solid from a solid. Usefull for adding later.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
Create(So : Solid from TopoDS; S : Shell from TopoDS)
|
||||
---Purpose: Add a shell to a solid.
|
||||
---Level: Public
|
||||
returns MakeSolid from BRepLib;
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------------
|
||||
|
||||
Add(me : in out; S : Shell from TopoDS)
|
||||
---Purpose: Add the shell to the current solid.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
----------------------------------------------
|
||||
-- Results
|
||||
----------------------------------------------
|
||||
|
||||
Solid(me) returns Solid from TopoDS
|
||||
---Purpose: Returns the new Solid.
|
||||
--
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Solid() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
FaceStatus(me; F: Face from TopoDS)
|
||||
---Purpose: returns the status of the Face after
|
||||
-- the shape creation.
|
||||
---Level: Public
|
||||
returns ShapeModification from BRepLib
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
|
||||
myDeletedFaces: ListOfShape from TopTools is protected;
|
||||
|
||||
end MakeSolid;
|
195
src/BRepLib/BRepLib_MakeSolid.cxx
Executable file
195
src/BRepLib/BRepLib_MakeSolid.cxx
Executable file
@@ -0,0 +1,195 @@
|
||||
// File: BRepLib_MakeSolid.cxx
|
||||
// Created: Wed Jan 4 13:41:20 1995
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@fuegox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeSolid.ixx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid()
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
Done();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_CompSolid& S)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
|
||||
TopExp_Explorer ex1, ex2;
|
||||
TopTools_MapOfShape aMapOfFaces;
|
||||
for (ex1.Init(S,TopAbs_SHELL); ex1.More(); ex1.Next()) {
|
||||
for (ex2.Init(ex1.Current(),TopAbs_FACE); ex2.More(); ex2.Next()) {
|
||||
if(!aMapOfFaces.Add(ex2.Current())) {
|
||||
myDeletedFaces.Append(ex2.Current());
|
||||
aMapOfFaces.Remove(ex2.Current());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Shape aShell;
|
||||
B.MakeShell(TopoDS::Shell(aShell));
|
||||
|
||||
TopTools_MapIteratorOfMapOfShape aFaceIter(aMapOfFaces);
|
||||
for(; aFaceIter.More(); aFaceIter.Next()) {
|
||||
B.Add(aShell, aFaceIter.Key());
|
||||
}
|
||||
|
||||
B.Add(myShape,aShell);
|
||||
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
B.Add(myShape,S);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
B.Add(myShape,S1);
|
||||
B.Add(myShape,S2);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Shell& S1, const TopoDS_Shell& S2, const TopoDS_Shell& S3)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
B.Add(myShape,S1);
|
||||
B.Add(myShape,S2);
|
||||
B.Add(myShape,S3);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
TopExp_Explorer ex;
|
||||
for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
|
||||
B.Add(myShape,ex.Current());
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeSolid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::BRepLib_MakeSolid(const TopoDS_Solid& So, const TopoDS_Shell& S)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeSolid(TopoDS::Solid(myShape));
|
||||
TopExp_Explorer ex;
|
||||
for (ex.Init(So,TopAbs_SHELL); ex.More(); ex.Next())
|
||||
B.Add(myShape,ex.Current());
|
||||
B.Add(myShape,S);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeSolid::Add(const TopoDS_Shell& S)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.Add(myShape,S);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Solid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Solid& BRepLib_MakeSolid::Solid()const
|
||||
{
|
||||
return TopoDS::Solid(Shape());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeSolid::operator TopoDS_Solid() const
|
||||
{
|
||||
return TopoDS::Solid(Shape());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FaceStatus
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_ShapeModification BRepLib_MakeSolid::FaceStatus
|
||||
(const TopoDS_Face& F) const
|
||||
{
|
||||
BRepLib_ShapeModification myStatus = BRepLib_Preserved;
|
||||
TopTools_ListIteratorOfListOfShape anIter(myDeletedFaces);
|
||||
|
||||
for(; anIter.More(); anIter.Next()) {
|
||||
if(F.IsSame(anIter.Value())) {
|
||||
myStatus = BRepLib_Deleted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return myStatus;
|
||||
}
|
||||
|
29
src/BRepLib/BRepLib_MakeVertex.cdl
Executable file
29
src/BRepLib/BRepLib_MakeVertex.cdl
Executable file
@@ -0,0 +1,29 @@
|
||||
-- File: BRepLib_MakeVertex.cdl
|
||||
-- Created: Tue Jul 6 17:57:32 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
|
||||
class MakeVertex from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methods to build vertices.
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Vertex from TopoDS
|
||||
|
||||
is
|
||||
Create (P : Pnt from gp)
|
||||
---Level: Public
|
||||
returns MakeVertex from BRepLib;
|
||||
|
||||
Vertex(me) returns Vertex from TopoDS
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Vertex() const;"
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
end MakeVertex;
|
47
src/BRepLib/BRepLib_MakeVertex.cxx
Executable file
47
src/BRepLib/BRepLib_MakeVertex.cxx
Executable file
@@ -0,0 +1,47 @@
|
||||
// File: BRepLib_MakeVertex.cxx
|
||||
// Created: Fri Jul 23 15:51:55 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeVertex.ixx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeVertex::BRepLib_MakeVertex(const gp_Pnt& P)
|
||||
{
|
||||
BRep_Builder B;
|
||||
B.MakeVertex(TopoDS::Vertex(myShape),P,BRepLib::Precision());
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakeVertex::Vertex()const
|
||||
{
|
||||
return TopoDS::Vertex(Shape());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
BRepLib_MakeVertex::operator TopoDS_Vertex() const
|
||||
{
|
||||
return Vertex();
|
||||
}
|
||||
|
||||
|
179
src/BRepLib/BRepLib_MakeWire.cdl
Executable file
179
src/BRepLib/BRepLib_MakeWire.cdl
Executable file
@@ -0,0 +1,179 @@
|
||||
-- File: BRepLib_MakeWire.cdl
|
||||
-- Created: Thu Jul 8 11:15:02 1993
|
||||
-- Author: Remi LEQUETTE
|
||||
-- <rle@phylox>
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
|
||||
|
||||
class MakeWire from BRepLib inherits MakeShape from BRepLib
|
||||
|
||||
---Purpose: Provides methods to build wires.
|
||||
--
|
||||
-- A wire may be built :
|
||||
--
|
||||
-- * From a single edge.
|
||||
--
|
||||
-- * From a wire and an edge.
|
||||
--
|
||||
-- - A new wire is created with the edges of the
|
||||
-- wire + the edge.
|
||||
--
|
||||
-- - If the edge is not connnected to the wire the
|
||||
-- flag NotDone is set and the method Wire will
|
||||
-- raise an error.
|
||||
--
|
||||
-- - The connection may be :
|
||||
--
|
||||
-- . Through an existing vertex. The edge is shared.
|
||||
--
|
||||
-- . Through a geometric coincidence of vertices.
|
||||
-- The edge is copied and the vertices from the
|
||||
-- edge are replaced by the vertices from the
|
||||
-- wire.
|
||||
--
|
||||
-- . The new edge and the connection vertices are
|
||||
-- kept by the algorithm.
|
||||
--
|
||||
--
|
||||
-- * From 2, 3, 4 edges.
|
||||
--
|
||||
-- - A wire is created from the first edge, the
|
||||
-- following edges are added.
|
||||
--
|
||||
-- * From many edges.
|
||||
--
|
||||
-- - The following syntax may be used :
|
||||
--
|
||||
-- BRepLib_MakeWire MW;
|
||||
--
|
||||
-- // for all the edges ...
|
||||
-- MW.Add(anEdge);
|
||||
--
|
||||
-- TopoDS_Wire W = MW;
|
||||
|
||||
|
||||
|
||||
uses
|
||||
WireError from BRepLib,
|
||||
Wire from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
MapOfShape from TopTools,
|
||||
ListOfShape from TopTools
|
||||
|
||||
raises
|
||||
NotDone from StdFail
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Purpose: NotDone MakeWire.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From edges
|
||||
----------------------------------------------
|
||||
|
||||
Create(E : Edge from TopoDS)
|
||||
---Purpose: Make a Wire from an edge.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
Create(E1,E2 : Edge from TopoDS)
|
||||
---Purpose: Make a Wire from two edges.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
Create(E1,E2,E3 : Edge from TopoDS)
|
||||
---Purpose: Make a Wire from three edges.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
Create(E1,E2,E3,E4 : Edge from TopoDS)
|
||||
---Purpose: Make a Wire from four edges.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- From wire and edge
|
||||
----------------------------------------------
|
||||
|
||||
Create(W : Wire from TopoDS)
|
||||
---Purpose: Make a Wire from a Wire. Usefull for adding later.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
Create(W : Wire from TopoDS; E : Edge from TopoDS)
|
||||
---Purpose: Add an edge to a wire.
|
||||
---Level: Public
|
||||
returns MakeWire from BRepLib;
|
||||
|
||||
----------------------------------------------
|
||||
-- Auxiliary methods
|
||||
----------------------------------------------
|
||||
|
||||
Add(me : in out; E : Edge from TopoDS)
|
||||
---Purpose: Add the edge <E> to the current wire.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Add(me : in out; W : Wire from TopoDS)
|
||||
---Purpose: Add the edges of <W> to the current wire.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Add(me : in out; L : ListOfShape from TopTools)
|
||||
---Purpose: Add the edges of <L> to the current wire.
|
||||
-- The edges are not to be consecutive. But they are
|
||||
-- to be all connected geometrically or topologically.
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
----------------------------------------------
|
||||
-- Results
|
||||
----------------------------------------------
|
||||
|
||||
Error(me) returns WireError from BRepLib
|
||||
---Level: Public
|
||||
is static;
|
||||
|
||||
Wire(me) returns Wire from TopoDS
|
||||
---Purpose: Returns the new wire.
|
||||
--
|
||||
---C++: return const &
|
||||
---C++: alias "Standard_EXPORT operator TopoDS_Wire() const;"
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Edge(me) returns Edge from TopoDS
|
||||
---Purpose: Returns the last edge added to the wire.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Vertex(me) returns Vertex from TopoDS
|
||||
---Purpose: Returns the last connecting vertex.
|
||||
--
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
raises
|
||||
NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
fields
|
||||
myError : WireError from BRepLib;
|
||||
myEdge : Edge from TopoDS;
|
||||
myVertex : Vertex from TopoDS;
|
||||
myVertices : MapOfShape from TopTools;
|
||||
FirstVertex : Vertex from TopoDS;
|
||||
VF, VL : Vertex from TopoDS;
|
||||
|
||||
end MakeWire;
|
437
src/BRepLib/BRepLib_MakeWire.cxx
Executable file
437
src/BRepLib/BRepLib_MakeWire.cxx
Executable file
@@ -0,0 +1,437 @@
|
||||
// File: BRepLib_MakeWire.cxx
|
||||
// Created: Fri Jul 23 15:51:57 1993
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@nonox>
|
||||
|
||||
|
||||
#include <BRepLib_MakeWire.ixx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLib_MakeEdge.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <gp.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire() :
|
||||
myError(BRepLib_EmptyWire)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Edge& E)
|
||||
{
|
||||
Add(E);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Edge& E1,
|
||||
const TopoDS_Edge& E2)
|
||||
{
|
||||
Add(E1);
|
||||
Add(E2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Edge& E1,
|
||||
const TopoDS_Edge& E2,
|
||||
const TopoDS_Edge& E3)
|
||||
{
|
||||
Add(E1);
|
||||
Add(E2);
|
||||
Add(E3);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Edge& E1,
|
||||
const TopoDS_Edge& E2,
|
||||
const TopoDS_Edge& E3,
|
||||
const TopoDS_Edge& E4)
|
||||
{
|
||||
Add(E1);
|
||||
Add(E2);
|
||||
Add(E3);
|
||||
Add(E4);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Wire& W)
|
||||
{
|
||||
Add(W);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepLib_MakeWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Wire& W,
|
||||
const TopoDS_Edge& E)
|
||||
{
|
||||
Add(W);
|
||||
Add(E);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeWire::Add(const TopoDS_Wire& W)
|
||||
{
|
||||
TopExp_Explorer ex(W,TopAbs_EDGE);
|
||||
while (ex.More()) {
|
||||
Add(TopoDS::Edge(ex.Current()));
|
||||
ex.Next();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
// PMN 19/03/1998 Pour des Probleme de performances on n'utilise pas
|
||||
// TopExp::Vertices sur des wire
|
||||
// PMN 10/09/1998 Dans le cas ou le wire est precedament ferme (ou degenere)
|
||||
// on emploie quand meme TopExp::Vertices ... Afin de lever
|
||||
// les ambiguites.
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeWire::Add(const TopoDS_Edge& E)
|
||||
{
|
||||
|
||||
Standard_Boolean forward = Standard_False;
|
||||
// pour dire si on decider d'ajouter forward
|
||||
Standard_Boolean reverse = Standard_False;
|
||||
// pour dire si on decide d'ajouter reversed
|
||||
Standard_Boolean init = Standard_False;
|
||||
// Pour savoir s'il on doit calculer VL, VF
|
||||
BRep_Builder B;
|
||||
TopoDS_Iterator it;
|
||||
|
||||
if (myEdge.IsNull()) {
|
||||
init = Standard_True;
|
||||
// first edge, create the wire
|
||||
B.MakeWire(TopoDS::Wire(myShape));
|
||||
|
||||
// set the edge
|
||||
myEdge = E;
|
||||
|
||||
// add the vertices
|
||||
for (it.Initialize(myEdge); it.More(); it.Next())
|
||||
myVertices.Add(it.Value());
|
||||
}
|
||||
|
||||
else {
|
||||
init = myShape.Closed(); // Si c'est ferme, on ne controle
|
||||
TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
|
||||
TopoDS_Edge EE = TopoDS::Edge(aLocalShape);
|
||||
// TopoDS_Edge EE = TopoDS::Edge(E.Oriented(TopAbs_FORWARD));
|
||||
|
||||
// test the vertices of the edge
|
||||
|
||||
Standard_Boolean connected = Standard_False;
|
||||
Standard_Boolean copyedge = Standard_False;
|
||||
|
||||
if (myError != BRepLib_NonManifoldWire) {
|
||||
if (VF.IsNull() || VL.IsNull())
|
||||
myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
|
||||
for (it.Initialize(EE); it.More(); it.Next()) {
|
||||
|
||||
const TopoDS_Vertex& VE = TopoDS::Vertex(it.Value());
|
||||
|
||||
// if the vertex is in the wire, ok for the connection
|
||||
if (myVertices.Contains(VE)) {
|
||||
connected = Standard_True;
|
||||
myVertex = VE;
|
||||
if (myError != BRepLib_NonManifoldWire) {
|
||||
// l est on toujours ?
|
||||
if (VF.IsSame(VL)) {
|
||||
// Orientation indetermine (en 3d) : On garde l'init
|
||||
if (!VF.IsSame(VE)) myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
else {
|
||||
if (VF.IsSame(VE)) {
|
||||
if (VE.Orientation() == TopAbs_FORWARD)
|
||||
reverse = Standard_True;
|
||||
else
|
||||
forward = Standard_True;
|
||||
}
|
||||
else if (VL.IsSame(VE)) {
|
||||
if (VE.Orientation() == TopAbs_REVERSED)
|
||||
reverse = Standard_True;
|
||||
else
|
||||
forward = Standard_True;
|
||||
}
|
||||
else
|
||||
myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// search if there is a similar vertex in the edge
|
||||
gp_Pnt PE = BRep_Tool::Pnt(VE);
|
||||
|
||||
// Standard_Boolean newvertex = Standard_False;
|
||||
TopTools_MapIteratorOfMapOfShape itm(myVertices);
|
||||
while (itm.More()) {
|
||||
|
||||
const TopoDS_Vertex& VW = TopoDS::Vertex(itm.Key());
|
||||
gp_Pnt PW = BRep_Tool::Pnt(VW);
|
||||
Standard_Real l = PE.Distance(PW);
|
||||
|
||||
if ((l < BRep_Tool::Tolerance(VE)) ||
|
||||
(l < BRep_Tool::Tolerance(VW))) {
|
||||
copyedge = Standard_True;
|
||||
if (myError != BRepLib_NonManifoldWire) {
|
||||
// l est on toujours ?
|
||||
if (VF.IsSame(VL)) {
|
||||
// Orientation indetermine (en 3d) : On garde l'init
|
||||
if (!VF.IsSame(VW)) myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
else {
|
||||
if (VF.IsSame(VW)) {
|
||||
if (VE.Orientation() == TopAbs_FORWARD)
|
||||
reverse = Standard_True;
|
||||
else
|
||||
forward = Standard_True;
|
||||
}
|
||||
else if (VL.IsSame(VW)) {
|
||||
if (VE.Orientation() == TopAbs_REVERSED)
|
||||
reverse = Standard_True;
|
||||
else
|
||||
forward = Standard_True;
|
||||
}
|
||||
else
|
||||
myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
itm.Next();
|
||||
}
|
||||
if (copyedge) {
|
||||
connected = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!connected) {
|
||||
myError = BRepLib_DisconnectedWire;
|
||||
NotDone();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!copyedge) {
|
||||
myEdge = EE;
|
||||
for (it.Initialize(EE); it.More(); it.Next())
|
||||
myVertices.Add(it.Value());
|
||||
}
|
||||
else {
|
||||
// copy the edge
|
||||
TopoDS_Shape Dummy = EE.EmptyCopied();
|
||||
myEdge = TopoDS::Edge(Dummy);
|
||||
myEdge.Closed(EE.Closed());
|
||||
|
||||
for (it.Initialize(EE); it.More(); it.Next()) {
|
||||
|
||||
const TopoDS_Vertex& VE = TopoDS::Vertex(it.Value());
|
||||
gp_Pnt PE = BRep_Tool::Pnt(VE);
|
||||
|
||||
Standard_Boolean newvertex = Standard_False;
|
||||
TopTools_MapIteratorOfMapOfShape itm(myVertices);
|
||||
while (itm.More()) {
|
||||
|
||||
const TopoDS_Vertex& VW = TopoDS::Vertex(itm.Key());
|
||||
gp_Pnt PW = BRep_Tool::Pnt(VW);
|
||||
Standard_Real l = PE.Distance(PW), tolE, tolW;
|
||||
tolW = BRep_Tool::Tolerance(VW);
|
||||
tolE = BRep_Tool::Tolerance(VE);
|
||||
|
||||
if ((l < tolE) || (l < tolW)) {
|
||||
|
||||
Standard_Real maxtol = .5*(tolW + tolE + l), cW, cE;
|
||||
if(maxtol > tolW && maxtol > tolE) {
|
||||
cW = (maxtol - tolE)/l;
|
||||
cE = 1. - cW;
|
||||
}
|
||||
else if (maxtol > tolW) {maxtol = tolE; cW = 0.; cE = 1.;}
|
||||
else {maxtol = tolW; cW = 1.; cE = 0.;}
|
||||
|
||||
gp_Pnt PC(cW*PW.X() + cE*PE.X(),cW*PW.Y() + cE*PE.Y(),cW*PW.Z() + cE*PE.Z());
|
||||
|
||||
B.UpdateVertex(VW, PC, maxtol);
|
||||
|
||||
newvertex = Standard_True;
|
||||
myVertex = VW;
|
||||
myVertex.Orientation(VE.Orientation());
|
||||
B.Add(myEdge,myVertex);
|
||||
B.Transfert(EE,myEdge,VE,myVertex);
|
||||
break;
|
||||
}
|
||||
|
||||
itm.Next();
|
||||
}
|
||||
if (!newvertex) {
|
||||
myVertices.Add(VE);
|
||||
B.Add(myEdge,VE);
|
||||
B.Transfert(EE,myEdge,VE,VE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// On decide ici de l'orientation de l'arete
|
||||
// S'il y a ambiguite (en 3d) on garde l'orientation donnee en entree
|
||||
// Cas d'ambiguite :
|
||||
// reverse et forward sont faux car on n'a rien decider :
|
||||
// wire ferme, vertex interne ...
|
||||
// reverse et forward sont vrai : Edge ferme ou degenere
|
||||
if ( ((forward == reverse) && (E.Orientation() == TopAbs_REVERSED)) ||
|
||||
( reverse && !forward) ) myEdge.Reverse();
|
||||
}
|
||||
|
||||
// add myEdge to myShape
|
||||
B.Add(myShape,myEdge);
|
||||
myShape.Closed(Standard_False);
|
||||
|
||||
// Initialize VF, VL
|
||||
if (init) TopExp::Vertices(TopoDS::Wire(myShape), VF,VL);
|
||||
else {
|
||||
if (myError == BRepLib_WireDone){ // Update only
|
||||
TopoDS_Vertex V1,V2,VRef;
|
||||
TopExp::Vertices(myEdge, V1, V2);
|
||||
if (V1.IsSame(myVertex)) VRef = V2;
|
||||
else if (V2.IsSame(myVertex)) VRef = V1;
|
||||
else {
|
||||
#if DEB
|
||||
cout << "MakeWire : Y A UN PROBLEME !!" << endl;
|
||||
#endif
|
||||
myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
|
||||
if (VF.IsSame(VL)) {
|
||||
// Cas particulier: il faut controler les orientations
|
||||
#if DEB
|
||||
if (!VF.IsSame(myVertex))
|
||||
cout << "MakeWire : Y A UN PROBLEME !!" << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
else { // Cas general
|
||||
if (VF.IsSame(myVertex)) VF = VRef;
|
||||
else if (VL.IsSame(myVertex)) VL = VRef;
|
||||
else {
|
||||
#if DEB
|
||||
cout << "MakeWire : Y A UN PROBLEME !!" << endl;
|
||||
#endif
|
||||
myError = BRepLib_NonManifoldWire;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myError == BRepLib_NonManifoldWire) {
|
||||
VF = VL = TopoDS_Vertex(); // nullify
|
||||
}
|
||||
}
|
||||
// Test myShape is closed
|
||||
if (!VF.IsNull() && !VL.IsNull() && VF.IsSame(VL))
|
||||
myShape.Closed(Standard_True);
|
||||
|
||||
myError = BRepLib_WireDone;
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Wire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Wire& BRepLib_MakeWire::Wire()const
|
||||
{
|
||||
return TopoDS::Wire(Shape());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Edge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Edge& BRepLib_MakeWire::Edge()const
|
||||
{
|
||||
return myEdge;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Vertex& BRepLib_MakeWire::Vertex()const
|
||||
{
|
||||
return myVertex;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : operator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_MakeWire::operator TopoDS_Wire() const
|
||||
{
|
||||
return Wire();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Error
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepLib_WireError BRepLib_MakeWire::Error() const
|
||||
{
|
||||
return myError;
|
||||
}
|
240
src/BRepLib/BRepLib_MakeWire_1.cxx
Executable file
240
src/BRepLib/BRepLib_MakeWire_1.cxx
Executable file
@@ -0,0 +1,240 @@
|
||||
// File: BRepLib_MakeWire_1.cxx
|
||||
// Created: Wed May 20 07:30:03 1998
|
||||
// Author: Didier PIFFAULT
|
||||
// <dpf@motox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <BRepLib_MakeWire.ixx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_MapOfOrientedShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
|
||||
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : Add the list of edges to the current wire
|
||||
//=======================================================================
|
||||
|
||||
void BRepLib_MakeWire::Add(const TopTools_ListOfShape& L)
|
||||
{
|
||||
myError = BRepLib_WireDone;
|
||||
if (!myShape.IsNull()) myShape.Closed(Standard_False);
|
||||
|
||||
if (!L.IsEmpty()) {
|
||||
NotDone();
|
||||
TopTools_MapOfShape mapLocale;
|
||||
mapLocale.Assign(myVertices);
|
||||
TopTools_DataMapOfShapeShape toCopy;
|
||||
TopTools_ListOfShape toAdd, nlist, rlist;
|
||||
BRep_Builder BB;
|
||||
|
||||
TopExp_Explorer exv;
|
||||
TopTools_MapIteratorOfMapOfShape itMS;
|
||||
TopTools_ListIteratorOfListOfShape itList(L);
|
||||
for (;itList.More(); itList.Next()) {
|
||||
const TopoDS_Edge& curEd=TopoDS::Edge(itList.Value());
|
||||
if (!curEd.IsNull()) {
|
||||
rlist.Clear();
|
||||
nlist.Clear();
|
||||
Standard_Boolean copEd=Standard_False;
|
||||
if (myEdge.IsNull()) {
|
||||
Add(curEd);
|
||||
if (!VF.IsNull()) mapLocale.Add(VF);
|
||||
if (!VL.IsNull()) mapLocale.Add(VL);
|
||||
NotDone();
|
||||
continue;
|
||||
}
|
||||
for (exv.Init(curEd, TopAbs_VERTEX); exv.More(); exv.Next()) {
|
||||
const TopoDS_Vertex& edVer=TopoDS::Vertex(exv.Current());
|
||||
rlist.Prepend(edVer);
|
||||
nlist.Prepend(edVer);
|
||||
if (!mapLocale.Contains(edVer)) {
|
||||
#ifndef DEB
|
||||
Standard_Boolean notYetFound = Standard_True;
|
||||
#else
|
||||
Standard_Boolean notYetFound;
|
||||
#endif
|
||||
Standard_Real gap=BRep_Tool::Tolerance(edVer);
|
||||
gp_Pnt pVer=BRep_Tool::Pnt(edVer);
|
||||
for (itMS.Initialize(mapLocale); itMS.More(); itMS.Next()) {
|
||||
notYetFound=Standard_True;
|
||||
const TopoDS_Vertex& refVer=TopoDS::Vertex(itMS.Key());
|
||||
gap +=BRep_Tool::Tolerance(refVer);
|
||||
if (pVer.Distance(BRep_Tool::Pnt(TopoDS::Vertex(refVer))) <= gap) {
|
||||
nlist.RemoveFirst();
|
||||
nlist.Prepend(refVer.Oriented(edVer.Orientation()));
|
||||
copEd=Standard_True;
|
||||
notYetFound=Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (notYetFound) mapLocale.Add(edVer);
|
||||
}
|
||||
}
|
||||
if (copEd) {
|
||||
TopoDS_Shape aLocalShape = curEd.EmptyCopied();
|
||||
TopoDS_Edge newEd=TopoDS::Edge(aLocalShape);
|
||||
// TopoDS_Edge newEd=TopoDS::Edge(curEd.EmptyCopied());
|
||||
BB.Transfert(curEd, newEd);
|
||||
newEd.Closed(curEd.Closed());
|
||||
TopTools_ListIteratorOfListOfShape itV(nlist);
|
||||
for (; itV.More(); itV.Next()) {
|
||||
BB.Add(newEd, itV.Value());
|
||||
BB.Transfert(curEd, newEd, TopoDS::Vertex(rlist.First()), TopoDS::Vertex(itV.Value()));
|
||||
rlist.RemoveFirst();
|
||||
}
|
||||
toAdd.Append(newEd);
|
||||
}
|
||||
else {
|
||||
toAdd.Append(curEd);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!toAdd.IsEmpty()) {
|
||||
TopoDS_Compound comp;
|
||||
BB.MakeCompound(comp);
|
||||
TopTools_MapIteratorOfMapOfOrientedShape itMOS;
|
||||
TopTools_MapOfOrientedShape theEdges;
|
||||
for (itList.Initialize(toAdd); itList.More(); itList.Next()) {
|
||||
BB.Add(comp, itList.Value());
|
||||
theEdges.Add(itList.Value());
|
||||
}
|
||||
TopTools_IndexedDataMapOfShapeListOfShape lesMeres;
|
||||
TopExp::MapShapesAndAncestors(comp, TopAbs_VERTEX, TopAbs_EDGE, lesMeres);
|
||||
TopoDS_Vertex vf, vl;
|
||||
TopoDS_Shape theKey;
|
||||
Standard_Boolean usedVertex;
|
||||
#ifndef DEB
|
||||
Standard_Boolean closedEdge = Standard_False;
|
||||
#else
|
||||
Standard_Boolean closedEdge;
|
||||
#endif
|
||||
Standard_Integer vvInd, lastInd;
|
||||
do {
|
||||
if (!VL.IsNull() && lesMeres.Contains(VL)) {
|
||||
if (!VF.IsNull()) closedEdge=VF.IsSame(VL);
|
||||
usedVertex=Standard_True;
|
||||
for (itList.Initialize(lesMeres.FindFromKey(VL)); itList.More(); itList.Next()) {
|
||||
if (theEdges.Contains(itList.Value())) {
|
||||
usedVertex=Standard_False;
|
||||
theEdges.Remove(itList.Value());
|
||||
TopExp::Vertices(TopoDS::Edge(itList.Value()), vf,vl);
|
||||
if (vf.IsSame(VL)) {
|
||||
BB.Add(myShape, itList.Value());
|
||||
myVertices.Add(vl);
|
||||
VL=vl;
|
||||
}
|
||||
else {
|
||||
if (closedEdge) {
|
||||
BB.Add(myShape, itList.Value());
|
||||
VF=vf;
|
||||
}
|
||||
else {
|
||||
BB.Add(myShape, itList.Value().Reversed());
|
||||
vf.Reverse();
|
||||
VL=vf;
|
||||
}
|
||||
myVertices.Add(vf);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (usedVertex) {
|
||||
lastInd=lesMeres.Extent();
|
||||
vvInd=lesMeres.FindIndex(VL);
|
||||
if (vvInd != lastInd) {
|
||||
theKey=lesMeres.FindKey(lastInd);
|
||||
nlist=lesMeres.FindFromIndex(lastInd);
|
||||
}
|
||||
lesMeres.RemoveLast();
|
||||
if (vvInd != lastInd) {
|
||||
lesMeres.Substitute(vvInd, theKey, nlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!VF.IsNull() && lesMeres.Contains(VF)) {
|
||||
usedVertex=Standard_True;
|
||||
for (itList.Initialize(lesMeres.FindFromKey(VF)); itList.More(); itList.Next()) {
|
||||
if (theEdges.Contains(itList.Value())) {
|
||||
usedVertex=Standard_False;
|
||||
theEdges.Remove(itList.Value());
|
||||
TopExp::Vertices(TopoDS::Edge(itList.Value()), vf,vl);
|
||||
if (vl.IsSame(VF)) {
|
||||
BB.Add(myShape, itList.Value());
|
||||
myVertices.Add(vf);
|
||||
VF=vf;
|
||||
}
|
||||
else {
|
||||
BB.Add(myShape, itList.Value().Reversed());
|
||||
vl.Reverse();
|
||||
myVertices.Add(vl);
|
||||
VF=vl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (usedVertex) {
|
||||
lastInd=lesMeres.Extent();
|
||||
vvInd=lesMeres.FindIndex(VF);
|
||||
if (vvInd != lastInd) {
|
||||
theKey=lesMeres.FindKey(lastInd);
|
||||
nlist=lesMeres.FindFromIndex(lastInd);
|
||||
}
|
||||
lesMeres.RemoveLast();
|
||||
if (vvInd != lastInd) {
|
||||
lesMeres.Substitute(vvInd, theKey, nlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (theEdges.Extent()>0) {
|
||||
Standard_Boolean noCandidat=Standard_True;
|
||||
for (itMOS.Initialize(theEdges); itMOS.More(); itMOS.Next()) {
|
||||
TopExp::Vertices(TopoDS::Edge(itMOS.Key()), vf,vl);
|
||||
if (myVertices.Contains(vl)) {
|
||||
if (myError==BRepLib_WireDone) myError = BRepLib_NonManifoldWire;
|
||||
BB.Add(myShape, itMOS.Key());
|
||||
myVertices.Add(vf);
|
||||
VF=vf;
|
||||
noCandidat=Standard_False;
|
||||
break;
|
||||
}
|
||||
else if (myVertices.Contains(vf)) {
|
||||
if (myError==BRepLib_WireDone) myError = BRepLib_NonManifoldWire;
|
||||
BB.Add(myShape, itMOS.Key());
|
||||
myVertices.Add(vl);
|
||||
VL=vl;
|
||||
noCandidat=Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (noCandidat) {
|
||||
theEdges.Clear();
|
||||
// Some Edges are not connected to first edge and the diagnosis is as follows
|
||||
// but the le "Maker" is Done() because otherwise it is not possible to return the constructed connected part...
|
||||
myError=BRepLib_DisconnectedWire;
|
||||
}
|
||||
else theEdges.Remove(itMOS.Key());
|
||||
}
|
||||
}
|
||||
} while (theEdges.Extent()>0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!VF.IsNull() && !VL.IsNull() && VF.IsSame(VL))
|
||||
myShape.Closed(Standard_True);
|
||||
Done();
|
||||
}
|
1
src/BRepLib/FILES
Executable file
1
src/BRepLib/FILES
Executable file
@@ -0,0 +1 @@
|
||||
BRepLib_MakeWire_1.cxx
|
Reference in New Issue
Block a user