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

Integration of OCCT 6.5.0 from SVN

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

81
src/Draft/Draft.cdl Executable file
View File

@@ -0,0 +1,81 @@
-- File: Draft.cdl
-- Created: Wed Aug 31 14:37:14 1994
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1994
package Draft
uses BRepTools,
TopoDS,
TopTools,
TopLoc,
TopAbs,
GeomAbs,
Geom,
Geom2d,
gp,
TColStd,
StdFail,
TCollection
is
class Modification; --- inherits Modification from BRepTools
class FaceInfo;
class EdgeInfo;
class VertexInfo;
enumeration ErrorStatus is
NoError,
FaceRecomputation,
EdgeRecomputation,
VertexRecomputation
end ErrorStatus;
class DataMapOfFaceFaceInfo instantiates
DataMap from TCollection(Face from TopoDS,
FaceInfo from Draft,
ShapeMapHasher from TopTools);
class DataMapOfEdgeEdgeInfo instantiates
DataMap from TCollection(Edge from TopoDS,
EdgeInfo from Draft,
ShapeMapHasher from TopTools);
class DataMapOfVertexVertexInfo instantiates
DataMap from TCollection(Vertex from TopoDS,
VertexInfo from Draft,
ShapeMapHasher from TopTools);
Angle(F: Face from TopoDS; Direction: Dir from gp)
returns Real from Standard
raises DomainError from Standard;
---Purpose: Returns the draft angle of the face <F> using the
-- direction <Direction>. The method is valid for :
-- - Plane faces,
-- - Cylindrical or conical faces, when the direction
-- of the axis of the surface is colinear with the
-- direction.
-- Otherwise, the exception DomainError is raised.
end Draft;

85
src/Draft/Draft.cxx Executable file
View File

@@ -0,0 +1,85 @@
// File: Draft.cxx
// Created: Mon Feb 20 17:29:07 1995
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <Draft.ixx>
#include <Geom_Surface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_Plane.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <ElSLib.hxx>
#include <Precision.hxx>
#include <Standard_DomainError.hxx>
//=======================================================================
//function : Angle
//purpose :
//=======================================================================
Standard_Real Draft::Angle(const TopoDS_Face& F,
const gp_Dir& D)
{
TopLoc_Location Lo;
Handle(Geom_Surface) S = BRep_Tool::Surface(F,Lo);
Handle(Standard_Type) TypeS = S->DynamicType();
if (TypeS == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
TypeS = S->DynamicType();
}
if (TypeS != STANDARD_TYPE(Geom_Plane) &&
TypeS != STANDARD_TYPE(Geom_ConicalSurface) &&
TypeS != STANDARD_TYPE(Geom_CylindricalSurface)) {
Standard_DomainError::Raise();
}
Standard_Real Angle;
S = Handle(Geom_Surface)::DownCast(S->Transformed(Lo.Transformation()));
if (TypeS == STANDARD_TYPE(Geom_Plane)) {
gp_Ax3 ax3(Handle(Geom_Plane)::DownCast(S)->Pln().Position());
gp_Vec normale(ax3.Direction());
if (!ax3.Direct()) {
normale.Reverse();
}
if (F.Orientation() == TopAbs_REVERSED) {
normale.Reverse();
}
Angle = ASin(normale.Dot(D));
}
else if (TypeS == STANDARD_TYPE(Geom_CylindricalSurface)) {
gp_Cylinder Cy(Handle(Geom_CylindricalSurface)::DownCast(S)->Cylinder());
Standard_Real testdir = D.Dot(Cy.Axis().Direction());
if (Abs(testdir) <= 1.-Precision::Angular()) {
Standard_DomainError::Raise();
}
Angle = 0.;
}
else { // STANDARD_TYPE(Geom_ConicalSurface)
gp_Cone Co(Handle(Geom_ConicalSurface)::DownCast(S)->Cone());
Standard_Real testdir = D.Dot(Co.Axis().Direction());
if (Abs(testdir) <= 1.-Precision::Angular()) {
Standard_DomainError::Raise();
}
Standard_Real umin,umax,vmin,vmax;
BRepTools::UVBounds(F,umin,umax,vmin,vmax);
gp_Pnt ptbid;
gp_Vec d1u,d1v;
ElSLib::D1(umin+umax/2.,vmin+vmax/2.,Co,ptbid,d1u,d1v);
d1u.Cross(d1v);
d1u.Normalize();
if (F.Orientation() == TopAbs_REVERSED) {
d1u.Reverse();
}
Angle = ASin(d1u.Dot(D));
}
return Angle;
}

149
src/Draft/Draft_EdgeInfo.cdl Executable file
View File

