1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

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

99
src/ChFi2d/ChFi2d.cdl Executable file
View File

@@ -0,0 +1,99 @@
-- File: ChFi2d.cdl
-- Created: Mon Jun 12 13:33:39 1995
-- Author: Philippe DERVIEUX
-- <phd@tlefon>
---Copyright: Matra Datavision 1995
-- Modified: Tue Oct 15 10:12:02 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
-- Add ChFi2d_TangencyError (PRO3529)
-- Modified: Tue Oct 22 09:23:11 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
-- Add ChFi2d_FirstEdgeDegenerated, ChFi2d_LastEdgeDegenerated,
-- ChFi2d_BothEdgesDegenerated (PRO4896)
-- Modified: Fri Sep 25 09:38:04 1998
-- Author: Joelle CHAUVET
-- <jct@sgi64>
-- ChFi2d_NotAuthorized is used if the edges are not
-- lines or circles (BUC60288)
package ChFi2d
---Purpose: This package contains the algorithms used to build
-- fillets or chamfers on planar wire.
uses
TopoDS,
TopTools,
gp
is
enumeration ConstructionError is
---Purpose: error that can occur during the
-- fillet construction on planar wire
NotPlanar,
---Purpose: the face is not planar
NoFace,
---Purpose: the face is null
InitialisationError,
---Purpose: the two faces used for the initialisation are
-- uncompatible.
ParametersError,
---Purpose: the parameters as distances or angle for
-- chamfer are less or equal to zero.
Ready,
---Purpose: the initialization has been succesfull.
IsDone,
ComputationError,
---Purpose: the algorithm could not find a solution.
ConnexionError,
---Purpose: the vertex given to locate the fillet or the
-- chamfer is not connected to 2 edges.
TangencyError,
---Purpose: the two edges connected to the vertex are tangent.
FirstEdgeDegenerated,
---Purpose: the first edge is degenerated.
LastEdgeDegenerated,
---Purpose: the last edge is degenerated.
BothEdgesDegenerated,
---Purpose: the two edges are degenerated.
NotAuthorized
---Purpose: One or the two edges connected to the vertex
-- is a fillet or a chamfer
-- One or the two edges connected to the vertex
-- is not a line or a circle
end ConstructionError;
class Builder;
CommonVertex( E1, E2 : Edge from TopoDS;
V : out Vertex from TopoDS)
returns Boolean
is private;
---Warning: <V> has sense only if the value <True> is returned
FindConnectedEdges( F : Face from TopoDS;
V : Vertex from TopoDS;
E1, E2 : out Edge from TopoDS)
returns ConstructionError from ChFi2d
is private;
---Warning: <E1> and <E2> has sense only if the returned value
-- is <IsDone>
end ChFi2d;

72
src/ChFi2d/ChFi2d.cxx Executable file
View File

@@ -0,0 +1,72 @@
// File: ChFi2d.cxx
// Created: Mon Jun 26 09:53:29 1995
// Author: Philippe DERVIEUX
// <phd@tlefon>
#include <ChFi2d.ixx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : CommonVertex
//purpose :
//=======================================================================
Standard_Boolean ChFi2d::CommonVertex(const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
TopoDS_Vertex& V)
{
TopoDS_Vertex firstVertex1, lastVertex1, firstVertex2, lastVertex2;
TopExp::Vertices(E1, firstVertex1, lastVertex1);
TopExp::Vertices(E2, firstVertex2, lastVertex2);
if (firstVertex1.IsSame(firstVertex2) ||
firstVertex1.IsSame(lastVertex2)) {
V = firstVertex1;
return Standard_True;
}
if (lastVertex1.IsSame(firstVertex2) ||
lastVertex1.IsSame(lastVertex2)) {
V = lastVertex1;
return Standard_True;
}
return Standard_False;
} // CommonVertex
//=======================================================================
//function : FindConnectedEdges
//purpose :
//=======================================================================
ChFi2d_ConstructionError ChFi2d::FindConnectedEdges(const TopoDS_Face& F,
const TopoDS_Vertex& V,
TopoDS_Edge& E1,
TopoDS_Edge& E2)
{
TopTools_IndexedDataMapOfShapeListOfShape vertexMap ;
TopExp::MapShapesAndAncestors (F, TopAbs_VERTEX,
TopAbs_EDGE, vertexMap);
if (vertexMap.Contains(V)) {
TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(V));
if (iterator.More()) {
E1 = TopoDS::Edge(iterator.Value());
iterator.Next();
} // if ...
else return ChFi2d_ConnexionError;
if (iterator.More()) {
E2 = TopoDS::Edge(iterator.Value());
iterator.Next();
} // if ...
else return ChFi2d_ConnexionError;
if(iterator.More()) return ChFi2d_ConnexionError;
} // if (isFind)
else return ChFi2d_ConnexionError;
return ChFi2d_IsDone;
} // FindConnectedEdges

286
src/ChFi2d/ChFi2d_Builder.cdl Executable file
View File

