mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
110
src/ShapeCustom/ShapeCustom.cdl
Executable file
110
src/ShapeCustom/ShapeCustom.cdl
Executable file
@@ -0,0 +1,110 @@
|
||||
-- File: ShapeCustom.cdl
|
||||
-- Created: Wed Jun 3 12:40:02 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@loufox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
package ShapeCustom
|
||||
|
||||
---Purpose: This package is intended to
|
||||
-- convert geometrical objects and topological. The
|
||||
-- modifications of one geometrical object to another
|
||||
-- (one) geometrical object are provided. The supported
|
||||
-- modifications are the following:
|
||||
-- conversion of BSpline and Bezier surfaces to analytical form,
|
||||
-- conversion of indirect elementary surfaces (with left-handed
|
||||
-- coordinate systems) into direct ones,
|
||||
-- conversion of elementary surfaces to surfaces of revolution,
|
||||
-- conversion of surface of linear extrusion, revolution, offset
|
||||
-- surface to bspline,
|
||||
-- modification of parameterization, degree, number of segments of bspline
|
||||
-- surfaces, scale the shape.
|
||||
|
||||
uses
|
||||
|
||||
gp,
|
||||
GeomAbs,
|
||||
Geom,
|
||||
Geom2d,
|
||||
TopLoc,
|
||||
TopoDS,
|
||||
BRepTools,
|
||||
TopTools,
|
||||
TColgp,
|
||||
Precision
|
||||
|
||||
is
|
||||
|
||||
class Surface;
|
||||
|
||||
class Curve;
|
||||
|
||||
class Curve2d;
|
||||
|
||||
class RestrictionParameters;
|
||||
|
||||
class DirectModification;
|
||||
|
||||
private class TrsfModification;
|
||||
private class BSplineRestriction;
|
||||
private class ConvertToRevolution;
|
||||
private class SweptToElementary;
|
||||
private class ConvertToBSpline;
|
||||
|
||||
ApplyModifier(S : Shape from TopoDS;
|
||||
M : Modification from BRepTools;
|
||||
context: in out DataMapOfShapeShape from TopTools;
|
||||
MD : in out Modifier from BRepTools)
|
||||
|
||||
returns Shape from TopoDS;
|
||||
---Purpose: Applies modifier to shape and checks sharing in the case assemblies.
|
||||
|
||||
DirectFaces(S: Shape from TopoDS) returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape without indirect surfaces.
|
||||
|
||||
ScaleShape (S: Shape from TopoDS; scale: Real) returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape which is scaled original
|
||||
|
||||
BSplineRestriction(S : Shape from TopoDS;
|
||||
Tol3d, Tol2d : Real;
|
||||
MaxDegree, MaxNbSegment : Integer;
|
||||
Continuity3d, Continuity2d: Shape from GeomAbs;
|
||||
Degree : Boolean;
|
||||
Rational : Boolean;
|
||||
aParameters : RestrictionParameters from ShapeCustom)
|
||||
returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape with all surfaces, curves and pcurves
|
||||
-- which type is BSpline/Bezier or based on them converted
|
||||
-- having Degree less than <MaxDegree> or number of spans less
|
||||
-- than <NbMaxSegment> in dependence on parameter priority <Degree>.
|
||||
-- <GmaxDegree> and <GMaxSegments> are maximum possible degree
|
||||
-- and number of spans correspondingly.
|
||||
-- These values will be used in those cases when approximation with
|
||||
-- specified parameters is impossible and one of GmaxDegree or
|
||||
-- GMaxSegments is selected in dependence on priority.
|
||||
-- Note that even if approximation is impossible with <GMaxDegree>
|
||||
-- then number of spans can exceed specified <GMaxSegment>
|
||||
-- <Rational> specifies if to convert Rational BSpline/Bezier into
|
||||
-- polynomial B-Spline.
|
||||
-- If flags ConvOffSurf,ConvOffCurve3d,ConvOffCurve2d are Standard_True there are means
|
||||
-- that Offset surfaces , Offset curves 3d and Offset curves 2d are converted to BSPline
|
||||
-- correspondingly.
|
||||
|
||||
ConvertToRevolution (S: Shape from TopoDS) returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape with all elementary periodic surfaces converted
|
||||
-- to Geom_SurfaceOfRevolution
|
||||
|
||||
SweptToElementary (S: Shape from TopoDS) returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape with all surfaces of revolution and linear extrusion
|
||||
-- convert to elementary periodic surfaces
|
||||
|
||||
ConvertToBSpline (S : Shape from TopoDS;
|
||||
extrMode : Boolean; revolMode: Boolean;
|
||||
offsetMode: Boolean; planeMode: Boolean = Standard_False)
|
||||
returns Shape from TopoDS;
|
||||
---Purpose: Returns a new shape with all surfaces of linear extrusion, revolution,
|
||||
-- offset, and planar surfaces converted according to flags to
|
||||
-- Geom_BSplineSurface (with same parameterisation).
|
||||
|
||||
end ShapeCustom;
|
191
src/ShapeCustom/ShapeCustom.cxx
Executable file
191
src/ShapeCustom/ShapeCustom.cxx
Executable file
@@ -0,0 +1,191 @@
|
||||
//#71 rln 09.03.99: S4135: new class _TrsfModification and method ::ScaleShape
|
||||
// abv 08.05.99: S4190: new class and method ConvertToRevolution
|
||||
// gka 01.08.99 S4188 : new class and method LimitDegreeShape
|
||||
// abv 16.06.99 general function ApplyModifier() implemented
|
||||
// gka 21.06.99 general LimitDegreeShape renamed to BSplineRestriction
|
||||
// szv 03.01.01 PositiveCones merged with DirectFaces
|
||||
#include <ShapeCustom.hxx>
|
||||
#include <ShapeCustom_DirectModification.hxx>
|
||||
#include <ShapeCustom_TrsfModification.hxx>
|
||||
#include <ShapeCustom_ConvertToRevolution.hxx>
|
||||
#include <ShapeCustom_BSplineRestriction.hxx>
|
||||
#include <ShapeCustom_ConvertToBSpline.hxx>
|
||||
#include <ShapeCustom_SweptToElementary.hxx>
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepTools_Modifier.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ApplyModifier
|
||||
//purpose : static
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
|
||||
const Handle(BRepTools_Modification) &M,
|
||||
TopTools_DataMapOfShapeShape &context,
|
||||
BRepTools_Modifier& MD )
|
||||
{
|
||||
// protect against INTERNAL/EXTERNAL shapes
|
||||
TopoDS_Shape SF = S.Oriented(TopAbs_FORWARD);
|
||||
|
||||
// Process COMPOUNDs separately in order to handle sharing in assemblies
|
||||
if ( SF.ShapeType() == TopAbs_COMPOUND ) {
|
||||
Standard_Boolean locModified = Standard_False;
|
||||
TopoDS_Compound C;
|
||||
BRep_Builder B;
|
||||
B.MakeCompound ( C );
|
||||
for ( TopoDS_Iterator it(SF); it.More(); it.Next() ) {
|
||||
TopoDS_Shape shape = it.Value();
|
||||
TopLoc_Location L = shape.Location(), nullLoc;
|
||||
shape.Location ( nullLoc );
|
||||
TopoDS_Shape res;
|
||||
if ( context.IsBound ( shape ) )
|
||||
res = context.Find ( shape ).Oriented ( shape.Orientation() );
|
||||
else res = ApplyModifier ( shape, M, context ,MD);
|
||||
if ( ! res.IsSame ( shape ) ) {
|
||||
context.Bind ( shape, res );
|
||||
locModified = Standard_True;
|
||||
}
|
||||
res.Location ( L );
|
||||
B.Add ( C, res );
|
||||
}
|
||||
if ( ! locModified ) return S;
|
||||
context.Bind ( SF, C );
|
||||
return C.Oriented ( S.Orientation() );
|
||||
}
|
||||
|
||||
// Modify the shape
|
||||
//BRepTools_Modifier Op(SF,M);
|
||||
MD.Init(SF);
|
||||
MD.Perform(M);
|
||||
|
||||
if ( ! MD.IsDone() ) return S;
|
||||
return MD.ModifiedShape(SF).Oriented(S.Orientation());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DirectFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::DirectFaces (const TopoDS_Shape& S)
|
||||
{
|
||||
// Create a modification description
|
||||
Handle(ShapeCustom_DirectModification) DM =
|
||||
new ShapeCustom_DirectModification();
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ApplyModifier ( S, DM, context, MD );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ScaleShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::ScaleShape (const TopoDS_Shape& S, const Standard_Real scale)
|
||||
{
|
||||
// Create a modification description
|
||||
gp_Trsf T;
|
||||
T.SetScale (gp_Pnt (0, 0, 0), scale);
|
||||
Handle(ShapeCustom_TrsfModification) TM = new ShapeCustom_TrsfModification(T);
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ShapeCustom::ApplyModifier ( S, TM, context,MD );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BSplineRestriction
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::BSplineRestriction (const TopoDS_Shape& S, const Standard_Real Tol3d,
|
||||
const Standard_Real Tol2d, const Standard_Integer MaxDegree,
|
||||
const Standard_Integer MaxNbSegment,
|
||||
const GeomAbs_Shape Continuity3d,
|
||||
const GeomAbs_Shape Continuity2d,
|
||||
const Standard_Boolean Degree,
|
||||
const Standard_Boolean Rational,
|
||||
const Handle(ShapeCustom_RestrictionParameters)& aParameters)
|
||||
{
|
||||
// Create a modification description
|
||||
|
||||
Handle(ShapeCustom_BSplineRestriction) BSR = new ShapeCustom_BSplineRestriction();
|
||||
BSR->SetTol3d(Tol3d);
|
||||
BSR->SetTol2d(Tol2d);
|
||||
BSR->SetMaxDegree(MaxDegree);
|
||||
BSR->SetMaxNbSegments(MaxNbSegment);
|
||||
BSR->SetContinuity3d(Continuity3d);
|
||||
BSR->SetContinuity2d(Continuity2d);
|
||||
BSR->SetPriority(Degree);
|
||||
BSR->SetConvRational(Rational);
|
||||
BSR->SetRestrictionParameters(aParameters);
|
||||
// Modify the shape
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ShapeCustom::ApplyModifier ( S, BSR, context ,MD);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToRevolution
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::ConvertToRevolution (const TopoDS_Shape& S)
|
||||
{
|
||||
// Create a modification description
|
||||
Handle(ShapeCustom_ConvertToRevolution) CRev =
|
||||
new ShapeCustom_ConvertToRevolution();
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ShapeCustom::ApplyModifier ( S, CRev, context,MD );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SweptToElementary
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::SweptToElementary (const TopoDS_Shape& S)
|
||||
{
|
||||
// Create a modification description
|
||||
Handle(ShapeCustom_SweptToElementary) SE =
|
||||
new ShapeCustom_SweptToElementary();
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ShapeCustom::ApplyModifier(S,SE,context,MD);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToBSpline
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeCustom::ConvertToBSpline (const TopoDS_Shape& S,
|
||||
const Standard_Boolean extrMode,
|
||||
const Standard_Boolean revolMode,
|
||||
const Standard_Boolean offsetMode,
|
||||
const Standard_Boolean planeMode)
|
||||
{
|
||||
// Create a modification description
|
||||
Handle(ShapeCustom_ConvertToBSpline) BSRev = new ShapeCustom_ConvertToBSpline();
|
||||
BSRev->SetExtrusionMode(extrMode);
|
||||
BSRev->SetRevolutionMode(revolMode);
|
||||
BSRev->SetOffsetMode(offsetMode);
|
||||
BSRev->SetPlaneMode(planeMode);
|
||||
TopTools_DataMapOfShapeShape context;
|
||||
BRepTools_Modifier MD;
|
||||
return ShapeCustom::ApplyModifier ( S, BSRev, context, MD);
|
||||
}
|
270
src/ShapeCustom/ShapeCustom_BSplineRestriction.cdl
Executable file
270
src/ShapeCustom/ShapeCustom_BSplineRestriction.cdl
Executable file
@@ -0,0 +1,270 @@
|
||||
-- File: ShapeCustom_BSplineRestriction.cdl
|
||||
-- Created: Fri Jun 18 12:02:57 1999
|
||||
-- Author: Galina Koulikova
|
||||
-- <gka@zamox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
private class BSplineRestriction from ShapeCustom inherits Modification from BRepTools
|
||||
|
||||
---Purpose: this tool intended for aproximation surfaces, curves and pcurves with
|
||||
-- specified degree , max number of segments, tolerance 2d, tolerance 3d. Specified
|
||||
-- continuity can be reduced if approximation with specified continuity was not done.
|
||||
|
||||
uses
|
||||
Surface from Geom,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Shape from TopoDS,
|
||||
Face from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Location from TopLoc,
|
||||
Shape from GeomAbs,
|
||||
Pnt from gp,
|
||||
RestrictionParameters from ShapeCustom
|
||||
|
||||
is
|
||||
Create returns mutable BSplineRestriction from ShapeCustom;
|
||||
---Purpose: Empty constructor.
|
||||
|
||||
|
||||
Create(anApproxSurfaceFlag,
|
||||
anApproxCurve3dFlag,
|
||||
anApproxCurve2dFlag : Boolean;
|
||||
aTol3d, aTol2d : Real;
|
||||
aContinuity3d, aContinuity2d: Shape from GeomAbs ;
|
||||
aMaxDegree, aNbMaxSeg : Integer;
|
||||
Degree, Rational : Boolean)
|
||||
returns mutable BSplineRestriction from ShapeCustom;
|
||||
---Purpose: Initializes with specified parameters of aproximation.
|
||||
|
||||
Create(anApproxSurfaceFlag, anApproxCurve3dFlag, anApproxCurve2dFlag: Boolean from Standard;
|
||||
aTol3d, aTol2d : Real;
|
||||
aContinuity3d, aContinuity2d : Shape from GeomAbs ;
|
||||
aMaxDegree, aNbMaxSeg : Integer;
|
||||
Degree, Rational : Boolean;
|
||||
aModes : RestrictionParameters from ShapeCustom)
|
||||
returns mutable BSplineRestriction from ShapeCustom;
|
||||
---Purpose: Initializes with specified parameters of aproximation.
|
||||
|
||||
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.
|
||||
--
|
||||
-- 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 curve from 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_True if Surface is modified or
|
||||
-- one of pcurves of edge is modified. In this case C is copy of
|
||||
-- geometric support of the edge.
|
||||
-- In other cases returns Standard_False, and <C>, <L>, <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 been modified.
|
||||
-- In this case,if curve on the surface is modified, <C>
|
||||
-- is the new geometric support of the edge, <L> the
|
||||
-- new location, <Tol> the new tolerance. If curve on the surface
|
||||
-- is not modified C is copy curve on surface from the edge <E>.
|
||||
--
|
||||
-- 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.
|
||||
|
||||
|
||||
ConvertSurface(me: mutable; aSurface : Surface from Geom; S : out Surface from Geom;
|
||||
UF,UL,VF,VL : Real from Standard;
|
||||
IsOf : Boolean from Standard = Standard_True)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns Standard_True if the surface has been modified.
|
||||
-- if flag IsOf equals Standard_True Offset surfaces are aproximated to Offset
|
||||
-- if Standard_False to BSpline
|
||||
|
||||
ConvertCurve(me: mutable;aCurve : in out Curve from Geom; C : out Curve from Geom; IsConvert : Boolean;
|
||||
First, Last : Real; TolCur : in out Real;IsOf : Boolean from Standard = Standard_True)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns Standard_True if the curve has been modified.
|
||||
-- if flag IsOf equals Standard_True Offset curves are aproximated to Offset
|
||||
-- if Standard_False to BSpline
|
||||
|
||||
ConvertCurve2d(me: mutable;aCurve : in out Curve from Geom2d; C : out Curve from Geom2d; IsConvert : Boolean;
|
||||
First, Last : Real; TolCur : in out Real;IsOf : Boolean from Standard = Standard_True)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns Standard_True if the pcurve has been modified.
|
||||
-- if flag IsOf equals Standard_True Offset pcurves are aproximated to Offset
|
||||
-- if Standard_False to BSpline
|
||||
|
||||
-- Methods for setting and obtaining fields
|
||||
|
||||
SetTol3d(me: mutable; Tol3d : Real from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets tolerance of aproximation for curve3d and surface
|
||||
|
||||
SetTol2d(me: mutable; Tol2d : Real from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets tolerance of aproximation for curve2d
|
||||
|
||||
ModifyApproxSurfaceFlag(me : mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether the
|
||||
-- surface is aproximated.
|
||||
|
||||
ModifyApproxCurve3dFlag(me : mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether the
|
||||
-- curve3d is aproximated.
|
||||
|
||||
ModifyApproxCurve2dFlag(me : mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether the curve2d is aproximated.
|
||||
|
||||
SetContinuity3d(me : mutable; Continuity3d : Shape from GeomAbs);
|
||||
---C++: inline
|
||||
---Purpose: Sets continuity3d for aproximation curve3d and surface.
|
||||
|
||||
SetContinuity2d(me : mutable; Continuity2d : Shape from GeomAbs);
|
||||
---C++: inline
|
||||
---Purpose: Sets continuity3d for aproximation curve2d.
|
||||
|
||||
SetMaxDegree(me : mutable; MaxDegree : Integer from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets max degree for aproximation.
|
||||
|
||||
SetMaxNbSegments(me : mutable; MaxNbSegments : Integer from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets max number of segments for aproximation.
|
||||
|
||||
SetPriority(me : mutable; Degree : Boolean from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets priority for aproximation curves and surface.
|
||||
-- If Degree is True approximation is made with degree less
|
||||
-- then specified MaxDegree at the expense of number of spanes.
|
||||
-- If Degree is False approximation is made with number of
|
||||
-- spans less then specified MaxNbSegment at the expense of
|
||||
-- specified MaxDegree.
|
||||
|
||||
SetConvRational(me : mutable; Rational : Boolean from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Sets flag for define if rational BSpline or Bezier is
|
||||
-- converted to polynomial. If Rational is True approximation
|
||||
-- for rational BSpline and Bezier is made to polynomial even
|
||||
-- if degree is less then MaxDegree and number of spans is less
|
||||
-- then specified MaxNbSegment.
|
||||
|
||||
GetRestrictionParameters(me)
|
||||
returns RestrictionParameters from ShapeCustom;
|
||||
---C++: inline
|
||||
---Purpose: Returns the container of modes which defines
|
||||
-- what geometry should be converted to BSplines.
|
||||
|
||||
SetRestrictionParameters(me: mutable;
|
||||
aModes: RestrictionParameters from ShapeCustom);
|
||||
---C++: inline
|
||||
---Purpose: Sets the container of modes which defines
|
||||
-- what geometry should be converted to BSplines.
|
||||
|
||||
Curve3dError(me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose:Returns error for aproximation curve3d.
|
||||
|
||||
Curve2dError(me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose:Returns error for aproximation curve2d.
|
||||
|
||||
SurfaceError(me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose:Returns error for aproximation surface.
|
||||
|
||||
NewPoint(me: mutable; V : Vertex from TopoDS;
|
||||
P : out Pnt from gp;
|
||||
Tol: out Real from Standard)
|
||||
|
||||
returns Boolean from Standard;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
MaxErrors (me; aCurve3dErr, aCurve2dErr : out Real) returns Real from Standard;
|
||||
---Purpose:Returns error for aproximation surface, curve3d and curve2d.
|
||||
|
||||
NbOfSpan (me) returns Integer from Standard;
|
||||
---Purpose:Returns number for aproximation surface, curve3d and curve2d.
|
||||
|
||||
|
||||
fields
|
||||
myContinuity3d,
|
||||
myContinuity2d : Shape from GeomAbs;
|
||||
myMaxDegree,
|
||||
myNbMaxSeg : Integer from Standard;
|
||||
myTol3d,
|
||||
myTol2d,
|
||||
mySurfaceError,
|
||||
myCurve3dError,
|
||||
myCurve2dError : Real from Standard;
|
||||
myNbOfSpan : Integer from Standard;
|
||||
myApproxSurfaceFlag,
|
||||
myApproxCurve3dFlag,
|
||||
myApproxCurve2dFlag : Boolean from Standard;
|
||||
myDeg : Boolean from Standard;
|
||||
myConvert : Boolean from Standard;
|
||||
myRational : Boolean from Standard;
|
||||
|
||||
myParameters : RestrictionParameters from ShapeCustom;
|
||||
|
||||
|
||||
end BSplineRestriction;
|
1418
src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx
Executable file
1418
src/ShapeCustom/ShapeCustom_BSplineRestriction.cxx
Executable file
File diff suppressed because it is too large
Load Diff
175
src/ShapeCustom/ShapeCustom_BSplineRestriction.lxx
Executable file
175
src/ShapeCustom/ShapeCustom_BSplineRestriction.lxx
Executable file
@@ -0,0 +1,175 @@
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTol3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetTol3d(const Standard_Real Tol3d)
|
||||
{
|
||||
myTol3d = Tol3d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTol2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetTol2d(const Standard_Real Tol2d)
|
||||
{
|
||||
myTol2d = Tol2d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyApproxSurfaceFlag
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_BSplineRestriction::ModifyApproxSurfaceFlag()
|
||||
{
|
||||
|
||||
return myApproxSurfaceFlag;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyApproxCurve3dFlag
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_BSplineRestriction::ModifyApproxCurve3dFlag()
|
||||
{
|
||||
return myApproxCurve3dFlag;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyApproxCurve2dFlag
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_BSplineRestriction::ModifyApproxCurve2dFlag()
|
||||
{
|
||||
return myApproxCurve2dFlag;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetContinuity3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetContinuity3d(const GeomAbs_Shape Continuity3d)
|
||||
{
|
||||
myContinuity3d = Continuity3d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetContinuity2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetContinuity2d(const GeomAbs_Shape Continuity2d)
|
||||
{
|
||||
myContinuity2d = Continuity2d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaxDegree
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetMaxDegree(const Standard_Integer MaxDegree)
|
||||
{
|
||||
myMaxDegree = MaxDegree;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaxNbSegments
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetMaxNbSegments(const Standard_Integer MaxNbSegments)
|
||||
{
|
||||
myNbMaxSeg = MaxNbSegments;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve3dError
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeCustom_BSplineRestriction::Curve3dError() const
|
||||
{
|
||||
return myCurve3dError;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve2dError
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeCustom_BSplineRestriction::Curve2dError() const
|
||||
{
|
||||
return myCurve2dError;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SurfaceError
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeCustom_BSplineRestriction::SurfaceError() const
|
||||
{
|
||||
return mySurfaceError;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPriority
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetPriority(const Standard_Boolean Degree)
|
||||
{
|
||||
myDeg = Degree;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetConvRational
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::SetConvRational(const Standard_Boolean Rational)
|
||||
{
|
||||
myRational = Rational;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRestrictionParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(ShapeCustom_RestrictionParameters) ShapeCustom_BSplineRestriction::
|
||||
GetRestrictionParameters() const
|
||||
{
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetRestrictionParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeCustom_BSplineRestriction::
|
||||
SetRestrictionParameters(const Handle(ShapeCustom_RestrictionParameters)& aModes)
|
||||
{
|
||||
myParameters = aModes;
|
||||
}
|
132
src/ShapeCustom/ShapeCustom_ConvertToBSpline.cdl
Executable file
132
src/ShapeCustom/ShapeCustom_ConvertToBSpline.cdl
Executable file
@@ -0,0 +1,132 @@
|
||||
-- File: ShapeCustom_ConvertToBSpline.cdl
|
||||
-- Created: Thu Jun 17 15:49:12 1999
|
||||
-- Author: data exchange team
|
||||
-- <det@lenox>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
private class ConvertToBSpline from ShapeCustom inherits Modification from BRepTools
|
||||
|
||||
---Purpose: implement a modification for BRepTools
|
||||
-- Modifier algortihm. Converts Surface of
|
||||
-- Linear Exctrusion, Revolution and Offset
|
||||
-- surfaces into BSpline Surface according to
|
||||
-- flags.
|
||||
|
||||
uses
|
||||
|
||||
Face from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Shape from GeomAbs,
|
||||
Surface from Geom,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Pnt from gp,
|
||||
Location from TopLoc
|
||||
is
|
||||
|
||||
Create returns mutable ConvertToBSpline from ShapeCustom;
|
||||
|
||||
SetExtrusionMode(me: mutable; extrMode: Boolean);
|
||||
---Purpose: Sets mode for convertion of Surfaces of Linear
|
||||
-- extrusion.
|
||||
|
||||
SetRevolutionMode(me: mutable; revolMode: Boolean);
|
||||
---Purpose: Sets mode for convertion of Surfaces of Revolution.
|
||||
|
||||
SetOffsetMode(me: mutable; offsetMode: Boolean);
|
||||
---Purpose: Sets mode for convertion of Offset surfaces.
|
||||
|
||||
SetPlaneMode(me: mutable; planeMode: Boolean);
|
||||
---Purpose: Sets mode for convertion of Plane surfaces.
|
||||
|
||||
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)
|
||||
returns 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. Otherwise, returns
|
||||
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||
-- significant.
|
||||
|
||||
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>).
|
||||
|
||||
IsToConvert(me; S : Surface from Geom;
|
||||
SS:out Surface from Geom)
|
||||
returns Boolean is private;
|
||||
|
||||
fields
|
||||
|
||||
myExtrMode : Boolean;
|
||||
myRevolMode : Boolean;
|
||||
myOffsetMode: Boolean;
|
||||
myPlaneMode : Boolean;
|
||||
|
||||
end ConvertToBSpline;
|
243
src/ShapeCustom/ShapeCustom_ConvertToBSpline.cxx
Executable file
243
src/ShapeCustom/ShapeCustom_ConvertToBSpline.cxx
Executable file
@@ -0,0 +1,243 @@
|
||||
// File: ShapeCustom_ConvertToBSpline.cxx
|
||||
// Created: Thu Jun 17 16:00:22 1999
|
||||
// Author: data exchange team
|
||||
// <det@lenox>
|
||||
|
||||
|
||||
#include <ShapeCustom_ConvertToBSpline.ixx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <ShapeConstruct.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_ConvertToBSpline
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_ConvertToBSpline::ShapeCustom_ConvertToBSpline():
|
||||
myExtrMode(Standard_True), myRevolMode(Standard_True),
|
||||
myOffsetMode(Standard_True), myPlaneMode(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsToConvert
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::IsToConvert(const Handle(Geom_Surface) &S,
|
||||
Handle(Geom_Surface) &SS) const
|
||||
{
|
||||
SS = S;
|
||||
if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast ( S );
|
||||
SS = RTS->BasisSurface();
|
||||
}
|
||||
if(SS->IsKind(STANDARD_TYPE(Geom_OffsetSurface)))
|
||||
if(myOffsetMode)
|
||||
return Standard_True;
|
||||
else {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast ( SS );
|
||||
Handle(Geom_Surface) basis = OS->BasisSurface();
|
||||
Handle(Geom_Surface) tmp;
|
||||
return IsToConvert(basis,tmp);
|
||||
}
|
||||
if ( SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) )
|
||||
return myExtrMode;
|
||||
if ( SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) )
|
||||
return myRevolMode;
|
||||
if ( SS->IsKind(STANDARD_TYPE(Geom_Plane)) )
|
||||
return myPlaneMode;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::NewSurface (const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
Standard_Real U1,U2,V1,V2;
|
||||
S->Bounds(U1,U2,V1,V2);
|
||||
Standard_Real Umin, Umax,Vmin,Vmax;
|
||||
BRepTools::UVBounds(F,Umin, Umax, Vmin, Vmax);
|
||||
if(Precision::IsInfinite(U1) || Precision::IsInfinite(U2)) {
|
||||
U1 = Umin;
|
||||
U2 = Umax;
|
||||
}
|
||||
if(Precision::IsInfinite(V1) || Precision::IsInfinite(V2)) {
|
||||
V1 = Vmin;
|
||||
V2 = Vmax;
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) surf;
|
||||
if ( ! IsToConvert ( S, surf) ) return Standard_False;
|
||||
|
||||
Handle(Geom_Surface) res;
|
||||
if(surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))&&!myOffsetMode) {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast ( surf );
|
||||
Handle(Geom_Surface) basis = OS->BasisSurface();
|
||||
Standard_Real offset = OS->Offset();
|
||||
Handle(Geom_BSplineSurface) bspl = ShapeConstruct::
|
||||
ConvertSurfaceToBSpline(basis,U1,U2,V1,V2,Precision::Approximation(),
|
||||
surf->Continuity(),10000,15);
|
||||
Handle(Geom_OffsetSurface) nOff = new Geom_OffsetSurface(bspl,offset);
|
||||
res = nOff;
|
||||
}
|
||||
else {
|
||||
GeomAbs_Shape cnt = surf->Continuity();
|
||||
if(surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface)))
|
||||
cnt = GeomAbs_C0; //pdn 30.06.99 because of hang-up in GeomConvert_ApproxSurface
|
||||
res = ShapeConstruct::ConvertSurfaceToBSpline(surf,U1,U2,V1,V2,Precision::Approximation(),
|
||||
cnt,10000,15);
|
||||
}
|
||||
if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)) ) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast ( S );
|
||||
Standard_Real UF, UL, VF, VL;
|
||||
RTS->Bounds ( UF, UL, VF, VL );
|
||||
S = new Geom_RectangularTrimmedSurface ( res, UF, UL, VF, VL );
|
||||
}
|
||||
else
|
||||
S = res;
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::NewCurve (const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
//:p5 abv 26 Feb 99: force copying of edge if any its pcurve will be replaced
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
|
||||
|
||||
// iterate on pcurves
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurveOnSurface() ) continue;
|
||||
Handle(Geom_Surface) S = GC->Surface();
|
||||
Handle(Geom_Surface) ES;
|
||||
if ( ! IsToConvert ( S, ES ) ) continue;
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::Curve ( E, L, f, l );
|
||||
if ( ! C.IsNull() ) C = Handle(Geom_Curve)::DownCast ( C->Copy() );
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::NewPoint (const TopoDS_Vertex& /*V*/,
|
||||
gp_Pnt& /*P*/, Standard_Real& /*Tol*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& /*NewF*/,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
|
||||
Handle(Geom_Surface) ES;
|
||||
|
||||
// just copy pcurve if either its surface is changing or edge was copied
|
||||
if ( ! IsToConvert ( S, ES ) && E.IsSame ( NewE ) ) return Standard_False;
|
||||
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
if ( ! C.IsNull() )
|
||||
C = Handle(Geom2d_Curve)::DownCast ( C->Copy() );
|
||||
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToBSpline::NewParameter (const TopoDS_Vertex& /*V*/,
|
||||
const TopoDS_Edge& /*E*/,
|
||||
Standard_Real& /*P*/,
|
||||
Standard_Real& /*Tol*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomAbs_Shape ShapeCustom_ConvertToBSpline::Continuity (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF1*/,
|
||||
const TopoDS_Face& /*NewF2*/)
|
||||
{
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
||||
|
||||
void ShapeCustom_ConvertToBSpline::SetExtrusionMode(const Standard_Boolean extrMode)
|
||||
{
|
||||
myExtrMode = extrMode;
|
||||
}
|
||||
|
||||
void ShapeCustom_ConvertToBSpline::SetRevolutionMode(const Standard_Boolean revolMode)
|
||||
{
|
||||
myRevolMode = revolMode;
|
||||
}
|
||||
|
||||
void ShapeCustom_ConvertToBSpline::SetOffsetMode(const Standard_Boolean offsetMode)
|
||||
{
|
||||
myOffsetMode = offsetMode;
|
||||
}
|
||||
|
||||
void ShapeCustom_ConvertToBSpline::SetPlaneMode(const Standard_Boolean planeMode)
|
||||
{
|
||||
myPlaneMode = planeMode;
|
||||
}
|
108
src/ShapeCustom/ShapeCustom_ConvertToRevolution.cdl
Executable file
108
src/ShapeCustom/ShapeCustom_ConvertToRevolution.cdl
Executable file
@@ -0,0 +1,108 @@
|
||||
-- File: ShapeCustom_ConvertToRevolution.cdl
|
||||
-- Created: Fri May 08 12:14:12 1999
|
||||
-- Author: Andrey BETENEV
|
||||
-- <abv@doomox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
private class ConvertToRevolution from ShapeCustom inherits Modification from BRepTools
|
||||
|
||||
---Purpose: implements a modification for the BRepTools
|
||||
-- Modifier algortihm. Converts all elementary
|
||||
-- surfaces into surfaces of revolution.
|
||||
|
||||
uses
|
||||
Vertex from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
Location from TopLoc,
|
||||
|
||||
Shape from GeomAbs,
|
||||
|
||||
Pnt from gp,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Surface from Geom
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable ConvertToRevolution from ShapeCustom;
|
||||
|
||||
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)
|
||||
returns 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. Otherwise, returns
|
||||
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||
-- significant.
|
||||
|
||||
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>).
|
||||
|
||||
end ConvertToRevolution;
|
260
src/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx
Executable file
260
src/ShapeCustom/ShapeCustom_ConvertToRevolution.cxx
Executable file
@@ -0,0 +1,260 @@
|
||||
#include <ShapeCustom_ConvertToRevolution.ixx>
|
||||
#include <Geom_ElementarySurface.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_ConvertToRevolution
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_ConvertToRevolution::ShapeCustom_ConvertToRevolution()
|
||||
{
|
||||
}
|
||||
|
||||
// Analyze surface: is it to be converted?
|
||||
static Standard_Boolean IsToConvert (const Handle(Geom_Surface) &S,
|
||||
Handle(Geom_ElementarySurface) &ES)
|
||||
{
|
||||
ES = Handle(Geom_ElementarySurface)::DownCast(S);
|
||||
if ( ES.IsNull() ) {
|
||||
if ( S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)) ) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast ( S );
|
||||
ES = Handle(Geom_ElementarySurface)::DownCast ( RTS->BasisSurface() );
|
||||
}
|
||||
else if ( S->IsKind(STANDARD_TYPE(Geom_OffsetSurface)) ) {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast ( S );
|
||||
ES = Handle(Geom_ElementarySurface)::DownCast ( OS->BasisSurface() );
|
||||
}
|
||||
if ( ES.IsNull() ) return Standard_False;
|
||||
}
|
||||
|
||||
return ES->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ||
|
||||
ES->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ||
|
||||
ES->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
|
||||
ES->IsKind(STANDARD_TYPE(Geom_ConicalSurface));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToRevolution::NewSurface (const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
|
||||
Handle(Geom_ElementarySurface) ES;
|
||||
if ( ! IsToConvert ( S, ES ) ) return Standard_False;
|
||||
|
||||
// remove location if it contains inversion
|
||||
/*
|
||||
gp_Trsf t = L.Transformation();
|
||||
gp_Mat m = t.VectorialPart();
|
||||
Standard_Boolean neg = t.IsNegative();
|
||||
Standard_Boolean det = ( m.Determinant() <0 ? Standard_True : Standard_False );
|
||||
if ( neg != det ) {
|
||||
ES = Handle(Geom_ElementarySurface)::DownCast ( ES->Transformed(t) );
|
||||
L.Identity();
|
||||
}
|
||||
*/
|
||||
|
||||
gp_Ax3 Ax3 = ES->Position();
|
||||
gp_Pnt pos = Ax3.Location();
|
||||
gp_Dir dir = Ax3.Direction();
|
||||
gp_Dir X = Ax3.XDirection();
|
||||
|
||||
// create basis line to rotate
|
||||
Handle(Geom_Curve) BasisCurve;
|
||||
if ( ES->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) {
|
||||
Handle(Geom_SphericalSurface) SS = Handle(Geom_SphericalSurface)::DownCast(ES);
|
||||
gp_Ax2 Ax2 ( pos, X ^ dir, X );
|
||||
Handle(Geom_Circle) Circ = new Geom_Circle ( Ax2, SS->Radius() );
|
||||
BasisCurve = new Geom_TrimmedCurve ( Circ, -PI/2., PI/2. );
|
||||
}
|
||||
else if ( ES->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ) {
|
||||
Handle(Geom_ToroidalSurface) TS = Handle(Geom_ToroidalSurface)::DownCast(ES);
|
||||
gp_Ax2 Ax2 ( pos.XYZ() + X.XYZ() * TS->MajorRadius(), X ^ dir, X );
|
||||
BasisCurve = new Geom_Circle ( Ax2, TS->MinorRadius() );
|
||||
}
|
||||
else if ( ES->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) {
|
||||
Handle(Geom_CylindricalSurface) CS = Handle(Geom_CylindricalSurface)::DownCast(ES);
|
||||
gp_Ax1 Ax1 ( pos.XYZ() + X.XYZ() * CS->Radius(), dir );
|
||||
BasisCurve = new Geom_Line ( Ax1 );
|
||||
}
|
||||
else if ( ES->IsKind(STANDARD_TYPE(Geom_ConicalSurface)) ) {
|
||||
Handle(Geom_ConicalSurface) CS = Handle(Geom_ConicalSurface)::DownCast(ES);
|
||||
gp_Dir N = dir.XYZ() + X.XYZ() * Tan ( CS->SemiAngle() );
|
||||
gp_Ax1 Ax1 ( pos.XYZ() + X.XYZ() * CS->RefRadius(), N );
|
||||
BasisCurve = new Geom_Line ( Ax1 );
|
||||
}
|
||||
|
||||
// create revolution with proper U parametrization
|
||||
gp_Ax1 Axis = Ax3.Axis();
|
||||
|
||||
// if the surface is indirect (taking into account locations), reverse dir
|
||||
|
||||
/*
|
||||
gp_Trsf t = L.Transformation();
|
||||
gp_Mat m = t.VectorialPart();
|
||||
Standard_Boolean neg = t.IsNegative();
|
||||
Standard_Boolean det = ( m.Determinant() <0 ? Standard_True : Standard_False );
|
||||
Standard_Boolean isdir = Ax3.Direct();
|
||||
if ( ( neg != det ) == isdir ) Axis.Reverse();
|
||||
*/
|
||||
if ( ! Ax3.Direct() ) Axis.Reverse();
|
||||
|
||||
Handle(Geom_SurfaceOfRevolution) Rev = new Geom_SurfaceOfRevolution ( BasisCurve, Axis );
|
||||
|
||||
// set resulting surface and restore trimming or offsetting if necessary
|
||||
if ( ES == S ) S = Rev;
|
||||
else {
|
||||
if ( S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)) ) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast ( S );
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
RTS->Bounds ( U1, U2, V1, V2 );
|
||||
S = new Geom_RectangularTrimmedSurface ( Rev, U1, U2, V1, V2 );
|
||||
}
|
||||
else if ( S->IsKind(STANDARD_TYPE(Geom_OffsetSurface)) ) {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast ( S );
|
||||
S = new Geom_OffsetSurface ( Rev, OS->Offset() );
|
||||
}
|
||||
else S = Rev;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToRevolution::NewCurve (const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
//:p5 abv 26 Feb 99: force copying of edge if any its pcurve will be replaced
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
|
||||
|
||||
// iterate on pcurves
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurveOnSurface() ) continue;
|
||||
Handle(Geom_Surface) S = GC->Surface();
|
||||
Handle(Geom_ElementarySurface) ES;
|
||||
if ( ! IsToConvert ( S, ES ) ) continue;
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::Curve ( E, L, f, l );
|
||||
if ( ! C.IsNull() ) C = Handle(Geom_Curve)::DownCast ( C->Copy() );
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToRevolution::NewPoint (const TopoDS_Vertex& /*V*/,
|
||||
gp_Pnt& /*P*/, Standard_Real& /*Tol*/)
|
||||
{
|
||||
// 3d points are never modified
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToRevolution::NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& /*NewF*/,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
|
||||
Handle(Geom_ElementarySurface) ES;
|
||||
|
||||
// just copy pcurve if either its surface is changing or edge was copied
|
||||
if ( ! IsToConvert ( S, ES ) && E.IsSame ( NewE ) ) return Standard_False;
|
||||
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
if ( ! C.IsNull() ) {
|
||||
C = Handle(Geom2d_Curve)::DownCast ( C->Copy() );
|
||||
|
||||
// for spherical surface, surface of revolution since based on TrimmedCurve
|
||||
// has V parametrisation shifted on 2PI; translate pcurve accordingly
|
||||
if ( ! ES.IsNull() && ES->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) {
|
||||
gp_Vec2d shift ( 0., 2*PI );
|
||||
C->Translate ( shift );
|
||||
}
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_ConvertToRevolution::NewParameter (const TopoDS_Vertex& /*V*/,
|
||||
const TopoDS_Edge& /*E*/,
|
||||
Standard_Real& /*P*/,
|
||||
Standard_Real& /*Tol*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomAbs_Shape ShapeCustom_ConvertToRevolution::Continuity (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF1*/,
|
||||
const TopoDS_Face& /*NewF2*/)
|
||||
{
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
||||
|
35
src/ShapeCustom/ShapeCustom_Curve.cdl
Executable file
35
src/ShapeCustom/ShapeCustom_Curve.cdl
Executable file
@@ -0,0 +1,35 @@
|
||||
-- File: ShapeCustom_Curve.cdl
|
||||
-- Created: Tue Aug 28 14:33:05 2001
|
||||
-- Author: data exchange team
|
||||
-- <det@friendox>
|
||||
---Copyright: Matra Datavision 2001
|
||||
|
||||
|
||||
class Curve from ShapeCustom
|
||||
|
||||
---Purpose: Converts BSpline curve to periodic
|
||||
|
||||
uses
|
||||
|
||||
Curve from Geom
|
||||
|
||||
is
|
||||
|
||||
Create returns Curve from ShapeCustom;
|
||||
|
||||
Create (C: Curve from Geom) returns Curve from ShapeCustom;
|
||||
|
||||
Init (me: in out; C: Curve from Geom);
|
||||
|
||||
ConvertToPeriodic (me: in out; substitute: Boolean; preci: Real = -1)
|
||||
returns Curve from Geom;
|
||||
---Purpose: Tries to convert the Curve to the Periodic form
|
||||
-- Returns the resulting curve
|
||||
-- Works only if the Curve is BSpline and is closed with
|
||||
-- Precision::Confusion()
|
||||
-- Else, or in case of failure, returns a Null Handle
|
||||
fields
|
||||
|
||||
myCurve: Curve from Geom;
|
||||
|
||||
end Curve;
|
101
src/ShapeCustom/ShapeCustom_Curve.cxx
Executable file
101
src/ShapeCustom/ShapeCustom_Curve.cxx
Executable file
@@ -0,0 +1,101 @@
|
||||
#include <ShapeCustom_Curve.ixx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <ShapeAnalysis_Curve.hxx>
|
||||
|
||||
|
||||
ShapeCustom_Curve::ShapeCustom_Curve()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_Curve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_Curve::ShapeCustom_Curve (const Handle(Geom_Curve)& C)
|
||||
{
|
||||
Init ( C );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeCustom_Curve::Init (const Handle(Geom_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToPeriodic
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) ShapeCustom_Curve::ConvertToPeriodic (const Standard_Boolean substitute,
|
||||
const Standard_Real preci)
|
||||
{
|
||||
Handle(Geom_Curve) newCurve;
|
||||
Handle(Geom_BSplineCurve) BSpl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
|
||||
if (BSpl.IsNull()) return newCurve;
|
||||
|
||||
// PTV 13.02.02: check if curve closed with tolerance
|
||||
Standard_Boolean closed = ShapeAnalysis_Curve::IsClosed(myCurve, preci);
|
||||
|
||||
if ( ! closed ) return newCurve;
|
||||
|
||||
Standard_Boolean converted = Standard_False; //:p6
|
||||
|
||||
if ( closed && ! BSpl->IsPeriodic() && BSpl->NbPoles() >3 ) {
|
||||
Standard_Boolean set = Standard_True;
|
||||
// if degree+1 at ends, first change it to 1 by rearranging knots
|
||||
if ( BSpl->Multiplicity(1) == BSpl->Degree() + 1 &&
|
||||
BSpl->Multiplicity(BSpl->NbKnots()) == BSpl->Degree() + 1 ) {
|
||||
Standard_Integer nbPoles = BSpl->NbPoles();
|
||||
TColgp_Array1OfPnt oldPoles(1,nbPoles);
|
||||
TColStd_Array1OfReal oldWeights(1,nbPoles);
|
||||
Standard_Integer nbKnots = BSpl->NbKnots();
|
||||
TColStd_Array1OfReal oldKnots(1,nbKnots);
|
||||
TColStd_Array1OfInteger oldMults(1,nbKnots);
|
||||
|
||||
BSpl->Poles(oldPoles);
|
||||
BSpl->Weights(oldWeights);
|
||||
BSpl->Knots(oldKnots);
|
||||
BSpl->Multiplicities(oldMults);
|
||||
|
||||
TColStd_Array1OfReal newKnots (1,nbKnots+2);
|
||||
TColStd_Array1OfInteger newMults(1,nbKnots+2);
|
||||
Standard_Real a = 0.5 * ( BSpl->Knot(2) - BSpl->Knot(1) +
|
||||
BSpl->Knot(nbKnots) - BSpl->Knot(nbKnots-1) );
|
||||
|
||||
newKnots(1) = oldKnots(1) - a;
|
||||
newKnots(nbKnots+2) = oldKnots(nbKnots) + a;
|
||||
newMults(1) = newMults(nbKnots+2) = 1;
|
||||
for (Standard_Integer i = 2; i<=nbKnots+1; i++) {
|
||||
newKnots(i) = oldKnots(i-1);
|
||||
newMults(i) = oldMults(i-1);
|
||||
}
|
||||
newMults(2) = newMults(nbKnots+1) = BSpl->Degree();
|
||||
Handle(Geom_BSplineCurve) res = new Geom_BSplineCurve(oldPoles, oldWeights,
|
||||
newKnots,newMults,
|
||||
BSpl->Degree(),BSpl->IsPeriodic());
|
||||
BSpl = res;
|
||||
}
|
||||
else if ( BSpl->Multiplicity(1) > BSpl->Degree() ||
|
||||
BSpl->Multiplicity(BSpl->NbKnots()) > BSpl->Degree() + 1 ) set = Standard_False;
|
||||
if ( set ) {
|
||||
BSpl->SetPeriodic(); // make periodic
|
||||
converted = Standard_True;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
cout << "Warning: ShapeCustom_Surface: Closed BSplineSurface is caused to be periodic" << endl;
|
||||
#endif
|
||||
if ( ! converted ) return newCurve;
|
||||
newCurve = BSpl;
|
||||
if ( substitute ) myCurve = newCurve;
|
||||
return newCurve;
|
||||
}
|
48
src/ShapeCustom/ShapeCustom_Curve2d.cdl
Executable file
48
src/ShapeCustom/ShapeCustom_Curve2d.cdl
Executable file
@@ -0,0 +1,48 @@
|
||||
-- File: ShapeCustom_Curve2d.cdl
|
||||
-- Created: Thu Dec 20 15:30:06 2001
|
||||
-- Author: Pavel TELKOV
|
||||
-- <ptv@valenox>
|
||||
---Copyright: Matra Datavision 2001
|
||||
|
||||
|
||||
class Curve2d from ShapeCustom
|
||||
|
||||
---Purpose: Converts curve2d to analytical form with given
|
||||
-- precision or simpify curve2d.
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
Line from Geom2d,
|
||||
Array1OfPnt2d from TColgp,
|
||||
BSplineCurve from Geom2d
|
||||
is
|
||||
|
||||
-- static methods
|
||||
IsLinear (myclass; thePoles : Array1OfPnt2d from TColgp;
|
||||
theTolerance : Real from Standard;
|
||||
theDeviation : in out Real from Standard)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Check if poleses is in the plane with given precision
|
||||
-- Returns false if no.
|
||||
|
||||
ConvertToLine2d (myclass; theCurve : Curve from Geom2d;
|
||||
theFirstIn, theLastIn : Real from Standard;
|
||||
theTolerance : Real from Standard;
|
||||
theNewFirst, theNewLast : in out Real from Standard;
|
||||
theDeviation: in out Real from Standard)
|
||||
returns Line from Geom2d;
|
||||
---Purpose: Try to convert BSpline2d or Bezier2d to line 2d
|
||||
-- only if it is linear. Recalculate first and last parameters.
|
||||
-- Returns line2d or null curve2d.
|
||||
|
||||
SimplifyBSpline2d (myclass; theBSpline2d : in out BSplineCurve from Geom2d;
|
||||
theTolerance : Real from Standard )
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Try to remove knots from bspline where local derivatives are the same.
|
||||
-- Remove knots with given precision.
|
||||
-- Returns false if Bsplien was not modified
|
||||
|
||||
--fields
|
||||
|
||||
|
||||
end Curve2d;
|
179
src/ShapeCustom/ShapeCustom_Curve2d.cxx
Executable file
179
src/ShapeCustom/ShapeCustom_Curve2d.cxx
Executable file
@@ -0,0 +1,179 @@
|
||||
// File: ShapeCustom_Curve2d.cxx
|
||||
// Created: 20.12.01 15:45:21
|
||||
// Author: Pavel TELKOV
|
||||
// Copyright: Matra Datavision 2001
|
||||
|
||||
// Last modification:
|
||||
|
||||
#include <ShapeCustom_Curve2d.ixx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLine
|
||||
//purpose : static
|
||||
//=======================================================================
|
||||
static gp_Lin2d GetLine (const gp_Pnt2d& P1, const gp_Pnt2d& P2,
|
||||
const Standard_Real c1, Standard_Real& cf, Standard_Real& cl)
|
||||
{
|
||||
gp_Vec2d avec (P1,P2);
|
||||
gp_Dir2d adir (avec);
|
||||
gp_Lin2d alin (P1,adir);
|
||||
alin.SetLocation (ElCLib::Value (c1, alin));
|
||||
cf = ElCLib::Parameter (alin, P1);
|
||||
cl = ElCLib::Parameter (alin, P2);
|
||||
return alin;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLinear
|
||||
//purpose : static
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_Curve2d::IsLinear(const TColgp_Array1OfPnt2d& thePoles,
|
||||
const Standard_Real tolerance,
|
||||
Standard_Real& Deviation)
|
||||
{
|
||||
Standard_Integer nbPoles = thePoles.Length();
|
||||
if(nbPoles < 2)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Real dMax = 0;
|
||||
Standard_Integer iMax1=0,iMax2=0;
|
||||
|
||||
Standard_Integer i;
|
||||
for(i = 1; i < nbPoles; i++)
|
||||
for(Standard_Integer j = i+1; j <= nbPoles; j++) {
|
||||
Standard_Real dist = thePoles(i).SquareDistance(thePoles(j));
|
||||
if(dist > dMax) {
|
||||
dMax = dist;
|
||||
iMax1 = i;
|
||||
iMax2 = j;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion();
|
||||
if(dMax < dPreci)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Real tol2 = tolerance*tolerance;
|
||||
gp_Vec2d avec (thePoles(iMax1),thePoles(iMax2));
|
||||
gp_Dir2d adir (avec);
|
||||
gp_Lin2d alin (thePoles(iMax1),adir);
|
||||
|
||||
Standard_Real aMax = 0.;
|
||||
for(i = 1; i <= nbPoles; i++) {
|
||||
Standard_Real dist = alin.SquareDistance(thePoles(i));
|
||||
if(dist > tol2)
|
||||
return Standard_False;
|
||||
if(dist > aMax)
|
||||
aMax = dist;
|
||||
}
|
||||
Deviation = sqrt(aMax);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToLine2d
|
||||
//purpose : static
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_Line) ShapeCustom_Curve2d::ConvertToLine2d (const Handle(Geom2d_Curve)& theCurve,
|
||||
const Standard_Real c1,
|
||||
const Standard_Real c2,
|
||||
const Standard_Real theTolerance,
|
||||
Standard_Real& cf,
|
||||
Standard_Real& cl,
|
||||
Standard_Real& theDeviation)
|
||||
{
|
||||
Handle(Geom2d_Line) aLine2d;
|
||||
gp_Pnt2d P1 = theCurve->Value(c1);
|
||||
gp_Pnt2d P2 = theCurve->Value(c2);
|
||||
Standard_Real dPreci = theTolerance*theTolerance;
|
||||
if(P1.SquareDistance(P2) < dPreci)
|
||||
return aLine2d; // it is not a line
|
||||
|
||||
Handle(Geom2d_BSplineCurve) bsc = Handle(Geom2d_BSplineCurve)::DownCast(theCurve);
|
||||
if (!bsc.IsNull()) {
|
||||
Standard_Integer nbPoles = bsc->NbPoles();
|
||||
TColgp_Array1OfPnt2d Poles(1,nbPoles);
|
||||
bsc->Poles(Poles);
|
||||
if(!ShapeCustom_Curve2d::IsLinear(Poles,theTolerance,theDeviation))
|
||||
return aLine2d; // non
|
||||
gp_Lin2d alin = GetLine (P1,P2,c1,cf,cl);
|
||||
aLine2d = new Geom2d_Line (alin);
|
||||
return aLine2d;
|
||||
}
|
||||
|
||||
Handle(Geom2d_BezierCurve) bzc = Handle(Geom2d_BezierCurve)::DownCast(theCurve);
|
||||
if (!bzc.IsNull()) {
|
||||
Standard_Integer nbPoles = bzc->NbPoles();
|
||||
TColgp_Array1OfPnt2d Poles(1,nbPoles);
|
||||
bzc->Poles(Poles);
|
||||
if(!ShapeCustom_Curve2d::IsLinear(Poles,theTolerance,theDeviation))
|
||||
return aLine2d; // non
|
||||
gp_Lin2d alin = GetLine (P1,P2,c1,cf,cl);
|
||||
aLine2d = new Geom2d_Line (alin);
|
||||
return aLine2d;
|
||||
}
|
||||
|
||||
return aLine2d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SimplifyBSpline2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_Curve2d::SimplifyBSpline2d (Handle(Geom2d_BSplineCurve)& theBSpline2d,
|
||||
const Standard_Real theTolerance)
|
||||
{
|
||||
Standard_Integer aInitNbK;
|
||||
Standard_Integer NbK = aInitNbK = theBSpline2d->NbKnots();
|
||||
// search knot to remove
|
||||
Standard_Boolean IsToRemove = Standard_True;
|
||||
Standard_Integer aKnotIndx = NbK-1;
|
||||
while (IsToRemove && NbK > 2)
|
||||
{
|
||||
Standard_Integer aMult = theBSpline2d->Multiplicity(aKnotIndx);
|
||||
Standard_Integer DegMult = theBSpline2d->Degree() - aMult;
|
||||
if ((DegMult > 1) && theBSpline2d->IsCN(DegMult))
|
||||
{
|
||||
Standard_Real U = theBSpline2d->Knot(aKnotIndx);
|
||||
gp_Vec2d aVec1 = theBSpline2d->LocalDN(U, aKnotIndx-1, aKnotIndx, DegMult);
|
||||
gp_Vec2d aVec2 = theBSpline2d->LocalDN(U, aKnotIndx, aKnotIndx+1, DegMult);
|
||||
// check the derivations are have the "same" angle
|
||||
if (aVec1.IsParallel(aVec2, Precision::Angular()))
|
||||
{
|
||||
// remove knot
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theBSpline2d->RemoveKnot(aKnotIndx,
|
||||
aMult-1,
|
||||
theTolerance);
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
aKnotIndx--;
|
||||
|
||||
NbK = theBSpline2d->NbKnots();
|
||||
if (aKnotIndx == 1 || aKnotIndx == NbK)
|
||||
IsToRemove = Standard_False;
|
||||
}
|
||||
return (aInitNbK > NbK);
|
||||
}
|
109
src/ShapeCustom/ShapeCustom_DirectModification.cdl
Executable file
109
src/ShapeCustom/ShapeCustom_DirectModification.cdl
Executable file
@@ -0,0 +1,109 @@
|
||||
-- File: ShapeCustom_DirectModification.cdl
|
||||
-- Created: Wed Jun 3 12:41:36 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@loufox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class DirectModification from ShapeCustom
|
||||
inherits Modification from BRepTools
|
||||
|
||||
---Purpose: implements a modification for the BRepTools
|
||||
-- Modifier algortihm. Will redress indirect
|
||||
-- surfaces.
|
||||
|
||||
uses
|
||||
Vertex from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
Location from TopLoc,
|
||||
|
||||
Shape from GeomAbs,
|
||||
|
||||
Pnt from gp,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Surface from Geom
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable DirectModification from ShapeCustom;
|
||||
|
||||
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)
|
||||
returns 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. Otherwise, returns
|
||||
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||
-- significant.
|
||||
|
||||
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>).
|
||||
|
||||
end DirectModification;
|
246
src/ShapeCustom/ShapeCustom_DirectModification.cxx
Executable file
246
src/ShapeCustom/ShapeCustom_DirectModification.cxx
Executable file
@@ -0,0 +1,246 @@
|
||||
//:l8 abv 15.01.99: CTS22022: writing correct pcurves for indirect tori
|
||||
//:p5 abv 26.02.99: PRO18207: force copying of edge if any its pcurve is to be replaced
|
||||
//szv#4 S4163
|
||||
//S4181 pdn 20.04.99 Modification of indirect rectangular trimming surfaces and taking
|
||||
// locations into account
|
||||
//szv 03.01.01 PositiveCones merged in
|
||||
#include <ShapeCustom_DirectModification.ixx>
|
||||
|
||||
#include <gp_Mat.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_ElementarySurface.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_DirectModification
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_DirectModification::ShapeCustom_DirectModification()
|
||||
{
|
||||
}
|
||||
|
||||
//S4181 returns 0 - none, 1 - indirect, 2 - negative cone, 3 - indirect negative cone
|
||||
static Standard_Integer IsIndirectSurface (Handle(Geom_Surface) &S,
|
||||
TopLoc_Location &L)
|
||||
{
|
||||
Standard_Integer result = 0;
|
||||
|
||||
Handle(Geom_Surface) TS = S;
|
||||
while (TS->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
|
||||
TS = Handle(Geom_RectangularTrimmedSurface)::DownCast(TS)->BasisSurface();
|
||||
|
||||
Handle(Geom_ElementarySurface) ES = Handle(Geom_ElementarySurface)::DownCast(TS);
|
||||
if (!ES.IsNull()) {
|
||||
// is the surface indirect ?
|
||||
gp_Trsf t = L.Transformation();
|
||||
Standard_Boolean neg = t.IsNegative();
|
||||
Standard_Boolean det = ( t.VectorialPart().Determinant() < 0.0 );
|
||||
Standard_Boolean dir = ES->Position().Direct();
|
||||
if ( (Standard_Boolean)( neg != det ) == dir ) result = 1;
|
||||
Handle(Geom_ConicalSurface) CS = Handle(Geom_ConicalSurface)::DownCast(ES);
|
||||
if (!CS.IsNull()) {
|
||||
// does the cone have negative semiangle ?
|
||||
if ( CS->SemiAngle() < 0.0 ) result += 2;
|
||||
}
|
||||
if (result) S = TS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_DirectModification::NewSurface (const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
|
||||
switch (IsIndirectSurface(S,L)) {
|
||||
case 1: { // Indirect surface
|
||||
// UReverse a copy of S
|
||||
S = S->UReversed();
|
||||
RevWires = Standard_True;
|
||||
RevFace = Standard_True;
|
||||
break;
|
||||
}
|
||||
case 2: { // Negative cone
|
||||
// U- and VReverse a copy of S
|
||||
S = S->VReversed();
|
||||
S->UReverse();
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
break;
|
||||
}
|
||||
case 3: { // Indirect negative cone
|
||||
// VReverse a copy of S
|
||||
S = S->VReversed();
|
||||
RevWires = Standard_True;
|
||||
RevFace = Standard_True;
|
||||
break;
|
||||
}
|
||||
default: return Standard_False;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_DirectModification::NewCurve (const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
//:p5 abv 26 Feb 99: force copying of edge if any its pcurve will be replaced
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
|
||||
|
||||
// iterate on pcurves
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurveOnSurface() ) continue;
|
||||
Handle(Geom_Surface) S = GC->Surface();
|
||||
TopLoc_Location Loc = GC->Location();
|
||||
if ( ! IsIndirectSurface ( S, Loc ) ) continue;
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::Curve ( E, L, f, l );
|
||||
if ( ! C.IsNull() ) C = Handle(Geom_Curve)::DownCast ( C->Copy() );
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_DirectModification::NewPoint (const TopoDS_Vertex& /*V*/,
|
||||
gp_Pnt& /*P*/,
|
||||
Standard_Real& /*Tol*/)
|
||||
{
|
||||
// 3d points are never modified
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_DirectModification::NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& NewF,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
|
||||
|
||||
Standard_Integer result = IsIndirectSurface ( S, L );
|
||||
if ( !result && E.IsSame(NewE) ) return Standard_False;
|
||||
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface( E, F, f, l );
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
|
||||
if ( result ) {
|
||||
|
||||
gp_Trsf2d T;
|
||||
|
||||
switch (result) {
|
||||
case 1: { // Indirect surface
|
||||
// mirror the PCurve about the V axis
|
||||
T.SetMirror(gp::OY2d());
|
||||
C = Handle(Geom2d_Curve)::DownCast(C->Transformed(T));
|
||||
break;
|
||||
}
|
||||
case 2: { // Negative cone
|
||||
// mirror the PCurve about the U and V axis
|
||||
T.SetMirror(gp::OX2d());
|
||||
C = Handle(Geom2d_Curve)::DownCast(C->Transformed(T));
|
||||
T.SetMirror(gp::OY2d());
|
||||
C->Transform(T);
|
||||
break;
|
||||
}
|
||||
case 3: { // Indirect negative cone
|
||||
// mirror the PCurve about the U axis
|
||||
T.SetMirror(gp::OX2d());
|
||||
C = Handle(Geom2d_Curve)::DownCast(C->Transformed(T));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//#26 rln When seam edge contains triangulations trimming is lost by BRep_Builder::UpdateEdge
|
||||
if (BRepTools::IsReallyClosed (E, F)) {
|
||||
//szv#4:S4163:12Mar99 SGI warning
|
||||
TopoDS_Shape sh = NewE.Reversed();
|
||||
Handle(Geom2d_Curve) tmp = BRep_Tool::CurveOnSurface( TopoDS::Edge(sh), NewF, f, l );
|
||||
if (tmp.IsNull()) {
|
||||
tmp = BRep_Tool::CurveOnSurface (E, F, f, l);
|
||||
BRep_Builder B;
|
||||
B.UpdateEdge (NewE, tmp, C, NewF, Tol);
|
||||
B.Range (NewE, NewF, f, l);
|
||||
//anyway, tmp will be removed later by BRepTools_Modifier
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//:p5 abv 26 Feb 99: force copying of pcurves if edge was copied
|
||||
if ( ! C.IsNull() ) C = Handle(Geom2d_Curve)::DownCast ( C->Copy() );
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_DirectModification::NewParameter (const TopoDS_Vertex& /*V*/,
|
||||
const TopoDS_Edge& /*E*/,
|
||||
Standard_Real& /*P*/,
|
||||
Standard_Real& /*Tol*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomAbs_Shape ShapeCustom_DirectModification::Continuity (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF1*/,
|
||||
const TopoDS_Face& /*NewF2*/)
|
||||
{
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
139
src/ShapeCustom/ShapeCustom_RestrictionParameters.cdl
Executable file
139
src/ShapeCustom/ShapeCustom_RestrictionParameters.cdl
Executable file
@@ -0,0 +1,139 @@
|
||||
-- File: ShapeCustom_RestrictionParameters.cdl
|
||||
-- Created: Mon May 22 16:23:30 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@friendox>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class RestrictionParameters from ShapeCustom inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class is axuluary tool which contains parameters for
|
||||
-- BSplineRestriction class.
|
||||
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable RestrictionParameters from ShapeCustom;
|
||||
---Purpose: Sets default parameters.
|
||||
|
||||
---Methods for modifying fields.
|
||||
|
||||
GMaxDegree(me: mutable) returns Integer;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) maximal degree of approximation.
|
||||
|
||||
GMaxSeg(me: mutable) returns Integer;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) maximal number of spans of
|
||||
-- approximation.
|
||||
|
||||
ConvertPlane (me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if Plane converted to BSpline surface.
|
||||
|
||||
ConvertBezierSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if Bezier surface converted to BSpline
|
||||
-- surface.
|
||||
|
||||
ConvertRevolutionSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if surface of Revolution converted to
|
||||
-- BSpline surface.
|
||||
|
||||
ConvertExtrusionSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if surface of LinearExtrusion converted
|
||||
-- to BSpline surface.
|
||||
|
||||
ConvertOffsetSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if Offset surface converted to BSpline
|
||||
-- surface.
|
||||
|
||||
ConvertCylindricalSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if cylindrical surface converted to BSpline
|
||||
-- surface.
|
||||
ConvertConicalSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if conical surface converted to BSpline
|
||||
-- surface.
|
||||
ConvertToroidalSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if toroidal surface converted to BSpline
|
||||
-- surface.
|
||||
|
||||
ConvertSphericalSurf(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if spherical surface converted to BSpline
|
||||
-- surface.
|
||||
|
||||
-- ConvertElementarySurf(me: mutable) returns Boolean;
|
||||
-- ---C++: inline
|
||||
-- ---C++: return &
|
||||
-- ---Purpose: Sets flag for define if Offset surface converted to BSpline
|
||||
-- -- surface.
|
||||
|
||||
SegmentSurfaceMode(me: mutable)returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets Segment mode for surface. If Segment is True surface is
|
||||
-- approximated in the bondaries of face lying on this surface.
|
||||
|
||||
ConvertCurve3d(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if 3d curve converted to BSpline curve.
|
||||
|
||||
ConvertOffsetCurv3d(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Sets flag for define if Offset curve3d converted to BSpline
|
||||
-- surface.
|
||||
|
||||
ConvertCurve2d(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) flag for define if 2d curve converted
|
||||
-- to BSpline curve.
|
||||
|
||||
ConvertOffsetCurv2d(me: mutable) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) flag for define if Offset curve2d
|
||||
-- converted to BSpline surface.
|
||||
|
||||
fields
|
||||
|
||||
myGMaxDegree: Integer from Standard;
|
||||
myGMaxSeg : Integer from Standard;
|
||||
|
||||
myConvPlane : Boolean;
|
||||
--myConvElementarySurf: Boolean;
|
||||
myConvConicalSurf : Boolean;
|
||||
myConvSphericalSurf : Boolean;
|
||||
myConvCylindricalSurf : Boolean;
|
||||
myConvToroidalSurf : Boolean;
|
||||
myConvBezierSurf : Boolean;
|
||||
myConvRevolSurf : Boolean;
|
||||
myConvExtrSurf : Boolean;
|
||||
myConvOffsetSurf : Boolean;
|
||||
mySegmentSurfaceMode: Boolean;
|
||||
myConvCurve3d : Boolean;
|
||||
myConvOffsetCurv3d : Boolean;
|
||||
myConvCurve2d : Boolean;
|
||||
myConvOffsetCurv2d : Boolean;
|
||||
|
||||
end RestrictionParameters;
|
37
src/ShapeCustom/ShapeCustom_RestrictionParameters.cxx
Executable file
37
src/ShapeCustom/ShapeCustom_RestrictionParameters.cxx
Executable file
@@ -0,0 +1,37 @@
|
||||
// File: ShapeCustom_RestrictionParameters.cxx
|
||||
// Created: Mon May 22 17:01:50 2000
|
||||
// Author: data exchange team
|
||||
// <det@friendox>
|
||||
|
||||
|
||||
#include <ShapeCustom_RestrictionParameters.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_RestrictionParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_RestrictionParameters::ShapeCustom_RestrictionParameters()
|
||||
{
|
||||
myGMaxSeg = 15;
|
||||
myGMaxDegree = 10000;
|
||||
|
||||
myConvPlane = Standard_False;
|
||||
//myConvElementarySurf = Standard_False;
|
||||
//conversion of elementary surfaces are off by default
|
||||
myConvConicalSurf = Standard_False;
|
||||
myConvSphericalSurf = Standard_False;
|
||||
myConvCylindricalSurf = Standard_False;
|
||||
myConvToroidalSurf = Standard_False;
|
||||
|
||||
myConvBezierSurf = Standard_False;
|
||||
myConvRevolSurf = Standard_True;
|
||||
myConvExtrSurf = Standard_True;
|
||||
myConvOffsetSurf = Standard_True;
|
||||
mySegmentSurfaceMode= Standard_True;
|
||||
myConvCurve3d = Standard_True;
|
||||
myConvOffsetCurv3d = Standard_True;
|
||||
myConvCurve2d = Standard_True;
|
||||
myConvOffsetCurv2d = Standard_True;
|
||||
}
|
||||
|
160
src/ShapeCustom/ShapeCustom_RestrictionParameters.lxx
Executable file
160
src/ShapeCustom/ShapeCustom_RestrictionParameters.lxx
Executable file
@@ -0,0 +1,160 @@
|
||||
// File: ShapeCustom_RestrictionParameters.lxx
|
||||
// Created: Mon May 22 17:05:18 2000
|
||||
// Author: data exchange team
|
||||
// <det@friendox>
|
||||
|
||||
//=======================================================================
|
||||
//function : GMaxDegree
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer& ShapeCustom_RestrictionParameters::GMaxDegree()
|
||||
{
|
||||
return myGMaxDegree;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GMaxSeg
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer& ShapeCustom_RestrictionParameters::GMaxSeg()
|
||||
{
|
||||
return myGMaxSeg;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertPlane
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertPlane()
|
||||
{
|
||||
return myConvPlane;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertBezierSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertBezierSurf()
|
||||
{
|
||||
return myConvBezierSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertRevolutionSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertRevolutionSurf()
|
||||
{
|
||||
return myConvRevolSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertExtrusionSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertExtrusionSurf()
|
||||
{
|
||||
return myConvExtrSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertOffsetSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertOffsetSurf()
|
||||
{
|
||||
return myConvOffsetSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SegmentSurfaceMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::SegmentSurfaceMode()
|
||||
{
|
||||
return mySegmentSurfaceMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertCurve3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertCurve3d()
|
||||
{
|
||||
return myConvCurve3d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertOffsetCurv3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertOffsetCurv3d()
|
||||
{
|
||||
return myConvOffsetCurv3d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertCurve2d()
|
||||
{
|
||||
return myConvCurve2d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertOffsetCurv2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertOffsetCurv2d()
|
||||
{
|
||||
return myConvOffsetCurv2d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertConicalSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertConicalSurf()
|
||||
{
|
||||
return myConvConicalSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertSphericalSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertSphericalSurf()
|
||||
{
|
||||
return myConvSphericalSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToroidalSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertToroidalSurf()
|
||||
{
|
||||
return myConvCylindricalSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertCylindricalSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
inline Standard_Boolean& ShapeCustom_RestrictionParameters::ConvertCylindricalSurf()
|
||||
{
|
||||
return myConvToroidalSurf;
|
||||
}
|
58
src/ShapeCustom/ShapeCustom_Surface.cdl
Executable file
58
src/ShapeCustom/ShapeCustom_Surface.cdl
Executable file
@@ -0,0 +1,58 @@
|
||||
-- File: ShapeCustom_Surface.cdl
|
||||
-- Created: Wed Jun 3 12:41:21 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@loufox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Surface from ShapeCustom
|
||||
|
||||
---Purpose: Converts a surface to the analitical form with given
|
||||
-- precision. Conversion is done only the surface is bspline
|
||||
-- of bezier and this can be approximed by some analytical
|
||||
-- surface with that precision.
|
||||
|
||||
uses
|
||||
Surface from Geom
|
||||
|
||||
is
|
||||
|
||||
Create returns Surface from ShapeCustom;
|
||||
|
||||
Create (S: Surface from Geom) returns Surface from ShapeCustom;
|
||||
|
||||
Init (me: in out; S: Surface from Geom);
|
||||
|
||||
Gap (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns maximal deviation of converted surface from the original
|
||||
-- one computed by last call to ConvertToAnalytical
|
||||
|
||||
ConvertToAnalytical (me: in out; tol: Real;
|
||||
substitute: Boolean)
|
||||
returns Surface from Geom;
|
||||
---Purpose: Tries to convert the Surface to an Analytic form
|
||||
-- Returns the result
|
||||
-- Works only if the Surface is BSpline or Bezier.
|
||||
-- Else, or in case of failure, returns a Null Handle
|
||||
--
|
||||
-- If <substitute> is True, the new surface replaces the actual
|
||||
-- one in <me>
|
||||
--
|
||||
-- It works by analysing the case which can apply, creating the
|
||||
-- corresponding analytic surface, then checking coincidence
|
||||
-- Warning: Parameter laws are not kept, hence PCurves should be redone
|
||||
|
||||
ConvertToPeriodic (me: in out; substitute: Boolean; preci: Real = -1)
|
||||
returns Surface from Geom;
|
||||
---Purpose: Tries to convert the Surface to the Periodic form
|
||||
-- Returns the resulting surface
|
||||
-- Works only if the Surface is BSpline and is closed with
|
||||
-- Precision::Confusion()
|
||||
-- Else, or in case of failure, returns a Null Handle
|
||||
fields
|
||||
|
||||
mySurf: Surface from Geom;
|
||||
myGap : Real; -- maximal deviation of converted surface from original one
|
||||
|
||||
end Surface;
|
507
src/ShapeCustom/ShapeCustom_Surface.cxx
Executable file
507
src/ShapeCustom/ShapeCustom_Surface.cxx
Executable file
@@ -0,0 +1,507 @@
|
||||
//abv 06.01.99 fix of misprint
|
||||
//:p6 abv 26.02.99: make ConvertToPeriodic() return Null if nothing done
|
||||
#include <ShapeCustom_Surface.ixx>
|
||||
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Cylinder.hxx>
|
||||
|
||||
#include <ElSLib.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
|
||||
#include <ShapeAnalysis_Geom.hxx>
|
||||
#include <ShapeAnalysis_Surface.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_Surface::ShapeCustom_Surface() : myGap (0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_Surface::ShapeCustom_Surface (const Handle(Geom_Surface)& S)
|
||||
: myGap (0)
|
||||
{
|
||||
Init ( S );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeCustom_Surface::Init (const Handle(Geom_Surface)& S)
|
||||
{
|
||||
mySurf = S;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToAnalytical
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Surface) ShapeCustom_Surface::ConvertToAnalytical (const Standard_Real tol,
|
||||
const Standard_Boolean substitute)
|
||||
{
|
||||
Handle(Geom_Surface) newSurf;
|
||||
|
||||
Standard_Integer nUP, nVP, nCP, i, j , UDeg, VDeg;
|
||||
Standard_Real U1, U2, V1, V2, C1, C2, DU, DV, U=0, V=0;
|
||||
Handle(Geom_Curve) iso;
|
||||
Standard_Boolean uClosed = Standard_True;
|
||||
|
||||
// seuls cas traites : BSpline et Bezier
|
||||
Handle(Geom_BSplineSurface) theBSplneS =
|
||||
Handle(Geom_BSplineSurface)::DownCast(mySurf);
|
||||
if (theBSplneS.IsNull()) {
|
||||
Handle(Geom_BezierSurface) theBezierS =
|
||||
Handle(Geom_BezierSurface)::DownCast(mySurf);
|
||||
if (!theBezierS.IsNull()) { // Bezier :
|
||||
nUP = theBezierS->NbUPoles();
|
||||
nVP = theBezierS->NbVPoles();
|
||||
UDeg = theBezierS->UDegree();
|
||||
VDeg = theBezierS->VDegree();
|
||||
}
|
||||
else return newSurf; // non reconnu : terminus
|
||||
}
|
||||
else { // BSpline :
|
||||
nUP = theBSplneS->NbUPoles();
|
||||
nVP = theBSplneS->NbVPoles();
|
||||
UDeg = theBSplneS->UDegree();
|
||||
VDeg = theBSplneS->VDegree();
|
||||
}
|
||||
|
||||
|
||||
mySurf->Bounds(U1, U2, V1, V2);
|
||||
// mySurf->Bounds(U1, U2, V1, V2);
|
||||
TColgp_Array1OfPnt p1(1, 3), p2(1, 3), p3(1, 3);
|
||||
TColStd_Array1OfReal R(1,3);
|
||||
gp_Pnt origPnt, resPnt;
|
||||
gp_Vec origD1U, resD1U, resD1V;
|
||||
|
||||
Standard_Boolean aCySpCo = Standard_False;
|
||||
Standard_Boolean aToroid = Standard_False;
|
||||
Standard_Boolean aPlanar = Standard_False;
|
||||
|
||||
if (nUP == 2 && nVP == 2) {
|
||||
if (UDeg == 1 && VDeg == 1) aPlanar = Standard_True;
|
||||
} else if (mySurf->IsUClosed()) { // VRAI IsUClosed
|
||||
if (mySurf->IsVClosed()) aToroid = Standard_True;
|
||||
else aCySpCo = Standard_True;
|
||||
} else {
|
||||
if(mySurf->IsVClosed()) { // VRAI IsVClosed
|
||||
aCySpCo = Standard_True;
|
||||
uClosed = Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
if (aPlanar) {
|
||||
// NearestPlane ...
|
||||
TColgp_Array1OfPnt Pnts(1,4);
|
||||
Pnts.SetValue(1,mySurf->Value(U1,V1));
|
||||
Pnts.SetValue(2,mySurf->Value(U2,V1));
|
||||
Pnts.SetValue(3,mySurf->Value(U1,V2));
|
||||
Pnts.SetValue(4,mySurf->Value(U2,V2));
|
||||
gp_Pln aPln;// Standard_Real Dmax;
|
||||
Standard_Integer It = ShapeAnalysis_Geom::NearestPlane (Pnts,aPln,myGap/*Dmax*/);
|
||||
|
||||
// ICI, on fabrique le plan, et zou
|
||||
if (It == 0 || myGap/*Dmax*/ > tol) return newSurf; // pas un plan
|
||||
|
||||
// IL RESTE a verifier l orientation ...
|
||||
// On regarde sur chaque surface les vecteurs P(U0->U1),P(V0->V1)
|
||||
// On prend la normale : les deux normales doivent etre dans le meme sens
|
||||
// Sinon, inverser la normale (pas le Pln entier !) et refaire la Plane
|
||||
newSurf = new Geom_Plane (aPln);
|
||||
gp_Vec uold (Pnts(1),Pnts(2));
|
||||
gp_Vec vold (Pnts(1),Pnts(3));
|
||||
gp_Vec nold = uold.Crossed (vold);
|
||||
gp_Vec unew (newSurf->Value(U1,V1), newSurf->Value(U2,V1));
|
||||
gp_Vec vnew (newSurf->Value(U1,V1), newSurf->Value(U1,V2));
|
||||
gp_Vec nnew = unew.Crossed (vnew);
|
||||
if (nold.Dot (nnew) < 0.0) {
|
||||
gp_Ax3 ax3 = aPln.Position();
|
||||
ax3.ZReverse();
|
||||
ax3.XReverse();
|
||||
aPln = gp_Pln (ax3);
|
||||
newSurf = new Geom_Plane (aPln);
|
||||
}
|
||||
|
||||
if (substitute) {
|
||||
Init (newSurf);
|
||||
}
|
||||
return newSurf;
|
||||
|
||||
|
||||
} else if (aCySpCo) {
|
||||
if (!uClosed) {
|
||||
C1 = U1; C2 = U2;
|
||||
U1 = V1; U2 = V2;
|
||||
V1 = C1; V2 = C2;
|
||||
nCP = nUP; nUP = nVP; nVP = nCP;
|
||||
}
|
||||
|
||||
for (i=1; i<=3; i++) {
|
||||
if (i==1) V = V1;
|
||||
else if (i==2) V = V2;
|
||||
else if (i==3) V = 0.5*(V1+V2);
|
||||
|
||||
if(uClosed) iso = mySurf->VIso(V);
|
||||
else iso = mySurf->UIso(V);
|
||||
|
||||
iso->D0(U1, p1(i));
|
||||
iso->D0(0.5*(U1+U2), p2(i));
|
||||
p3(i).SetCoord(0.5*(p1(i).X()+p2(i).X()),
|
||||
0.5*(p1(i).Y()+p2(i).Y()),
|
||||
0.5*(p1(i).Z()+p2(i).Z()));
|
||||
R(i) = p3(i).Distance(p1(i));
|
||||
// cout<<"sphere, i="<<i<<" V="<<V<<" R="<<R(i)<<" p1="<<p1(i).X()<<","<<p1(i).Y()<<","<<p1(i).Z()<<" p2="<<p2(i).X()<<","<<p2(i).Y()<<","<<p2(i).Z()<<" p3="<<p3(i).X()<<","<<p3(i).Y()<<","<<p3(i).Z()<<endl;
|
||||
}
|
||||
|
||||
iso->D1 (0.,origPnt,origD1U);
|
||||
gp_Vec xVec(p3(3), p1(3));
|
||||
gp_Vec aVec(p3(1), p3(2));
|
||||
// gp_Dir xDir(xVec); ne sert pas. Null si R3 = 0
|
||||
gp_Dir aDir(aVec);
|
||||
gp_Ax3 aAx3 (p3(1),aDir,xVec);
|
||||
// CKY 3-FEV-1997 : verification du sens de description
|
||||
//gp_Dir AXY = aAx3.YDirection(); // AXY not used (skl)
|
||||
if (aAx3.YDirection().Dot (origD1U) < 0) {
|
||||
#ifdef DEBUG
|
||||
cout<<" Surface Analytique : sens a inverser"<<endl;
|
||||
#endif
|
||||
aAx3.YReverse(); // mais X reste !
|
||||
}
|
||||
|
||||
if (nVP > 2) {
|
||||
if ((Abs(R(1)) < tol) &&
|
||||
(Abs(R(2)) < tol) &&
|
||||
(Abs(R(3)) > tol)) {
|
||||
// deja fait gp_Ax3 aAx3(p3(1), aDir, xVec);
|
||||
//gp_Ax3 aAx3(p3(3), aDir);
|
||||
Handle(Geom_SphericalSurface) anObject =
|
||||
new Geom_SphericalSurface(aAx3, R(3));
|
||||
if (!uClosed) anObject->UReverse();
|
||||
newSurf = anObject;
|
||||
}
|
||||
}
|
||||
else if (nVP == 2) {
|
||||
|
||||
// deja fait gp_Ax3 aAx3(p3(1), aDir, xVec);
|
||||
//gp_Ax3 aAx3(p3(1), aDir);
|
||||
|
||||
if (Abs(R(2)-R(1)) < tol) {
|
||||
Handle(Geom_CylindricalSurface) anObject =
|
||||
new Geom_CylindricalSurface(aAx3, R(1));
|
||||
if (!uClosed) anObject->UReverse();
|
||||
newSurf = anObject;
|
||||
}
|
||||
else {
|
||||
gp_Vec aVec2(p1(1), p1(2));
|
||||
Standard_Real angle = aVec.Angle(aVec2);
|
||||
if (R(1) < R(2)) {
|
||||
Handle(Geom_ConicalSurface) anObject =
|
||||
new Geom_ConicalSurface(aAx3, angle, R(1));
|
||||
//if (!uClosed) anObject->UReverse();
|
||||
anObject->UReverse();
|
||||
newSurf = anObject;
|
||||
}
|
||||
else {
|
||||
aDir.Reverse();
|
||||
gp_Vec anotherXVec(p3(2), p1(2));
|
||||
gp_Dir anotherXDir(anotherXVec);
|
||||
gp_Ax3 anotherAx3(p3(2), aDir, anotherXDir);
|
||||
Handle(Geom_ConicalSurface) anObject =
|
||||
new Geom_ConicalSurface(anotherAx3, angle, R(2));
|
||||
//if (!uClosed) anObject->UReverse();
|
||||
anObject->UReverse();
|
||||
newSurf = anObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (aToroid) {
|
||||
// test by iso U and isoV
|
||||
Standard_Boolean isFound = Standard_False;
|
||||
for (j=1; (j<=2) && !isFound; j++) {
|
||||
if (j==2) {
|
||||
C1 = U1; C2 = U2;
|
||||
U1 = V1; U2 = V2;
|
||||
V1 = C1; V2 = C2;
|
||||
}
|
||||
for (i=1; i<=3; i++) {
|
||||
if (i==1) U = U1;
|
||||
else if (i==2) U = 0.5*(U1+U2);
|
||||
else if (i==3) U = 0.25*(U1+U2);
|
||||
|
||||
iso = mySurf->UIso(U);
|
||||
|
||||
iso->D0(V1, p1(i));
|
||||
iso->D0(0.5*(V1+V2), p2(i));
|
||||
p3(i).SetCoord(0.5*(p1(i).X()+p2(i).X()),
|
||||
0.5*(p1(i).Y()+p2(i).Y()),
|
||||
0.5*(p1(i).Z()+p2(i).Z()));
|
||||
R(i) = p3(i).Distance(p1(i));
|
||||
}
|
||||
if ((Abs(R(1)-R(2))< tol) &&
|
||||
(Abs(R(1)-R(3))< tol)) {
|
||||
gp_Pnt p10(0.5*(p3(1).X()+p3(2).X()),
|
||||
0.5*(p3(1).Y()+p3(2).Y()),
|
||||
0.5*(p3(1).Z()+p3(2).Z()));
|
||||
gp_Vec aVec(p10, p3(1));
|
||||
gp_Vec aVec2(p10, p3(3));
|
||||
Standard_Real RR1 = R(1), RR2 = R(2), RR3;
|
||||
aVec ^= aVec2;
|
||||
|
||||
if (aVec.Magnitude() <= gp::Resolution()) aVec.SetCoord(0., 0., 1.);
|
||||
|
||||
gp_Dir aDir(aVec);
|
||||
|
||||
gp_Ax3 aAx3(p10, aDir);
|
||||
RR1 = p10.Distance(p3(1));
|
||||
// modif empirique (pourtant NON DEMONTREE) : inverser roles RR1,RR2
|
||||
// CKY, 24-JAN-1997
|
||||
if (RR1 < RR2) { RR3 = RR1; RR1 = RR2; RR2 = RR3; }
|
||||
Handle(Geom_ToroidalSurface) anObject =
|
||||
new Geom_ToroidalSurface(aAx3, RR1, RR2);
|
||||
if (j==2) anObject->UReverse();
|
||||
anObject->D1 (0.,0.,resPnt,resD1U,resD1V);
|
||||
#ifdef DEBUG
|
||||
if (resD1U.Dot(origD1U) < 0 && j != 2)
|
||||
cout<<" Tore a inverser !"<<endl;
|
||||
#endif
|
||||
newSurf = anObject;
|
||||
isFound = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newSurf.IsNull()) return newSurf;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// verification
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
Handle(GeomAdaptor_HSurface) NHS = new GeomAdaptor_HSurface (newSurf);
|
||||
GeomAdaptor_Surface& SurfAdapt = NHS->ChangeSurface();
|
||||
|
||||
const Standard_Integer NP = 21;
|
||||
Standard_Real S, T; // U,V deja fait
|
||||
gp_Pnt P3d, P3d2;
|
||||
Standard_Boolean onSurface = Standard_True;
|
||||
|
||||
Standard_Real dis; myGap = 0.;
|
||||
|
||||
DU = (U2-U1)/(NP-1);
|
||||
DV = (V2-V1)/(NP-1);
|
||||
for (j=1; (j<=NP) && onSurface; j++) {
|
||||
V = V1 + DV*(j-1);
|
||||
|
||||
if(uClosed) iso = mySurf->VIso(V);
|
||||
else iso = mySurf->UIso(V);
|
||||
|
||||
for (i=1; i<=NP; i++) {
|
||||
U = U1 + DU*(i-1);
|
||||
iso->D0(U, P3d);
|
||||
switch (SurfAdapt.GetType()){
|
||||
|
||||
case GeomAbs_Cylinder :
|
||||
{
|
||||
gp_Cylinder Cylinder = SurfAdapt.Cylinder();
|
||||
ElSLib::Parameters( Cylinder, P3d, S, T);
|
||||
break;
|
||||
}
|
||||
case GeomAbs_Cone :
|
||||
{
|
||||
gp_Cone Cone = SurfAdapt.Cone();
|
||||
ElSLib::Parameters( Cone, P3d, S, T);
|
||||
break;
|
||||
}
|
||||
case GeomAbs_Sphere :
|
||||
{
|
||||
gp_Sphere Sphere = SurfAdapt.Sphere();
|
||||
ElSLib::Parameters( Sphere, P3d, S, T);
|
||||
break;
|
||||
}
|
||||
case GeomAbs_Torus :
|
||||
{
|
||||
gp_Torus Torus = SurfAdapt.Torus();
|
||||
ElSLib::Parameters( Torus, P3d, S, T);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
newSurf->D0(S, T, P3d2);
|
||||
|
||||
dis = P3d.Distance(P3d2);
|
||||
if (dis > myGap) myGap = dis;
|
||||
|
||||
if (dis > tol) {
|
||||
onSurface = Standard_False;
|
||||
newSurf.Nullify();
|
||||
// The presumption is rejected
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (substitute && !NHS.IsNull()) {
|
||||
Init (newSurf);
|
||||
}
|
||||
return newSurf;
|
||||
}
|
||||
|
||||
//%pdn 30 Nov 98: converting bspline surfaces with degree+1 at ends to periodic
|
||||
// UKI60591, entity 48720
|
||||
Handle(Geom_Surface) ShapeCustom_Surface::ConvertToPeriodic (const Standard_Boolean substitute,
|
||||
const Standard_Real preci)
|
||||
{
|
||||
Handle(Geom_Surface) newSurf;
|
||||
Handle(Geom_BSplineSurface) BSpl = Handle(Geom_BSplineSurface)::DownCast(mySurf);
|
||||
if (BSpl.IsNull()) return newSurf;
|
||||
|
||||
ShapeAnalysis_Surface sas(mySurf);
|
||||
Standard_Boolean uclosed = sas.IsUClosed(preci);
|
||||
Standard_Boolean vclosed = sas.IsVClosed(preci);
|
||||
|
||||
if ( ! uclosed && ! vclosed ) return newSurf;
|
||||
|
||||
Standard_Boolean converted = Standard_False; //:p6
|
||||
|
||||
if ( uclosed && ! BSpl->IsUPeriodic() && BSpl->NbUPoles() >3 ) {
|
||||
Standard_Boolean set = Standard_True;
|
||||
// if degree+1 at ends, first change it to 1 by rearranging knots
|
||||
if ( BSpl->UMultiplicity(1) == BSpl->UDegree() + 1 &&
|
||||
BSpl->UMultiplicity(BSpl->NbUKnots()) == BSpl->UDegree() + 1 ) {
|
||||
Standard_Integer nbUPoles = BSpl->NbUPoles();
|
||||
Standard_Integer nbVPoles = BSpl->NbVPoles();
|
||||
TColgp_Array2OfPnt oldPoles(1,nbUPoles,1,nbVPoles);
|
||||
TColStd_Array2OfReal oldWeights(1,nbUPoles,1,nbVPoles);
|
||||
Standard_Integer nbUKnots = BSpl->NbUKnots();
|
||||
Standard_Integer nbVKnots = BSpl->NbVKnots();
|
||||
TColStd_Array1OfReal oldUKnots(1,nbUKnots);
|
||||
TColStd_Array1OfReal oldVKnots(1,nbVKnots);
|
||||
TColStd_Array1OfInteger oldUMults(1,nbUKnots);
|
||||
TColStd_Array1OfInteger oldVMults(1,nbVKnots);
|
||||
|
||||
BSpl->Poles(oldPoles);
|
||||
BSpl->Weights(oldWeights);
|
||||
BSpl->UKnots(oldUKnots);
|
||||
BSpl->VKnots(oldVKnots);
|
||||
BSpl->UMultiplicities(oldUMults);
|
||||
BSpl->VMultiplicities(oldVMults);
|
||||
|
||||
TColStd_Array1OfReal newUKnots (1,nbUKnots+2);
|
||||
TColStd_Array1OfInteger newUMults(1,nbUKnots+2);
|
||||
Standard_Real a = 0.5 * ( BSpl->UKnot(2) - BSpl->UKnot(1) +
|
||||
BSpl->UKnot(nbUKnots) - BSpl->UKnot(nbUKnots-1) );
|
||||
|
||||
newUKnots(1) = oldUKnots(1) - a;
|
||||
newUKnots(nbUKnots+2) = oldUKnots(nbUKnots) + a;
|
||||
newUMults(1) = newUMults(nbUKnots+2) = 1;
|
||||
for (Standard_Integer i = 2; i<=nbUKnots+1; i++) {
|
||||
newUKnots(i) = oldUKnots(i-1);
|
||||
newUMults(i) = oldUMults(i-1);
|
||||
}
|
||||
newUMults(2) = newUMults(nbUKnots+1) = BSpl->UDegree();
|
||||
Handle(Geom_BSplineSurface) res = new Geom_BSplineSurface(oldPoles,
|
||||
oldWeights,
|
||||
newUKnots,oldVKnots,
|
||||
newUMults,oldVMults,
|
||||
BSpl->UDegree(),BSpl->VDegree(),
|
||||
BSpl->IsUPeriodic(),BSpl->IsVPeriodic());
|
||||
BSpl = res;
|
||||
}
|
||||
else if ( BSpl->UMultiplicity(1) > BSpl->UDegree() ||
|
||||
BSpl->UMultiplicity(BSpl->NbUKnots()) > BSpl->UDegree() + 1 ) set = Standard_False;
|
||||
if ( set ) {
|
||||
BSpl->SetUPeriodic(); // make periodic
|
||||
converted = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if ( vclosed && ! BSpl->IsVPeriodic() && BSpl->NbVPoles() >3 ) {
|
||||
Standard_Boolean set = Standard_True;
|
||||
// if degree+1 at ends, first change it to 1 by rearranging knots
|
||||
if ( BSpl->VMultiplicity(1) == BSpl->VDegree() + 1 &&
|
||||
BSpl->VMultiplicity(BSpl->NbVKnots()) == BSpl->VDegree() + 1 ) {
|
||||
Standard_Integer nbUPoles = BSpl->NbUPoles();
|
||||
Standard_Integer nbVPoles = BSpl->NbVPoles();
|
||||
TColgp_Array2OfPnt oldPoles(1,nbUPoles,1,nbVPoles);
|
||||
TColStd_Array2OfReal oldWeights(1,nbUPoles,1,nbVPoles);
|
||||
Standard_Integer nbUKnots = BSpl->NbUKnots();
|
||||
Standard_Integer nbVKnots = BSpl->NbVKnots();
|
||||
TColStd_Array1OfReal oldUKnots(1,nbUKnots);
|
||||
TColStd_Array1OfReal oldVKnots(1,nbVKnots);
|
||||
TColStd_Array1OfInteger oldUMults(1,nbUKnots);
|
||||
TColStd_Array1OfInteger oldVMults(1,nbVKnots);
|
||||
|
||||
BSpl->Poles(oldPoles);
|
||||
BSpl->Weights(oldWeights);
|
||||
BSpl->UKnots(oldUKnots);
|
||||
BSpl->VKnots(oldVKnots);
|
||||
BSpl->UMultiplicities(oldUMults);
|
||||
BSpl->VMultiplicities(oldVMults);
|
||||
|
||||
TColStd_Array1OfReal newVKnots (1,nbVKnots+2);
|
||||
TColStd_Array1OfInteger newVMults(1,nbVKnots+2);
|
||||
Standard_Real a = 0.5 * ( BSpl->VKnot(2) - BSpl->VKnot(1) +
|
||||
BSpl->VKnot(nbVKnots) - BSpl->VKnot(nbVKnots-1) );
|
||||
|
||||
newVKnots(1) = oldVKnots(1) - a;
|
||||
newVKnots(nbVKnots+2) = oldVKnots(nbVKnots) + a;
|
||||
newVMults(1) = newVMults(nbVKnots+2) = 1;
|
||||
for (Standard_Integer i = 2; i<=nbVKnots+1; i++) {
|
||||
newVKnots(i) = oldVKnots(i-1);
|
||||
newVMults(i) = oldVMults(i-1);
|
||||
}
|
||||
newVMults(2) = newVMults(nbVKnots+1) = BSpl->VDegree();
|
||||
Handle(Geom_BSplineSurface) res = new Geom_BSplineSurface(oldPoles,
|
||||
oldWeights,
|
||||
oldUKnots,newVKnots,
|
||||
oldUMults,newVMults,
|
||||
BSpl->UDegree(),BSpl->VDegree(),
|
||||
BSpl->IsUPeriodic(),BSpl->IsVPeriodic());
|
||||
BSpl = res;
|
||||
}
|
||||
else if ( BSpl->VMultiplicity(1) > BSpl->VDegree() ||
|
||||
BSpl->VMultiplicity(BSpl->NbVKnots()) > BSpl->VDegree() + 1 ) set = Standard_False;
|
||||
if ( set ) {
|
||||
BSpl->SetVPeriodic(); // make periodic
|
||||
converted = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "Warning: ShapeCustom_Surface: Closed BSplineSurface is caused to be periodic" << endl;
|
||||
#endif
|
||||
if ( ! converted ) return newSurf;
|
||||
newSurf = BSpl;
|
||||
if ( substitute ) mySurf = newSurf;
|
||||
return newSurf;
|
||||
}
|
9
src/ShapeCustom/ShapeCustom_Surface.lxx
Executable file
9
src/ShapeCustom/ShapeCustom_Surface.lxx
Executable file
@@ -0,0 +1,9 @@
|
||||
// File: ShapeCustom_Surface.lxx
|
||||
// Created: Thu Jul 9 15:38:42 1998
|
||||
// Author: data exchange team
|
||||
// <det@pronox.nnov.matra-dtv.fr>
|
||||
|
||||
inline Standard_Real ShapeCustom_Surface::Gap() const
|
||||
{
|
||||
return myGap;
|
||||
}
|
107
src/ShapeCustom/ShapeCustom_SweptToElementary.cdl
Executable file
107
src/ShapeCustom/ShapeCustom_SweptToElementary.cdl
Executable file
@@ -0,0 +1,107 @@
|
||||
-- File: ShapeCustom_SweptToElementary.cdl
|
||||
-- Created: Wed Dec 10 17:04:23 2003
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@petrox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2003
|
||||
|
||||
private class SweptToElementary from ShapeCustom inherits Modification from BRepTools
|
||||
|
||||
---Purpose: implements a modification for the BRepTools
|
||||
-- Modifier algortihm. Converts all elementary
|
||||
-- surfaces into surfaces of revolution.
|
||||
|
||||
uses
|
||||
Vertex from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
Location from TopLoc,
|
||||
|
||||
Shape from GeomAbs,
|
||||
|
||||
Pnt from gp,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
Surface from Geom
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable SweptToElementary from ShapeCustom;
|
||||
|
||||
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)
|
||||
returns 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. Otherwise, returns
|
||||
-- Standard_False, and <S>, <L>, <Tol> are not
|
||||
-- significant.
|
||||
|
||||
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>).
|
||||
|
||||
end SweptToElementary;
|
295
src/ShapeCustom/ShapeCustom_SweptToElementary.cxx
Executable file
295
src/ShapeCustom/ShapeCustom_SweptToElementary.cxx
Executable file
@@ -0,0 +1,295 @@
|
||||
#include <ShapeCustom_SweptToElementary.ixx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
|
||||
#include <Geom_SweptSurface.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
|
||||
#include <Adaptor3d_SurfaceOfRevolution.hxx>
|
||||
#include <Adaptor3d_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <GeomAdaptor_HCurve.hxx>
|
||||
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Cylinder.hxx>
|
||||
#include <gp_Sphere.hxx>
|
||||
#include <gp_Cone.hxx>
|
||||
#include <gp_Torus.hxx>
|
||||
|
||||
#include <ShapeAnalysis_Surface.hxx>
|
||||
|
||||
#include <BRepTools.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_SweptToElementary
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_SweptToElementary::ShapeCustom_SweptToElementary()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsToConvert
|
||||
//purpose : auxilary (Analyze surface: is it to be converted?)
|
||||
//=======================================================================
|
||||
static Standard_Boolean IsToConvert (const Handle(Geom_Surface) &S,
|
||||
Handle(Geom_SweptSurface) &SS)
|
||||
{
|
||||
Handle(Geom_Surface) Stmp;
|
||||
|
||||
if(S->IsKind(STANDARD_TYPE(Geom_SweptSurface))) {
|
||||
SS = Handle(Geom_SweptSurface)::DownCast(S);
|
||||
return Standard_True;
|
||||
}
|
||||
if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
|
||||
Handle(Geom_RectangularTrimmedSurface) RTS =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
|
||||
Stmp = RTS->BasisSurface();
|
||||
}
|
||||
else if(S->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
|
||||
Handle(Geom_OffsetSurface) OS = Handle(Geom_OffsetSurface)::DownCast(S);
|
||||
Stmp = OS->BasisSurface();
|
||||
}
|
||||
if(Stmp.IsNull() ) return Standard_False;
|
||||
if(S->IsKind(STANDARD_TYPE(Geom_SweptSurface))) {
|
||||
SS = Handle(Geom_SweptSurface)::DownCast(Stmp);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_SweptToElementary::NewSurface(const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
Handle(Geom_SweptSurface) SS;
|
||||
if(!IsToConvert(S,SS)) return Standard_False;
|
||||
|
||||
// case SurfaceOfRevolution
|
||||
if(SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
|
||||
Handle(Geom_SurfaceOfRevolution) SR = Handle(Geom_SurfaceOfRevolution)::DownCast(SS);
|
||||
Handle(Geom_Curve) bc = SR->BasisCurve();
|
||||
gp_Ax1 ax1 = SR->Axis();
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve();
|
||||
HC->ChangeCurve().Load(bc,bc->FirstParameter(),bc->LastParameter());
|
||||
Adaptor3d_SurfaceOfRevolution AS(HC,ax1);
|
||||
switch(AS.GetType()){
|
||||
// skl 18.12.2003 - plane not used, problems in PRO14665.igs
|
||||
//case GeomAbs_Plane : {
|
||||
// Handle(Geom_Plane) Pl = new Geom_Plane(AS.Plane());
|
||||
// S = Pl;
|
||||
//} break;
|
||||
case GeomAbs_Cylinder : {
|
||||
Handle(Geom_CylindricalSurface) Cy =
|
||||
new Geom_CylindricalSurface(AS.Cylinder());
|
||||
S = Cy;
|
||||
} break;
|
||||
case GeomAbs_Sphere : {
|
||||
Handle(Geom_SphericalSurface) Sp =
|
||||
new Geom_SphericalSurface(AS.Sphere());
|
||||
S = Sp;
|
||||
} break;
|
||||
case GeomAbs_Cone : {
|
||||
Handle(Geom_ConicalSurface) Co =
|
||||
new Geom_ConicalSurface(AS.Cone());
|
||||
S = Co;
|
||||
} break;
|
||||
case GeomAbs_Torus : {
|
||||
Handle(Geom_ToroidalSurface) To =
|
||||
new Geom_ToroidalSurface(AS.Torus());
|
||||
S = To;
|
||||
} break;
|
||||
default : return Standard_False; break;
|
||||
}
|
||||
}
|
||||
// case SurfaceOfLinearExtrusion
|
||||
else if(SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
|
||||
Handle(Geom_SurfaceOfLinearExtrusion) SLE =
|
||||
Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(SS);
|
||||
Handle(Geom_Curve) bc = SLE->BasisCurve();
|
||||
gp_Dir dir = SLE->Direction();
|
||||
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve();
|
||||
HC->ChangeCurve().Load(bc,bc->FirstParameter(),bc->LastParameter());
|
||||
Adaptor3d_SurfaceOfLinearExtrusion AS(HC,dir);
|
||||
switch(AS.GetType()){
|
||||
// skl 18.12.2003 - plane not used, problems in ims013.igs
|
||||
//case GeomAbs_Plane : {
|
||||
// Handle(Geom_Plane) Pl = new Geom_Plane(AS.Plane());
|
||||
// S = Pl;
|
||||
//} break;
|
||||
case GeomAbs_Cylinder : {
|
||||
Handle(Geom_CylindricalSurface) Cy =
|
||||
new Geom_CylindricalSurface(AS.Cylinder());
|
||||
S = Cy;
|
||||
} break;
|
||||
default : return Standard_False; break;
|
||||
}
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_SweptToElementary::NewCurve(const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
//:p5 abv 26 Feb 99: force copying of edge if any its pcurve will be replaced
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
|
||||
|
||||
// iterate on pcurves
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurveOnSurface() ) continue;
|
||||
Handle(Geom_Surface) S = GC->Surface();
|
||||
Handle(Geom_SweptSurface) SS;
|
||||
if(!IsToConvert(S,SS)) continue;
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::Curve ( E, L, f, l );
|
||||
if ( ! C.IsNull() ) C = Handle(Geom_Curve)::DownCast ( C->Copy() );
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_SweptToElementary::NewPoint(const TopoDS_Vertex& /*V*/,
|
||||
gp_Pnt& /*P*/,Standard_Real& /*Tol*/)
|
||||
{
|
||||
// 3d points are never modified
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_SweptToElementary::NewCurve2d(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& NewF,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
|
||||
Handle(Geom_SweptSurface) SS;
|
||||
|
||||
// just copy pcurve if either its surface is changing or edge was copied
|
||||
if ( !IsToConvert(S,SS) && E.IsSame(NewE) ) return Standard_False;
|
||||
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
if ( ! C.IsNull() ) {
|
||||
C = Handle(Geom2d_Curve)::DownCast ( C->Copy() );
|
||||
Handle(Geom_Surface) NS = BRep_Tool::Surface(NewF,L);
|
||||
if ( !NS.IsNull() && NS->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ) {
|
||||
if(SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
|
||||
Handle(Geom_SurfaceOfRevolution) SR = Handle(Geom_SurfaceOfRevolution)::DownCast(SS);
|
||||
Standard_Real U1,U2,V1,V2;
|
||||
SR->Bounds(U1,U2,V1,V2);
|
||||
gp_Pnt P0;
|
||||
SR->D0(U1,V1,P0);
|
||||
Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface(NS);
|
||||
gp_Pnt2d p2d = sas->ValueOfUV(P0,Precision::Confusion());
|
||||
gp_Vec2d shift(p2d.X()-U1,p2d.Y()-V1);
|
||||
C->Translate(shift);
|
||||
}
|
||||
}
|
||||
if ( !NS.IsNull() && NS->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) {
|
||||
if(SS->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
|
||||
Handle(Geom_SurfaceOfRevolution) SR = Handle(Geom_SurfaceOfRevolution)::DownCast(SS);
|
||||
gp_Pnt PR,PS;
|
||||
Handle(Geom_SphericalSurface) SPH = Handle(Geom_SphericalSurface)::DownCast(NS);
|
||||
Standard_Real US1,US2,VS1,VS2;
|
||||
SPH->Bounds(US1,US2,VS1,VS2);
|
||||
SPH->D0(US1,VS1,PS);
|
||||
Standard_Real UR1,UR2,VR1,VR2;
|
||||
SR->Bounds(UR1,UR2,VR1,VR2);
|
||||
SR->D0(UR1,VR1,PR);
|
||||
gp_Pnt P0 = SPH->Location();
|
||||
gp_Vec VS(P0,PS);
|
||||
gp_Vec VR(P0,PR);
|
||||
Standard_Real angle = VS.Angle(VR);
|
||||
gp_Vec2d shift(0,VS1-VR1+angle);
|
||||
C->Translate(shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance ( E );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_SweptToElementary::NewParameter(const TopoDS_Vertex& /*V*/,
|
||||
const TopoDS_Edge& /*E*/,
|
||||
Standard_Real& /*P*/,
|
||||
Standard_Real& /*Tol*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
GeomAbs_Shape ShapeCustom_SweptToElementary::Continuity(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF1*/,
|
||||
const TopoDS_Face& /*NewF2*/)
|
||||
{
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
||||
|
82
src/ShapeCustom/ShapeCustom_TrsfModification.cdl
Executable file
82
src/ShapeCustom/ShapeCustom_TrsfModification.cdl
Executable file
@@ -0,0 +1,82 @@
|
||||
-- File: ShapeCustom_TrsfModification.cdl
|
||||
-- Created: Tue Mar 9 13:59:08 1999
|
||||
-- Author: Roman LYGIN
|
||||
-- <rln@kinox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
private class TrsfModification from ShapeCustom inherits TrsfModification from BRepTools
|
||||
|
||||
---Purpose: Complements BRepTools_TrsfModification to provide reversible
|
||||
-- scaling regarding tolerances.
|
||||
-- Uses actual tolerances (attached to the shapes) not ones
|
||||
-- returned by BRep_Tool::Tolerance to work with tolerances
|
||||
-- lower than Precision::Confusion.
|
||||
|
||||
uses
|
||||
Face from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Location from TopLoc,
|
||||
Shape from GeomAbs,
|
||||
|
||||
Surface from Geom,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
|
||||
Trsf from gp,
|
||||
Pnt from gp
|
||||
|
||||
is
|
||||
Create (T: Trsf from gp) returns mutable TrsfModification from ShapeCustom;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
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)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Calls inherited method.
|
||||
-- Sets <Tol> as actual tolerance of <F> multiplied with scale
|
||||
-- factor.
|
||||
|
||||
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: Calls inherited method.
|
||||
-- Sets <Tol> as actual tolerance of <E> multiplied with scale
|
||||
-- factor.
|
||||
|
||||
NewPoint (me: mutable; V : Vertex from TopoDS;
|
||||
P : out Pnt from gp;
|
||||
Tol: out Real from Standard)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Calls inherited method.
|
||||
-- Sets <Tol> as actual tolerance of <V> multiplied with scale
|
||||
-- factor.
|
||||
|
||||
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: Calls inherited method.
|
||||
-- Sets <Tol> as actual tolerance of <E> multiplied with scale
|
||||
-- factor.
|
||||
|
||||
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: Calls inherited method.
|
||||
-- Sets <Tol> as actual tolerance of <V> multiplied with scale
|
||||
-- factor.
|
||||
|
||||
end TrsfModification;
|
99
src/ShapeCustom/ShapeCustom_TrsfModification.cxx
Executable file
99
src/ShapeCustom/ShapeCustom_TrsfModification.cxx
Executable file
@@ -0,0 +1,99 @@
|
||||
// File: ShapeCustom_TrsfModification.cxx
|
||||
// Created: Tue Mar 9 13:59:48 1999
|
||||
// Author: Roman LYGIN
|
||||
// <rln@kinox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <ShapeCustom_TrsfModification.ixx>
|
||||
#include <BRep_TVertex.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_TFace.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeCustom_TrsfModification
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeCustom_TrsfModification::ShapeCustom_TrsfModification(const gp_Trsf& T):
|
||||
BRepTools_TrsfModification(T)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_TrsfModification::NewSurface(const TopoDS_Face& F,
|
||||
Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires,
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
Standard_Boolean result = BRepTools_TrsfModification::NewSurface(F, S, L, Tol, RevWires, RevFace);
|
||||
Tol = (*((Handle(BRep_TFace)*)&F.TShape()))->Tolerance() * Abs(Trsf().ScaleFactor());
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_TrsfModification::NewCurve(const TopoDS_Edge& E,
|
||||
Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
Standard_Boolean result = BRepTools_TrsfModification::NewCurve (E, C, L, Tol);
|
||||
Tol = (*((Handle(BRep_TEdge)*)&E.TShape()))->Tolerance() * Abs(Trsf().ScaleFactor());
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_TrsfModification::NewPoint(const TopoDS_Vertex& V,
|
||||
gp_Pnt& P,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
Standard_Boolean result = BRepTools_TrsfModification::NewPoint (V, P, Tol);
|
||||
Tol = (*((Handle(BRep_TVertex)*)&V.TShape()))->Tolerance() * Abs(Trsf().ScaleFactor());
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_TrsfModification::NewCurve2d(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& NewE,
|
||||
const TopoDS_Face& NewF,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
Standard_Boolean result = BRepTools_TrsfModification::NewCurve2d (E, F, NewE, NewF, C, Tol);
|
||||
Tol = (*((Handle(BRep_TEdge)*)&E.TShape()))->Tolerance() * Abs(Trsf().ScaleFactor());
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeCustom_TrsfModification::NewParameter(const TopoDS_Vertex& V,
|
||||
const TopoDS_Edge& E,
|
||||
Standard_Real& P,
|
||||
Standard_Real& Tol)
|
||||
{
|
||||
Standard_Boolean result = BRepTools_TrsfModification::NewParameter (V, E, P, Tol);
|
||||
Tol = (*((Handle(BRep_TVertex)*)&V.TShape()))->Tolerance() * Abs(Trsf().ScaleFactor());
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user