@@ -0,0 +1,149 @@
-- File: Draft_EdgeInfo.cdl
-- Created: Wed Aug 31 15:57:34 1994
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1994
class EdgeInfo from Draft
---Purpose:
uses Curve from Geom,
Curve from Geom2d,
Pnt from gp,
Face from TopoDS
raises DomainError from Standard
is
Create
returns EdgeInfo from Draft;
Create(HasNewGeometry: Boolean from Standard)
returns EdgeInfo from Draft;
Add(me: in out; F: Face from TopoDS)
is static;
RootFace(me: in out; F: Face from TopoDS)
is static;
Tangent(me: in out; P: Pnt from gp)
is static;
IsTangent(me; P: out Pnt from gp)
returns Boolean from Standard
is static;
NewGeometry(me)
returns Boolean from Standard
is static;
SetNewGeometry(me: in out; NewGeom : Boolean from Standard)
is static;
Geometry(me)
returns Curve from Geom
is static;
---C++: return const&
FirstFace(me)
returns Face from TopoDS
is static;
---C++: return const&
SecondFace(me)
returns Face from TopoDS
is static;
---C++: return const&
FirstPC(me)
returns Curve from Geom2d
is static;
---C++: return const&
SecondPC(me)
returns Curve from Geom2d
is static;
---C++: return const&
ChangeGeometry(me: in out)
returns Curve from Geom
is static;
---C++: return &
ChangeFirstPC(me: in out)
returns Curve from Geom2d
is static;
---C++: return &
ChangeSecondPC(me: in out)
returns Curve from Geom2d
is static;
---C++: return &
RootFace(me)
---C++: return const&
returns Face from TopoDS
is static;
Tolerance(me: in out; tol: Real from Standard)
is static;
Tolerance(me)
returns Real from Standard
is static;
fields
myNewGeom : Boolean from Standard;
myGeom : Curve from Geom;
myFirstF : Face from TopoDS;
mySeconF : Face from TopoDS;
myFirstPC : Curve from Geom2d;
mySeconPC : Curve from Geom2d;
myRootFace: Face from TopoDS;
myTgt : Boolean from Standard;
myPt : Pnt from gp;
myTol : Real from Standard;
end EdgeInfo;

213
src/Draft/Draft_EdgeInfo.cxx Executable file
View File