@@ -0,0 +1,286 @@
-- File: ChFi2d_Builder.cdl
-- Created: Mon Jun 12 13:53:51 1995
-- Author: Philippe DERVIEUX
-- <phd@tlefon>
---Copyright: Matra Datavision 1995
-- Modified: Tue Oct 22 09:23:11 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
-- add new method BuildNewEdge with special flag IsDegenerated (PRO4896)
class Builder from ChFi2d
---Purpose: This class contains the algorithm used to build
-- fillet on planar wire.
uses
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
ConstructionError from ChFi2d,
SequenceOfShape from TopTools,
DataMapOfShapeShape from TopTools,
Pln from gp,
Real from Standard,
Boolean from Standard
is
Create ;
Create ( F : Face );
---Purpose: The face <F> can be build on a closed or an open
-- wire.
Init( me : in out; F : Face );
Init( me : in out; RefFace, ModFace : Face );
AddFillet ( me : in out; V : Vertex; Radius : Real ) returns Edge;
---Purpose: Add a fillet of radius <Radius> on the wire
-- between the two edges connected to the vertex <V>.
-- <AddFillet> returns the fillet edge. The returned
-- edge has sense only if the status <status> is
-- <IsDone>
ModifyFillet ( me : in out; Fillet : Edge; Radius : Real)
returns Edge;
---Purpose: modify the fillet radius and return the new fillet
-- edge. this edge has sense only if the status
-- <status> is <IsDone>.
RemoveFillet( me : in out; Fillet : Edge)
returns Vertex;
---Purpose: removes the fillet <Fillet> and returns the vertex
-- connecting the two adjacent edges to this fillet.
AddChamfer ( me : in out; E1, E2 : Edge; D1, D2 : Real )
returns Edge;
---Purpose: Add a chamfer on the wire between the two edges
-- connected <E1> and <E2>. <AddChamfer> returns the
-- chamfer edge. This edge has sense only if the
-- status <status> is <IsDone>.
AddChamfer ( me : in out; E : Edge; V : Vertex; D, Ang : Real )
returns Edge;
---Purpose: Add a chamfer on the wire between the two edges
-- connected to the vertex <V>. The chamfer will make
-- an angle <Ang> with the edge <E>, and one of its
-- extremities will be on <E> at distance <D>. The
-- returned edge has sense only if the status
-- <status> is <IsDone>.
-- Warning: The value of <Ang> must be expressed in Radian.
ModifyChamfer ( me : in out; Chamfer : Edge;
E1 : Edge; E2 : Edge; D1, D2 : Real)
returns Edge;
---Purpose: modify the chamfer <Chamfer> and returns the new
-- chamfer edge.
-- This edge as sense only if the status <status> is
-- <IsDone>.
ModifyChamfer ( me : in out; Chamfer, E : Edge; D, Ang : Real)
returns Edge;
---Purpose: modify the chamfer <Chamfer> and returns the new
-- chamfer edge. This edge as sense only if the
-- status <status> is <IsDone>.
-- Warning: The value of <Ang> must be expressed in Radian.
RemoveChamfer( me : in out; Chamfer : Edge)
returns Vertex;
---Purpose: removes the chamfer <Chamfer> and returns the
-- vertex connecting the two adjacent edges to this
-- chamfer.
Result( me ) returns Face;
---Purpose: returns the modified face
---C++: inline
IsModified( me; E : Edge ) returns Boolean;
---C++: inline
FilletEdges( me ) returns SequenceOfShape;
---Purpose: returns the list of new edges
---C++: return const &
---C++: inline
NbFillet( me ) returns Integer;
---C++: inline
ChamferEdges( me ) returns SequenceOfShape;
---Purpose: returns the list of new edges
---C++: return const &
---C++: inline
NbChamfer( me ) returns Integer;
---C++: inline
HasDescendant( me; E : Edge) returns Boolean;
---C++: inline
DescendantEdge( me; E : Edge) returns Edge;
---Purpose: returns the modified edge if <E> has descendant or
-- <E> in the other case.
---C++: return const &
---C++: inline
BasisEdge( me; E : Edge) returns Edge;
---Purpose: Returns the parent edge of <E>
-- Warning: If <E>is a basis edge, the returned edge would be
-- equal to <E>
---C++: return const &
Status(me) returns ConstructionError from ChFi2d;
---C++: inline
ComputeFillet ( me : in out; V : Vertex; E1, E2 : Edge; Radius : Real;
TrimE1, TrimE2, Fillet : out Edge)
is private;
---Purpose: Is internaly used by <AddFillet>.
-- Warning: <TrimE1>, <TrimE2>, <Fillet> has sense only if the
-- status <status> is equal to <IsDone>
ComputeChamfer ( me : in out; V : Vertex; E1, E2 : Edge;
D1, D2 : Real;
TrimE1, TrimE2, Chamfer : out Edge)
is private;
---Purpose: Is internaly used by <AddChamfer>. The chamfer is
-- computed from a vertex, two edges and two
-- distances
-- Warning: <TrimE1>, <TrimE2> and <Chamfer> has sense only if
-- if the status <status> is equal to <IsDone>
ComputeChamfer ( me : in out; V : Vertex; E1 : Edge; D, Ang : Real;
E2 : Edge; TrimE1, TrimE2, Chamfer : out Edge)
is private;
---Purpose: Is internaly used by <AddChamfer>. The chamfer is
-- computed from an edge, a vertex, a distance
-- and an angle
-- Warning: <TrimE1>, <TrimE2>, and <Chamfer> has
-- sense only if the status <status> is equal to
-- <IsDone>
BuildFilletEdge(me : in out; V : Vertex; AdjEdge1, AdjEdge2 : Edge;
Radius : Real;
NewExtr1, NewExtr2 : out Vertex)
returns Edge
is private;
---Purpose: Is internaly used by <ComputeFillet>.
-- <NewExtr1> and <NewExtr2> will contains the new
-- extremities of <AdjEdge1> and <AdjEdge2>
-- Warning: The returned edge has sense only if the status
-- <status> is equal to <IsDone>
-- or to one of those specific cases :
-- <FirstEdgeDegenerated>
-- <LastEdgeDegenerated>
-- <BothEdgesDegenerated>
BuildChamferEdge(me : in out; V : Vertex; AdjEdge1, AdjEdge2 : Edge;
D1, D2 : Real;
NewExtr1, NewExtr2 : out Vertex)
returns Edge
is private;
---Purpose: Is internaly used by <ComputeFillet>.
-- <NewExtr1> and <NewExtr2> will contains the new
-- extremities of <AdjEdge1> and <AdjEdge2>
-- Warning: The returned edge has sense only if the status
-- <status> is equal to <IsDone>
BuildChamferEdge(me : in out; V : Vertex; AdjEdge2 : Edge;
D, Ang : Real;
AdjEdge1 : Edge; NewExtr1, NewExtr2 : out Vertex)
returns Edge
is private;
---Purpose: Is internaly used by <ComputeFillet>.
-- <NewExtr1> and <NewExtr2> will contains the new
-- extremities of <AdjEdge1> and <AdjEdge2>
-- Warning: The returned edge has sense only if the status
-- <status> is equal to <IsDone>
BuildNewWire ( me : in out; OldE1, OldE2, E1, Fillet, E2 : Edge)
is private;
---Purpose: replaces in the new face <newFace> <OldE1> and
-- <OldE2> by <E1>, <Fillet> and <E2>
-- or by <Fillet> and <E2> if <E1> is degenerated
-- or by <E1> and <Fillet> if <E2> is degenerated
-- or by <Fillet> if <E1> and <E2> are degenerated .
BuildNewEdge ( me ; E1 : Edge; OldExtr, NewExtr : Vertex)
returns Edge
is private;
---Purpose: Changes <OldExtr> of <E1> by <NewExtr>
BuildNewEdge ( me ; E1 : Edge; OldExtr, NewExtr : Vertex;
IsDegenerated : out Boolean)
returns Edge
is private;
---Purpose: Changes <OldExtr> of <E1> by <NewExtr>
-- returns E1 and IsDegenerated = Standard_True
-- if the new edge is degenerated
UpDateHistory( me : in out; E1, E2, TrimE1, TrimE2, NewEdge : Edge;
Id : Integer)
is private;
---Purpose: Writes <NewEdge> in <fillets> if <Id> is equal to
-- 1, or in <chamfers> if <Id> is Equal to 2.
-- Writes the modifications in <history> :
-- <TrimE1> is given by <E1>, <TrimE2> by <E2>
-- if <TrimE1> and <TrimE2> are not degenerated.
UpDateHistory( me : in out; E1, E2, TrimE1, TrimE2 : Edge)
is private;
---Purpose: Writes the modifications in <history> . <TrimE1>
-- is given by <E1>, <TrimE2> by <E2>.
IsAFillet( me; E : Edge) returns Boolean is private;
IsAChamfer( me; E : Edge) returns Boolean is private;
fields
status : ConstructionError from ChFi2d;
refFace : Face from TopoDS;
newFace : Face from TopoDS;
fillets : SequenceOfShape from TopTools;
chamfers : SequenceOfShape from TopTools;
history : DataMapOfShapeShape from TopTools;
end Builder;

1196
src/ChFi2d/ChFi2d_Builder.cxx Executable file

File diff suppressed because it is too large Load Diff

107
src/ChFi2d/ChFi2d_Builder.lxx Executable file
View File

@@ -0,0 +1,107 @@
// File: ChFi2d_Builder.lxx
// Created: Mon Jun 12 18:14:50 1995
// Author: Philippe DERVIEUX
// <phd@tlefon>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
//=======================================================================
//function : Result
//purpose :
//=======================================================================
inline TopoDS_Face ChFi2d_Builder::Result() const
{
TopoDS_Face aFace = newFace;
aFace.Orientation(refFace.Orientation());
return aFace;
}
//=======================================================================
//function : IsModified
//purpose :
//=======================================================================
inline Standard_Boolean ChFi2d_Builder::IsModified
(const TopoDS_Edge& E) const
{
return history.IsBound(E);
}
//=======================================================================
//function : FilletEdges
//purpose :
//=======================================================================
inline const TopTools_SequenceOfShape& ChFi2d_Builder::FilletEdges() const
{
return fillets;
}
//=======================================================================
//function : ChamferEdges
//purpose :
//=======================================================================
inline const TopTools_SequenceOfShape& ChFi2d_Builder::ChamferEdges() const
{
return chamfers;
}
//=======================================================================
//function : NbFillet
//purpose :
//=======================================================================
inline Standard_Integer ChFi2d_Builder::NbFillet() const
{
return fillets.Length();
}
//=======================================================================
//function : NbChamfer
//purpose :
//=======================================================================
inline Standard_Integer ChFi2d_Builder::NbChamfer() const
{
return chamfers.Length();
}
//=======================================================================
//function : HasDescendant
//purpose :
//=======================================================================
inline Standard_Boolean ChFi2d_Builder::HasDescendant
(const TopoDS_Edge& E) const
{
return history.IsBound(E);
}
//=======================================================================
//function : DescendantEdge
//purpose :
//=======================================================================
inline const TopoDS_Edge& ChFi2d_Builder::DescendantEdge(const TopoDS_Edge& E) const
{
return TopoDS::Edge(history.Find(E));
} // DescendantEdge
//=======================================================================
//function : Status
//purpose :
//=======================================================================
inline ChFi2d_ConstructionError ChFi2d_Builder::Status() const
{
return status;
}

791
src/ChFi2d/ChFi2d_Builder_0.cxx Executable file
View File