@@ -0,0 +1,213 @@
// File: Draft_EdgeInfo.cxx
// Created: Wed Aug 31 16:36:09 1994
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <Draft_EdgeInfo.ixx>
#include <Standard_DomainError.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
//function : Draft_EdgeInfo
//purpose :
//=======================================================================
Draft_EdgeInfo::Draft_EdgeInfo():
myNewGeom(Standard_False),myTgt(Standard_False),myTol(0)
{}
//=======================================================================
//function : Draft_EdgeInfo
//purpose :
//=======================================================================
Draft_EdgeInfo::Draft_EdgeInfo(const Standard_Boolean HasNewGeometry):
myNewGeom(HasNewGeometry),myTgt(Standard_False),myTol(0)
{}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Draft_EdgeInfo::Add(const TopoDS_Face& F)
{
if (myFirstF.IsNull()) {
myFirstF = F;
}
else if (!myFirstF.IsSame(F) && mySeconF.IsNull()) {
mySeconF = F;
}
myTol=Max(myTol, BRep_Tool::Tolerance(F));
}
//=======================================================================
//function : RootFace
//purpose :
//=======================================================================
void Draft_EdgeInfo::RootFace(const TopoDS_Face& F)
{
myRootFace = F;
}
//=======================================================================
//function : Tangent
//purpose :
//=======================================================================
void Draft_EdgeInfo::Tangent(const gp_Pnt& P)
{
myTgt = Standard_True;
myPt = P;
}
//=======================================================================
//function : IsTangent
//purpose :
//=======================================================================
Standard_Boolean Draft_EdgeInfo::IsTangent(gp_Pnt& P) const
{
P = myPt;
return myTgt;
}
//=======================================================================
//function : NewGeometry
//purpose :
//=======================================================================
Standard_Boolean Draft_EdgeInfo::NewGeometry() const
{
return myNewGeom;
}
//=======================================================================
//function : SetNewGeometry
//purpose :
//=======================================================================
void Draft_EdgeInfo::SetNewGeometry( const Standard_Boolean NewGeom )
{
myNewGeom = NewGeom;
}
//=======================================================================
//function : Geometry
//purpose :
//=======================================================================
const Handle(Geom_Curve)& Draft_EdgeInfo::Geometry() const
{
return myGeom;
}
//=======================================================================
//function : FirstFace
//purpose :
//=======================================================================
const TopoDS_Face& Draft_EdgeInfo::FirstFace () const
{
return myFirstF;
}
//=======================================================================
//function : SecondFace
//purpose :
//=======================================================================
const TopoDS_Face& Draft_EdgeInfo::SecondFace () const
{
return mySeconF;
}
//=======================================================================
//function : ChangeGeometry
//purpose :
//=======================================================================
Handle(Geom_Curve)& Draft_EdgeInfo::ChangeGeometry()
{
return myGeom;
}
//=======================================================================
//function : Handle_Geom2d_Curve&
//purpose :
//=======================================================================
const Handle(Geom2d_Curve)& Draft_EdgeInfo::FirstPC() const
{
return myFirstPC;
}
//=======================================================================
//function : Handle_Geom2d_Curve&
//purpose :
//=======================================================================
const Handle(Geom2d_Curve)& Draft_EdgeInfo::SecondPC() const
{
return mySeconPC;
}
//=======================================================================
//function : ChangeFirstPC
//purpose :
//=======================================================================
Handle(Geom2d_Curve)& Draft_EdgeInfo::ChangeFirstPC()
{
return myFirstPC;
}
//=======================================================================
//function : ChangeSecondPC
//purpose :
//=======================================================================
Handle(Geom2d_Curve)& Draft_EdgeInfo::ChangeSecondPC()
{
return mySeconPC;
}
//=======================================================================
//function : RootFace
//purpose :
//=======================================================================
const TopoDS_Face & Draft_EdgeInfo::RootFace() const
{
return myRootFace;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
void Draft_EdgeInfo::Tolerance(const Standard_Real tol)
{
myTol=tol;
}
Standard_Real Draft_EdgeInfo::Tolerance() const
{
return myTol;
}

102
src/Draft/Draft_FaceInfo.cdl Executable file
View File

@@ -0,0 +1,102 @@
-- File: Draft_FaceInfo.cdl
-- Created: Wed Aug 31 14:53:45 1994
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1994
class FaceInfo from Draft
---Purpose:
uses Surface from Geom,
Curve from Geom,
Face from TopoDS
raises DomainError from Standard
is
Create
returns FaceInfo from Draft;
Create(S: Surface from Geom; HasNewGeometry: Boolean from Standard)
returns FaceInfo from Draft;
RootFace(me: in out; F: Face from TopoDS)
is static;
NewGeometry(me)
returns Boolean from Standard
is static;
Add(me: in out; F: Face from TopoDS)
is static;
FirstFace(me)
returns Face from TopoDS
---C++: return const&
is static;
SecondFace(me)
returns Face from TopoDS
---C++: return const&
is static;
Geometry(me)
returns Surface from Geom
is static;
---C++: return const&
ChangeGeometry(me: in out)
returns Surface from Geom
is static;
---C++: return &
RootFace(me)
---C++: return const&
returns Face from TopoDS
is static;
ChangeCurve(me: in out)
returns Curve from Geom
---C++: return &
is static;
Curve(me)
returns Curve from Geom
---C++: return const&
is static;
fields
myNewGeom : Boolean from Standard;
myGeom : Surface from Geom;
myRootFace: Face from TopoDS;
myF1 : Face from TopoDS;
myF2 : Face from TopoDS;
myCurv : Curve from Geom;
end FaceInfo;

145
src/Draft/Draft_FaceInfo.cxx Executable file
View File

@@ -0,0 +1,145 @@
// File: Draft_FaceInfo.cxx
// Created: Wed Aug 31 15:30:06 1994
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <Draft_FaceInfo.ixx>
#include <Geom_RectangularTrimmedSurface.hxx>
//=======================================================================
//function : Draft_FaceInfo
//purpose :
//=======================================================================
Draft_FaceInfo::Draft_FaceInfo ()
{
}
//=======================================================================
//function : Draft_FaceInfo
//purpose :
//=======================================================================
Draft_FaceInfo::Draft_FaceInfo (const Handle(Geom_Surface)& S,\
const Standard_Boolean HasNewGeometry):
myNewGeom(HasNewGeometry)
{
Handle(Geom_RectangularTrimmedSurface) T = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
if (!T.IsNull()) myGeom = T->BasisSurface();
else myGeom = S;
}
//=======================================================================
//function : RootFace
//purpose :
//=======================================================================
void Draft_FaceInfo::RootFace(const TopoDS_Face& F)
{
myRootFace = F;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Draft_FaceInfo::Add(const TopoDS_Face& F)
{
if (myF1.IsNull()) {
myF1 = F;
}
else if (myF2.IsNull()) {
myF2 = F;
}
}
//=======================================================================
//function : FirstFace
//purpose :
//=======================================================================
const TopoDS_Face& Draft_FaceInfo::FirstFace () const
{
return myF1;
}
//=======================================================================
//function : SecondFace
//purpose :
//=======================================================================
const TopoDS_Face& Draft_FaceInfo::SecondFace () const
{
return myF2;
}
//=======================================================================
//function : NewGeometry
//purpose :
//=======================================================================
Standard_Boolean Draft_FaceInfo::NewGeometry() const
{
return myNewGeom;
}
//=======================================================================
//function : Geometry
//purpose :
//=======================================================================
const Handle(Geom_Surface)& Draft_FaceInfo::Geometry() const
{
return myGeom;
}
//=======================================================================
//function : ChangeGeometry
//purpose :
//=======================================================================
Handle(Geom_Surface)& Draft_FaceInfo::ChangeGeometry()
{
return myGeom;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
const Handle(Geom_Curve)& Draft_FaceInfo::Curve() const
{
return myCurv;
}
//=======================================================================
//function : ChangeCurve
//purpose :
//=======================================================================
Handle(Geom_Curve)& Draft_FaceInfo::ChangeCurve()
{
return myCurv;
}
//=======================================================================
//function : RootFace
//purpose :
//=======================================================================
const TopoDS_Face & Draft_FaceInfo::RootFace() const
{
return myRootFace;
}

322
src/Draft/Draft_Modification.cdl Executable file
View File

@@ -0,0 +1,322 @@
-- File: Draft_Modification.cdl
-- Created: Tue Aug 30 11:13:43 1994
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1994
class Modification from Draft inherits Modification from BRepTools
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
Location from TopLoc,
ListOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
Orientation from TopAbs,
Shape from GeomAbs,
Surface from Geom,
Curve from Geom,
Curve from Geom2d,
Pnt from gp,
Lin from gp,
Pln from gp,
Dir from gp,
ErrorStatus from Draft,
DataMapOfFaceFaceInfo from Draft,
DataMapOfEdgeEdgeInfo from Draft,
DataMapOfVertexVertexInfo from Draft
raises NotDone from StdFail,
NoSuchObject from Standard,
ConstructionError from Standard
is
Create(S: Shape from TopoDS)
returns mutable Modification from Draft;
Clear(me: mutable)
---Purpose: Resets on the same shape.
is static;
Init(me: mutable; S: Shape from TopoDS)
---Purpose: Changes the basis shape and resets.
is static;
Add(me: mutable; F : Face from TopoDS;
Direction : Dir from gp;
Angle : Real from Standard;
NeutralPlane: Pln from gp;
Flag : Boolean from Standard = Standard_True)
---Purpose: Adds the face F and propagates the draft
-- modification to its neighbour faces if they are
-- tangent. If an error occurs, will return False and
-- ProblematicShape will return the "bad" face.
returns Boolean from Standard
raises ConstructionError from Standard
-- The exception is raised if ProblematicShape does not
-- return a null shape
is static;
Remove(me: mutable; F: Face from TopoDS)
---Purpose: Removes the face F and the neighbour faces if they
-- are tangent. It will be necessary to call this
-- method if the method Add returns Standard_False,
-- to unset ProblematicFace.
raises NoSuchObject from Standard
-- The exception is raised if F has not been added.
is static;
Perform(me: mutable)
---Purpose: Performs the draft angle modification and sets the
-- value returned by the method IsDone. If an error
-- occurs, IsDone will return Standard_False, and an
-- error status will be given by the method Error,
-- and the shape on which the problem appeared will
-- be given by ProblematicShape
raises ConstructionError from Standard
--- The exception is raised if ProblematicShape does not
-- return a null shape.
is static;
IsDone(me)
---Purpose: Returns True if Perform has been succesfully
-- called. Otherwise more information can be obtained
-- using the methods Error() and ProblematicShape().
returns Boolean from Standard
is static;
Error(me)
returns ErrorStatus from Draft
is static;
ProblematicShape(me)
---Purpose: Returns the shape (Face, Edge or Vertex) on which
-- an error occured.
returns Shape from TopoDS
---C++: return const&
is static;
ConnectedFaces(me: mutable; F: Face from TopoDS)
returns ListOfShape from TopTools
---Purpose: Returns all the faces which have been added
-- together with the face <F>.
--
---C++: return const&
raises NoSuchObject from Standard,
-- The exception is raised if F has not been added.
NotDone from StdFail
-- The exception is raised if IsDone returns False.
is static;
ModifiedFaces(me: mutable)
returns ListOfShape from TopTools
---Purpose: Returns all the faces on which a modification has
-- been given.
--
---C++: return const&
raises NotDone from StdFail
-- The exception is raised if ProblematicShape does not return
-- a null shape.
is static;
-- Methods inherited from BRepTools_Modification
NewSurface(me: mutable; F : Face from TopoDS;
S : out Surface from Geom;
L : out Location from TopLoc;
Tol : out Real from Standard;
RevWires : out Boolean from Standard;
RevFace : out Boolean from Standard)
---Purpose: Returns Standard_True if the face <F> has been
-- modified. In this case, <S> is the new geometric
-- support of the face, <L> the new location,<Tol>
-- the new tolerance.<RevWires> has to be set to
-- Standard_True when the modification reverses the
-- normal of the surface.(the wires have to be
-- reversed). <RevFace> has to be set to
-- Standard_True if the orientation of the modified
-- face changes in the shells which contain it. Here
-- it will be set to Standard_False.
--
-- Otherwise, returns Standard_False, and <S>, <L>,
-- <Tol> , <RevWires> ,<RevFace> are not significant.
returns Boolean from Standard
;
NewCurve(me: mutable; E : Edge from TopoDS;
C : out Curve from Geom;
L : out Location from TopLoc;
Tol: out Real from Standard)
returns Boolean from Standard
;
---Purpose: Returns Standard_True if the edge <E> has been
-- modified. In this case, <C> is the new geometric
-- support of the edge, <L> the new location, <Tol>
-- the new tolerance. Otherwise, returns
-- Standard_False, and <C>, <L>, <Tol> are not
-- significant.
NewPoint(me: mutable; V : Vertex from TopoDS;
P : out Pnt from gp;
Tol: out Real from Standard)
returns Boolean from Standard
;
---Purpose: Returns Standard_True if the vertex <V> has been
-- modified. In this case, <P> is the new geometric
-- support of the vertex, <Tol> the new tolerance.
-- Otherwise, returns Standard_False, and <P>, <Tol>
-- are not significant.
NewCurve2d(me: mutable; E : Edge from TopoDS;
F : Face from TopoDS;
NewE : Edge from TopoDS;
NewF : Face from TopoDS;
C : out Curve from Geom2d;
Tol : out Real from Standard)
returns Boolean from Standard
;
---Purpose: Returns Standard_True if the edge <E> has a new
-- curve on surface on the face <F>.In this case, <C>
-- is the new geometric support of the edge, <L> the
-- new location, <Tol> the new tolerance.
--
-- Otherwise, returns Standard_False, and <C>, <L>,
-- <Tol> are not significant.
--
-- <NewE> is the new edge created from <E>. <NewF>
-- is the new face created from <F>. They may be usefull.
NewParameter(me: mutable; V : Vertex from TopoDS;
E : Edge from TopoDS;
P : out Real from Standard;
Tol: out Real from Standard)
returns Boolean from Standard
;
---Purpose: Returns Standard_True if the Vertex <V> has a new
-- parameter on the edge <E>. In this case, <P> is
-- the parameter, <Tol> the new tolerance.
-- Otherwise, returns Standard_False, and <P>, <Tol>
-- are not significant.
Continuity(me: mutable; E : Edge from TopoDS;
F1,F2 : Face from TopoDS;
NewE : Edge from TopoDS;
NewF1,NewF2: Face from TopoDS)
returns Shape from GeomAbs;
---Purpose: Returns the continuity of <NewE> between <NewF1>
-- and <NewF2>.
--
-- <NewE> is the new edge created from <E>. <NewF1>
-- (resp. <NewF2>) is the new face created from <F1>
-- (resp. <F2>).
-- Private implementation methods
InternalAdd(me: mutable; F : Face from TopoDS;
Direction : Dir from gp;
Angle : Real from Standard;
NeutralPlane: Pln from gp;
Flag : Boolean from Standard = Standard_True)
returns Boolean from Standard
is static private;
Propagate(me: mutable)
returns Boolean from Standard
is static private;
NewCurve(me: mutable; C : Curve from Geom;
S : Surface from Geom;
OriS : Orientation from TopAbs;
Direction : Dir from gp;
Angle : Real from Standard;
NeutralPlane: Pln from gp;
Flag : Boolean from Standard = Standard_True)
returns mutable Curve from Geom
is static private;
NewSurface(me: mutable; S : Surface from Geom;
OriS : Orientation from TopAbs;
Direction : Dir from gp;
Angle : Real from Standard;
NeutralPlane: Pln from gp)
returns mutable Surface from Geom
is static private;
fields
myFMap : DataMapOfFaceFaceInfo from Draft;
myEMap : DataMapOfEdgeEdgeInfo from Draft;
myVMap : DataMapOfVertexVertexInfo from Draft;
myComp : Boolean from Standard;
myShape : Shape from TopoDS;
badShape: Shape from TopoDS;
errStat : ErrorStatus from Draft;
curFace : Face from TopoDS;
conneF : ListOfShape from TopTools;
myEFMap : IndexedDataMapOfShapeListOfShape from TopTools;
end Modification;

508
src/Draft/Draft_Modification.cxx Executable file
View File

@@ -0,0 +1,508 @@
// File: Draft_Modification.cxx
// Created: Tue Aug 30 11:48:17 1994
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <Draft_Modification.ixx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <Geom_Surface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Draft_DataMapIteratorOfDataMapOfFaceFaceInfo.hxx>
#include <Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo.hxx>
#include <Draft_FaceInfo.hxx>
#include <Draft_EdgeInfo.hxx>
#include <Draft_VertexInfo.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_NoSuchObject.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <GeomProjLib.hxx>
#include <Precision.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
//function : Draft_Modification
//purpose :
//=======================================================================
Draft_Modification::Draft_Modification (const TopoDS_Shape& S) :
myComp(Standard_False),myShape(S)
{
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,myEFMap);
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Draft_Modification::Clear ()
{
myComp = Standard_False;
myFMap.Clear();
myEMap.Clear();
myVMap.Clear();
myEFMap.Clear();
badShape.Nullify();
errStat = Draft_NoError;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Draft_Modification::Init(const TopoDS_Shape& S)
{
myShape = S;
Clear();
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,myEFMap);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::Add(const TopoDS_Face& F,
const gp_Dir& Direction,
const Standard_Real Angle,
const gp_Pln& NeutralPlane,
const Standard_Boolean Flag)
{
if (!badShape.IsNull()) {
Standard_ConstructionError::Raise();
}
if (myComp) {
Clear();
}
curFace = F;
return InternalAdd(F,Direction,Angle,NeutralPlane, Flag);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void Draft_Modification::Remove(const TopoDS_Face& F)
{
if (!myFMap.IsBound(F) || myComp) {
Standard_NoSuchObject::Raise();
}
conneF.Clear();
TopTools_ListIteratorOfListOfShape ltod;
curFace = myFMap(F).RootFace();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap);
while (itf.More()) {
const TopoDS_Face& theF = itf.Key();
if (myFMap(theF).RootFace().IsSame(curFace)) {
conneF.Append(theF);
if (theF.IsSame(badShape)) {
badShape.Nullify();
}
}
itf.Next();
}
ltod.Initialize(conneF);
while (ltod.More()) {
myFMap.UnBind(TopoDS::Face(ltod.Value()));
ltod.Next();
}
conneF.Clear();
Draft_DataMapIteratorOfDataMapOfEdgeEdgeInfo ite(myEMap);
while (ite.More()) {
const TopoDS_Edge& theE = ite.Key();
if (myEMap(theE).RootFace().IsSame(curFace)) {
conneF.Append(theE);
}
ite.Next();
}
ltod.Initialize(conneF);
while (ltod.More()) {
myEMap.UnBind(TopoDS::Edge(ltod.Value()));
ltod.Next();
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::IsDone() const
{
return myComp && badShape.IsNull();
}
//=======================================================================
//function : Error
//purpose :
//=======================================================================
Draft_ErrorStatus Draft_Modification::Error() const
{
return errStat;
}
//=======================================================================
//function : ProblematicShape
//purpose :
//=======================================================================
const TopoDS_Shape& Draft_Modification::ProblematicShape() const
{
return badShape;
}
//=======================================================================
//function : ConnectedFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape & Draft_Modification::ConnectedFaces(const TopoDS_Face& F)
{
if (!myFMap.IsBound(F)) {
Standard_NoSuchObject::Raise();
}
if (!IsDone()) {
StdFail_NotDone::Raise();
}
conneF.Clear();
curFace = myFMap(F).RootFace();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap);
while (itf.More()) {
const TopoDS_Face& theF = itf.Key();
if (myFMap(theF).RootFace().IsSame(curFace)) {
conneF.Append(theF);
}
itf.Next();
}
return conneF;
}
//=======================================================================
//function : ModifiedFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape & Draft_Modification::ModifiedFaces()
{
if (!badShape.IsNull()) {
StdFail_NotDone::Raise();
}
conneF.Clear();
Draft_DataMapIteratorOfDataMapOfFaceFaceInfo itf(myFMap);
while (itf.More()) {
const TopoDS_Face& theF = itf.Key();
if (!myFMap(theF).RootFace().IsNull()) {
conneF.Append(theF);
}
itf.Next();
}
return conneF;
}
//=======================================================================
//function : NewSurface
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::NewSurface(const TopoDS_Face& F,
Handle(Geom_Surface)& S,
TopLoc_Location& L,
Standard_Real& Tol,
Standard_Boolean& RevWires,
Standard_Boolean& RevFace)
{
if (!IsDone()) {Standard_DomainError::Raise();}
if (!myFMap.IsBound(F) || !myFMap(F).NewGeometry()) {
return Standard_False;
}
RevWires = Standard_False;
RevFace = Standard_False;
Tol = BRep_Tool::Tolerance(F);
S = BRep_Tool::Surface(F,L);
L.Identity();
S = myFMap(F).Geometry();
return Standard_True;
}
//=======================================================================
//function : NewCurve
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::NewCurve(const TopoDS_Edge& E,
Handle(Geom_Curve)& C,
TopLoc_Location& L,
Standard_Real& Tol)
{
if (!IsDone()) {Standard_DomainError::Raise();}
if (!myEMap.IsBound(E))
return Standard_False;
const Draft_EdgeInfo& Einf= myEMap(E);
if (!myEMap(E).NewGeometry())
return Standard_False;
Tol = Einf.Tolerance();
Tol = Max(Tol, BRep_Tool::Tolerance(E));
L.Identity();
C = myEMap(E).Geometry();
return Standard_True;
}
//=======================================================================
//function : NewPoint
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::NewPoint(const TopoDS_Vertex& V,
gp_Pnt& P,
Standard_Real& Tol)
{
if (!IsDone()) {Standard_DomainError::Raise();};
if (!myVMap.IsBound(V)) {
return Standard_False;
}
Tol = BRep_Tool::Tolerance(V);
P = myVMap(V).Geometry();
return Standard_True;
}
//=======================================================================
//function : NewCurve2d
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::NewCurve2d(const TopoDS_Edge& E,
const TopoDS_Face& F,
const TopoDS_Edge& NewE,
const TopoDS_Face&,
Handle(Geom2d_Curve)& C,
Standard_Real& Tol)
{
if (!IsDone()) {Standard_DomainError::Raise();};
if (!myEMap.IsBound(E)) {
return Standard_False;
}
Standard_Real Fp,Lp;
BRep_Tool::Range(NewE,Fp,Lp);
Handle(Geom_Surface) SB = myFMap(F).Geometry();
const Draft_EdgeInfo& Einf = myEMap(E);
if ( Einf.FirstFace().IsSame(F) && !Einf.FirstPC().IsNull()) {
C = Einf.FirstPC();
}
else if ( Einf.SecondFace().IsSame(F) && !Einf.SecondPC().IsNull()) {
C = Einf.SecondPC();
}
else {
if (!myEMap(E).NewGeometry()) {
Standard_Real Fpi,Lpi;
BRep_Tool::Range(E,Fpi,Lpi);
if (Fpi <= Fp && Fp <= Lpi && Fpi <= Lp && Lp <= Lpi) {
return Standard_False;
}
}
Tol = BRep_Tool::Tolerance(E);
// if (!BRep_Tool::IsClosed(E,F)) {
BRep_Tool::Range(NewE,Fp,Lp);
Handle(Geom_TrimmedCurve) TC = new Geom_TrimmedCurve(myEMap(E).Geometry(),
Fp,Lp);
Fp = TC->FirstParameter();
Lp = TC->LastParameter();
BRep_Builder B;
B.Range( NewE, Fp, Lp );
C = GeomProjLib::Curve2d(TC,Fp, Lp, SB, Tol);
}
Handle(Standard_Type) typs = SB->DynamicType();
if (typs == STANDARD_TYPE(Geom_RectangularTrimmedSurface) ) {
SB = Handle(Geom_RectangularTrimmedSurface)::DownCast(SB)->BasisSurface();
typs = SB->DynamicType();
}
Standard_Boolean JeRecadre = Standard_False;
if (typs == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
Handle(Geom_Curve) aC =
Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(SB)->BasisCurve();
Handle(Standard_Type) typc = aC->DynamicType();
if (typc == STANDARD_TYPE(Geom_Circle)) JeRecadre = Standard_True;
}
JeRecadre = JeRecadre ||
(typs == STANDARD_TYPE(Geom_CylindricalSurface)) ||
(typs == STANDARD_TYPE(Geom_SphericalSurface)) ||
(typs == STANDARD_TYPE(Geom_ConicalSurface));
if ( JeRecadre) {
gp_Pnt2d PF,PL;
BRep_Tool::UVPoints(E,F,PF,PL);
gp_Pnt2d NewPF = C->Value(Fp);
gp_Vec2d vectra(2.*PI,0.);
if (NewPF.Translated(vectra).SquareDistance(PF)
< NewPF.SquareDistance(PF)) {
C->Translate(vectra);
}
else if (NewPF.Translated(-vectra).SquareDistance(PF)
< NewPF.SquareDistance(PF)) {
C->Translate(-vectra);
}
}
return Standard_True;
}
//=======================================================================
//function : NewParameter
//purpose :
//=======================================================================
Standard_Boolean Draft_Modification::NewParameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
Standard_Real& P,
Standard_Real& Tol)
{
if (!IsDone()) {Standard_DomainError::Raise();};
if (!myVMap.IsBound(V)) {
return Standard_False;
}
P = myVMap(V).Parameter(E);
Handle(Geom_Curve) GC = myEMap(E).Geometry();
Handle(Standard_Type) typc = GC->DynamicType();
if (typc == STANDARD_TYPE(Geom_TrimmedCurve)) {
GC = Handle(Geom_TrimmedCurve)::DownCast(GC);
typc = GC->DynamicType();
}
if (GC->IsClosed()) {
TopoDS_Vertex FV = TopExp::FirstVertex(E);
Standard_Real paramf;
if (myVMap.IsBound(FV)) {
paramf = myVMap(FV).Parameter(E);
}
else {
paramf = BRep_Tool::Parameter(FV,E);
}
//Patch
Standard_Real FirstPar = GC->FirstParameter(), LastPar = GC->LastParameter();
Standard_Real pconf = Precision::PConfusion();
if (Abs( paramf - LastPar ) <= pconf)
{
paramf = FirstPar;
FV.Orientation(E.Orientation());
if (V.IsEqual( FV ))
P = paramf;
}
FV.Orientation(E.Orientation());
if (!V.IsEqual(FV) && P <= paramf) {
if (GC->IsPeriodic()) {
P += GC->Period();
}
else {
P = GC->LastParameter();
}
}
}
Tol = Max (BRep_Tool::Tolerance(V), BRep_Tool::Tolerance(E));
return Standard_True;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Draft_Modification::Continuity(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopoDS_Edge&,
const TopoDS_Face&,
const TopoDS_Face&)
{
return BRep_Tool::Continuity(E,F1,F2);
}

2178
src/Draft/Draft_Modification_1.cxx Executable file

File diff suppressed because it is too large Load Diff

92
src/Draft/Draft_VertexInfo.cdl Executable file
View File

@@ -0,0 +1,92 @@
-- File: Draft_VertexInfo.cdl
-- Created: Wed Aug 31 16:47:03 1994
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1994
class VertexInfo from Draft
---Purpose:
uses Pnt from gp,
Edge from TopoDS,
ListOfShape from TopTools,
ListOfReal from TColStd,
ListIteratorOfListOfShape from TopTools
raises DomainError from Standard,
NoMoreObject from Standard
is
Create
returns VertexInfo from Draft;
Add(me: in out; E: Edge from TopoDS)
is static;
Geometry(me)
returns Pnt from gp
is static;
---C++: return const&
Parameter(me: in out; E: Edge from TopoDS)
returns Real from Standard
raises DomainError from Standard
is static;
InitEdgeIterator(me: in out)
is static;
Edge(me)
returns Edge from TopoDS
is static;
---C++: return const&
NextEdge(me: in out)
raises NoMoreObject from Standard
is static;
MoreEdge(me)
returns Boolean from Standard
is static;
ChangeGeometry(me: in out)
returns Pnt from gp
is static;
---C++: return &
ChangeParameter(me: in out; E: Edge from TopoDS)
returns Real from Standard
is static;
---C++: return &
fields
myGeom : Pnt from gp;
myEdges : ListOfShape from TopTools;
myParams : ListOfReal from TColStd;
myItEd : ListIteratorOfListOfShape from TopTools;
end VertexInfo;

140
src/Draft/Draft_VertexInfo.cxx Executable file
View File

@@ -0,0 +1,140 @@
// File: Draft_VertexInfo.cxx
// Created: Thu Sep 1 10:18:30 1994
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <Draft_VertexInfo.ixx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : Draft_VertexInfo
//purpose :
//=======================================================================
Draft_VertexInfo::Draft_VertexInfo () {}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Draft_VertexInfo::Add(const TopoDS_Edge& E)
{
for (myItEd.Initialize(myEdges); myItEd.More(); myItEd.Next()) {
if (E.IsSame(myItEd.Value())) {
break;
}
}
if (!myItEd.More()) {
myEdges.Append(E);
myParams.Append(RealLast());
}
}
//=======================================================================
//function : Geometry
//purpose :
//=======================================================================
const gp_Pnt& Draft_VertexInfo::Geometry () const
{
return myGeom;
}
//=======================================================================
//function : ChangeGeometry
//purpose :
//=======================================================================
gp_Pnt& Draft_VertexInfo::ChangeGeometry ()
{
return myGeom;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Draft_VertexInfo::Parameter (const TopoDS_Edge& E)
{
TColStd_ListIteratorOfListOfReal itp(myParams);
myItEd.Initialize(myEdges);
for (; myItEd.More(); myItEd.Next(),itp.Next()) {
if (myItEd.Value().IsSame(E)) {
return itp.Value();
}
}
Standard_DomainError::Raise(); return 0;
}
//=======================================================================
//function : ChangeParameter
//purpose :
//=======================================================================
Standard_Real& Draft_VertexInfo::ChangeParameter (const TopoDS_Edge& E)
{
TColStd_ListIteratorOfListOfReal itp(myParams);
myItEd.Initialize(myEdges);
for (; myItEd.More(); myItEd.Next(),itp.Next()) {
if (myItEd.Value().IsSame(E)) {
return itp.Value();
}
}
Standard_DomainError::Raise(); return itp.Value();
}
//=======================================================================
//function : InitEdgeIterator
//purpose :
//=======================================================================
void Draft_VertexInfo::InitEdgeIterator ()
{
myItEd.Initialize(myEdges);
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TopoDS_Edge& Draft_VertexInfo::Edge () const
{
return TopoDS::Edge(myItEd.Value());
}
//=======================================================================
//function : MoreEdge
//purpose :
//=======================================================================
Standard_Boolean Draft_VertexInfo::MoreEdge() const
{
return myItEd.More();
}
//=======================================================================
//function : NextEdge
//purpose :
//=======================================================================
void Draft_VertexInfo::NextEdge()
{
myItEd.Next();
}

1
src/Draft/FILES Executable file
View File

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