@@ -0,0 +1,791 @@
// File: ChFi2d_Builder_1.cxx
// Created: Fri Jul 7 16:43:30 1995
// Author: Philippe DERVIEUX
// <phd@tlefon>
// Modified : 08/07/97 : JPI : traitement des edges degeneres comme pour les fillets 2D
// Modified: Fri Sep 25 09:38:04 1998
// Author: Joelle CHAUVET
// <jct@sgi64>
// status = ChFi2d_NotAuthorized si les aretes ne sont pas
// des droites ou des cercles; fonction IsLineOrCircle
// (BUC60288)
#include <ChFi2d.hxx>
#include <ChFi2d_Builder.ixx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeFace.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <ElCLib.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAPI.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2dInt_GInter.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shape.hxx>
gp_Pnt ComputePoint(const TopoDS_Vertex& V,const TopoDS_Edge& E,
const Standard_Real D1, Standard_Real& Param1);
gp_Pnt ComputePoint(const TopoDS_Face& F, const Handle(Geom_Line)& L,
const TopoDS_Edge& E, Standard_Real& Param);
void OrientChamfer(TopoDS_Edge& chamfer,
const TopoDS_Edge& E,
const TopoDS_Vertex& V);
static Standard_Boolean IsLineOrCircle(const TopoDS_Edge& E,
const TopoDS_Face& F);
//=======================================================================
//function : AddChamfer
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const Standard_Real D1,
const Standard_Real D2)
{
TopoDS_Vertex commonVertex;
TopoDS_Edge basisEdge1, basisEdge2;
TopoDS_Edge E1Mod, E2Mod, chamfer;
Standard_Boolean hasConnection = ChFi2d::CommonVertex(E1, E2, commonVertex);
if (!hasConnection) return chamfer;
if (IsAFillet(E1) || IsAChamfer(E1) ||
IsAFillet(E2) || IsAChamfer(E2)) {
status = ChFi2d_NotAuthorized;
return chamfer;
} // if (IsAChamfer ...
if (!IsLineOrCircle(E1,newFace)
|| !IsLineOrCircle(E2,newFace) ) {
status = ChFi2d_NotAuthorized;
return chamfer;
} // if (!IsLineOrCircle ...
// EE1 and EE2 are copies of E1 and E2 with the good orientation
// on <newFace>
TopoDS_Edge EE1, EE2;
status = ChFi2d::FindConnectedEdges(newFace, commonVertex, EE1, EE2);
if (EE1.IsSame(E2)) {
TopAbs_Orientation orient = EE1.Orientation();
EE1 = EE2;
EE2 = E2;
EE2.Orientation(orient);
}
ComputeChamfer(commonVertex, EE1, EE2, D1, D2,
E1Mod, E2Mod, chamfer);
if (status == ChFi2d_IsDone
|| status == ChFi2d_FirstEdgeDegenerated
|| status == ChFi2d_LastEdgeDegenerated
|| status == ChFi2d_BothEdgesDegenerated) {
// if (status == ChFi2d_IsDone) {
BuildNewWire(EE1, EE2, E1Mod, chamfer, E2Mod);
basisEdge1 = BasisEdge(EE1);
basisEdge2 = BasisEdge(EE2);
UpDateHistory(basisEdge1, basisEdge2,
E1Mod, E2Mod, chamfer, 2);
status = ChFi2d_IsDone;
return TopoDS::Edge(chamfers.Value(chamfers.Length()));
}
return chamfer;
} // AddChamfer
//=======================================================================
//function : AddChamfer
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E,
const TopoDS_Vertex& V,
const Standard_Real D,
const Standard_Real Ang)
{
TopoDS_Edge aChamfer, adjEdge1, adjEdge2;
status = ChFi2d::FindConnectedEdges(newFace, V, adjEdge1, adjEdge2);
if (status == ChFi2d_ConnexionError) return aChamfer;
// adjEdge1 is a copy of E with the good orientation
// on <newFace>
if (adjEdge2.IsSame(E)) {
TopAbs_Orientation orient = adjEdge2.Orientation();
adjEdge2 = adjEdge1;
adjEdge1 = E;
adjEdge1.Orientation(orient);
}
if (IsAFillet(adjEdge1) || IsAChamfer(adjEdge1) ||
IsAFillet(adjEdge2) || IsAChamfer(adjEdge2)) {
status = ChFi2d_NotAuthorized;
return aChamfer;
} // if (IsAChamfer ...
if (!IsLineOrCircle(adjEdge1,newFace)
|| !IsLineOrCircle(adjEdge1,newFace) ) {
status = ChFi2d_NotAuthorized;
return aChamfer;
} // if (!IsLineOrCircle ...
TopoDS_Edge E1, E2;
ComputeChamfer(V, adjEdge1, D, Ang,
adjEdge2, E1, E2, aChamfer);
TopoDS_Edge basisEdge1, basisEdge2;
if (status == ChFi2d_IsDone
|| status == ChFi2d_FirstEdgeDegenerated
|| status == ChFi2d_LastEdgeDegenerated
|| status == ChFi2d_BothEdgesDegenerated) {
// if (status == ChFi2d_IsDone) {
BuildNewWire(adjEdge1, adjEdge2, E1, aChamfer, E2);
basisEdge1 = BasisEdge(adjEdge1);
basisEdge2 = BasisEdge(adjEdge2);
UpDateHistory(basisEdge1, basisEdge2,
E1, E2, aChamfer, 2);
status = ChFi2d_IsDone;
return TopoDS::Edge(chamfers.Value(chamfers.Length()));
}
return aChamfer;
}
//=======================================================================
//function : ComputeChamfer
//purpose :
//=======================================================================
void ChFi2d_Builder::ComputeChamfer(const TopoDS_Vertex& V,
const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const Standard_Real D1,
const Standard_Real D2,
TopoDS_Edge& TrimE1,
TopoDS_Edge& TrimE2,
TopoDS_Edge& Chamfer)
{
TopoDS_Vertex newExtr1, newExtr2;
Standard_Boolean Degen1, Degen2;
Chamfer = BuildChamferEdge(V, E1, E2, D1, D2, newExtr1, newExtr2);
if ( status != ChFi2d_IsDone) return;
TrimE1 = BuildNewEdge(E1, V, newExtr1, Degen1);
TrimE2 = BuildNewEdge(E2, V, newExtr2, Degen2);
if (Degen1 && Degen2 ) status = ChFi2d_BothEdgesDegenerated;
if (Degen1 && !Degen2 ) status = ChFi2d_FirstEdgeDegenerated;
if (!Degen1 && Degen2 ) status = ChFi2d_LastEdgeDegenerated;
// TrimE1 = BuildNewEdge(E1, V, newExtr1);
// TrimE2 = BuildNewEdge(E2, V, newExtr2);
} // ComputeChamfer
//=======================================================================
//function : ComputeChamfer
//purpose :
//=======================================================================
void ChFi2d_Builder::ComputeChamfer(const TopoDS_Vertex& V,
const TopoDS_Edge& E1,
const Standard_Real D,
const Standard_Real Ang,
const TopoDS_Edge& E2,
TopoDS_Edge& TrimE1,
TopoDS_Edge& TrimE2,
TopoDS_Edge& Chamfer)
{
TopoDS_Vertex newExtr1, newExtr2;
Standard_Boolean Degen1, Degen2;
Chamfer = BuildChamferEdge(V, E1, D, Ang, E2, newExtr1, newExtr2);
if ( status != ChFi2d_IsDone) return;
TrimE1 = BuildNewEdge(E1, V, newExtr1, Degen1);
TrimE2 = BuildNewEdge(E2, V, newExtr2, Degen2);
if (Degen1 && Degen2 ) status = ChFi2d_BothEdgesDegenerated;
if (Degen1 && !Degen2 ) status = ChFi2d_FirstEdgeDegenerated;
if (!Degen1 && Degen2 ) status = ChFi2d_LastEdgeDegenerated;
// TrimE1 = BuildNewEdge(E1, V, newExtr1);
// TrimE2 = BuildNewEdge(E2, V, newExtr2);
} // ComputeChamfer
//=======================================================================
//function : ModifyFillet
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::ModifyChamfer(const TopoDS_Edge& Chamfer,
const TopoDS_Edge& E1,
const TopoDS_Edge& E2,
const Standard_Real D1,
const Standard_Real D2)
{
TopoDS_Vertex aVertex = RemoveChamfer(Chamfer);
TopoDS_Edge adjEdge1, adjEdge2;
status = ChFi2d::FindConnectedEdges(newFace, aVertex, adjEdge1, adjEdge2);
TopoDS_Edge aChamfer;
if (status == ChFi2d_ConnexionError) return aChamfer;
// adjEdge1 and adjEdge2 are copies of E1 and E2 with the good orientation
// on <newFace>
if (adjEdge1.IsSame(E2)) {
TopAbs_Orientation orient = adjEdge1.Orientation();
adjEdge1 = adjEdge2;
adjEdge2 = E2;
adjEdge2.Orientation(orient);
}
aChamfer = AddChamfer(adjEdge1, adjEdge2, D1, D2);
return aChamfer;
} // ModifyChamfer
//=======================================================================
//function : ModifyFillet
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::ModifyChamfer(const TopoDS_Edge& Chamfer,
const TopoDS_Edge& E,
const Standard_Real D,
const Standard_Real Ang)
{
TopoDS_Vertex aVertex = RemoveChamfer(Chamfer);
TopoDS_Edge adjEdge1, adjEdge2;
status = ChFi2d::FindConnectedEdges(newFace, aVertex, adjEdge1, adjEdge2);
TopoDS_Edge aChamfer;
if (status == ChFi2d_ConnexionError) return aChamfer;
if (adjEdge1.IsSame(E))
aChamfer = AddChamfer(adjEdge1, aVertex, D, Ang);
else aChamfer = AddChamfer(adjEdge2, aVertex, D, Ang);
return aChamfer;
} // ModifyChamfer
//=======================================================================
//function : RemoveChamfer
//purpose :
//=======================================================================
TopoDS_Vertex ChFi2d_Builder::RemoveChamfer(const TopoDS_Edge& Chamfer)
{
TopoDS_Vertex commonVertex;
Standard_Integer i = 1;
Standard_Integer IsFind = Standard_False;
while (i <= chamfers.Length()) {
const TopoDS_Edge& aChamfer = TopoDS::Edge(chamfers.Value(i));
if (aChamfer.IsSame(Chamfer)) {
chamfers.Remove(i);
IsFind = Standard_True;
break;
}
i++;
}
if (!IsFind) return commonVertex;
TopoDS_Vertex firstVertex, lastVertex;
TopExp::Vertices(Chamfer, firstVertex, lastVertex);
TopoDS_Edge adjEdge1, adjEdge2;
status = ChFi2d::FindConnectedEdges(newFace, firstVertex,
adjEdge1, adjEdge2);
if (status == ChFi2d_ConnexionError) return commonVertex;
TopoDS_Edge basisEdge1, basisEdge2, E1, E2;
// E1 and E2 are the adjacentes edges to Chamfer
if (adjEdge1.IsSame(Chamfer)) E1 = adjEdge2;
else E1 = adjEdge1;
basisEdge1 = BasisEdge(E1);
status = ChFi2d::FindConnectedEdges(newFace, lastVertex,adjEdge1, adjEdge2);
if (status == ChFi2d_ConnexionError) return commonVertex;
if (adjEdge1.IsSame(Chamfer)) E2 = adjEdge2;
else E2 = adjEdge1;
basisEdge2 = BasisEdge(E2);
TopoDS_Vertex connectionE1Chamfer, connectionE2Chamfer;
Standard_Boolean hasConnection =
ChFi2d::CommonVertex(basisEdge1, basisEdge2, commonVertex);
if (!hasConnection) {
status = ChFi2d_ConnexionError;
return commonVertex;
}
hasConnection = ChFi2d::CommonVertex(E1, Chamfer, connectionE1Chamfer);
if (!hasConnection) {
status = ChFi2d_ConnexionError;
return commonVertex;
}
hasConnection = ChFi2d::CommonVertex(E2, Chamfer, connectionE2Chamfer);
if (!hasConnection) {
status = ChFi2d_ConnexionError;
return commonVertex;
}
// rebuild edges on wire
TopoDS_Edge newEdge1, newEdge2;
TopoDS_Vertex v, v1, v2;
BRepLib_MakeEdge makeEdge;
TopLoc_Location loc;
Standard_Real first, last;
TopExp::Vertices(E1, firstVertex, lastVertex);
TopExp::Vertices(basisEdge1, v1, v2);
if (v1.IsSame(commonVertex)) v = v2;
else v = v1;
if ( firstVertex.IsSame(v) || lastVertex.IsSame(v))
// It means the edge support only one fillet. In this case
// the new edge must be the basis edge.
newEdge1 = basisEdge1;
else {
// It means the edge support one fillet on each end.
if (firstVertex.IsSame(connectionE1Chamfer)) {
// syntaxe invalide sur NT
// const Handle(Geom_Curve)& curve =
// BRep_Tool::Curve(E1, loc, first, last);
Handle(Geom_Curve) curve = BRep_Tool::Curve(E1, loc, first, last);
makeEdge.Init(curve, commonVertex, lastVertex);
newEdge1 = makeEdge.Edge();
newEdge1.Orientation(basisEdge1.Orientation());
newEdge1.Location(basisEdge1.Location());
} // if (firstVertex ...
else if (lastVertex.IsSame(connectionE1Chamfer)) {
// syntaxe invalide sur NT
// const Handle(Geom_Curve)& curve =
// BRep_Tool::Curve(E1, loc, first, last);
Handle(Geom_Curve) curve = BRep_Tool::Curve(E1, loc, first, last);
makeEdge.Init(curve, firstVertex, commonVertex);
newEdge1 = makeEdge.Edge();
newEdge1.Orientation(basisEdge1.Orientation());
newEdge1.Location(basisEdge1.Location());
} // else if (lastVertex ...
} // else ...
TopExp::Vertices(basisEdge2, v1, v2);
if (v1.IsSame(commonVertex)) v = v2;
else v = v1;
TopExp::Vertices(E2, firstVertex, lastVertex);
if ( firstVertex.IsSame(v) || lastVertex.IsSame(v))
// It means the edge support only one fillet. In this case
// the new edge must be the basis edge.
newEdge2 = basisEdge2;
else {
// It means the edge support one fillet on each end.
if (firstVertex.IsSame(connectionE2Chamfer)) {
// syntaxe invalide sur NT
// const Handle(Geom_Curve)& curve =
// BRep_Tool::Curve(E2, loc, first, last);
Handle(Geom_Curve) curve = BRep_Tool::Curve(E2, loc, first, last);
makeEdge.Init(curve, commonVertex, lastVertex);
newEdge2 = makeEdge.Edge();
newEdge2.Orientation(basisEdge2.Orientation());
newEdge2.Location(basisEdge2.Location());
} // if (firstVertex ...
else if (lastVertex.IsSame(connectionE2Chamfer)) {
// syntaxe invalide sur NT
// const Handle(Geom_Curve)& curve =
// BRep_Tool::Curve(E2, loc, first, last);
Handle(Geom_Curve) curve = BRep_Tool::Curve(E2, loc, first, last);
makeEdge.Init(curve, firstVertex, commonVertex);
newEdge2 = makeEdge.Edge();
newEdge2.Orientation(basisEdge2.Orientation());
newEdge2.Location(basisEdge2.Location());
} // else if (lastVertex ...
} // else ...
// rebuild the newFace
TopExp_Explorer Ex(newFace, TopAbs_EDGE);
TopoDS_Wire newWire;
BRep_Builder B;
B.MakeWire(newWire);
while (Ex.More()) {
const TopoDS_Edge& theEdge = TopoDS::Edge(Ex.Current());
if (!theEdge.IsSame(E1) &&
!theEdge.IsSame(E2) &&
!theEdge.IsSame(Chamfer) )
B.Add(newWire, theEdge);
else {
if (theEdge == E1)
B.Add(newWire, newEdge1);
else if (theEdge == E2)
B.Add(newWire, newEdge2);
} // else
Ex.Next();
} // while ...
BRepAdaptor_Surface Adaptor3dSurface(refFace);
BRepLib_MakeFace mFace(Adaptor3dSurface.Plane(), newWire);
newFace.Nullify();
newFace = mFace;
UpDateHistory(basisEdge1, basisEdge2, newEdge1, newEdge2);
return commonVertex;
} // RemoveChamfer
//=======================================================================
//function : BuildChamferEdge
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::BuildChamferEdge(const TopoDS_Vertex& V,
const TopoDS_Edge& AdjEdge1,
const TopoDS_Edge& AdjEdge2,
const Standard_Real D1,
const Standard_Real D2,
TopoDS_Vertex& NewExtr1,
TopoDS_Vertex& NewExtr2)
{
TopoDS_Edge chamfer;
if ( D1 <= 0 || D2 <= 0) {
status = ChFi2d_ParametersError;
return chamfer;
} // if ( D1 <=0 ...
Standard_Real param1, param2;
gp_Pnt p1 = ComputePoint(V, AdjEdge1, D1, param1);
gp_Pnt p2 = ComputePoint(V, AdjEdge2, D2, param2);
Standard_Real tol = Precision::Confusion();
BRep_Builder B;
B.MakeVertex(NewExtr1, p1, tol);
B.MakeVertex(NewExtr2, p2, tol);
NewExtr1.Orientation(TopAbs_FORWARD);
NewExtr2.Orientation(TopAbs_REVERSED);
// chamfer edge construction
TopLoc_Location loc;
const Handle(Geom_Surface) refSurf = BRep_Tool::Surface(refFace, loc);
gp_Vec myVec( p1, p2);
gp_Dir myDir(myVec);
Handle(Geom_Line) newLine = new Geom_Line( p1, myDir);
Standard_Real param = ElCLib::Parameter(newLine->Lin(), p2);
B.MakeEdge(chamfer, newLine, tol);
B.Range(chamfer,0., param);
B.Add(chamfer, NewExtr1);
B.UpdateVertex(NewExtr1,0., chamfer, tol);
B.Add(chamfer, NewExtr2);
B.UpdateVertex(NewExtr2,param, chamfer, tol);
OrientChamfer(chamfer, AdjEdge1, V);
// set the orientation of NewExtr1 and NewExtr2 for the adjacent edges
TopoDS_Vertex V1 = TopExp::FirstVertex(AdjEdge1);
TopoDS_Vertex V2 = TopExp::LastVertex(AdjEdge1);
if (V1.IsSame(V)) NewExtr1.Orientation(V1.Orientation());
else NewExtr1.Orientation(V2.Orientation());
V1 = TopExp::FirstVertex(AdjEdge2);
V2 = TopExp::LastVertex(AdjEdge2);
if (V1.IsSame(V)) NewExtr2.Orientation(V1.Orientation());
else NewExtr2.Orientation(V2.Orientation());
B.UpdateVertex(NewExtr1, param1, AdjEdge1, tol);
B.UpdateVertex(NewExtr2, param2, AdjEdge2, tol);
status = ChFi2d_IsDone;
return chamfer;
} // BuildChamferEdge
//=======================================================================
//function : BuildFilletEdge
//purpose :
//=======================================================================
TopoDS_Edge ChFi2d_Builder::BuildChamferEdge(const TopoDS_Vertex& V,
const TopoDS_Edge& AdjEdge1,
const Standard_Real D,
const Standard_Real Ang,
const TopoDS_Edge& AdjEdge2,
TopoDS_Vertex& NewExtr1,
TopoDS_Vertex& NewExtr2)
{
TopoDS_Edge chamfer;
if ( D <= 0 || Ang <= 0) {
status = ChFi2d_ParametersError;
return chamfer;
} // if ( D <= 0 ...
Standard_Real param1, param2;
gp_Pnt p1 = ComputePoint(V, AdjEdge1, D, param1);
gp_Pnt p = BRep_Tool::Pnt(V);
gp_Vec myVec( p1, p);
// compute the tangent vector on AdjEdge2 at the vertex V.
BRepAdaptor_Curve c(AdjEdge2, refFace);
Standard_Real first, last;
first = c.FirstParameter();
last = c.LastParameter();
gp_Pnt aPoint;
gp_Vec tan;
c.D1(first, aPoint, tan);
if (aPoint.Distance(p) > Precision::Confusion()) {
c.D1(last, aPoint, tan);
}
// tangent orientation
TopoDS_Vertex v1, v2;
TopExp::Vertices(AdjEdge2, v1, v2);
TopAbs_Orientation orient;
if (v1.IsSame(V)) orient = v1.Orientation();
else orient = v2.Orientation();
if (orient == TopAbs_REVERSED) tan *= -1;
// compute the chamfer geometric support
gp_Ax1 RotAxe(p1, tan^myVec);
gp_Vec vecLin = myVec.Rotated(RotAxe, -Ang);
gp_Dir myDir(vecLin);
Handle(Geom_Line) newLine = new Geom_Line( p1, myDir);
BRep_Builder B1;
B1.MakeEdge(chamfer, newLine, Precision::Confusion());
gp_Pnt p2 = ComputePoint(refFace, newLine, AdjEdge2, param2);
Standard_Real tol = Precision::Confusion();
BRep_Builder B;
B.MakeVertex(NewExtr1, p1, tol);
B.MakeVertex(NewExtr2, p2, tol);
NewExtr1.Orientation(TopAbs_FORWARD);
NewExtr2.Orientation(TopAbs_REVERSED);
// chamfer edge construction
Standard_Real param = ElCLib::Parameter(newLine->Lin(), p2);
B.MakeEdge(chamfer, newLine, tol);
B.Range(chamfer,0., param);
B.Add(chamfer, NewExtr1);
B.UpdateVertex(NewExtr1,0., chamfer, tol);
B.Add(chamfer, NewExtr2);
B.UpdateVertex(NewExtr2,param, chamfer, tol);
OrientChamfer(chamfer, AdjEdge1, V);
// set the orientation of NewExtr1 and NewExtr2 for the adjacent edges
TopoDS_Vertex V1 = TopExp::FirstVertex(AdjEdge1);
TopoDS_Vertex V2 = TopExp::LastVertex(AdjEdge1);
if (V1.IsSame(V)) NewExtr1.Orientation(V1.Orientation());
else NewExtr1.Orientation(V2.Orientation());
V1 = TopExp::FirstVertex(AdjEdge2);
V2 = TopExp::LastVertex(AdjEdge2);
if (V1.IsSame(V)) NewExtr2.Orientation(V1.Orientation());
else NewExtr2.Orientation(V2.Orientation());
B.UpdateVertex(NewExtr1, param1, AdjEdge1, tol);
B.UpdateVertex(NewExtr2, param2, AdjEdge2, tol);
status = ChFi2d_IsDone;
return chamfer;
}
//=======================================================================
//function : ComputePoint
//purpose :
//=======================================================================
gp_Pnt ComputePoint(const TopoDS_Vertex& V,const TopoDS_Edge& E,
const Standard_Real D, Standard_Real& Param)
{
// geometric support
BRepAdaptor_Curve c(E);
Standard_Real first, last;
first = c.FirstParameter();
last = c.LastParameter();
gp_Pnt thePoint;
if (c.GetType() == GeomAbs_Line) {
gp_Pnt p1, p2;
TopoDS_Vertex v1, v2;
TopExp::Vertices(E, v1, v2);
p1 = BRep_Tool::Pnt(v1);
p2 = BRep_Tool::Pnt(v2);
gp_Vec myVec( p1, p2);
myVec.Normalize();
myVec *= D;
if (v2.IsSame(V)) {
myVec *= -1; // change the sense of myVec
thePoint = p2.Translated(myVec);
} // if (v2 ...
else thePoint = p1.Translated(myVec);
Param = ElCLib::Parameter(c.Line(), thePoint);
//szv:OCC20823-begin
c.D0(Param, thePoint);
//szv:OCC20823-end
return thePoint;
} // if (C->IsKind(TYPE ...
if (c.GetType() == GeomAbs_Circle) {
gp_Circ cir = c.Circle();
Standard_Real radius = cir.Radius();
TopoDS_Vertex v1, v2;
TopExp::Vertices(E, v1, v2);
Standard_Real param1,param2;
if (V.IsSame(v1)) {
param1 = BRep_Tool::Parameter(v1,E);
param2 = BRep_Tool::Parameter(v2,E);
}
else {
param1 = BRep_Tool::Parameter(v2,E);
param2 = BRep_Tool::Parameter(v1,E);
}
Standard_Real deltaAlpha = D/radius;
if (param1 > param2) Param = param1 - deltaAlpha;
else Param = param1 + deltaAlpha;
c.D0(Param, thePoint);
return thePoint;
} // if (C->IsKind(TYPE ...
else {
// in all other case than lines and circles.
gp_Pnt p;
TopoDS_Vertex v1, v2;
TopExp::Vertices(E, v1, v2);
if (V.IsSame(v1)) {
p = BRep_Tool::Pnt(v1);
}
else {
p = BRep_Tool::Pnt(v2);
}
GeomAdaptor_Curve cc = c.Curve();
if (p.Distance(c.Value(first)) <= Precision::Confusion()) {
GCPnts_AbscissaPoint computePoint(cc, D, first);
Param = computePoint.Parameter();
}
else {
GCPnts_AbscissaPoint computePoint(cc, D, last);
Param = computePoint.Parameter();
}
thePoint = cc.Value(Param);
return thePoint;
} // else ...
return thePoint;
} // ComputePoint
//=======================================================================
//function : ComputePoint
//purpose :
//=======================================================================
gp_Pnt ComputePoint(const TopoDS_Face& F,
const Handle(Geom_Line)& L,
const TopoDS_Edge& E,
Standard_Real& Param)
{
BRepAdaptor_Surface Adaptor3dSurface(F);
Handle(Geom_Plane) refSurf = new Geom_Plane(Adaptor3dSurface.Plane());
Handle(Geom2d_Curve) lin2d = GeomAPI::To2d(L, refSurf->Pln());
Handle(Geom2d_Curve) c2d;
Standard_Real first, last;
c2d = BRep_Tool::CurveOnSurface(E, F, first, last);
Geom2dAdaptor_Curve adaptorL(lin2d);
Geom2dAdaptor_Curve adaptorC(c2d);
Geom2dInt_GInter Intersection(adaptorL, adaptorC,
Precision::PIntersection(),
Precision::PIntersection());
Standard_Real paramOnLine = 1E300;
gp_Pnt2d p2d;
if (Intersection.IsDone()) {
Standard_Integer i = 1;
while ( i <= Intersection.NbPoints()) {
IntRes2d_IntersectionPoint iP = Intersection.Point(i);
if (iP.ParamOnFirst() < paramOnLine) {
p2d = iP.Value();
paramOnLine = iP.ParamOnFirst();
Param = iP.ParamOnSecond();
} // if (iP.ParamOnFirst ...
i++;
} // while ( i <= ...
} // if (Intersection.IsDone ...
gp_Pnt thePoint = Adaptor3dSurface.Value(p2d.X(), p2d.Y());
return thePoint;
} // ComputePoint
//=======================================================================
//function : OrientChamfer
//purpose :
//=======================================================================
void OrientChamfer(TopoDS_Edge& chamfer,
const TopoDS_Edge& E,
const TopoDS_Vertex& V)
{
TopAbs_Orientation vOrient, orient = E.Orientation();
TopoDS_Vertex v1, v2;
TopExp::Vertices(E, v1, v2);
if (v1.IsSame(V)) vOrient = v2.Orientation();
else vOrient = v1.Orientation();
if ((orient == TopAbs_FORWARD && vOrient == TopAbs_FORWARD) ||
(orient == TopAbs_REVERSED && vOrient == TopAbs_REVERSED))
chamfer.Orientation(TopAbs_FORWARD);
else chamfer.Orientation(TopAbs_REVERSED);
} // OrientChamfer
//=======================================================================
//function : IsLineOrCircle
//purpose :
//=======================================================================
Standard_Boolean IsLineOrCircle(const TopoDS_Edge& E,
const TopoDS_Face& F)
{
Standard_Real first, last;
TopLoc_Location loc;
// syntaxe invalide sur NT
// const Handle(Geom2d_Curve)& C =
// BRep_Tool::CurveOnSurface(E,F,first,last);
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,first,last);
Handle(Geom2d_Curve) basisC;
Handle(Geom2d_TrimmedCurve) TC = Handle(Geom2d_TrimmedCurve)::DownCast(C);
if (!TC.IsNull())
basisC = Handle(Geom2d_Curve)::DownCast(TC->BasisCurve());
else
basisC = Handle(Geom2d_Curve)::DownCast(C);
if ( basisC->DynamicType() == STANDARD_TYPE(Geom2d_Circle)
|| basisC->DynamicType() == STANDARD_TYPE(Geom2d_Line) ) {
return Standard_True;
}
else {
return Standard_False;
} // else ...
} // IsLineOrCircle

1
src/ChFi2d/FILES Executable file
View File

@@ -0,0 +1 @@
ChFi2d_Builder_0.cxx