mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
2
src/ShapeAnalysis/FILES
Executable file
2
src/ShapeAnalysis/FILES
Executable file
@@ -0,0 +1,2 @@
|
||||
ShapeAnalysis_BoxBndTree.hxx
|
||||
ShapeAnalysis_BoxBndTree.cxx
|
183
src/ShapeAnalysis/ShapeAnalysis.cdl
Executable file
183
src/ShapeAnalysis/ShapeAnalysis.cdl
Executable file
@@ -0,0 +1,183 @@
|
||||
-- File: ShapeAnalysis.cdl
|
||||
-- Created: Wed Jun 3 11:59:35 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
package ShapeAnalysis
|
||||
|
||||
---Purpose: This package is intended to analyze geometrical objects
|
||||
-- and topological shapes. Analysis domain includes both
|
||||
-- exploring geometrical and topological properties of
|
||||
-- shapes and checking their conformance to Open CASCADE requirements.
|
||||
-- The directions of analysis provided by tools of this package are:
|
||||
-- computing quantities of subshapes,
|
||||
-- computing parameters of points on curve and surface,
|
||||
-- computing surface singularities,
|
||||
-- checking edge and wire consistency,
|
||||
-- checking edges order in the wire,
|
||||
-- checking face bounds orientation,
|
||||
-- checking small faces,
|
||||
-- analyzing shape tolerances,
|
||||
-- analyzing of free bounds of the shape.
|
||||
|
||||
uses
|
||||
gp,
|
||||
TColStd,
|
||||
TCollection,
|
||||
TColgp,
|
||||
Bnd,
|
||||
Geom,
|
||||
Geom2d,
|
||||
GeomAdaptor,
|
||||
Extrema,
|
||||
IntRes2d,
|
||||
TopAbs,
|
||||
TopLoc,
|
||||
TopoDS,
|
||||
TopTools,
|
||||
ShapeExtend,
|
||||
Adaptor3d
|
||||
|
||||
is
|
||||
|
||||
class Geom;
|
||||
---Purpose: Basic analysis on geometry
|
||||
|
||||
class Curve;
|
||||
---Purpose: Analysis on 2d and 3d curve (projecting points)
|
||||
|
||||
class Surface;
|
||||
---Purpose: Analysis on surface (computing singularities)
|
||||
|
||||
class Edge;
|
||||
---Purpose: Analysis on edge (geometrical and topological querying,
|
||||
-- curves consistency, etc.)
|
||||
|
||||
class Wire;
|
||||
---Purpose: Comprehensive alysis of the wire lying on the face or surface
|
||||
|
||||
class WireOrder;
|
||||
---Purpose: Analysis of the edges order in the wire
|
||||
|
||||
class WireVertex;
|
||||
---Purpose: Analysis of the vertex in context of the wire
|
||||
|
||||
class CheckSmallFace;
|
||||
---Purpose: Analysis of the face size
|
||||
|
||||
class Shell;
|
||||
---Purpose: Checking orientation in the shell
|
||||
|
||||
class ShapeTolerance;
|
||||
---Purpose: Calculating shape tolerances
|
||||
|
||||
--class OverlapEdges; now it is in package OverlapShape of Products
|
||||
---Purpose: Container for keeping information about
|
||||
-- overlapping edges
|
||||
|
||||
--class CheckCoincidenceTool; now it is in package OverlapShape of Products
|
||||
---Purpose: Tool for checking coincidence of faces and edges
|
||||
|
||||
-- Class intended for analyzing shape contents
|
||||
|
||||
class ShapeContents;
|
||||
---Purpose: Dumps shape contents
|
||||
|
||||
|
||||
-- Classes intended for free bounds analysis
|
||||
|
||||
class FreeBounds;
|
||||
---Purpose: Constructing free bounds of the shape
|
||||
|
||||
class FreeBoundData;
|
||||
---Purpose: Data structure for storing free bound
|
||||
|
||||
class FreeBoundsProperties;
|
||||
---Purpose: Analysis of properties of free bounds
|
||||
|
||||
class TransferParameters;
|
||||
---Purpose: Transfers parameters between curve 3d of edge and its pcurves
|
||||
|
||||
class TransferParametersProj;
|
||||
---Purpose: Transfers parameters between curve 3d of edge and its
|
||||
-- pcurves. This algorithm uses projection for not
|
||||
-- sameparameter edges.
|
||||
|
||||
class SequenceOfFreeBounds instantiates
|
||||
Sequence from TCollection (FreeBoundData from ShapeAnalysis);
|
||||
|
||||
class HSequenceOfFreeBounds instantiates
|
||||
HSequence from TCollection (FreeBoundData from ShapeAnalysis,
|
||||
SequenceOfFreeBounds from ShapeAnalysis);
|
||||
|
||||
class DataMapOfShapeListOfReal instantiates
|
||||
DataMap from TCollection(Shape from TopoDS,
|
||||
ListOfReal from TColStd,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
--class SequenceOfOverlapEdges instantiates
|
||||
--Sequence from TCollection (OverlapEdges from ShapeAnalysis);
|
||||
-- now it is in package OverlapShape of Products
|
||||
|
||||
--class IndexedDataMapOfShapeSequenceOfOverlapEdges instantiates
|
||||
--IndexedDataMap from TCollection(Shape from TopoDS,
|
||||
--SequenceOfOverlapEdges from ShapeAnalysis,
|
||||
--ShapeMapHasher from TopTools);
|
||||
-- now it is in package OverlapShape of Products
|
||||
|
||||
|
||||
OuterWire (face: Face from TopoDS) returns Wire from TopoDS;
|
||||
---Purpose: Returns the outer wire on the face <Face>.
|
||||
-- This is replacement of the method BRepTools::OuterWire
|
||||
-- until it works badly.
|
||||
-- Returns the first wire oriented as outer according to
|
||||
-- FClass2d_Classifier. If none, last wire is returned.
|
||||
|
||||
TotCross2D(sewd: WireData from ShapeExtend; aFace: Face from TopoDS)
|
||||
returns Real;
|
||||
---Purpose: Returns a total area of 2d wire
|
||||
|
||||
ContourArea(theWire : Wire from TopoDS) returns Real;
|
||||
--sewd: WireData from ShapeExtend) returns Real;
|
||||
---Purpose: Returns a total area of 3d wire
|
||||
|
||||
IsOuterBound (face: Face from TopoDS) returns Boolean;
|
||||
---Purpose: Returns True if <F> has outer bound.
|
||||
---Remarks: This method checks only presence of outer bound, it does not
|
||||
-- check mutual orientation of the bounds on a face
|
||||
|
||||
AdjustByPeriod(Val: Real; ToVal: Real; Period: Real)
|
||||
returns Real;
|
||||
---Purpose: Returns a shift required to move point
|
||||
-- <Val> to the range [ToVal-Period/2,ToVal+Period/2].
|
||||
-- This shift will be the divisible by Period.
|
||||
-- Intended for adjusting parameters on periodic surfaces.
|
||||
|
||||
AdjustToPeriod(Val: Real; ValMin: Real; ValMax: Real)
|
||||
returns Real;
|
||||
---Purpose: Returns a shift required to move point
|
||||
-- <Val> to the range [ValMin,ValMax].
|
||||
-- This shift will be the divisible by Period
|
||||
-- with Period = ValMax - ValMin.
|
||||
-- Intended for adjusting parameters on periodic surfaces.
|
||||
|
||||
FindBounds (shape: Shape from TopoDS;
|
||||
V1 : in out Vertex from TopoDS;
|
||||
V2 : in out Vertex from TopoDS);
|
||||
---Purpose: Finds the start and end vertices of the shape
|
||||
-- Shape can be of the following type:
|
||||
-- vertex: V1 and V2 are the same and equal to <shape>,
|
||||
-- edge : V1 is start and V2 is end vertex (see ShapeAnalysis_Edge
|
||||
-- methods FirstVertex and LastVertex),
|
||||
-- wire : V1 is start vertex of the first edge, V2 is end vertex
|
||||
-- of the last edge (also see ShapeAnalysis_Edge).
|
||||
-- If wire contains no edges V1 and V2 are nullified
|
||||
-- If none of the above V1 and V2 are nullified
|
||||
---Remark: V1 and V2 can be of any orientation
|
||||
|
||||
GetFaceUVBounds(F: Face from TopoDS; Umin, Umax, Vmin, Vmax: out Real);
|
||||
---Purpose: Computes exact UV bounds of all wires on the face
|
||||
|
||||
end ShapeAnalysis;
|
298
src/ShapeAnalysis/ShapeAnalysis.cxx
Executable file
298
src/ShapeAnalysis/ShapeAnalysis.cxx
Executable file
@@ -0,0 +1,298 @@
|
||||
// File: ShapeAnalysis.cxx
|
||||
// Created: Thu Jan 20 12:25:31 2000
|
||||
// Author: data exchange team
|
||||
// <det@nnov>
|
||||
// pdn 15.11.98 new methods
|
||||
//:n3 abv 08.02.99: PRO17820: ShapeAnalysis::OuterWire instead of BRepTools::OuterWire()
|
||||
// szv #1 05.03.99: PRO15686: compute UV points for Plane surfaces in case of same vertices
|
||||
//#4 szv S4163: optimizations
|
||||
//:s5 abv 22.04.99 Adding debug printouts in catch {} blocks
|
||||
//%21 pdn 15.04.99 CTS22655
|
||||
|
||||
#include <ShapeAnalysis.ixx>
|
||||
|
||||
// PLANTAGE IsOuterBound, 15-SEP-1998
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepTopAdaptor_FClass2d.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_XY.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Bnd_Box2d.hxx>
|
||||
#include <ShapeAnalysis_Curve.hxx>
|
||||
|
||||
#include <TColgp_SequenceOfPnt2d.hxx>
|
||||
#include <TColgp_SequenceOfPnt.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <BRepTools.hxx>
|
||||
#include <TopExp.hxx>
|
||||
|
||||
//static Standard_Integer numpb = 0;
|
||||
|
||||
//=======================================================================
|
||||
//function : AdjustByPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis::AdjustByPeriod(const Standard_Real Val,
|
||||
const Standard_Real ToVal,
|
||||
const Standard_Real Period)
|
||||
{
|
||||
Standard_Real diff = Val - ToVal;
|
||||
Standard_Real D = Abs ( diff );
|
||||
Standard_Real P = Abs ( Period );
|
||||
if ( D <= 0.5 * P ) return 0.;
|
||||
if ( P < 1e-100 ) return diff;
|
||||
return ( diff >0 ? -P : P ) * (Standard_Integer)( D / P + 0.5 );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AdjustToPeriod
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis::AdjustToPeriod(const Standard_Real Val,
|
||||
const Standard_Real ValMin,
|
||||
const Standard_Real ValMax)
|
||||
{
|
||||
return AdjustByPeriod ( Val, 0.5 * ( ValMin + ValMax ), ValMax - ValMin );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis::FindBounds(const TopoDS_Shape& shape,TopoDS_Vertex& V1,TopoDS_Vertex& V2)
|
||||
{
|
||||
V1.Nullify();
|
||||
V2.Nullify();
|
||||
ShapeAnalysis_Edge EA;
|
||||
if (shape.ShapeType() == TopAbs_WIRE) {
|
||||
TopoDS_Wire W = TopoDS::Wire(shape);
|
||||
//invalid work with reversed wires replaced on TopExp
|
||||
TopExp::Vertices(W,V1,V2);
|
||||
//invalid work with reversed wires
|
||||
/*TopoDS_Iterator iterWire(W);
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (iterWire.More()) {
|
||||
TopoDS_Edge E = TopoDS::Edge (iterWire.Value());
|
||||
V1 = EA.FirstVertex (E); iterWire.Next();
|
||||
for ( ; iterWire.More(); iterWire.Next() ) E = TopoDS::Edge (iterWire.Value());
|
||||
V2 = EA.LastVertex (E);
|
||||
}*/
|
||||
}
|
||||
else if (shape.ShapeType() == TopAbs_EDGE) {
|
||||
V1 = EA.FirstVertex (TopoDS::Edge (shape));
|
||||
V2 = EA.LastVertex (TopoDS::Edge (shape));
|
||||
}
|
||||
else if (shape.ShapeType() == TopAbs_VERTEX)
|
||||
V1 = V2 = TopoDS::Vertex (shape);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReverceSeq
|
||||
//purpose : auxilary
|
||||
//=======================================================================
|
||||
template<class HSequence>
|
||||
static inline void ReverceSeq (HSequence& Seq)
|
||||
{
|
||||
Standard_Integer j=Seq.Length();
|
||||
for(Standard_Integer i=1; i<Seq.Length(); i++) {
|
||||
if(i>=j) break;
|
||||
Seq.Exchange(i,j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : TotCross2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis::TotCross2D(const Handle(ShapeExtend_WireData)& sewd,
|
||||
const TopoDS_Face& aFace)
|
||||
{
|
||||
Standard_Integer i, nbc = 0;
|
||||
gp_Pnt2d fuv,luv, uv0;
|
||||
Standard_Real totcross=0;
|
||||
for(i=1; i<=sewd->NbEdges(); i++) {
|
||||
TopoDS_Edge edge = sewd->Edge(i);
|
||||
Standard_Real f2d, l2d;
|
||||
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface(edge,aFace,f2d,l2d);
|
||||
if ( !c2d.IsNull() ) {
|
||||
nbc++;
|
||||
TColgp_SequenceOfPnt2d SeqPnt;
|
||||
ShapeAnalysis_Curve::GetSamplePoints (c2d, f2d, l2d, SeqPnt);
|
||||
if( edge.Orientation()==1 )
|
||||
ReverceSeq(SeqPnt);
|
||||
if(nbc==1) {
|
||||
fuv=SeqPnt.Value(1);
|
||||
uv0=fuv;
|
||||
}
|
||||
Standard_Integer j=1;
|
||||
for( ; j<=SeqPnt.Length(); j++) {
|
||||
luv = SeqPnt.Value(j);
|
||||
totcross += (fuv.X()-luv.X())*(fuv.Y()+luv.Y())/2;
|
||||
fuv=luv;
|
||||
}
|
||||
}
|
||||
}
|
||||
totcross += (fuv.X()-uv0.X())*(fuv.Y()+uv0.Y())/2;
|
||||
return totcross;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ContourArea
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis::ContourArea(const TopoDS_Wire& theWire)
|
||||
//const Handle(ShapeExtend_WireData)& sewd)
|
||||
|
||||
{
|
||||
Standard_Integer i =1, nbc = 0;
|
||||
gp_Pnt fuv,luv, uv0;
|
||||
//Standard_Real totcross=0;
|
||||
gp_XYZ aTotal(0.,0.,0.);
|
||||
TopoDS_Iterator aIte(theWire,Standard_False);
|
||||
//for(i=1; i<=sewd->NbEdges(); i++) {
|
||||
for( ; aIte.More(); aIte.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(aIte.Value()); //sewd->Edge(i);
|
||||
Standard_Real first, last;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,first, last);
|
||||
if ( !c3d.IsNull() ) {
|
||||
|
||||
TColgp_SequenceOfPnt aSeqPnt;
|
||||
if(!ShapeAnalysis_Curve::GetSamplePoints (c3d, first, last, aSeqPnt))
|
||||
continue;
|
||||
nbc++;
|
||||
if( edge.Orientation()==TopAbs_REVERSED )
|
||||
ReverceSeq(aSeqPnt);
|
||||
if(nbc==1) {
|
||||
fuv=aSeqPnt.Value(1);
|
||||
uv0=fuv;
|
||||
}
|
||||
Standard_Integer j=1;
|
||||
for( ; j<=aSeqPnt.Length(); j++) {
|
||||
luv = aSeqPnt.Value(j);
|
||||
aTotal += luv.XYZ()^ fuv.XYZ();//
|
||||
fuv=luv;
|
||||
}
|
||||
}
|
||||
}
|
||||
aTotal += uv0.XYZ()^fuv.XYZ();//
|
||||
Standard_Real anArea = aTotal.Modulus()*0.5;
|
||||
return anArea;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsOuterBound
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis::IsOuterBound(const TopoDS_Face& face)
|
||||
{
|
||||
TopoDS_Face F = face;
|
||||
TopoDS_Wire W;
|
||||
F.Orientation(TopAbs_FORWARD);
|
||||
Standard_Integer nbw = 0;
|
||||
for (TopExp_Explorer exp(F,TopAbs_WIRE); exp.More(); exp.Next()) {
|
||||
W = TopoDS::Wire (exp.Current()); nbw ++;
|
||||
}
|
||||
//skl 08.04.2002
|
||||
if (nbw == 1) {
|
||||
Handle(ShapeExtend_WireData) sewd = new ShapeExtend_WireData(W);
|
||||
Standard_Real totcross = TotCross2D(sewd,F);
|
||||
return (totcross >= 0);
|
||||
}
|
||||
else {
|
||||
BRepAdaptor_Surface Ads ( F, Standard_False );
|
||||
Standard_Real tol = BRep_Tool::Tolerance(F);
|
||||
Standard_Real toluv = Min ( Ads.UResolution(tol), Ads.VResolution(tol) );
|
||||
BRepTopAdaptor_FClass2d fcl (F,toluv);
|
||||
Standard_Boolean rescl = (fcl.PerformInfinitePoint () == TopAbs_OUT);
|
||||
return rescl;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OuterBound
|
||||
//purpose : replacement of bad BRepTools::OuterBound()
|
||||
//=======================================================================
|
||||
//:n3
|
||||
|
||||
TopoDS_Wire ShapeAnalysis::OuterWire(const TopoDS_Face& face)
|
||||
{
|
||||
TopoDS_Face F = face;
|
||||
F.Orientation(TopAbs_FORWARD);
|
||||
|
||||
BRep_Builder B;
|
||||
TopoDS_Wire W;
|
||||
TopoDS_Iterator exp (F, Standard_False);
|
||||
while ( exp.More() ) {
|
||||
if(exp.Value().ShapeType() != TopAbs_WIRE)
|
||||
continue;
|
||||
W = TopoDS::Wire ( exp.Value() );
|
||||
exp.Next();
|
||||
if ( ! exp.More() ) return W;
|
||||
//szv#4:S4163:12Mar99 SGI warns
|
||||
TopoDS_Shape sh = F.EmptyCopied();
|
||||
TopoDS_Face fc = TopoDS::Face( sh );
|
||||
B.Add ( fc, W );
|
||||
if ( ShapeAnalysis::IsOuterBound ( fc ) ) return W;
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFaceUVBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis::GetFaceUVBounds (const TopoDS_Face& F,
|
||||
Standard_Real& UMin, Standard_Real& UMax,
|
||||
Standard_Real& VMin, Standard_Real& VMax)
|
||||
{
|
||||
TopoDS_Face FF = F;
|
||||
FF.Orientation(TopAbs_FORWARD);
|
||||
TopExp_Explorer ex(FF,TopAbs_EDGE);
|
||||
if (!ex.More()) {
|
||||
TopLoc_Location L;
|
||||
BRep_Tool::Surface(F,L)->Bounds(UMin,UMax,VMin,VMax);
|
||||
return;
|
||||
}
|
||||
|
||||
Bnd_Box2d B;
|
||||
ShapeAnalysis_Edge sae;
|
||||
ShapeAnalysis_Curve sac;
|
||||
for (;ex.More();ex.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(ex.Current());
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
Standard_Real f, l;
|
||||
if ( ! sae.PCurve ( edge, F, c2d, f, l, Standard_False ) ) continue;
|
||||
sac.FillBndBox ( c2d, f, l, 20, Standard_True, B );
|
||||
}
|
||||
B.Get(UMin,VMin,UMax,VMax);
|
||||
}
|
137
src/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx
Executable file
137
src/ShapeAnalysis/ShapeAnalysis_BoxBndTree.cxx
Executable file
@@ -0,0 +1,137 @@
|
||||
// File: ShapeAnalysis_BoxBndTree.cxx
|
||||
// Created: 14.02.05 12:39:31
|
||||
// Author: Alexey MORENOV
|
||||
// Copyright: Open CASCADE 2005
|
||||
|
||||
#include <ShapeAnalysis_BoxBndTree.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <ShapeAnalysis.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Reject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
||||
Reject (const Bnd_Box& theBnd) const
|
||||
{
|
||||
Standard_Boolean fch = myFBox.IsOut(theBnd);
|
||||
Standard_Boolean lch = myLBox.IsOut(theBnd);
|
||||
if (fch == Standard_False || lch == Standard_False) return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Accept
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
||||
Accept (const Standard_Integer& theObj)
|
||||
{
|
||||
if (theObj < 1 || theObj > mySeq->Length())
|
||||
Standard_NoSuchObject::Raise
|
||||
("ShapeAnalysis_BoxBndTreeSelector::Accept : no such object for current index");
|
||||
Standard_Boolean IsAccept = Standard_False;
|
||||
if (myList.Contains(theObj))
|
||||
return Standard_False;
|
||||
|
||||
|
||||
TopoDS_Wire W = TopoDS::Wire (mySeq->Value (theObj));
|
||||
TopoDS_Vertex V1,V2;
|
||||
ShapeAnalysis::FindBounds (W,V1,V2);
|
||||
if(myShared){
|
||||
if (myLVertex.IsSame(V1)){
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
||||
IsAccept = Standard_True;
|
||||
}
|
||||
else {
|
||||
if (myLVertex.IsSame(V2)){
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
|
||||
IsAccept = Standard_True;
|
||||
}
|
||||
else {
|
||||
if (myFVertex.IsSame(V2)){
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
||||
IsAccept = Standard_True;
|
||||
}
|
||||
else {
|
||||
if (myFVertex.IsSame(V1)){
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4);
|
||||
IsAccept = Standard_True;
|
||||
}
|
||||
else myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAccept){
|
||||
SetNb(theObj);
|
||||
myStop = Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
else myStop = Standard_False;
|
||||
}
|
||||
|
||||
else{
|
||||
gp_Pnt p1 = BRep_Tool::Pnt(V1);
|
||||
gp_Pnt p2 = BRep_Tool::Pnt(V2);
|
||||
|
||||
Standard_Real tailhead, tailtail, headhead, headtail;
|
||||
tailhead = p1.Distance(myLPnt);
|
||||
tailtail = p2.Distance(myLPnt);
|
||||
headhead = p1.Distance(myFPnt);
|
||||
headtail = p2.Distance(myFPnt);
|
||||
Standard_Real dm1 = tailhead, dm2 = headtail;
|
||||
Standard_Integer res1 = 0, res2 = 0;
|
||||
if (tailhead > tailtail) {res1 = 1; dm1 = tailtail;}
|
||||
if (headtail > headhead) {res2 = 1; dm2 = headhead;}
|
||||
Standard_Integer result = res1;
|
||||
Standard_Real min3d;
|
||||
min3d = Min (dm1, dm2);
|
||||
if (min3d > myMin3d)
|
||||
return Standard_False;
|
||||
|
||||
myMin3d = min3d;
|
||||
if (min3d > myTol)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
SetNb(theObj);
|
||||
|
||||
if (min3d == 0)
|
||||
myStop = Standard_True;
|
||||
|
||||
if (dm1 > dm2)
|
||||
{
|
||||
dm1 = dm2;
|
||||
result = res2 + 2;
|
||||
}
|
||||
|
||||
|
||||
switch (result) {
|
||||
case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
||||
case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
||||
case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
|
||||
case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
92
src/ShapeAnalysis/ShapeAnalysis_BoxBndTree.hxx
Executable file
92
src/ShapeAnalysis/ShapeAnalysis_BoxBndTree.hxx
Executable file
@@ -0,0 +1,92 @@
|
||||
// File: ShapeAnalysis_BoxBndTree.hxx
|
||||
// Created: 14.02.05 12:38:56
|
||||
// Author: Alexey MORENOV
|
||||
// Copyright: Open CASCADE 2005
|
||||
|
||||
#ifndef ShapeAnalysis_BoxBndTree_HeaderFile
|
||||
#define ShapeAnalysis_BoxBndTree_HeaderFile
|
||||
|
||||
#include <NCollection_UBTree.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <TopTools_HArray1OfShape.hxx>
|
||||
|
||||
#include <ShapeExtend.hxx>
|
||||
#include <ShapeExtend_Status.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
|
||||
typedef NCollection_UBTree <Standard_Integer , Bnd_Box> ShapeAnalysis_BoxBndTree;
|
||||
|
||||
class ShapeAnalysis_BoxBndTreeSelector
|
||||
: public ShapeAnalysis_BoxBndTree::Selector
|
||||
{
|
||||
public:
|
||||
ShapeAnalysis_BoxBndTreeSelector
|
||||
(Handle (TopTools_HArray1OfShape) theSeq,
|
||||
Standard_Boolean theShared)
|
||||
: mySeq(theSeq), myShared(theShared), myNb(0), myTol(1e-7), myMin3d(1e-7),
|
||||
myStatus(ShapeExtend::EncodeStatus (ShapeExtend_OK)){}
|
||||
|
||||
void DefineBoxes (const Bnd_Box& theFBox, const Bnd_Box& theLBox)
|
||||
{ myFBox = theFBox;
|
||||
myLBox = theLBox; }
|
||||
|
||||
void DefineVertexes (TopoDS_Vertex theVf, TopoDS_Vertex theVl)
|
||||
{ myFVertex = theVf;
|
||||
myLVertex = theVl;
|
||||
myStatus=ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
}
|
||||
|
||||
void DefinePnt (gp_Pnt theFPnt, gp_Pnt theLPnt)
|
||||
{ myFPnt = theFPnt;
|
||||
myLPnt = theLPnt;
|
||||
myStatus =ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
}
|
||||
|
||||
Standard_Integer GetNb ()
|
||||
{ return myNb; }
|
||||
|
||||
void SetNb (Standard_Integer theNb)
|
||||
{ myNb = theNb; }
|
||||
|
||||
void LoadList(Standard_Integer elem)
|
||||
{ myList.Add(elem); }
|
||||
|
||||
void SetStop ()
|
||||
{ myStop = Standard_False; }
|
||||
|
||||
void SetTolerance (Standard_Real theTol)
|
||||
{
|
||||
myTol = theTol;
|
||||
myMin3d = theTol;
|
||||
myStatus=ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
}
|
||||
|
||||
Standard_Boolean ContWire(Standard_Integer nbWire)
|
||||
{ return myList.Contains(nbWire); }
|
||||
|
||||
inline Standard_Boolean LastCheckStatus (const ShapeExtend_Status Status) const
|
||||
{ return ShapeExtend::DecodeStatus ( myStatus, Status ); }
|
||||
|
||||
Standard_Boolean Reject (const Bnd_Box& theBnd) const;
|
||||
Standard_Boolean Accept (const Standard_Integer &);
|
||||
|
||||
private:
|
||||
Bnd_Box myFBox;
|
||||
Bnd_Box myLBox;
|
||||
Handle (TopTools_HArray1OfShape) mySeq;
|
||||
Standard_Boolean myShared;
|
||||
Standard_Integer myStatus;
|
||||
Standard_Integer myNb;
|
||||
TopoDS_Vertex myFVertex;
|
||||
TopoDS_Vertex myLVertex;
|
||||
gp_Pnt myFPnt;
|
||||
gp_Pnt myLPnt;
|
||||
TColStd_MapOfInteger myList;
|
||||
Standard_Real myTol;
|
||||
Standard_Real myMin3d;
|
||||
};
|
||||
|
||||
#endif
|
203
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cdl
Executable file
203
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cdl
Executable file
@@ -0,0 +1,203 @@
|
||||
-- File: ShapeAnalysis_CheckSmallFace.cdl
|
||||
-- Created: Mon Sep 13 10:19:37 1999
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class CheckSmallFace from ShapeAnalysis
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Face from TopoDS,
|
||||
Pnt from gp,
|
||||
Edge from TopoDS,
|
||||
Compound from TopoDS,
|
||||
DataMapOfShapeShape from TopTools,
|
||||
DataMapOfShapeListOfReal from ShapeAnalysis,
|
||||
DataMapOfShapeListOfShape from TopTools,
|
||||
Status from ShapeExtend
|
||||
|
||||
is
|
||||
Create returns CheckSmallFace from ShapeAnalysis;
|
||||
---Purpose :Creates an empty tool
|
||||
|
||||
|
||||
-- CheckShape (me : in out; S : Shape from TopoDS);
|
||||
---Purpose : Checks a Shape i.e. each of its faces, records checks as
|
||||
-- diagnostics in the <infos>
|
||||
--
|
||||
-- If <infos> has not been set before, no check is done
|
||||
--
|
||||
-- For faces which are in a Shell, topological data are recorded
|
||||
-- to allow recovering connectivities after fixing or removing
|
||||
-- the small faces or parts of faces
|
||||
|
||||
-- CheckFace (me : in out; F : Face from TopoDS; inshell : Boolean);
|
||||
---Purpose : Enchains various checks on a face
|
||||
-- inshell : to compute more informations, relevant to topology
|
||||
|
||||
|
||||
IsSpotFace (me; F : Face from TopoDS;
|
||||
spot : out Pnt from gp; spotol : out Real;
|
||||
tol : Real = -1.0) returns Integer;
|
||||
---Purpose : Checks if a Face is as a Spot
|
||||
-- Returns 0 if not, 1 if yes, 2 if yes and all vertices are the
|
||||
-- same
|
||||
-- By default, considers the tolerance zone of its vertices
|
||||
-- A given value <tol> may be given to check a spot of this size
|
||||
-- If a Face is a Spot, its location is returned in <spot>, and
|
||||
-- <spotol> returns an equivalent tolerance, which is computed as
|
||||
-- half of max dimension of min-max box of the face
|
||||
|
||||
CheckSpotFace (me : in out; F : Face from TopoDS; tol : Real = -1.0) returns Boolean;
|
||||
---Purpose : Acts as IsSpotFace, but records in <infos> a diagnostic
|
||||
-- "SpotFace" with the Pnt as value (data "Location")
|
||||
|
||||
IsStripSupport (me: in out; F : Face; tol : Real = -1.0) returns Boolean;
|
||||
---Purpose : Checks if a Face lies on a Surface which is a strip
|
||||
-- So the Face is a strip. But a Face may be a strip elsewhere ..
|
||||
--
|
||||
-- A given value <tol> may be given to check max width
|
||||
-- By default, considers the tolerance zone of its edges
|
||||
-- Returns 0 if not a strip support, 1 strip in U, 2 strip in V
|
||||
|
||||
CheckStripEdges (me; E1, E2 : Edge from TopoDS; tol : Real;
|
||||
dmax : out Real) returns Boolean;
|
||||
---Purpose : Checks if two edges define a strip, i.e. distance maxi below
|
||||
-- tolerance, given or some of those of E1 and E2
|
||||
|
||||
FindStripEdges (me: in out; F : Face from TopoDS;
|
||||
E1, E2 : out Edge from TopoDS; tol : Real;dmax : out Real) returns Boolean;
|
||||
---Purpose : Searchs for two and only two edges up tolerance
|
||||
-- Returns True if OK, false if not 2 edges
|
||||
-- If True, returns the two edges and their maximum distance
|
||||
|
||||
|
||||
CheckSingleStrip (me : in out; F : Face from TopoDS; E1,E2 : in out Edge from TopoDS;tol : Real = -1.0)
|
||||
returns Boolean;
|
||||
---Purpose : Checks if a Face is a single strip, i.e. brings two great
|
||||
-- edges which are confused on their whole length, possible other
|
||||
-- edges are small or null length
|
||||
--
|
||||
-- Returns 0 if not a strip support, 1 strip in U, 2 strip in V
|
||||
-- Records diagnostic in info if it is a single strip
|
||||
|
||||
|
||||
CheckStripFace (me : in out; F : Face from TopoDS;E1,E2 : in out Edge from TopoDS; tol : Real = -1.0)
|
||||
returns Boolean;
|
||||
---Purpose : Checks if a Face is as a Strip
|
||||
-- Returns 0 if not or non determined, 1 if in U, 2 if in V
|
||||
-- By default, considers the tolerance zone of its edges
|
||||
-- A given value <tol> may be given to check a strip of max this width
|
||||
--
|
||||
-- If a Face is determined as a Strip, it is delinited by two
|
||||
-- lists of edges. These lists are recorded in diagnostic
|
||||
-- Diagnostic "StripFace" brings data "Direction" (U or V),
|
||||
-- "List1" , "List2" (if they could be computed)
|
||||
|
||||
|
||||
CheckSplittingVertices (me : in out; F : Face from TopoDS; MapEdges :in out DataMapOfShapeListOfShape from TopTools;
|
||||
MapParam :in out DataMapOfShapeListOfReal from ShapeAnalysis; theAllVert : in out Compound from TopoDS) returns Integer;
|
||||
---Purpose : Checks if a Face brings vertices which split it, either
|
||||
-- confused with non adjacent vertices, or confused with their
|
||||
-- projection on non adjacent edges
|
||||
-- Returns the count of found splitting vertices
|
||||
-- Each vertex then brings a diagnostic "SplittingVertex",
|
||||
-- with data : "Face" for the face, "Edge" for the split edge
|
||||
|
||||
|
||||
CheckPin (me : in out; F : Face from TopoDS; whatrow,sence : in out Integer) returns Boolean;
|
||||
---Purpose : Checks if a Face has a pin, which can be edited
|
||||
-- No singularity : no pin, returns 0
|
||||
-- If there is a pin, checked topics, with returned value :
|
||||
-- - 0 : nothing to do more
|
||||
-- - 1 : "smooth", i.e. not a really sharp pin
|
||||
-- -> diagnostic "SmoothPin"
|
||||
-- - 2 : stretched pin, i.e. is possible to relimit the face by
|
||||
-- another vertex, so that this vertex still gives a pin
|
||||
-- -> diagnostic "StretchedPin" with location of vertex (Pnt)
|
||||
|
||||
CheckTwisted (me : in out; F : Face from TopoDS; paramu,paramv : in out Real) returns Boolean;
|
||||
---Purpose : Checks if a Face is twisted (apart from checking Pin, i.e. it
|
||||
-- does not give information on pin, only "it is twisted")
|
||||
|
||||
CheckPinFace(me : in out; F : Face from TopoDS;mapEdges : in out DataMapOfShapeShape from TopTools;toler : Real = -1.0) returns Boolean;
|
||||
|
||||
CheckPinEdges(me; theFirstEdge: Edge from TopoDS;theSecondEdge: Edge from TopoDS; coef1,coef2 : Real;toler : Real) returns Boolean;
|
||||
|
||||
Status (me; status: Status from ShapeExtend) returns Boolean;
|
||||
---Purpose: Returns the status of last call to Perform()
|
||||
-- ShapeExtend_OK : face was OK, nothing done
|
||||
-- ShapeExtend_DONE1: some wires are fixed
|
||||
-- ShapeExtend_DONE2: orientation of wires fixed
|
||||
-- ShapeExtend_DONE3: missing seam added
|
||||
-- ShapeExtend_DONE4: small area wire removed
|
||||
-- ShapeExtend_DONE5: natural bounds added
|
||||
-- ShapeExtend_FAIL1: some fails during fixing wires
|
||||
-- ShapeExtend_FAIL2: cannot fix orientation of wires
|
||||
-- ShapeExtend_FAIL3: cannot add missing seam
|
||||
-- ShapeExtend_FAIL4: cannot remove small area wire
|
||||
---C++: inline
|
||||
SetTolerance (me : in out; tol : Real);
|
||||
---Purpose : Sets a fixed Tolerance to check small face
|
||||
-- By default, local tolerance zone is considered
|
||||
---C++: inline
|
||||
|
||||
-- SetMaxTolerance (me : in out; tol : Real);
|
||||
---Purpose : Sets a fixed MaxTolerance to check small face
|
||||
---C++: inline
|
||||
|
||||
-- SetMinTolerance (me : in out; tol : Real);
|
||||
---Purpose : Sets a fixed Tolerance to check small face
|
||||
-- By default, local tolerance zone is considered
|
||||
---C++: inline
|
||||
|
||||
-- MaxTolerance (me : in out);
|
||||
---Purpose : Unset fixed tolerance, comes back to local tolerance zones
|
||||
---C++: inline
|
||||
|
||||
-- MinTolerance (me : in out);
|
||||
---Purpose : Unset fixed tolerance, comes back to local tolerance zones
|
||||
---C++: inline
|
||||
|
||||
Tolerance (me) returns Real;
|
||||
---Purpose : Returns the tolerance to check small faces, negative value if
|
||||
-- local tolerances zones are to be considered
|
||||
---C++: inline
|
||||
|
||||
StatusSpot (me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusStrip(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusPin(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusTwisted(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusSplitVert(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusPinFace(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusPinEdges(me; status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
fields
|
||||
|
||||
myComp : Shape from TopoDS;
|
||||
myStatus : Integer; -- error statusis
|
||||
myStatusSpot : Integer;
|
||||
myStatusStrip : Integer;
|
||||
myStatusPin : Integer;
|
||||
myStatusTwisted : Integer;
|
||||
myStatusSplitVert: Integer;
|
||||
myStatusPinFace : Integer;
|
||||
myStatusPinEdges : Integer;
|
||||
myPrecision : Real;
|
||||
|
||||
end CheckSmallFace;
|
923
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx
Executable file
923
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.cxx
Executable file
@@ -0,0 +1,923 @@
|
||||
#include <ShapeAnalysis_CheckSmallFace.ixx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TColStd_ListOfReal.hxx>
|
||||
#include <ShapeExtend.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shell.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
|
||||
#include <ShapeAnalysis_Curve.hxx>
|
||||
//#include <GeomLProp_SLProps.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <Geom_ElementarySurface.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TopTools_Array1OfShape.hxx>
|
||||
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
|
||||
#include <TColgp_SequenceOfXYZ.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
//#include <ShapeFix_Wire.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <TopoDS_Builder.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <GeomLib.hxx>
|
||||
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <ShapeAnalysis_WireOrder.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <ShapeAnalysis_Wire.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
//=======================================================
|
||||
//function : ShapeAnalysis_CheckSmallFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_CheckSmallFace::ShapeAnalysis_CheckSmallFace()
|
||||
{
|
||||
myStatusSpot = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
myStatusStrip = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
myStatusPin = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
myStatusTwisted = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
myStatusSplitVert = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
|
||||
}
|
||||
static void MinMaxPnt
|
||||
(const gp_Pnt& p, Standard_Integer& nb,
|
||||
Standard_Real& minx, Standard_Real& miny, Standard_Real& minz,
|
||||
Standard_Real& maxx, Standard_Real& maxy, Standard_Real& maxz)
|
||||
{
|
||||
Standard_Real x,y,z;
|
||||
p.Coord (x,y,z);
|
||||
if (nb < 1) { minx = maxx = x; miny = maxy = y; minz = maxz = z; }
|
||||
else {
|
||||
if (minx > x) minx = x; if (maxx < x) maxx = x;
|
||||
if (miny > y) miny = y; if (maxy < y) maxy = y;
|
||||
if (minz > z) minz = z; if (maxz < z) maxz = z;
|
||||
}
|
||||
nb ++;
|
||||
}
|
||||
|
||||
static Standard_Boolean MinMaxSmall
|
||||
(const Standard_Real minx, const Standard_Real miny, const Standard_Real minz, const Standard_Real maxx, const Standard_Real maxy, const Standard_Real maxz, const Standard_Real toler)
|
||||
{
|
||||
Standard_Real dx = maxx - minx;
|
||||
Standard_Real dy = maxy - miny;
|
||||
Standard_Real dz = maxz - minz;
|
||||
|
||||
if ((dx > toler && !Precision::IsInfinite (dx)) ||
|
||||
(dy > toler && !Precision::IsInfinite (dy)) ||
|
||||
(dz > toler && !Precision::IsInfinite (dz)))
|
||||
return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSpotFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_CheckSmallFace::IsSpotFace(const TopoDS_Face& F,gp_Pnt& spot,Standard_Real& spotol,const Standard_Real tol) const
|
||||
{
|
||||
|
||||
Standard_Real toler = tol; Standard_Real tolv = tol;
|
||||
// Compute tolerance to get : from greatest tol of vertices
|
||||
// In addition, also computes min-max of vertices
|
||||
// To finally compare mini-max box with tolerance
|
||||
// gka Mar2000 Protection against faces without wires
|
||||
// but they occur due to bugs in the algorithm itself, it needs to be fixed
|
||||
Standard_Boolean isWir = Standard_False;
|
||||
for(TopoDS_Iterator itw(F,Standard_False) ; itw.More();itw.Next()) {
|
||||
if(itw.Value().ShapeType() != TopAbs_WIRE)
|
||||
continue;
|
||||
TopoDS_Wire w1 = TopoDS::Wire(itw.Value());
|
||||
if (!w1.IsNull()) {isWir = Standard_True; break;}
|
||||
}
|
||||
if(!isWir) return Standard_True;
|
||||
Standard_Integer nbv = 0;
|
||||
Standard_Real minx =0 ,miny = 0 ,minz = 0,maxx = Precision::Infinite(), maxy = Precision::Infinite(),maxz = Precision::Infinite();
|
||||
TopoDS_Vertex V0;
|
||||
Standard_Boolean same = Standard_True;
|
||||
for (TopExp_Explorer iv(F,TopAbs_VERTEX); iv.More(); iv.Next()) {
|
||||
TopoDS_Vertex V = TopoDS::Vertex (iv.Current());
|
||||
if (V0.IsNull()) V0 = V;
|
||||
else if (same) { if (!V0.IsSame(V)) same = Standard_False; }
|
||||
|
||||
gp_Pnt pnt = BRep_Tool::Pnt (V);
|
||||
// Standard_Real x,y,z;
|
||||
MinMaxPnt (pnt, nbv, minx,miny,minz, maxx,maxy,maxz);
|
||||
|
||||
if (tol < 0) {
|
||||
tolv = BRep_Tool::Tolerance (V);
|
||||
if (tolv > toler) toler = tolv;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, testing
|
||||
if (!MinMaxSmall(minx,miny,minz,maxx,maxy,maxz,toler)) return 0;
|
||||
|
||||
// All vertices are confused
|
||||
// Check edges (a closed edge may be a non-null length edge !)
|
||||
// By picking intermediate point on each one
|
||||
for (TopExp_Explorer ie(F,TopAbs_EDGE); ie.More(); ie.Next()) {
|
||||
TopoDS_Edge E = TopoDS::Edge (ie.Current());
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) C3D = BRep_Tool::Curve (E,cf,cl);
|
||||
if (C3D.IsNull()) continue;
|
||||
gp_Pnt debut = C3D->Value (cf);
|
||||
gp_Pnt milieu = C3D->Value ( (cf+cl)/2);
|
||||
if (debut.SquareDistance(milieu) > toler*toler) return 0;
|
||||
}
|
||||
|
||||
spot.SetCoord ( (minx+maxx)/2. , (miny+maxy)/2. , (minz+maxz)/2. );
|
||||
spotol = maxx-minx;
|
||||
spotol = Max (spotol, maxy-miny);
|
||||
spotol = Max (spotol, maxz-minz);
|
||||
spotol = spotol/2.;
|
||||
|
||||
return (same ? 2 : 1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSpotFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckSpotFace(const TopoDS_Face& F,const Standard_Real tol)
|
||||
{
|
||||
gp_Pnt spot;
|
||||
Standard_Real spotol;
|
||||
Standard_Integer stat = IsSpotFace (F,spot,spotol,tol);
|
||||
if(!stat) return Standard_False;
|
||||
switch(stat) {
|
||||
case 1: myStatusSpot = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
||||
case 2: myStatusSpot = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
||||
default : break;
|
||||
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsStripSupport
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::IsStripSupport(const TopoDS_Face& F,const Standard_Real tol)
|
||||
{
|
||||
|
||||
Standard_Real toler = tol;
|
||||
if (toler < 0) toler = 1.e-07; // ?? better to compute tolerance zones
|
||||
|
||||
TopLoc_Location loc;
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (F,loc);
|
||||
if (surf.IsNull()) return 0;
|
||||
|
||||
// Checking on poles for bezier-bspline
|
||||
// A more general way is to check Values by scanning ISOS (slower)
|
||||
|
||||
Handle(Geom_BSplineSurface) bs = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
Handle(Geom_BezierSurface) bz = Handle(Geom_BezierSurface)::DownCast(surf);
|
||||
|
||||
// Standard_Integer stat = 2; // 2 : small in V direction
|
||||
if (!bs.IsNull() || !bz.IsNull()) {
|
||||
Standard_Boolean cbz = (!bz.IsNull());
|
||||
Standard_Integer iu,iv, nbu, nbv;
|
||||
if (cbz) { nbu = bz->NbUPoles(), nbv = bz->NbVPoles(); }
|
||||
else { nbu = bs->NbUPoles(), nbv = bs->NbVPoles(); }
|
||||
// Standard_Real dx = 0, dy = 0, dz = 0;
|
||||
// Standard_Real x,y,z;
|
||||
Standard_Real minx,miny,minz,maxx,maxy,maxz;
|
||||
Standard_Boolean issmall = Standard_True;
|
||||
|
||||
for (iu = 1; iu <= nbu; iu ++) {
|
||||
// for each U line, scan poles in V (V direction)
|
||||
Standard_Integer nb = 0;
|
||||
for (iv = 1; iv <= nbv; iv ++) {
|
||||
gp_Pnt unp = (cbz ? bz->Pole(iu,iv) : bs->Pole(iu,iv));
|
||||
MinMaxPnt (unp, nb, minx,miny,minz, maxx,maxy,maxz);
|
||||
}
|
||||
if (!MinMaxSmall(minx,miny,minz,maxx,maxy,maxz,toler))
|
||||
{ issmall = Standard_False; break; } // small in V ?
|
||||
}
|
||||
if (issmall) {
|
||||
myStatusStrip = ShapeExtend::EncodeStatus ( ShapeExtend_DONE2);
|
||||
return issmall; // OK, small in V
|
||||
}
|
||||
issmall = Standard_True;
|
||||
for (iv = 1; iv <= nbv; iv ++) {
|
||||
// for each V line, scan poles in U (U direction)
|
||||
Standard_Integer nb = 0;
|
||||
for (iu = 1; iu <= nbu; iu ++) {
|
||||
gp_Pnt unp = (cbz ? bz->Pole(iu,iv) : bs->Pole(iu,iv));
|
||||
MinMaxPnt (unp, nb, minx,miny,minz, maxx,maxy,maxz);
|
||||
}
|
||||
if (!MinMaxSmall(minx,miny,minz,maxx,maxy,maxz,toler))
|
||||
{ issmall = Standard_False; break; } // small in U ?
|
||||
}
|
||||
if (issmall) {
|
||||
myStatusStrip = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
||||
return issmall;
|
||||
}// OK, small in U
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckStripEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckStripEdges(const TopoDS_Edge& E1,const TopoDS_Edge& E2,const Standard_Real tol,Standard_Real& dmax) const
|
||||
{
|
||||
// We have the topological configuration OK : 2 edges, 2 vertices
|
||||
// But, are these two edges well confused ?
|
||||
Standard_Real toler = tol;
|
||||
if (tol < 0) {
|
||||
Standard_Real tole = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
|
||||
if (toler < tole / 2.) toler = tole/2.;
|
||||
}
|
||||
|
||||
// We project a list of points from each curve, on the opposite one,
|
||||
// we check the distance
|
||||
Standard_Integer nbint = 10;
|
||||
|
||||
ShapeAnalysis_Curve SAC;
|
||||
Standard_Real cf1,cl1,cf2,cl2,u; dmax = 0;
|
||||
Handle(Geom_Curve) C1,C2;
|
||||
C1 = BRep_Tool::Curve (E1,cf1,cl1);
|
||||
C2 = BRep_Tool::Curve (E2,cf2,cl2);
|
||||
if(C1.IsNull() || C2.IsNull()) return Standard_False;
|
||||
cf1 = Max(cf1, C1->FirstParameter());
|
||||
cl1 = Min(cl1, C1->LastParameter());
|
||||
Handle(Geom_TrimmedCurve) C1T = new Geom_TrimmedCurve(C1,cf1,cl1,Standard_True);
|
||||
//pdn protection against feature in Trimmed_Curve
|
||||
cf1 = C1T->FirstParameter();
|
||||
cl1 = C1T->LastParameter();
|
||||
Handle(Geom_TrimmedCurve) CC;
|
||||
cf2 = Max(cf2, C2->FirstParameter());
|
||||
cl2 = Min(cl2, C2->LastParameter());
|
||||
Handle(Geom_TrimmedCurve) C2T = new Geom_TrimmedCurve(C2,cf2,cl2, Standard_True);
|
||||
cf2 = C2T->FirstParameter();
|
||||
cl2 = C2T->LastParameter();
|
||||
|
||||
Standard_Real cd1 = (cl1 - cf1)/nbint;
|
||||
Standard_Real cd2 = (cl2 - cf2)/nbint;
|
||||
Standard_Real f,l;
|
||||
f = cf2; l = cl2;
|
||||
for (int numcur = 0; numcur < 2; numcur ++) {
|
||||
u = cf1;
|
||||
if (numcur) { CC = C1T; C1T = C2T; C2T = CC;
|
||||
cd1 = cd2; //smh added replacing step and replacing first
|
||||
u = cf2; //parameter
|
||||
f = cf1; l = cl1;
|
||||
}
|
||||
for (int nump = 0; nump <= nbint; nump ++) {
|
||||
gp_Pnt p2, p1 = C1T->Value (u);
|
||||
Standard_Real para;
|
||||
//pdn Adaptor curve is used to avoid of enhancing of domain.
|
||||
GeomAdaptor_Curve GAC(C2T);
|
||||
Standard_Real dist = SAC.Project (GAC,p1,toler,p2,para);
|
||||
//pdn check if parameter of projection is in the domain of the edge.
|
||||
if (para < f || para > l) return Standard_False;
|
||||
if (dist > dmax) dmax = dist;
|
||||
if (dist > toler) return Standard_False;
|
||||
u += cd1;
|
||||
}
|
||||
}
|
||||
return (dmax < toler);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindStripEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::FindStripEdges(const TopoDS_Face& F,TopoDS_Edge& E1,TopoDS_Edge& E2,const Standard_Real tol,Standard_Real& dmax)
|
||||
{
|
||||
E1.Nullify(); E2.Nullify();
|
||||
Standard_Integer nb = 0;
|
||||
for (TopExp_Explorer ex(F,TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
TopoDS_Edge E = TopoDS::Edge (ex.Current());
|
||||
TopoDS_Vertex V1,V2;
|
||||
TopExp::Vertices (E,V1,V2);
|
||||
gp_Pnt p1,p2;
|
||||
p1 = BRep_Tool::Pnt (V1);
|
||||
p2 = BRep_Tool::Pnt (V2);
|
||||
Standard_Real toler = tol;
|
||||
if (toler <= 0) toler = (BRep_Tool::Tolerance(V1) + BRep_Tool::Tolerance(V2) ) / 2.;
|
||||
|
||||
// Extremities
|
||||
Standard_Real dist = p1.Distance(p2);
|
||||
// Middle point
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) CC;
|
||||
CC = BRep_Tool::Curve (E,cf,cl);
|
||||
Standard_Boolean isNullLength = Standard_True;
|
||||
if (!CC.IsNull()) {
|
||||
gp_Pnt pp = CC->Value ( (cf+cl)/2.);
|
||||
if (pp.Distance(p1) < toler && pp.Distance(p2) < toler) continue;
|
||||
isNullLength = Standard_False;
|
||||
}
|
||||
if (dist <= toler && isNullLength) continue; //smh
|
||||
nb ++;
|
||||
if (nb == 1) E1 = E;
|
||||
else if (nb == 2) E2 = E;
|
||||
else return Standard_False;
|
||||
}
|
||||
// Now, check these two edge to define a strip !
|
||||
if (!E1.IsNull()&&!E2.IsNull())
|
||||
if(!CheckStripEdges (E1,E2,tol,dmax)) return Standard_False;
|
||||
else {
|
||||
myStatusStrip = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
||||
return Standard_True ;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSingleStrip
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckSingleStrip(const TopoDS_Face& F,
|
||||
TopoDS_Edge& E1, TopoDS_Edge& E2,const Standard_Real tol)
|
||||
{
|
||||
Standard_Real toler = tol;
|
||||
Standard_Real minx,miny,minz,maxx,maxy,maxz;
|
||||
|
||||
// In this case, we have 2 vertices and 2 great edges. Plus possibly 2 small
|
||||
// edges, one on each vertex
|
||||
TopoDS_Vertex V1,V2;
|
||||
Standard_Integer nb = 0;
|
||||
for (TopExp_Explorer itv (F,TopAbs_VERTEX); itv.More(); itv.Next()) {
|
||||
TopoDS_Vertex V = TopoDS::Vertex (itv.Current());
|
||||
if (V1.IsNull()) V1 = V;
|
||||
else if (V1.IsSame(V)) continue;
|
||||
else if (V2.IsNull()) V2 = V;
|
||||
else if (V2.IsSame(V)) continue;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
// Checking edges
|
||||
//TopoDS_Edge E1,E2;
|
||||
nb = 0;
|
||||
for (TopExp_Explorer ite (F,TopAbs_EDGE); ite.More(); ite.Next()) {
|
||||
TopoDS_Edge E = TopoDS::Edge (ite.Current());
|
||||
TopoDS_Vertex VA,VB;
|
||||
TopExp::Vertices (E,VA,VB);
|
||||
if (tol < 0) {
|
||||
Standard_Real tolv;
|
||||
tolv = BRep_Tool::Tolerance (VA);
|
||||
if (toler < tolv) toler = tolv;
|
||||
tolv = BRep_Tool::Tolerance (VB);
|
||||
if (toler < tolv) toler = tolv;
|
||||
}
|
||||
|
||||
// Edge on same vertex : small one ?
|
||||
if (VA.IsSame(VB)) {
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) C3D;
|
||||
if (!BRep_Tool::Degenerated(E)) C3D = BRep_Tool::Curve (E,cf,cl);
|
||||
if (C3D.IsNull()) continue; // DGNR
|
||||
Standard_Integer np = 0;
|
||||
gp_Pnt deb = C3D->Value(cf);
|
||||
MinMaxPnt (deb,np,minx,miny,minz,maxx,maxy,maxz);
|
||||
gp_Pnt fin = C3D->Value(cl);
|
||||
MinMaxPnt (fin,np,minx,miny,minz,maxx,maxy,maxz);
|
||||
gp_Pnt mid = C3D->Value( (cf+cl)/2. );
|
||||
MinMaxPnt (mid,np,minx,miny,minz,maxx,maxy,maxz);
|
||||
if (!MinMaxSmall (minx,miny,minz,maxx,maxy,maxz,toler)) return Standard_False;
|
||||
} else {
|
||||
// Other case : two maximum allowed
|
||||
nb ++;
|
||||
if (nb > 2) return Standard_False;
|
||||
if (nb == 1) { V1 = VA; V2 = VB; E1 = E; }
|
||||
else if (nb == 2) {
|
||||
if (V1.IsSame(VA) && !V2.IsSame(VB)) return Standard_False;
|
||||
if (V1.IsSame(VB) && !V2.IsSame(VA)) return Standard_False;
|
||||
E2 = E;
|
||||
}
|
||||
else return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
if (nb < 2) return Standard_False; // only one vertex : cannot be a strip ...
|
||||
|
||||
// Checking if E1 and E2 define a Strip
|
||||
Standard_Real dmax;
|
||||
if (!CheckStripEdges (E1,E2,tol,dmax)) return Standard_False;
|
||||
myStatusStrip = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckStripFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckStripFace(const TopoDS_Face& F,
|
||||
TopoDS_Edge& E1, TopoDS_Edge& E2,const Standard_Real tol)
|
||||
{
|
||||
|
||||
// Standard_Integer stat;
|
||||
if(CheckSingleStrip (F,E1,E2,tol)) return Standard_True ; // it is a strip
|
||||
|
||||
// IsStripSupport used as rejection. But this kind of test may be done
|
||||
// on ANY face, once we are SURE that FindStripEdges is reliable (and fast
|
||||
// enough)
|
||||
|
||||
// ?? record a diagnostic StripFace, but without yet lists of edges
|
||||
// ?? Record Diagnostic "StripFace", no data (should be "Edges1" "Edges2")
|
||||
// but direction is known (1:U 2:V)
|
||||
// TopoDS_Edge E1,E2;
|
||||
Standard_Real dmax;
|
||||
if(FindStripEdges (F,E1,E2,tol,dmax)) return Standard_True;
|
||||
|
||||
// Now, trying edges : if there are 2 and only 2 edges greater than tolerance
|
||||
// (given or sum of vertex tolerances), do they define a strip
|
||||
// Warning : if yes, they bring different vertices ...
|
||||
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSplittingVertices
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_CheckSmallFace::CheckSplittingVertices(const TopoDS_Face& F,
|
||||
TopTools_DataMapOfShapeListOfShape& MapEdges,
|
||||
ShapeAnalysis_DataMapOfShapeListOfReal& MapParam,
|
||||
TopoDS_Compound& theAllVert)
|
||||
{
|
||||
|
||||
// Prepare array of vertices with their locations //TopTools
|
||||
Standard_Integer nbv = 0, nbp = 0;
|
||||
//TopoDS_Compound theAllVert;
|
||||
BRep_Builder theBuilder;
|
||||
//theBuilder.MakeCompound(theAllVert);
|
||||
TopExp_Explorer itv; // svv Jan11 2000 : porting on DEC
|
||||
for (itv.Init(F,TopAbs_VERTEX); itv.More(); itv.Next()) nbv ++;
|
||||
|
||||
if (nbv == 0) return 0;
|
||||
TopTools_Array1OfShape vtx (1,nbv);
|
||||
TColgp_Array1OfPnt vtp (1,nbv);
|
||||
TColStd_Array1OfReal vto (1,nbv);
|
||||
|
||||
nbp = 0;
|
||||
for (itv.Init(F,TopAbs_VERTEX); itv.More(); itv.Next()) {
|
||||
nbp ++;
|
||||
TopoDS_Vertex unv = TopoDS::Vertex (itv.Current());
|
||||
vtx.SetValue (nbp,unv);
|
||||
gp_Pnt unp = BRep_Tool::Pnt (unv);
|
||||
vtp.SetValue (nbp,unp);
|
||||
Standard_Real unt = myPrecision;
|
||||
if (unt < 0) unt =BRep_Tool::Tolerance (unv);
|
||||
vto.SetValue (nbp,unt);
|
||||
}
|
||||
nbv = nbp; nbp = 0; // now, counting splitting vertices
|
||||
|
||||
// Check edges : are vertices (other than extremities) confused with it ?
|
||||
ShapeAnalysis_Curve SAC;
|
||||
for (Standard_Integer iv = 1; iv <= nbv; iv ++) {
|
||||
TopoDS_Vertex V = TopoDS::Vertex (vtx.Value(iv));
|
||||
TopTools_ListOfShape listEdge;
|
||||
TColStd_ListOfReal listParam;
|
||||
Standard_Boolean issplit = Standard_False;
|
||||
for (TopExp_Explorer ite(F,TopAbs_EDGE); ite.More(); ite.Next()) {
|
||||
TopoDS_Edge E = TopoDS::Edge (ite.Current());
|
||||
TopoDS_Vertex V1,V2;
|
||||
TopExp::Vertices (E,V1,V2);
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) C3D = BRep_Tool::Curve (E,cf,cl);
|
||||
if (C3D.IsNull()) continue;
|
||||
if (V.IsSame(V1) || V.IsSame(V2)) continue;
|
||||
gp_Pnt unp = vtp.Value(iv);
|
||||
Standard_Real unt = vto.Value(iv);
|
||||
gp_Pnt proj;
|
||||
Standard_Real param;
|
||||
Standard_Real dist = SAC.Project (C3D,unp,unt*10.,proj,param,cf,cl);
|
||||
if (dist == 0.0) continue; //smh
|
||||
// Splitting Vertex to record ?
|
||||
if (dist < unt) {
|
||||
// If Split occurs at beginning or end, it is not a split ...
|
||||
Standard_Real fpar, lpar, eps = 1.e-06;
|
||||
if (param >=cl || param <= cf) continue; // Out of range
|
||||
fpar = param - cf; lpar = param - cl;
|
||||
if ((Abs(fpar) < eps) || (Abs(lpar) < eps)) continue; // Near end or start
|
||||
listEdge.Append(E);
|
||||
listParam.Append(param);
|
||||
issplit = Standard_True;
|
||||
|
||||
}
|
||||
}
|
||||
if(issplit) {
|
||||
nbp ++;
|
||||
theBuilder.Add(theAllVert, V);
|
||||
MapEdges.Bind(V,listEdge);
|
||||
MapParam.Bind(V,listParam);
|
||||
}
|
||||
}
|
||||
if(nbp != 0)
|
||||
myStatusSplitVert = ShapeExtend::EncodeStatus (ShapeExtend_DONE);
|
||||
return nbp;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Integer IsoStat
|
||||
(const TColgp_Array2OfPnt& poles,
|
||||
const Standard_Integer uorv, const Standard_Integer rank,
|
||||
const Standard_Real tolpin, const Standard_Real toler)
|
||||
{
|
||||
Standard_Integer i, np = 0;
|
||||
Standard_Integer i0 = (uorv == 1 ? poles.LowerCol() : poles.LowerRow());
|
||||
Standard_Integer i1 = (uorv == 1 ? poles.UpperCol() : poles.UpperRow());
|
||||
Standard_Real xmin,ymin,zmin, xmax,ymax,zmax;
|
||||
for (i = i0; i <= i1; i ++) {
|
||||
if (uorv == 1) MinMaxPnt (poles(rank,i),np,xmin,ymin,zmin, xmax,ymax,zmax);
|
||||
else MinMaxPnt (poles(i,rank), np, xmin,ymin,zmin, xmax,ymax,zmax);
|
||||
}
|
||||
if (MinMaxSmall (xmin,ymin,zmin, xmax,ymax,zmax, tolpin)) return 0;
|
||||
if (MinMaxSmall (xmin,ymin,zmin, xmax,ymax,zmax, toler)) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
static Standard_Boolean CheckPoles(const TColgp_Array2OfPnt& poles, Standard_Integer uorv, Standard_Integer rank)
|
||||
{
|
||||
Standard_Integer i0 = (uorv == 1 ? poles.LowerCol() : poles.LowerRow());
|
||||
Standard_Integer i1 = (uorv == 1 ? poles.UpperCol() : poles.UpperRow());
|
||||
for (Standard_Integer i = i0; i <= i1-1; i ++) {
|
||||
if (uorv == 1) if(poles(rank,i).IsEqual(poles(rank, i+1), 1e-15)) return Standard_True;
|
||||
else if(poles(i,rank).IsEqual(poles(i+1,rank), 1e-15)) return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : CheckPin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckPin (const TopoDS_Face& F, Standard_Integer& whatrow,Standard_Integer& sens)
|
||||
{
|
||||
TopLoc_Location loc;
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (F,loc);
|
||||
if (surf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) return Standard_False;
|
||||
|
||||
Standard_Real toler = myPrecision;
|
||||
if (toler < 0) toler = 1.e-4;
|
||||
Standard_Real tolpin = 1.e-9; // for sharp sharp pin
|
||||
|
||||
// Checking the poles
|
||||
|
||||
// Take the poles : they give good idea of sharpness of a pin
|
||||
Standard_Integer nbu = 0 , nbv = 0;
|
||||
Handle(Geom_BSplineSurface) bs = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
Handle(Geom_BezierSurface) bz = Handle(Geom_BezierSurface)::DownCast(surf);
|
||||
if (!bs.IsNull()) { nbu = bs->NbUPoles(); nbv = bs->NbVPoles(); }
|
||||
if (!bz.IsNull()) { nbu = bz->NbUPoles(); nbv = bz->NbVPoles(); }
|
||||
if (nbu == 0 || nbv == 0) return Standard_False;
|
||||
|
||||
TColgp_Array2OfPnt allpoles (1,nbu,1,nbv);
|
||||
if (!bs.IsNull()) bs->Poles (allpoles);
|
||||
if (!bz.IsNull()) bz->Poles (allpoles);
|
||||
|
||||
// Check each natural bound if it is a singularity (i.e. a pin)
|
||||
|
||||
sens = 0;
|
||||
Standard_Integer stat = 0; // 0 none, 1 in U, 2 in V
|
||||
whatrow = 0; // 0 no row, else rank of row
|
||||
stat = IsoStat(allpoles,1, 1,tolpin,toler);
|
||||
if (stat) { sens = 1; whatrow = nbu; }
|
||||
|
||||
stat = IsoStat(allpoles,1,nbu,tolpin,toler);
|
||||
if (stat) { sens = 1; whatrow = nbu; }
|
||||
|
||||
stat = IsoStat(allpoles,2, 1,tolpin,toler);
|
||||
if (stat) { sens = 2; whatrow = 1; }
|
||||
|
||||
stat = IsoStat(allpoles,2,nbv,tolpin,toler);
|
||||
if (stat) { sens = 2; whatrow = nbv; }
|
||||
|
||||
if (!sens) return Standard_False; // no pin
|
||||
|
||||
switch(stat) {
|
||||
case 1: myStatusPin = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
||||
case 2: myStatusPin = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
||||
default : break;
|
||||
}
|
||||
// cout<<(whatstat == 1 ? "Smooth" : "Sharp")<<" Pin on "<<(sens == 1 ? "U" : "V")<<" Row n0 "<<whatrow<<endl;
|
||||
if (stat == 1 )
|
||||
{
|
||||
// Standard_Boolean EqualPoles = Standard_False;
|
||||
if(CheckPoles(allpoles, 2, nbv)|| CheckPoles(allpoles, 2, 1)
|
||||
||CheckPoles(allpoles, 1, nbu)|| CheckPoles(allpoles, 1, 1))
|
||||
myStatusPin = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
||||
}
|
||||
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
static Standard_Real TwistedNorm
|
||||
(const Standard_Real x1, const Standard_Real y1, const Standard_Real z1, const Standard_Real x2, const Standard_Real y2, const Standard_Real z2)
|
||||
{ return (x1*x2) + (y1*y2) + (z1*z2); }
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckTwisted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckTwisted (const TopoDS_Face& F, Standard_Real& paramu,
|
||||
Standard_Real& paramv)
|
||||
{
|
||||
TopLoc_Location loc;
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (F,loc);
|
||||
if (surf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) return Standard_False;
|
||||
|
||||
Standard_Real toler = myPrecision;
|
||||
if (toler < 0) toler = 1.e-4;
|
||||
//// GeomLProp_SLProps GLS (surf,2,toler);
|
||||
GeomAdaptor_Surface GAS (surf);
|
||||
|
||||
// to be done : on isos of the surface
|
||||
// and on edges, at least of outer wire
|
||||
Standard_Integer nbint = 5;
|
||||
TColStd_Array2OfReal nx (1,nbint+1,1,nbint+1);
|
||||
TColStd_Array2OfReal ny (1,nbint+1,1,nbint+1);
|
||||
TColStd_Array2OfReal nz (1,nbint+1,1,nbint+1);
|
||||
Standard_Integer iu,iv;
|
||||
Standard_Real umin,umax,vmin,vmax;
|
||||
surf->Bounds (umin,umax,vmin,vmax);
|
||||
Standard_Real u = umin, du = (umax-umin)/nbint;
|
||||
Standard_Real v = vmin, dv = (umax-umin)/nbint;
|
||||
|
||||
// gp_Dir norm;
|
||||
for (iu = 1; iu <= nbint; iu ++) {
|
||||
for (iv = 1; iv <= nbint; iv ++) {
|
||||
// GLS.SetParameters (u,v);
|
||||
// if (GLS.IsNormalDefined()) norm = GLS.Normal();
|
||||
gp_Pnt curp; gp_Vec V1,V2,VXnorm;
|
||||
GAS.D1 (u,v,curp,V1,V2);
|
||||
VXnorm = V1.Crossed(V2);
|
||||
nx.SetValue (iu,iv,VXnorm.X());
|
||||
ny.SetValue (iu,iv,VXnorm.Y());
|
||||
nz.SetValue (iu,iv,VXnorm.Z());
|
||||
v += dv;
|
||||
}
|
||||
u += du;
|
||||
v = vmin;
|
||||
}
|
||||
|
||||
// Now, comparing normals on support surface, in both senses
|
||||
// In principle, it suffuces to check within outer bound
|
||||
|
||||
for (iu = 1; iu < nbint; iu ++) {
|
||||
for (iv = 1; iv < nbint; iv ++) {
|
||||
// We here check each normal (iu,iv) with (iu,iv+1) and with (iu+1,iv)
|
||||
// if for each test, we have negative scalar product, this means angle > 90deg
|
||||
// it is the criterion to say it is twisted
|
||||
if (TwistedNorm ( nx(iu,iv),ny(iu,iv),nz(iu,iv) , nx(iu,iv+1),ny(iu,iv+1),nz(iu,iv+1) ) < 0. ||
|
||||
TwistedNorm ( nx(iu,iv),ny(iu,iv),nz(iu,iv) , nx(iu+1,iv),ny(iu+1,iv),nz(iu+1,iv) ) < 0. ) {
|
||||
myStatusTwisted = ShapeExtend::EncodeStatus (ShapeExtend_DONE);
|
||||
paramu = umin+du*iu-du/2;
|
||||
paramv = vmin+dv*iv-dv/2;
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now, comparing normals on edges ... to be done
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckPinFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Warning: This function not tested on many examples
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckPinFace(const TopoDS_Face& F,
|
||||
TopTools_DataMapOfShapeShape& mapEdges,const Standard_Real toler)
|
||||
{
|
||||
//ShapeFix_Wire sfw;
|
||||
TopExp_Explorer exp_w (F,TopAbs_WIRE);
|
||||
exp_w.More();
|
||||
Standard_Real coef1=0, coef2; // =0 for deleting warning (skl)
|
||||
TopoDS_Wire theCurWire = TopoDS::Wire (exp_w.Current());
|
||||
ShapeAnalysis_WireOrder wi;
|
||||
ShapeAnalysis_Wire sfw;
|
||||
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData(theCurWire);
|
||||
sfw.Load(sbwd);
|
||||
sfw.CheckOrder(wi);
|
||||
Handle(TopTools_HSequenceOfShape) newedges = new TopTools_HSequenceOfShape();
|
||||
Standard_Integer nb = wi.NbEdges();
|
||||
Standard_Integer i = 0;
|
||||
for ( i=1; i <= nb; i++ )
|
||||
newedges->Append ( sbwd->Edge ( wi.Ordered(i) ) );
|
||||
for ( i=1; i <= nb; i++ )
|
||||
sbwd->Set ( TopoDS::Edge ( newedges->Value(i) ), i );
|
||||
//sfw.Init(theCurWire, F, Precision::Confusion());
|
||||
//sfw.FixReorder();
|
||||
//theCurWire = sfw.Wire();
|
||||
theCurWire = sbwd->Wire();
|
||||
i=1;
|
||||
Standard_Boolean done = Standard_False;
|
||||
Standard_Real tol = Precision::Confusion();
|
||||
TopoDS_Edge theFirstEdge, theSecondEdge;
|
||||
Standard_Real d1=0,d2=0;
|
||||
for (TopExp_Explorer exp_e (F,TopAbs_EDGE); exp_e.More(); exp_e.Next())
|
||||
{
|
||||
TopoDS_Vertex V1,V2;
|
||||
gp_Pnt p1, p2;
|
||||
if (i==1)
|
||||
{
|
||||
theFirstEdge = TopoDS::Edge (exp_e.Current());
|
||||
V1 = TopExp::FirstVertex(theFirstEdge);
|
||||
V2 = TopExp::LastVertex(theFirstEdge);
|
||||
p1 = BRep_Tool::Pnt(V1);
|
||||
p2 = BRep_Tool::Pnt(V2);
|
||||
tol = Max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2));
|
||||
if (toler > 0) //tol = Max(tol, toler); gka
|
||||
tol = toler;
|
||||
d1 = p1.Distance(p2);
|
||||
if (d1 == 0) return Standard_False;
|
||||
if (d1/tol>=1) coef1 = d1/tol; else continue;
|
||||
if (coef1<=3) continue;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
//Check the length of edge
|
||||
theSecondEdge = TopoDS::Edge (exp_e.Current());
|
||||
V1 = TopExp::FirstVertex(theSecondEdge);
|
||||
V2 = TopExp::LastVertex(theSecondEdge);
|
||||
|
||||
p1 = BRep_Tool::Pnt(V1);
|
||||
p2 = BRep_Tool::Pnt(V2);
|
||||
if (toler == -1) tol = Max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2));
|
||||
else tol= toler;
|
||||
if (p1.Distance(p2)> tol) continue;
|
||||
//If there are two pin edges, record them in diagnostic
|
||||
d2 = p1.Distance(p2); //gka
|
||||
if (d2 == 0) return Standard_False;
|
||||
if (d2/tol >= 1) coef2 = d2/tol; else continue;
|
||||
if (coef2<=3) continue;
|
||||
if (coef1>coef2*10) continue;
|
||||
if (coef2>coef1*10)
|
||||
{
|
||||
theFirstEdge = theSecondEdge;
|
||||
coef1 = coef2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CheckPinEdges(theFirstEdge, theSecondEdge, coef1, coef2,toler))
|
||||
{
|
||||
mapEdges.Bind(theFirstEdge,theSecondEdge);
|
||||
myStatusPinFace = ShapeExtend::EncodeStatus (ShapeExtend_DONE);
|
||||
done = Standard_True;
|
||||
}
|
||||
|
||||
theFirstEdge = theSecondEdge;
|
||||
coef1 = coef2;
|
||||
//d1 = d2;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckPinEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
// Warning: This function not tested on many examples
|
||||
|
||||
Standard_Boolean ShapeAnalysis_CheckSmallFace::CheckPinEdges(const TopoDS_Edge& theFirstEdge,const TopoDS_Edge& theSecondEdge,const Standard_Real coef1,
|
||||
const Standard_Real coef2,const Standard_Real toler) const
|
||||
{
|
||||
|
||||
Standard_Real cf1,cl1,cf2,cl2;
|
||||
Handle(Geom_Curve) C1,C2,C3;
|
||||
C1 = BRep_Tool::Curve (theFirstEdge,cf1,cl1);
|
||||
C2 = BRep_Tool::Curve (theSecondEdge,cf2,cl2);
|
||||
gp_Pnt p1, p2, pp1, pp2, pv;
|
||||
Standard_Real d1 = (cf1-cl1)/coef1;
|
||||
Standard_Real d2 = (cf2-cl2)/coef2;
|
||||
//Standard_Real d1 = cf1-cl1/30; //10; gka
|
||||
//Standard_Real d2 = cf2-cl2/30; //10;
|
||||
p1 = C1->Value(cf1);
|
||||
p2 = C1->Value(cl1);
|
||||
pp1 = C2->Value(cf2);
|
||||
pp2 = C2->Value(cl2);
|
||||
Standard_Real tol;
|
||||
Standard_Real paramc1=0, paramc2=0; // =0 for deleting warning (skl)
|
||||
TopoDS_Vertex theSharedV = TopExp::LastVertex(theFirstEdge);
|
||||
if (toler == -1) tol = BRep_Tool::Tolerance(theSharedV); else tol = toler;
|
||||
pv = BRep_Tool::Pnt(theSharedV);
|
||||
if (pv.Distance(p1)<=tol) paramc1 = cf1;
|
||||
else if(pv.Distance(p2)<=tol) paramc1 = cl1;
|
||||
if (pv.Distance(pp1)<=tol) paramc2 = cf2;
|
||||
else if(pv.Distance(pp2)<=tol) paramc2 = cl2;
|
||||
//Computing first derivative vectors and compare angle
|
||||
// gp_Vec V11, V12, V21, V22;
|
||||
// gp_Pnt tmp;
|
||||
// C1->D2(paramc1, tmp, V11, V21);
|
||||
// C2->D2(paramc2, tmp, V12, V22);
|
||||
// Standard_Real angle1, angle2;
|
||||
// try{
|
||||
// angle1 = V11.Angle(V12);
|
||||
// angle2 = V21.Angle(V22);
|
||||
// }
|
||||
// catch (Standard_Failure)
|
||||
// {
|
||||
// cout << "Couldn't compute angle between derivative vectors" <<endl;
|
||||
// return Standard_False;
|
||||
// }
|
||||
// cout << "angle1 " << angle1<< endl;
|
||||
// cout << "angle2 " << angle2<< endl;
|
||||
// if (angle1<=0.0001) return Standard_True;
|
||||
gp_Pnt proj;
|
||||
if (p1.Distance(p2)<pp1.Distance(pp2))
|
||||
{
|
||||
C3=C1;
|
||||
if (paramc1==cf1)
|
||||
proj = C1->Value(paramc1 + (coef1-3)*d1);
|
||||
else proj = C1->Value(paramc1-3*d1);
|
||||
//proj = C1->Value(paramc1 + 9*d1);
|
||||
//else proj = C1->Value(paramc1-d1);
|
||||
}
|
||||
else
|
||||
{
|
||||
C3=C2;
|
||||
if (paramc2==cf2)
|
||||
proj = C2->Value(paramc2 + (coef2-3)*d2);
|
||||
else proj = C2->Value(paramc2 -3*d2);
|
||||
//proj = C2->Value(paramc2 + 9*d2);
|
||||
//else proj = C2->Value(paramc2 -d2);
|
||||
}
|
||||
Standard_Real param;
|
||||
GeomAdaptor_Curve GAC(C3);
|
||||
Standard_Real f = C3->FirstParameter();
|
||||
Standard_Real l = C3->LastParameter();
|
||||
gp_Pnt result;
|
||||
ShapeAnalysis_Curve SAC;
|
||||
Standard_Real dist = SAC.Project (GAC,proj,tol,result,param);
|
||||
//pdn check if parameter of projection is in the domain of the edge.
|
||||
if (param < f || param > l) return Standard_False;
|
||||
if (dist > tol) return Standard_False;
|
||||
if (dist <= tol) {
|
||||
//Computing first derivative vectors and compare angle
|
||||
gp_Vec V11, V12, V21, V22;
|
||||
gp_Pnt tmp;
|
||||
C1->D2(paramc1, tmp, V11, V21);
|
||||
C2->D2(paramc2, tmp, V12, V22);
|
||||
Standard_Real angle1=0, angle2=0;
|
||||
try{
|
||||
angle1 = V11.Angle(V12);
|
||||
angle2 = V21.Angle(V22);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
cout << "Couldn't compute angle between derivative vectors" <<endl;
|
||||
return Standard_False;
|
||||
}
|
||||
// cout << "angle1 " << angle1<< endl;
|
||||
// cout << "angle2 " << angle2<< endl;
|
||||
if ((angle1<=0.001 && angle2<=0.01) || ((PI-angle2)<= 0.001 && (PI-angle2)<= 0.01)) return Standard_True;
|
||||
else return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
61
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.lxx
Executable file
61
src/ShapeAnalysis/ShapeAnalysis_CheckSmallFace.lxx
Executable file
@@ -0,0 +1,61 @@
|
||||
#include <ShapeExtend.hxx>
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::Status(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatus, status );
|
||||
}
|
||||
|
||||
|
||||
inline void ShapeAnalysis_CheckSmallFace::SetTolerance(const Standard_Real tol)
|
||||
{
|
||||
myPrecision = tol;
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Real ShapeAnalysis_CheckSmallFace::Tolerance() const
|
||||
{
|
||||
return myPrecision;
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusSpot(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusSpot, status );
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusStrip(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusStrip, status );
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusPin(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusPin, status );
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusTwisted(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusTwisted, status );
|
||||
|
||||
}
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusPinFace(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusPinFace, status );
|
||||
|
||||
}
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusPinEdges(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusPinEdges, status );
|
||||
|
||||
}
|
||||
inline Standard_Boolean ShapeAnalysis_CheckSmallFace::StatusSplitVert(const ShapeExtend_Status status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusSplitVert, status );
|
||||
|
||||
}
|
||||
|
||||
|
178
src/ShapeAnalysis/ShapeAnalysis_Curve.cdl
Executable file
178
src/ShapeAnalysis/ShapeAnalysis_Curve.cdl
Executable file
@@ -0,0 +1,178 @@
|
||||
-- File: ShapeAnalysis_Curve.cdl
|
||||
-- Created: Wed Jun 3 12:00:34 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Curve from ShapeAnalysis
|
||||
|
||||
---Purpose: Analyzing tool for 2d or 3d curve.
|
||||
-- Computes parameters of projected point onto a curve.
|
||||
|
||||
uses
|
||||
XYZ from gp,
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Box2d from Bnd,
|
||||
Curve from Geom,
|
||||
Curve from Adaptor3d,
|
||||
Curve from Geom2d,
|
||||
Array1OfPnt from TColgp,
|
||||
SequenceOfPnt from TColgp,
|
||||
SequenceOfPnt2d from TColgp
|
||||
|
||||
is
|
||||
Project (me; C3D: Curve from Geom;
|
||||
P3D: Pnt from gp;
|
||||
preci: Real;
|
||||
proj: out Pnt from gp;
|
||||
param: out Real;
|
||||
AdjustToEnds: Boolean = Standard_True)
|
||||
returns Real;
|
||||
---Purpose : Projects a Point on a Curve.
|
||||
-- Computes the projected point and its parameter on the curve.
|
||||
-- <preci> is used as 3d precision (hence, 0 will produce
|
||||
-- reject unless exact confusion).
|
||||
-- The number of iterations is limited.
|
||||
-- If AdjustToEnds is True, point will be adjusted to the end
|
||||
-- of the curve if distance is less than <preci>
|
||||
--
|
||||
-- Returned value is the distance between the given point and
|
||||
-- computed one.
|
||||
|
||||
Project (me; C3D: Curve from Adaptor3d;
|
||||
P3D: Pnt from gp;
|
||||
preci: Real;
|
||||
proj: out Pnt from gp;
|
||||
param: out Real;
|
||||
AdjustToEnds: Boolean = Standard_True)
|
||||
returns Real;
|
||||
---Purpose : Projects a Point on a Curve.
|
||||
-- Computes the projected point and its parameter on the curve.
|
||||
-- <preci> is used as 3d precision (hence, 0 will produce
|
||||
-- reject unless exact confusion).
|
||||
-- The number of iterations is limited.
|
||||
--
|
||||
-- Returned value is the distance between the given point and
|
||||
-- computed one.
|
||||
|
||||
Project (me; C3D: Curve from Geom;
|
||||
P3D: Pnt from gp;
|
||||
preci: Real;
|
||||
proj: out Pnt from gp;
|
||||
param: out Real;
|
||||
cf, cl: Real;
|
||||
AdjustToEnds: Boolean = Standard_True)
|
||||
returns Real;
|
||||
---Purpose : Projects a Point on a Curve, but parameters are limited
|
||||
-- between <cf> and <cl>.
|
||||
-- The range [cf, cl] is extended with help of Adaptor3d on the
|
||||
-- basis of 3d precision <preci>.
|
||||
-- If AdjustToEnds is True, point will be adjusted to the end
|
||||
-- of the curve if distance is less than <preci>
|
||||
|
||||
ProjectAct(me; C3D : Curve from Adaptor3d;
|
||||
P3D : Pnt from gp;
|
||||
preci: Real;
|
||||
proj : out Pnt from gp;
|
||||
param: out Real)
|
||||
returns Real;
|
||||
|
||||
NextProject(me; paramPrev: Real;
|
||||
C3D : Curve from Geom;
|
||||
P3D : Pnt from gp;
|
||||
preci : Real;
|
||||
proj : out Pnt from gp;
|
||||
param : out Real;
|
||||
cf, cl : Real;
|
||||
AdjustToEnds: Boolean = Standard_True)
|
||||
returns Real;
|
||||
---Purpose: Projects a Point on a Curve using Newton method.
|
||||
-- <paramPrev> is taken as the first approximation of solution.
|
||||
-- If Newton algorithm fails the method Project() is used.
|
||||
-- If AdjustToEnds is True, point will be adjusted to the end
|
||||
-- of the curve if distance is less than <preci>
|
||||
|
||||
NextProject(me; paramPrev: Real;
|
||||
C3D : Curve from Adaptor3d;
|
||||
P3D : Pnt from gp;
|
||||
preci : Real;
|
||||
proj : out Pnt from gp;
|
||||
param : out Real)
|
||||
returns Real;
|
||||
---Purpose: Projects a Point on a Curve using Newton method.
|
||||
-- <paramPrev> is taken as the first approximation of solution.
|
||||
-- If Newton algorithm fails the method Project() is used.
|
||||
|
||||
ValidateRange (me; Crv: Curve from Geom; First, Last: out Real;
|
||||
prec: Real) returns Boolean;
|
||||
---Purpose: Validate parameters First and Last for the given curve
|
||||
-- in order to make them valid for creation of edge.
|
||||
-- This includes:
|
||||
-- - limiting range [First,Last] by range of curve
|
||||
-- - adjusting range [First,Last] for periodic (or closed)
|
||||
-- curve if Last < First
|
||||
-- Returns True if parameters are OK or are successfully
|
||||
-- corrected, or False if parameters cannot be corrected.
|
||||
-- In the latter case, parameters are reset to range of curve.
|
||||
|
||||
FillBndBox (me; C2d: Curve from Geom2d; First, Last: Real;
|
||||
NPoints: Integer; Exact: Boolean;
|
||||
Box: out Box2d from Bnd);
|
||||
---Purpose: Computes a boundary box on segment of curve C2d from First
|
||||
-- to Last. This is done by taking NPoints points from the
|
||||
-- curve and, if Exact is True, by searching for exact
|
||||
-- extrema. All these points are added to Box.
|
||||
|
||||
SelectForwardSeam (me; C1, C2: Curve from Geom2d) returns Integer;
|
||||
---Purpose: Defines which pcurve (C1 or C2) should be chosen for FORWARD
|
||||
-- seam edge.
|
||||
---Returns: 1 for C1,
|
||||
-- 2 for C2,
|
||||
-- 0 if C1 and/or C2 are neither lines nor BoundedCurves, or if could
|
||||
-- not analyze.
|
||||
-- Warning: It is an absolute selection, hence C1 is MANDATORY on the
|
||||
-- FORWARD Edge, C2 on the REVERSED. Whatever the sense of the
|
||||
-- Wires and Faces which contain it.
|
||||
|
||||
IsPlanar (myclass; pnts : Array1OfPnt from TColgp;
|
||||
Normal: in out XYZ from gp;
|
||||
preci : Real = 0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if points are planar with given preci. If Normal has not zero
|
||||
-- modulus, checks with given normal
|
||||
|
||||
IsPlanar (myclass; curve : Curve from Geom;
|
||||
Normal: in out XYZ from gp;
|
||||
preci : Real = 0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if curve is planar with given preci. If Normal has not zero
|
||||
-- modulus, checks with given normal
|
||||
|
||||
GetSamplePoints (myclass; curve: Curve from Geom2d; first, last: Real;
|
||||
seq: out SequenceOfPnt2d from TColgp) returns Boolean;
|
||||
---Purpose: Returns sample points which will serve as linearisation
|
||||
-- of the2d curve in range (first, last)
|
||||
-- The distribution of sample points is consystent with
|
||||
-- what is used by BRepTopAdaptor_FClass2d
|
||||
|
||||
GetSamplePoints (myclass; curve: Curve from Geom; first, last: Real;
|
||||
seq: out SequenceOfPnt from TColgp) returns Boolean;
|
||||
---Purpose: Returns sample points which will serve as linearisation
|
||||
-- of the curve in range (first, last)
|
||||
|
||||
IsClosed (myclass; curve : Curve from Geom; preci: Real = -1) returns Boolean;
|
||||
---Purpose: Tells if the Curve is closed with given precision.
|
||||
-- If <preci> < 0 then Precision::Confusion is used.
|
||||
|
||||
IsPeriodic (myclass; curve : Curve from Geom) returns Boolean;
|
||||
---Purpose: This method was implemented as fix for changes in trimmed curve
|
||||
-- behaviour. For the moment trimmed curve returns false anyway.
|
||||
-- So it is necessary to adapt all Data exchange tools for this behaviour.
|
||||
-- Current implementation takes into account that curve may be offset.
|
||||
|
||||
IsPeriodic (myclass; curve : Curve from Geom2d) returns Boolean;
|
||||
---Purpose: The same as for Curve3d.
|
||||
|
||||
end Curve;
|
1224
src/ShapeAnalysis/ShapeAnalysis_Curve.cxx
Executable file
1224
src/ShapeAnalysis/ShapeAnalysis_Curve.cxx
Executable file
File diff suppressed because it is too large
Load Diff
284
src/ShapeAnalysis/ShapeAnalysis_Edge.cdl
Executable file
284
src/ShapeAnalysis/ShapeAnalysis_Edge.cdl
Executable file
@@ -0,0 +1,284 @@
|
||||
-- File: ShapeAnalysis_Edge.cdl
|
||||
-- Created: Mon Jun 8 10:40:58 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Edge from ShapeAnalysis
|
||||
|
||||
---Purpose: Tool for analyzing the edge.
|
||||
-- Queries geometrical representations of the edge (3d curve, pcurve
|
||||
-- on the given face or surface) and topological sub-shapes (bounding
|
||||
-- vertices).
|
||||
-- Provides methods for analyzing geometry and topology consistency
|
||||
-- (3d and pcurve(s) consistency, their adjacency to the vertices).
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Vec2d from gp,
|
||||
Curve from Geom2d,
|
||||
Curve from Geom,
|
||||
Surface from Geom,
|
||||
Vertex from TopoDS,
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
Location from TopLoc,
|
||||
Status from ShapeExtend
|
||||
|
||||
is
|
||||
|
||||
Create returns Edge from ShapeAnalysis;
|
||||
---Purpose: Empty constructor; initialises Status to OK
|
||||
|
||||
HasCurve3d (me; edge: Edge from TopoDS) returns Boolean;
|
||||
---Purpose: Tells if the edge has a 3d curve
|
||||
|
||||
Curve3d (me; edge : Edge from TopoDS;
|
||||
C3d : out Curve from Geom;
|
||||
cf, cl: out Real;
|
||||
orient: Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the 3d curve and bounding parameteres for the edge
|
||||
-- Returns False if no 3d curve.
|
||||
-- If <orient> is True (default), takes orientation into account:
|
||||
-- if the edge is reversed, cf and cl are toggled
|
||||
|
||||
IsClosed3d (me; edge: Edge from TopoDS) returns Boolean;
|
||||
---Purpose: Gives True if the edge has a 3d curve, this curve is closed,
|
||||
-- and the edge has the same vertex at start and end
|
||||
|
||||
HasPCurve (me; edge: Edge from TopoDS;
|
||||
face: Face from TopoDS)
|
||||
returns Boolean;
|
||||
---Purpose: Tells if the Edge has a pcurve on the face.
|
||||
|
||||
HasPCurve (me; edge : Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc)
|
||||
returns Boolean;
|
||||
---Purpose: Tells if the edge has a pcurve on the surface (with location).
|
||||
|
||||
PCurve (me; edge : Edge from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
C2d : out Curve from Geom2d;
|
||||
cf, cl: out Real;
|
||||
orient: Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
|
||||
PCurve (me; edge : Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc;
|
||||
C2d : out Curve from Geom2d;
|
||||
cf, cl : out Real;
|
||||
orient : Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the pcurve and bounding parameteres for the edge
|
||||
-- lying on the surface.
|
||||
-- Returns False if the edge has no pcurve on this surface.
|
||||
-- If <orient> is True (default), takes orientation into account:
|
||||
-- if the edge is reversed, cf and cl are toggled
|
||||
|
||||
BoundUV (me; edge : Edge from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
first, last: out Pnt2d from gp)
|
||||
returns Boolean;
|
||||
|
||||
BoundUV (me; edge : Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc;
|
||||
first, last: out Pnt2d from gp)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the ends of pcurve
|
||||
-- Calls method PCurve with <orient> equal to True
|
||||
|
||||
IsSeam (me; edge: Edge from TopoDS;
|
||||
face: Face from TopoDS)
|
||||
returns Boolean;
|
||||
|
||||
IsSeam (me; edge : Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc)
|
||||
returns Boolean;
|
||||
---Purpose: Returns True if the edge has two pcurves on one surface
|
||||
---Remark : Calls BRep_Tool::IsClosed()
|
||||
|
||||
FirstVertex (me; edge: Edge from TopoDS) returns Vertex from TopoDS;
|
||||
---Purpose: Returns start vertex of the edge (taking edge orientation
|
||||
-- into account).
|
||||
---Remark: Vertex orientation is always FORWARD
|
||||
|
||||
LastVertex (me; edge: Edge from TopoDS) returns Vertex from TopoDS;
|
||||
---Purpose: Returns end vertex of the edge (taking edge orientation
|
||||
-- into account).
|
||||
---Remark: Vertex orientation is always REVERSED
|
||||
|
||||
GetEndTangent2d (me; edge: Edge from TopoDS;
|
||||
face: Face from TopoDS;
|
||||
atEnd: Boolean;
|
||||
pos : out Pnt2d from gp;
|
||||
tang: out Vec2d from gp;
|
||||
dparam: Real from Standard =0.0)
|
||||
returns Boolean;
|
||||
|
||||
GetEndTangent2d (me; edge: Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc;
|
||||
atEnd: Boolean;
|
||||
pos : out Pnt2d from gp;
|
||||
tang: out Vec2d from gp;
|
||||
dparam: Real from Standard =0.0)
|
||||
returns Boolean;
|
||||
---Purpose: Returns tangent of the edge pcurve at its start (if atEnd is
|
||||
-- False) or end (if True), regarding the orientation of edge.
|
||||
-- If edge is REVERSED, tangent is reversed before return.
|
||||
-- Returns True if pcurve is available and tangent is computed
|
||||
-- and is not null, else False.
|
||||
|
||||
CheckVerticesWithCurve3d (me: in out; edge : Edge from TopoDS;
|
||||
preci: Real = -1;
|
||||
vtx : Integer = 0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks the start and/or end vertex of the edge for matching
|
||||
-- with 3d curve with the given precision.
|
||||
-- <vtx> = 1 : start vertex only
|
||||
-- <vtx> = 2 : end vertex only
|
||||
-- <vtx> = 0 : both (default)
|
||||
-- If preci < 0 the vertices are considered with their own
|
||||
-- tolerances, else with the given <preci>.
|
||||
---Returns: True if mismatching of the vertex to the curve was detected
|
||||
-- else returns False (OK)
|
||||
---Status : OK - ends of the 3d curve are comprised by checked vertices
|
||||
-- FAIL1 - edge has no 3d curve
|
||||
-- DONE1 - if first vertex of the edge does not comprise start of 3d curve
|
||||
-- DONE2 - if last vertex of the edge does not comprise end of 3d curve
|
||||
|
||||
CheckVerticesWithPCurve (me: in out; edge : Edge from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
preci: Real = -1;
|
||||
vtx : Integer = 0)
|
||||
returns Boolean;
|
||||
|
||||
CheckVerticesWithPCurve (me: in out; edge : Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc;
|
||||
preci : Real = -1;
|
||||
vtx : Integer = 0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks the start and/or end vertex of the edge for matching
|
||||
-- with pcurve with the given precision.
|
||||
-- <vtx> = 1 : start vertex
|
||||
-- <vtx> = 2 : end vertex
|
||||
-- <vtx> = 0 : both
|
||||
-- If preci < 0 the vertices are considered with their own
|
||||
-- tolerances, else with the given <preci>.
|
||||
---Returns: True if mismatching of the curves to the vertex was detected
|
||||
-- else returns False (OK)
|
||||
---Status : OK - ends of the 3d curve are comprised by checked vertices
|
||||
-- FAIL1 - edge has no pcurve on a given (sur)face
|
||||
-- DONE1 - if first vertex of the edge does not comprise start of pcurve
|
||||
-- DONE2 - if last vertex of the edge does not comprise end of pcurve
|
||||
|
||||
CheckVertexTolerance(me: in out; edge : Edge from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
toler1: out Real;
|
||||
toler2: out Real)
|
||||
returns Boolean;
|
||||
CheckVertexTolerance(me: in out; edge : Edge from TopoDS;
|
||||
toler1: out Real;
|
||||
toler2: out Real)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if it is necessary to increase tolerances of the edge
|
||||
-- vertices to comprise the ends of 3d curve and pcurve on
|
||||
-- the given face (first method) or all pcurves stored in an edge
|
||||
-- (second one)
|
||||
-- toler1 returns necessary tolerance for first vertex,
|
||||
-- toler2 returns necessary tolerance for last vertex.
|
||||
---Returns: True, if tolerances should be increased, otherwise False
|
||||
---Status:
|
||||
-- OK : the original tolerances are sufficient
|
||||
-- DONE1: the tolerance of first vertex should be increased
|
||||
-- DONE2: the tolerance of last vertex should be increased
|
||||
-- FAIL1: edge has no vertice(s), no check is done
|
||||
-- FAIL2: edge has no 3d curve, only pcurves are checked
|
||||
-- FAIL3: edge has no pcurve on a given face, only 3d curve is checked
|
||||
|
||||
CheckCurve3dWithPCurve (me: in out; edge: Edge from TopoDS;
|
||||
face: Face from TopoDS)
|
||||
returns Boolean;
|
||||
|
||||
CheckCurve3dWithPCurve (me: in out; edge :Edge from TopoDS;
|
||||
surface : Surface from Geom;
|
||||
location: Location from TopLoc)
|
||||
returns Boolean;
|
||||
---Purpose: Checks mutual orientation of 3d curve and pcurve on the
|
||||
-- analysis of curves bounding points
|
||||
---Returns: Returns True if mismatching of orientation was detected,
|
||||
-- else returns False (if OK or no curve)
|
||||
---Status:
|
||||
-- OK : orientations match each other (both go in the same
|
||||
-- directions), or edge is closed
|
||||
-- DONE1: orientations mismatch each other (curves go in
|
||||
-- opposite directions)
|
||||
-- FAIL1: no pcurve
|
||||
-- FAIL2: no 3d curve
|
||||
|
||||
CheckPoints (me: in out; P1A, P1B: Pnt from gp;
|
||||
P2A, P2B: Pnt from gp;
|
||||
preci1, preci2: Real)
|
||||
returns Boolean is private;
|
||||
---Purpose: Check points by pairs (A and A, B and B) with precisions
|
||||
-- (preci1 and preci2).
|
||||
-- P1 are the points either from 3d curve or from vertices,
|
||||
-- P2 are the points from pcurve
|
||||
---Returns: False if status is OK, else True
|
||||
--- Status:
|
||||
-- OK : distances (P1A, P2A) and (P1B, P2B) are within
|
||||
-- precisions
|
||||
-- DONE1: distance (P1A, P2B) + (P1B, P2A) is less than
|
||||
-- distance (P1A, P2A) + (P1B, P2B),
|
||||
-- the precisions are not taken into account in this case
|
||||
|
||||
|
||||
|
||||
Status (me; status: Status from ShapeExtend) returns Boolean;
|
||||
---Purpose: Returns the status (in the form of True/False) of last Check
|
||||
---Returns: True if status contains bit corresponding to enumerated argument
|
||||
|
||||
CheckSameParameter (me: in out; edge : Edge from TopoDS;
|
||||
maxdev: out Real;
|
||||
NbControl: Integer = 23)
|
||||
returns Boolean;
|
||||
---Purpose: Checks the edge to be SameParameter.
|
||||
-- Calculates the maximal deviation between 3d curve and each
|
||||
-- pcurve of the edge on <NbControl> equidistant points (the same
|
||||
-- algorithm as in BRepCheck; default value is 23 as in BRepCheck).
|
||||
-- This deviation is returned in <maxdev> parameter.
|
||||
-- If deviation is greater than tolerance of the edge (i.e.
|
||||
-- incorrect flag) returns False, else returns True.
|
||||
---Returns: True if edge has either SameParameter False and/or its real
|
||||
-- deviation of curves is more than tolerance
|
||||
---Status : OK - Edge is SameParameter with the associated tolerance
|
||||
-- DONE1 - if deviation of the pcurves from 3d curve is greater
|
||||
-- than tolerance of edge
|
||||
-- DONE2 - if SameParameter flag in edge is False
|
||||
-- FAIL1 - edge does not have 3d curve
|
||||
-- FAIL2 - if some computational problems were encountered (when
|
||||
-- projecting points on curves)
|
||||
|
||||
CheckOverlapping(me :in out; theEdge1, theEdge2 : Edge from TopoDS;
|
||||
theTolOverlap:in out Real; theDomainDist : Real =0.0) returns Boolean;
|
||||
---Purpose: Checks the first edge is overlapped with second edge.
|
||||
-- If distance between two edges is less then theTolOverlap
|
||||
-- edges is overlapped.
|
||||
-- theDomainDis - length of part of edges on wich edges is overlapped.
|
||||
---Status : DONE3 - edges is overlapped on whole length
|
||||
-- : DONE4 - edges is overlapped on the length equal to theDomainDist
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myStatus: Integer is protected;
|
||||
|
||||
end Edge;
|
956
src/ShapeAnalysis/ShapeAnalysis_Edge.cxx
Executable file
956
src/ShapeAnalysis/ShapeAnalysis_Edge.cxx
Executable file
@@ -0,0 +1,956 @@
|
||||
//:o8 abv 19.02.99: CTS18541.stp #18559: coeff 1.0001 added in CheckVertexTol
|
||||
//:p1 abv 22.02.99: protection against edges with no vertices (infinite)
|
||||
//szv#4 S4163
|
||||
//:s1 abv 22.04.99: PRO7226 #489490: protect against Null 3d curve
|
||||
//:s4 abv 26.04.99: sim6049.igs 21677: copy of curve is necessary to get True SP
|
||||
// abv 06.05.99: S4137: adding methods GetTangent2d()
|
||||
#include <ShapeAnalysis_Edge.ixx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <Adaptor3d_CurveOnSurface.hxx>
|
||||
#include <Geom2dAdaptor_HCurve.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <Extrema_LocateExtPC.hxx>
|
||||
|
||||
#include <ShapeExtend.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_Edge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_Edge::ShapeAnalysis_Edge()
|
||||
{
|
||||
myStatus = 0;//ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BoundUV
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::BoundUV (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face,
|
||||
gp_Pnt2d& first, gp_Pnt2d& last) const
|
||||
{
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface) S = BRep_Tool::Surface(face, L);
|
||||
return BoundUV (edge, S, L, first, last);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BoundUV
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::BoundUV (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surface,
|
||||
const TopLoc_Location& location,
|
||||
gp_Pnt2d& first, gp_Pnt2d& last) const
|
||||
{
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
Standard_Real uf,ul;
|
||||
if (!PCurve (edge, surface, location, c2d, uf, ul)) return Standard_False;
|
||||
first = c2d->Value (uf);
|
||||
last = c2d->Value (ul);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasCurve3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::HasCurve3d (const TopoDS_Edge& edge) const
|
||||
{
|
||||
Standard_Real cf, cl;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve (edge, cf, cl);
|
||||
return !c3d.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Curve3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::Curve3d (const TopoDS_Edge& edge,
|
||||
Handle(Geom_Curve)& C3d,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
const Standard_Boolean orient) const
|
||||
{
|
||||
TopLoc_Location L;
|
||||
C3d = BRep_Tool::Curve (edge, L, cf, cl);
|
||||
if( !C3d.IsNull() && !L.IsIdentity() ) {
|
||||
C3d = Handle(Geom_Curve)::DownCast(C3d->Transformed(L.Transformation()));
|
||||
cf = C3d->TransformedParameter(cf, L.Transformation());
|
||||
cl = C3d->TransformedParameter(cl, L.Transformation());
|
||||
}
|
||||
if (orient) {
|
||||
if (edge.Orientation() == TopAbs_REVERSED)
|
||||
{Standard_Real tmp = cf; cf = cl; cl = tmp;}
|
||||
}
|
||||
return !C3d.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsClosed3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::IsClosed3d (const TopoDS_Edge& edge) const
|
||||
{
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve (edge,cf,cl);
|
||||
if (c3d.IsNull()) return Standard_False;
|
||||
if (!c3d->IsClosed()) return Standard_False;
|
||||
return FirstVertex (edge).IsSame (LastVertex (edge));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::HasPCurve (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face) const
|
||||
{
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(face, L);
|
||||
return HasPCurve (edge, S, L);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::HasPCurve (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surface,
|
||||
const TopLoc_Location& location) const
|
||||
{
|
||||
//try { //szv#4:S4163:12Mar99 waste try
|
||||
Standard_Real cf, cl;
|
||||
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface (edge, surface, location, cf, cl);
|
||||
return !c2d.IsNull();
|
||||
/* }
|
||||
catch (Standard_Failure) {
|
||||
}
|
||||
return Standard_False; */
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::PCurve (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face,
|
||||
Handle(Geom2d_Curve)& C2d,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
const Standard_Boolean orient) const
|
||||
{
|
||||
//:abv 20.05.02: take into account face orientation
|
||||
// COMMENTED BACK - NEEDS MORE CHANGES IN ALL SHAPEHEALING
|
||||
// C2d = BRep_Tool::CurveOnSurface (edge, face, cf, cl);
|
||||
// if (orient && edge.Orientation() == TopAbs_REVERSED) {
|
||||
// Standard_Real tmp = cf; cf = cl; cl = tmp;
|
||||
// }
|
||||
// return !C2d.IsNull();
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(face, L);
|
||||
return PCurve (edge, S, L, C2d, cf, cl, orient);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::PCurve (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surface,
|
||||
const TopLoc_Location& location,
|
||||
Handle(Geom2d_Curve)& C2d,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
const Standard_Boolean orient) const
|
||||
{
|
||||
C2d = BRep_Tool::CurveOnSurface (edge, surface, location, cf, cl);
|
||||
if ( orient && edge.Orientation() == TopAbs_REVERSED ) {
|
||||
Standard_Real tmp = cf; cf = cl; cl = tmp;
|
||||
}
|
||||
return !C2d.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSeam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::IsSeam (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face) const
|
||||
{
|
||||
return BRep_Tool::IsClosed (edge, face);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSeam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::IsSeam (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surface,
|
||||
const TopLoc_Location& location) const
|
||||
{
|
||||
return BRep_Tool::IsClosed (edge, surface, location);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FirstVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Vertex ShapeAnalysis_Edge::FirstVertex (const TopoDS_Edge& edge) const
|
||||
{
|
||||
TopoDS_Vertex V;
|
||||
if (edge.Orientation() == TopAbs_REVERSED) {
|
||||
V = TopExp::LastVertex(edge);
|
||||
V.Reverse();
|
||||
}
|
||||
else {
|
||||
V = TopExp::FirstVertex (edge);
|
||||
}
|
||||
return V;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LastVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Vertex ShapeAnalysis_Edge::LastVertex (const TopoDS_Edge& edge) const
|
||||
{
|
||||
TopoDS_Vertex V;
|
||||
if (edge.Orientation() == TopAbs_REVERSED) {
|
||||
V = TopExp::FirstVertex(edge);
|
||||
V.Reverse();
|
||||
}
|
||||
else {
|
||||
V = TopExp::LastVertex (edge);
|
||||
}
|
||||
return V;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Status
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::Status (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus (myStatus, Status);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEndTangent2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::GetEndTangent2d (const TopoDS_Edge &edge,
|
||||
const TopoDS_Face &face,
|
||||
const Standard_Boolean atend1, /* skl : change "atend" to "atend1" */
|
||||
gp_Pnt2d &pnt,
|
||||
gp_Vec2d &v,
|
||||
const Standard_Real dparam) const
|
||||
{
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface) S = BRep_Tool::Surface ( face, L );
|
||||
return GetEndTangent2d ( edge, S, L, atend1, pnt, v, dparam );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEndTangent2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::GetEndTangent2d (const TopoDS_Edge &edge,
|
||||
const Handle(Geom_Surface)& S,
|
||||
const TopLoc_Location& L,
|
||||
const Standard_Boolean atend2, /* skl : change "atend" to "atend2" */
|
||||
gp_Pnt2d &pnt,
|
||||
gp_Vec2d &v,
|
||||
const Standard_Real dparam) const
|
||||
{
|
||||
Standard_Real cf, cl;
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
if ( ! PCurve ( edge, S, L, c2d, cf, cl ) ) {
|
||||
v = gp_Vec2d(0,0);
|
||||
return Standard_False;
|
||||
}
|
||||
Standard_Real dpnew = dparam;
|
||||
|
||||
if(dpnew>Precision::Confusion()) {
|
||||
gp_Pnt2d ptmp;
|
||||
Standard_Real par1,par2,delta=(cl-cf)*dpnew;
|
||||
if(Abs(delta)<Precision::PConfusion()) {
|
||||
dpnew=0.0;
|
||||
}
|
||||
else {
|
||||
if(atend2) {
|
||||
par1 = cl;
|
||||
par2 = cl - delta;
|
||||
c2d->D0(par1,pnt);
|
||||
c2d->D0(par2,ptmp);
|
||||
v = pnt.XY() - ptmp.XY();
|
||||
}
|
||||
else {
|
||||
par1 = cf;
|
||||
par2 = cf + delta;
|
||||
c2d->D0(par1,pnt);
|
||||
c2d->D0(par2,ptmp);
|
||||
v = ptmp.XY() - pnt.XY();
|
||||
}
|
||||
if( v.SquareMagnitude() < Precision::PConfusion()*Precision::PConfusion() ) {
|
||||
dpnew=0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dpnew<=Precision::Confusion()) {
|
||||
// get non-null tangency searching until 3rd derivative, or as straight btw ends
|
||||
Standard_Real par = ( atend2 ? cl : cf );
|
||||
c2d->D1 ( par, pnt, v );
|
||||
if ( v.SquareMagnitude() < Precision::PConfusion()*Precision::PConfusion() ) {
|
||||
gp_Vec2d d1;
|
||||
c2d->D2 ( par, pnt, d1, v );
|
||||
if ( v.SquareMagnitude() < Precision::PConfusion()*Precision::PConfusion() ) {
|
||||
gp_Vec2d d2;
|
||||
c2d->D3 ( par, pnt, d1, d2, v );
|
||||
if ( v.SquareMagnitude() < Precision::PConfusion()*Precision::PConfusion() ) {
|
||||
gp_Pnt2d p2;
|
||||
c2d->D0 ( ( atend2 ? cf : cl ), p2 );
|
||||
v = p2.XY() - pnt.XY();
|
||||
if ( v.SquareMagnitude() < Precision::PConfusion()*Precision::PConfusion() )
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( edge.Orientation() == TopAbs_REVERSED ) v.Reverse();
|
||||
}
|
||||
|
||||
//if ( edge.Orientation() == TopAbs_REVERSED ) v.Reverse();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckCurve3dWithPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckCurve3dWithPCurve (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(face, L);
|
||||
return CheckCurve3dWithPCurve (edge, S, L);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckCurve3dWithPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckCurve3dWithPCurve (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surface,
|
||||
const TopLoc_Location& location)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
|
||||
if(surface->IsKind(STANDARD_TYPE(Geom_Plane)))
|
||||
return Standard_False;
|
||||
|
||||
Handle (Geom2d_Curve) c2d;
|
||||
Standard_Real f2d, l2d; //szv#4:S4163:12Mar99 moved down f3d, l3d
|
||||
if (!PCurve (edge, surface, location, c2d, f2d ,l2d, Standard_False)) {
|
||||
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle (Geom_Curve) c3d; //szv#4:S4163:12Mar99 moved
|
||||
Standard_Real f3d, l3d; //szv#4:S4163:12Mar99 moved
|
||||
if (!Curve3d (edge, c3d, f3d, l3d, Standard_False)) {
|
||||
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Real preci1 = BRep_Tool::Tolerance (FirstVertex (edge)),
|
||||
preci2 = BRep_Tool::Tolerance (LastVertex (edge));
|
||||
|
||||
gp_Pnt2d p2d1 = c2d->Value (f2d),
|
||||
p2d2 = c2d->Value (l2d);
|
||||
|
||||
//#39 rln 17.11.98 S4054, annie_surf.igs entity 39
|
||||
return CheckPoints (c3d->Value (f3d)/*.Transformed (location.Transformation())*/,
|
||||
c3d->Value (l3d)/*.Transformed (location.Transformation())*/,
|
||||
surface->Value (p2d1.X(), p2d1.Y()).Transformed (location.Transformation()),
|
||||
surface->Value (p2d2.X(), p2d2.Y()).Transformed (location.Transformation()),
|
||||
preci1, preci2);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckPoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckPoints (const gp_Pnt& P1A,
|
||||
const gp_Pnt& P1B,
|
||||
const gp_Pnt& P2A,
|
||||
const gp_Pnt& P2B,
|
||||
const Standard_Real preci1,
|
||||
const Standard_Real preci2)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
if (P1A.SquareDistance (P2A) <= preci1 * preci1 &&
|
||||
P1B.SquareDistance (P2B) <= preci2 * preci2)
|
||||
return Standard_False;
|
||||
else if (P1A.Distance (P2B) + (P1B.Distance (P2A)) <
|
||||
P1A.Distance (P2A) + (P1B.Distance (P2B)))
|
||||
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVerticesWithCurve3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckVerticesWithCurve3d (const TopoDS_Edge& edge,
|
||||
const Standard_Real preci,
|
||||
const Standard_Integer vtx)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
|
||||
TopoDS_Vertex V1 = FirstVertex (edge);
|
||||
TopoDS_Vertex V2 = LastVertex (edge);
|
||||
gp_Pnt p1v = BRep_Tool::Pnt (V1);
|
||||
gp_Pnt p2v = BRep_Tool::Pnt (V2);
|
||||
|
||||
Standard_Real cf,cl;
|
||||
Handle(Geom_Curve) c3d;
|
||||
if ( ! Curve3d (edge,c3d,cf,cl) ) {
|
||||
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// on va faire les checks ...
|
||||
if (vtx != 2) {
|
||||
// 1er VTX
|
||||
gp_Pnt p13d = c3d->Value(cf);
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (p1v.Distance(p13d) > (preci < 0 ? BRep_Tool::Tolerance (V1) : preci))
|
||||
myStatus |= ShapeExtend_DONE1;
|
||||
}
|
||||
|
||||
if (vtx != 1) {
|
||||
// 2me VTX
|
||||
gp_Pnt p23d = c3d->Value(cl);
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (p2v.Distance(p23d) > (preci < 0 ? BRep_Tool::Tolerance (V2) : preci))
|
||||
myStatus |= ShapeExtend_DONE2;
|
||||
}
|
||||
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVerticesWithPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckVerticesWithPCurve (const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face,
|
||||
const Standard_Real preci,
|
||||
const Standard_Integer vtx)
|
||||
{
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(face, L);
|
||||
return CheckVerticesWithPCurve (edge, S, L, preci, vtx); //szv#4:S4163:12Mar99 `vtx,preci` wrong parameters order
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVerticesWithPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckVerticesWithPCurve (const TopoDS_Edge& edge,
|
||||
const Handle(Geom_Surface)& surf,
|
||||
const TopLoc_Location& loc,
|
||||
const Standard_Real preci,
|
||||
const Standard_Integer vtx)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
|
||||
|
||||
TopoDS_Vertex V1 = FirstVertex (edge);
|
||||
TopoDS_Vertex V2 = LastVertex (edge);
|
||||
gp_Pnt p1v = BRep_Tool::Pnt (V1);
|
||||
gp_Pnt p2v = BRep_Tool::Pnt (V2);
|
||||
|
||||
Standard_Real cf, cl;
|
||||
Handle(Geom2d_Curve) c2d;
|
||||
if ( ! PCurve ( edge, surf, loc, c2d, cf, cl ) ) {
|
||||
myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// on va faire les checks ...
|
||||
if (vtx != 2) { // 1er VTX
|
||||
gp_Pnt2d p1uv = c2d->Value (cf);
|
||||
gp_Pnt p12d = surf->Value (p1uv.X(), p1uv.Y());
|
||||
// szv#4:S4163:12Mar99 optimized
|
||||
if ( p1v.Distance(p12d) > (preci < 0 ? BRep_Tool::Tolerance (V1) : preci) )
|
||||
myStatus |= ShapeExtend_DONE1;
|
||||
}
|
||||
|
||||
if (vtx != 1) { // 2me VTX
|
||||
gp_Pnt2d p2uv = c2d->Value (cl);
|
||||
gp_Pnt p22d = surf->Value (p2uv.X(), p2uv.Y());
|
||||
// szv#4:S4163:12Mar99 optimized
|
||||
if ( p2v.Distance(p22d) > (preci < 0 ? BRep_Tool::Tolerance (V2) : preci) )
|
||||
myStatus |= ShapeExtend_DONE2;
|
||||
}
|
||||
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVertexTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer CheckVertexTolerance(const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face,
|
||||
const Standard_Boolean checkAll,
|
||||
Standard_Real& toler1,
|
||||
Standard_Real& toler2)
|
||||
{
|
||||
Standard_Integer Status = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
|
||||
ShapeAnalysis_Edge sae;
|
||||
TopoDS_Vertex V1 = sae.FirstVertex (edge);
|
||||
TopoDS_Vertex V2 = sae.LastVertex (edge);
|
||||
if ( V1.IsNull() || V2.IsNull() ) { //:p1 abv 22 Feb 99: r76sy.stp
|
||||
Status |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL1);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Standard_Real old1 = BRep_Tool::Tolerance (V1);
|
||||
Standard_Real old2 = BRep_Tool::Tolerance (V2);
|
||||
gp_Pnt pnt1 = BRep_Tool::Pnt (V1);
|
||||
gp_Pnt pnt2 = BRep_Tool::Pnt (V2);
|
||||
|
||||
Standard_Real a, b;
|
||||
Handle(Geom_Curve) c3d;
|
||||
if ( ! sae.Curve3d(edge, c3d, a, b, Standard_True)) {
|
||||
if ( ! BRep_Tool::Degenerated ( edge ) )
|
||||
Status |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||
toler1 = toler2 = 0.;
|
||||
// return Standard_False;
|
||||
}
|
||||
else {
|
||||
toler1 = pnt1.SquareDistance (c3d->Value (a));
|
||||
toler2 = pnt2.SquareDistance (c3d->Value (b));
|
||||
}
|
||||
|
||||
if ( checkAll ) {
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&edge.TShape());
|
||||
for (BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if (GC.IsNull() || !GC->IsCurveOnSurface()) continue;
|
||||
Handle(Geom2d_Curve) pcurve;
|
||||
Handle(Geom_Surface) S = GC->Surface();
|
||||
TopLoc_Location L = edge.Location() * GC->Location();
|
||||
sae.PCurve (edge, S, L, pcurve, a, b, Standard_True);
|
||||
gp_Pnt2d p1 = pcurve->Value (a);
|
||||
gp_Pnt2d p2 = pcurve->Value (b);
|
||||
gp_Pnt P1 = S->Value (p1.X(), p1.Y()).Transformed (L.Transformation());
|
||||
gp_Pnt P2 = S->Value (p2.X(), p2.Y()).Transformed (L.Transformation());
|
||||
toler1 = Max (toler1, pnt1.SquareDistance (P1));
|
||||
toler2 = Max (toler2, pnt2.SquareDistance (P2));
|
||||
}
|
||||
}
|
||||
//:abv 10.06.02: porting C40 -> dev (CC670-12608.stp)
|
||||
// Check with given face is needed for plane surfaces (if no stored pcurves)
|
||||
else if ( ! face.IsNull() ) {
|
||||
Handle(Geom2d_Curve) pcurve;
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(face, L);
|
||||
if ( sae.PCurve(edge, S, L, pcurve, a, b, Standard_True)) {
|
||||
gp_Pnt2d p1 = pcurve->Value (a);
|
||||
gp_Pnt2d p2 = pcurve->Value (b);
|
||||
gp_Pnt P1 = S->Value (p1.X(), p1.Y()).Transformed (L.Transformation());
|
||||
gp_Pnt P2 = S->Value (p2.X(), p2.Y()).Transformed (L.Transformation());
|
||||
toler1 = Max (toler1, pnt1.SquareDistance (P1));
|
||||
toler2 = Max (toler2, pnt2.SquareDistance (P2));
|
||||
}
|
||||
else Status |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL3);
|
||||
}
|
||||
|
||||
//:o8 abv 19 Feb 99: CTS18541.stp #18559: coeff 1.0001 added
|
||||
//szv 18 Aug 99: edge tolerance is taken in consideration
|
||||
Standard_Real tole = BRep_Tool::Tolerance (edge);
|
||||
toler1 = Max (1.0000001 * Sqrt (toler1), tole);
|
||||
toler2 = Max (1.0000001 * Sqrt (toler2), tole);
|
||||
if ( toler1 > old1)
|
||||
Status |= ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
||||
if ( toler2 > old2)
|
||||
Status |= ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVertexTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckVertexTolerance(const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face,
|
||||
Standard_Real& toler1,
|
||||
Standard_Real& toler2)
|
||||
{
|
||||
myStatus = ::CheckVertexTolerance ( edge, face, Standard_False, toler1, toler2 );
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckVertexTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckVertexTolerance(const TopoDS_Edge& edge,
|
||||
Standard_Real& toler1,
|
||||
Standard_Real& toler2)
|
||||
{
|
||||
TopoDS_Face F;
|
||||
myStatus = ::CheckVertexTolerance ( edge, F, Standard_True, toler1, toler2 );
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//static : Validate
|
||||
//purpose: For SameParameter: compute it for two curves
|
||||
//note: This function is made from Validate() in BRepCheck_Edge.cxx
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean ComputeDeviation (const Adaptor3d_Curve& CRef,
|
||||
const Adaptor3d_Curve& Other,
|
||||
const Standard_Boolean SameParameter,
|
||||
Standard_Real &dev,
|
||||
const Standard_Integer NCONTROL)
|
||||
{
|
||||
Standard_Boolean OK = Standard_True;
|
||||
Standard_Real dev2 = dev*dev;
|
||||
|
||||
Standard_Real First = CRef.FirstParameter(), Last = CRef.LastParameter();
|
||||
Standard_Real OFirst = Other.FirstParameter(), OLast = Other.LastParameter(); //szv#4:S4163:12Mar99 moved
|
||||
|
||||
Standard_Boolean proj = (!SameParameter || First != OFirst || Last != OLast); //szv#4:S4163:12Mar99 optimized
|
||||
|
||||
Standard_Integer NCtrl = ( NCONTROL < 1 )? 1 : NCONTROL; //szv#4:S4163:12Mar99 anti-exception
|
||||
|
||||
if (!proj) {
|
||||
for (Standard_Integer i = 0; i <= NCtrl; i++) {
|
||||
Standard_Real prm = ((NCtrl-i)*First + i*Last)/NCtrl;
|
||||
gp_Pnt pref = CRef.Value(prm);
|
||||
gp_Pnt pother = Other.Value(prm);
|
||||
Standard_Real dist2 = pref.SquareDistance(pother);
|
||||
if ( dev2 < dist2 ) dev2 = dist2;
|
||||
}
|
||||
dev = Sqrt ( dev2 );
|
||||
}
|
||||
else {
|
||||
gp_Pnt pd = CRef.Value(First);
|
||||
gp_Pnt pdo = Other.Value(OFirst);
|
||||
Standard_Real dist2 = pd.SquareDistance(pdo);
|
||||
if ( dev2 < dist2 ) dev = Sqrt ( dev2 = dist2 );
|
||||
|
||||
pd = CRef.Value(Last);
|
||||
pdo = Other.Value(OLast);
|
||||
dist2 = pd.SquareDistance(pdo);
|
||||
if ( dev2 < dist2 ) dev = Sqrt ( dev2 = dist2 );
|
||||
|
||||
Extrema_LocateExtPC refd, otherd; //szv#4:S4163:12Mar99 warning
|
||||
refd.Initialize(CRef,First,Last,Precision::PConfusion());
|
||||
otherd.Initialize(Other,OFirst,OLast,Precision::PConfusion());
|
||||
|
||||
for (Standard_Integer i = 1; i < NCtrl; i++) { //szv#4:S4163:12Mar99 was bug
|
||||
Standard_Real rprm = ((NCtrl-i)*First + i*Last)/NCtrl;
|
||||
gp_Pnt pref = CRef.Value(rprm);
|
||||
Standard_Real oprm = ((NCtrl-i)*OFirst + i*OLast)/NCtrl;
|
||||
gp_Pnt pother = Other.Value(oprm);
|
||||
|
||||
refd.Perform(pother,rprm);
|
||||
if ( ! refd.IsDone() ) OK = Standard_False;
|
||||
else if ( dev2 < refd.SquareDistance() ) {dev2 = refd.SquareDistance(); dev = sqrt (dev2);}
|
||||
|
||||
otherd.Perform(pref,oprm);
|
||||
if ( ! otherd.IsDone() ) OK = Standard_False;
|
||||
else if ( dev2 < otherd.SquareDistance() ) {dev2 = otherd.SquareDistance(); dev = sqrt (dev2);}
|
||||
}
|
||||
}
|
||||
dev *= 1.00001;//ims007 entity 8067 edge 3; 1e-07USA60022 (4255, 4-th edge) SA_Check and BRepCh find distinct points001; // ensure that dev*dev >= dev2
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSameParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckSameParameter (const TopoDS_Edge& edge,
|
||||
Standard_Real& maxdev,
|
||||
const Standard_Integer NbControl)
|
||||
{
|
||||
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
|
||||
if (BRep_Tool::Degenerated (edge)) return Standard_False;
|
||||
|
||||
maxdev = 0;
|
||||
|
||||
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&edge.TShape());
|
||||
Standard_Boolean SameParameter = TE->SameParameter();
|
||||
|
||||
GeomAdaptor_Curve AC3d;
|
||||
|
||||
// find 3d curve
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurve3D() ) continue;
|
||||
Handle(Geom_Curve) C3d = GC->Curve3D();
|
||||
if ( C3d.IsNull() ) continue; //:s1 abv 22 Apr 99: PRO7226 #489490
|
||||
TopLoc_Location loc = GC->Location();
|
||||
if ( ! loc.IsIdentity() )
|
||||
C3d = Handle(Geom_Curve)::DownCast ( C3d->Transformed ( loc ) );
|
||||
else C3d = Handle(Geom_Curve)::DownCast ( C3d->Copy() ); //:s4 abv 26 Apr 99: sim6049.igs 21677: necessary to get True SP (!!?)
|
||||
Standard_Real First, Last;
|
||||
GC->Range ( First, Last );
|
||||
AC3d.Load ( C3d, First, Last );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! itcr.More() ) {
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// iterate on pcurves
|
||||
itcr.Initialize ( TE->Curves() );
|
||||
for ( ; itcr.More(); itcr.Next() ) {
|
||||
Handle(BRep_GCurve) GC = Handle(BRep_GCurve)::DownCast(itcr.Value());
|
||||
if ( GC.IsNull() || ! GC->IsCurveOnSurface() ) continue;
|
||||
|
||||
Standard_Real f, l;
|
||||
GC->Range ( f, l );
|
||||
Handle(Geom_Surface) Su = GC->Surface();
|
||||
TopLoc_Location loc = GC->Location();
|
||||
if (!loc.IsIdentity())
|
||||
Su = Handle(Geom_Surface)::DownCast ( Su->Transformed ( loc ) );
|
||||
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Su);
|
||||
|
||||
Handle(Geom2d_Curve) PC = GC->PCurve();
|
||||
Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
|
||||
//Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
|
||||
Adaptor3d_CurveOnSurface ACS;
|
||||
ACS.Load(GHPC);
|
||||
ACS.Load(GAHS);
|
||||
if ( ! ComputeDeviation ( AC3d, ACS, SameParameter, maxdev, NbControl-1 ) ) {
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
|
||||
}
|
||||
|
||||
if ( GC->IsCurveOnClosedSurface() ) {
|
||||
GHPC->ChangeCurve2d().Load ( GC->PCurve2(), f, l ); // same bounds
|
||||
ACS.Load(GAHS); // sans doute inutile
|
||||
ACS.Load(GHPC); // meme remarque...
|
||||
if ( ! ComputeDeviation ( AC3d, ACS, SameParameter, maxdev, NbControl-1 ) ) {
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( maxdev > TE->Tolerance() )
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
|
||||
if ( ! SameParameter )
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
|
||||
|
||||
return Status ( ShapeExtend_DONE );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsOverlapPartEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean IsOverlapPartEdges(const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecEdge,
|
||||
const Standard_Real& theTolerance,
|
||||
const Standard_Real& theStep,
|
||||
const Standard_Real& theStartLength,
|
||||
const Standard_Real& theEndLenght)
|
||||
{
|
||||
TColStd_SequenceOfInteger aSeqIntervals;
|
||||
BRepAdaptor_Curve aAdCurve1(theFirstEdge);
|
||||
|
||||
BRepExtrema_DistShapeShape aMinDist;
|
||||
aMinDist.LoadS1(theSecEdge);
|
||||
|
||||
for(Standard_Real aS = theStartLength; aS <= theEndLenght; aS+=theStep/2) {
|
||||
|
||||
gp_Pnt aPoint;
|
||||
if(aS <= Precision::Confusion()) {
|
||||
TopoDS_Vertex V1 = TopExp::FirstVertex(theFirstEdge,Standard_True);
|
||||
aPoint = BRep_Tool::Pnt(V1);
|
||||
}
|
||||
else {
|
||||
GCPnts_AbscissaPoint aAbsPoint(Precision::Confusion(),aAdCurve1,aS,aAdCurve1.FirstParameter());
|
||||
if(aAbsPoint.IsDone())
|
||||
aAdCurve1.D0(aAbsPoint.Parameter(),aPoint);
|
||||
else continue;
|
||||
}
|
||||
BRep_Builder aB;
|
||||
TopoDS_Vertex aV;
|
||||
aB.MakeVertex(aV,aPoint,Precision::Confusion());
|
||||
aMinDist.LoadS2(aV);
|
||||
aMinDist.Perform();
|
||||
if( aMinDist.IsDone() && aMinDist.Value() >= theTolerance)
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckOverlapping
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Edge::CheckOverlapping(const TopoDS_Edge& theEdge1,
|
||||
const TopoDS_Edge& theEdge2,
|
||||
Standard_Real& theTolOverlap,
|
||||
const Standard_Real theDomainDist)
|
||||
{
|
||||
Standard_Boolean isOverlap = Standard_False;
|
||||
BRepAdaptor_Curve aAdCurve1(theEdge1);
|
||||
Standard_Real aLength1 = GCPnts_AbscissaPoint::Length (aAdCurve1);
|
||||
BRepAdaptor_Curve aAdCurve2(theEdge2);
|
||||
Standard_Real aLength2 = GCPnts_AbscissaPoint::Length (aAdCurve2);
|
||||
TopoDS_Edge aFirstEdge = (aLength1 >= aLength2 ? theEdge2: theEdge1);
|
||||
TopoDS_Edge aSecEdge = (aLength1 >= aLength2 ? theEdge1: theEdge2);
|
||||
Standard_Real aLength = Min(aLength1,aLength2);
|
||||
|
||||
//check overalpping between edges on whole edges
|
||||
Standard_Real aStep = Min(aLength1,aLength2)/2;
|
||||
isOverlap = IsOverlapPartEdges(aFirstEdge,aSecEdge,theTolOverlap,aStep,0.,Min(aLength1,aLength2));
|
||||
|
||||
if(isOverlap) {
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3);
|
||||
return isOverlap;
|
||||
}
|
||||
if(theDomainDist ==0.0)
|
||||
return isOverlap;
|
||||
|
||||
//check overalpping between edges on segment with length less than theDomainDist
|
||||
|
||||
Standard_Real aDomainTol = (theDomainDist > Min( aLength1,aLength2) ? Min( aLength1,aLength2) :theDomainDist);
|
||||
BRepExtrema_DistShapeShape aMinDist(aFirstEdge,aSecEdge,theTolOverlap);
|
||||
Standard_Real aresTol = theTolOverlap;
|
||||
if(aMinDist.IsDone()) {
|
||||
aresTol = aMinDist.Value();
|
||||
if(aresTol >= theTolOverlap) return Standard_False;
|
||||
Standard_Integer NbSol = aMinDist.NbSolution();
|
||||
for(Standard_Integer i =1; i<= NbSol && !isOverlap; i++) {
|
||||
BRepExtrema_SupportType aType1 = aMinDist.SupportTypeShape1(i);
|
||||
Standard_Real aEndLength, aStartLength, aLengthP;
|
||||
if(aType1 == BRepExtrema_IsVertex) {
|
||||
TopoDS_Shape aSupportShape1 = aMinDist.SupportOnShape1(i);
|
||||
TopoDS_Vertex aV1,aV2;
|
||||
TopExp::Vertices (aFirstEdge, aV1, aV2, Standard_True);
|
||||
if( aV1.IsSame(aSupportShape1))
|
||||
aLengthP = 0.0;
|
||||
else
|
||||
aLengthP =aLength;
|
||||
}
|
||||
else if(aType1 == BRepExtrema_IsOnEdge) {
|
||||
Standard_Real aParam1, aFirst, aLast;
|
||||
aMinDist.ParOnEdgeS1 ( i, aParam1 );
|
||||
BRep_Tool::Range(aFirstEdge,aFirst,aLast);
|
||||
BRepAdaptor_Curve anAdaptor(aFirstEdge);
|
||||
aLengthP = GCPnts_AbscissaPoint::Length(anAdaptor,aFirst,aParam1);
|
||||
}
|
||||
else continue;
|
||||
aStartLength = aLengthP - aDomainTol/2;
|
||||
if( aStartLength <0.0) {
|
||||
aStartLength =0;
|
||||
aEndLength = aDomainTol;
|
||||
}
|
||||
aEndLength = aLengthP + aDomainTol/2;
|
||||
if(aEndLength > aLength) {
|
||||
aEndLength = aLength;
|
||||
aStartLength = aEndLength - aDomainTol;
|
||||
}
|
||||
aStep = (aEndLength - aStartLength)/5;
|
||||
isOverlap = (IsOverlapPartEdges(aFirstEdge,aSecEdge,theTolOverlap,aStep,aStartLength,aEndLength));
|
||||
}
|
||||
}
|
||||
if(isOverlap)
|
||||
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4);
|
||||
|
||||
theTolOverlap = aresTol;
|
||||
return isOverlap;
|
||||
}
|
126
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cdl
Executable file
126
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cdl
Executable file
@@ -0,0 +1,126 @@
|
||||
-- File: ShapeAnalysis_FreeBoundData.cdl
|
||||
-- Created: Tue Aug 25 10:48:55 1998
|
||||
-- Author: Pavel DURANDIN <pdn@nnov.matra-dtv.fr>
|
||||
-- Roman LYGIN <rln@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class FreeBoundData from ShapeAnalysis inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class is intended to represent free bound and to store
|
||||
-- its properties.
|
||||
--
|
||||
-- This class is used by ShapeAnalysis_FreeBoundsProperties
|
||||
-- class when storing each free bound and its properties.
|
||||
--
|
||||
-- The properties stored in this class are the following:
|
||||
-- - area of the contour,
|
||||
-- - perimeter of the contour,
|
||||
-- - ratio of average length to average width of the contour,
|
||||
-- - average width of contour,
|
||||
-- - notches (narrow 'V'-like sub-contours) on the contour and
|
||||
-- their maximum width.
|
||||
--
|
||||
-- This class provides methods for setting and getting fields
|
||||
-- only.
|
||||
|
||||
uses
|
||||
|
||||
Wire from TopoDS,
|
||||
HSequenceOfShape from TopTools,
|
||||
DataMapOfShapeReal from TopTools
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable FreeBoundData from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create (freebound: Wire from TopoDS)
|
||||
returns mutable FreeBoundData from ShapeAnalysis;
|
||||
---Purpose: Creates object with contour given in the form of TopoDS_Wire
|
||||
|
||||
Clear (me: mutable);
|
||||
---Purpose: Clears all properties of the contour.
|
||||
-- Contour bound itself is not cleared.
|
||||
|
||||
|
||||
-- Methods for setting fields
|
||||
|
||||
SetFreeBound (me: mutable; freebound: Wire from TopoDS);
|
||||
---Purpose: Sets contour
|
||||
---C++: inline
|
||||
|
||||
SetArea (me: mutable; area: Real);
|
||||
---Purpose: Sets area of the contour
|
||||
---C++: inline
|
||||
|
||||
SetPerimeter (me: mutable; perimeter: Real);
|
||||
---Purpose: Sets perimeter of the contour
|
||||
---C++: inline
|
||||
|
||||
SetRatio (me: mutable; ratio: Real);
|
||||
---Purpose: Sets ratio of average length to average width of the contour
|
||||
---C++: inline
|
||||
|
||||
SetWidth (me: mutable; width: Real);
|
||||
---Purpose: Sets average width of the contour
|
||||
---C++: inline
|
||||
|
||||
AddNotch (me: mutable; notch: Wire from TopoDS; width: Real);
|
||||
---Purpose: Adds notch on the contour with its maximum width
|
||||
|
||||
|
||||
-- Methods for getting fields
|
||||
|
||||
FreeBound (me) returns Wire from TopoDS;
|
||||
---Purpose: Returns contour
|
||||
---C++: inline
|
||||
|
||||
Area (me) returns Real;
|
||||
---Purpose: Returns area of the contour
|
||||
---C++: inline
|
||||
|
||||
Perimeter (me) returns Real;
|
||||
---Purpose: Returns perimeter of the contour
|
||||
---C++: inline
|
||||
|
||||
Ratio (me) returns Real;
|
||||
---Purpose: Returns ratio of average length to average width of the contour
|
||||
---C++: inline
|
||||
|
||||
Width (me) returns Real;
|
||||
---Purpose: Returns average width of the contour
|
||||
---C++: inline
|
||||
|
||||
NbNotches (me) returns Integer;
|
||||
---Purpose: Returns number of notches on the contour
|
||||
---C++: inline
|
||||
|
||||
Notches (me) returns HSequenceOfShape from TopTools;
|
||||
---Purpose: Returns sequence of notches on the contour
|
||||
---C++: inline
|
||||
|
||||
Notch (me; index: Integer) returns Wire from TopoDS;
|
||||
---Purpose: Returns notch on the contour
|
||||
---C++: inline
|
||||
|
||||
NotchWidth (me; index: Integer) returns Real;
|
||||
---Purpose: Returns maximum width of notch specified by its rank number
|
||||
-- on the contour
|
||||
|
||||
NotchWidth (me; notch: Wire from TopoDS) returns Real;
|
||||
---Purpose: Returns maximum width of notch specified as TopoDS_Wire
|
||||
-- on the contour
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myBound : Wire from TopoDS;
|
||||
myArea : Real;
|
||||
myPerimeter : Real;
|
||||
myRatio : Real;
|
||||
myWidth : Real;
|
||||
myNotches : HSequenceOfShape from TopTools;
|
||||
myNotchesParams: DataMapOfShapeReal from TopTools;
|
||||
|
||||
end FreeBoundData;
|
83
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx
Executable file
83
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx
Executable file
@@ -0,0 +1,83 @@
|
||||
// File: ShapeAnalysis_FreeBoundData.cxx
|
||||
// Created: Tue Aug 25 12:42:28 1998
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <ShapeAnalysis_FreeBoundData.ixx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBoundData
|
||||
//purpose : Empty constructor
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData()
|
||||
{
|
||||
myNotches = new TopTools_HSequenceOfShape();
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBoundData
|
||||
//purpose : Creates object with contour given in the form of TopoDS_Wire
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData(const TopoDS_Wire& freebound)
|
||||
{
|
||||
myNotches = new TopTools_HSequenceOfShape();
|
||||
Clear();
|
||||
SetFreeBound(freebound);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose : Clears all properties of the contour. Contour bound itself is not cleared.
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBoundData::Clear()
|
||||
{
|
||||
myArea = -1;
|
||||
myPerimeter = -1;
|
||||
myRatio = -1;
|
||||
myWidth = -1;
|
||||
myNotches->Clear();
|
||||
myNotchesParams.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddNotch
|
||||
//purpose : Adds notch on free bound with its maximum width
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBoundData::AddNotch(const TopoDS_Wire& notch,const Standard_Real width)
|
||||
{
|
||||
if (myNotchesParams.IsBound(notch)) return;
|
||||
myNotches->Append(notch);
|
||||
myNotchesParams.Bind(notch, width);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NotchWidth
|
||||
//purpose : Returns maximum width of notch specified by its rank number
|
||||
// on the contour
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const Standard_Integer index) const
|
||||
{
|
||||
TopoDS_Wire wire = TopoDS::Wire(myNotches -> Value(index));
|
||||
return myNotchesParams.Find(wire);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NotchWidth
|
||||
//purpose : Returns maximum width of notch specified as TopoDS_Wire
|
||||
// on the contour
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const TopoDS_Wire& notch) const
|
||||
{
|
||||
return myNotchesParams.Find(notch);
|
||||
}
|
142
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.lxx
Executable file
142
src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.lxx
Executable file
@@ -0,0 +1,142 @@
|
||||
// File: ShapeAnalysis_FreeBoundData.lxx
|
||||
// Created: Thu Sep 17 18:05:04 1998
|
||||
// Author: data exchange team
|
||||
// <det@nnov.matra-dtv.fr>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFreeBound
|
||||
//purpose : Sets contour
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_FreeBoundData::SetFreeBound(const TopoDS_Wire& freebound)
|
||||
{
|
||||
myBound = freebound;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetArea
|
||||
//purpose : Sets area of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_FreeBoundData::SetArea(const Standard_Real area)
|
||||
{
|
||||
myArea = area;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPerimeter
|
||||
//purpose : Sets perimeter of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_FreeBoundData::SetPerimeter(const Standard_Real perimeter)
|
||||
{
|
||||
myPerimeter = perimeter;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetRatio
|
||||
//purpose : Sets ratio of average length to average width of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_FreeBoundData::SetRatio(const Standard_Real ratio)
|
||||
{
|
||||
myRatio = ratio;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWidth
|
||||
//purpose : Sets average width of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_FreeBoundData::SetWidth(const Standard_Real width)
|
||||
{
|
||||
myWidth = width;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddNotch
|
||||
//purpose : Adds notch on free bound with its maximum width
|
||||
//=======================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : FreeBound
|
||||
//purpose : Returns contour
|
||||
//=======================================================================
|
||||
|
||||
inline TopoDS_Wire ShapeAnalysis_FreeBoundData::FreeBound() const
|
||||
{
|
||||
return myBound;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Area
|
||||
//purpose : Returns area of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_FreeBoundData::Area() const
|
||||
{
|
||||
return myArea;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perimeter
|
||||
//purpose : Returns perimeter of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_FreeBoundData::Perimeter() const
|
||||
{
|
||||
return myPerimeter;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Ratio
|
||||
//purpose : Returns ratio of average length to average width of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_FreeBoundData::Ratio() const
|
||||
{
|
||||
return myRatio;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Width
|
||||
//purpose : Returns average width of the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_FreeBoundData::Width() const
|
||||
{
|
||||
return myWidth;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNotches
|
||||
//purpose : Returns number of notches on the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_FreeBoundData::NbNotches() const
|
||||
{
|
||||
return myNotches->Length();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Notches
|
||||
//purpose : Returns sequence of notches on the contour
|
||||
//=======================================================================
|
||||
|
||||
inline Handle_TopTools_HSequenceOfShape ShapeAnalysis_FreeBoundData::Notches() const
|
||||
{
|
||||
return myNotches;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Notch
|
||||
//purpose : Returns notch on the contour
|
||||
//=======================================================================
|
||||
|
||||
inline TopoDS_Wire ShapeAnalysis_FreeBoundData::Notch(const Standard_Integer index) const
|
||||
{
|
||||
return TopoDS::Wire(myNotches->Value(index));
|
||||
}
|
181
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.cdl
Executable file
181
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.cdl
Executable file
@@ -0,0 +1,181 @@
|
||||
-- File: ShapeAnalysis_FreeBounds.cdl
|
||||
-- Created: Wed Jun 3 12:07:11 1998
|
||||
-- Author: Daniel RISSER
|
||||
-- <dan@sgi100>
|
||||
---Copyright: Matra Datavision 1998
|
||||
-- Modified Mon Sep 14 10:20:25 1998 by Roman LYGIN (rln)
|
||||
-- 1. Analysis of actual free bounds of the shells.
|
||||
-- 2. Options to extract closed sub-wires out of closed and open
|
||||
-- wires
|
||||
-- 3. Improved algorithm for connecting free edges into wires
|
||||
|
||||
|
||||
class FreeBounds from ShapeAnalysis
|
||||
|
||||
---Purpose: This class is intended to output free bounds of the shape
|
||||
-- (free bounds are the wires consisting of edges referenced by the
|
||||
-- only face).
|
||||
-- This class works on two distinct types of shapes when analyzing
|
||||
-- their free bounds:
|
||||
-- 1. compound of faces.
|
||||
-- Analyzer of sewing algorithm (BRepAlgo_Sewing) is used for
|
||||
-- for forecasting free bounds that would be obtained after
|
||||
-- performing sewing
|
||||
-- 2. compound of shells.
|
||||
-- Actual free bounds (edges shared by the only face in the shell)
|
||||
-- are output in this case. ShapeAnalysis_Shell is used for that.
|
||||
--
|
||||
-- When connecting edges into the wires algorithm tries to build
|
||||
-- wires of maximum length. Two options are provided for a user
|
||||
-- to extract closed sub-contours out of closed and/or open contours.
|
||||
--
|
||||
-- Free bounds are returned as two compounds, one for closed and one
|
||||
-- for open wires.
|
||||
--
|
||||
-- This class also provides some static methods for advanced use:
|
||||
-- connecting edges/wires to wires, extracting closed sub-wires out
|
||||
-- of wires, dispatching wires into compounds for closed and open
|
||||
-- wires.
|
||||
-- NOTE. Ends of the edge or wire mean hereafter their end vertices.
|
||||
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Vertex from TopoDS,
|
||||
Wire from TopoDS,
|
||||
Compound from TopoDS,
|
||||
HSequenceOfShape from TopTools,
|
||||
DataMapOfShapeShape from TopTools,
|
||||
HArray1OfShape from TopTools
|
||||
|
||||
is
|
||||
Create returns FreeBounds from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create (shape : Shape from TopoDS;
|
||||
toler : Real;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_True)
|
||||
returns FreeBounds from ShapeAnalysis;
|
||||
---Purpose: Builds forecasting free bounds of the <shape>.
|
||||
-- <shape> should be a compound of faces.
|
||||
-- This constructor is to be used for forecasting free edges
|
||||
-- with help of sewing analyzer BRepAlgo_Sewing which is called
|
||||
-- with tolerance <toler>.
|
||||
-- Free edges are connected into wires only when their ends are
|
||||
-- at distance less than <toler>.
|
||||
-- If <splitclosed> is True extracts closed sub-wires out of
|
||||
-- built closed wires.
|
||||
-- If <splitopen> is True extracts closed sub-wires out of
|
||||
-- built open wires.
|
||||
|
||||
Create (shape : Shape from TopoDS;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_True;
|
||||
checkinternaledges : Boolean = Standard_False)
|
||||
returns FreeBounds from ShapeAnalysis;
|
||||
---Purpose: Builds actual free bounds of the <shape>.
|
||||
-- <shape> should be a compound of shells.
|
||||
-- This constructor is to be used for getting free edges (ones
|
||||
-- referenced by the only face) with help of analyzer
|
||||
-- ShapeAnalysis_Shell.
|
||||
-- Free edges are connected into wires only when they share the
|
||||
-- same vertex.
|
||||
-- If <splitclosed> is True extracts closed sub-wires out of
|
||||
-- built closed wires.
|
||||
-- If <splitopen> is True extracts closed sub-wires out of
|
||||
-- built open wires.
|
||||
|
||||
GetClosedWires (me) returns Compound from TopoDS;
|
||||
---Purpose: Returns compound of closed wires out of free edges.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
GetOpenWires (me) returns Compound from TopoDS;
|
||||
---Purpose: Returns compound of open wires out of free edges.
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
|
||||
|
||||
---Level: Advanced
|
||||
|
||||
ConnectEdgesToWires (myclass; edges : in out HSequenceOfShape from TopTools;
|
||||
toler : Real;
|
||||
shared: Boolean;
|
||||
wires : out HSequenceOfShape from TopTools);
|
||||
---Purpose: Builds sequnce of <wires> out of sequence of not sorted
|
||||
-- <edges>.
|
||||
-- Tries to build wires of maximum length. Building a wire is
|
||||
-- stopped when no edges can be connected to it at its head or
|
||||
-- at its tail.
|
||||
--
|
||||
-- Orientation of the edge can change when connecting.
|
||||
-- If <shared> is True connection is performed only when
|
||||
-- adjacent edges share the same vertex.
|
||||
-- If <shared> is False connection is performed only when
|
||||
-- ends of adjacent edges are at distance less than <toler>.
|
||||
|
||||
ConnectWiresToWires (myclass; iwires: in out HSequenceOfShape from TopTools;
|
||||
toler : Real;
|
||||
shared: Boolean;
|
||||
owires: out HSequenceOfShape from TopTools);
|
||||
|
||||
ConnectWiresToWires (myclass; iwires: in out HSequenceOfShape from TopTools;
|
||||
toler : Real;
|
||||
shared: Boolean;
|
||||
owires: out HSequenceOfShape from TopTools;
|
||||
vertices: out DataMapOfShapeShape
|
||||
from TopTools);
|
||||
---Purpose: Builds sequnce of <owires> out of sequence of not sorted
|
||||
-- <iwires>.
|
||||
-- Tries to build wires of maximum length. Building a wire is
|
||||
-- stopped when no wires can be connected to it at its head or
|
||||
-- at its tail.
|
||||
--
|
||||
-- Orientation of the wire can change when connecting.
|
||||
-- If <shared> is True connection is performed only when
|
||||
-- adjacent wires share the same vertex.
|
||||
-- If <shared> is False connection is performed only when
|
||||
-- ends of adjacent wires are at distance less than <toler>.
|
||||
-- Map <vertices> stores the correspondence between original
|
||||
-- end vertices of the wires and new connecting vertices.
|
||||
|
||||
SplitWires (myclass; wires : HSequenceOfShape from TopTools;
|
||||
toler : Real;
|
||||
shared: Boolean;
|
||||
closed: out HSequenceOfShape from TopTools;
|
||||
open : out HSequenceOfShape from TopTools);
|
||||
---Purpose: Extracts closed sub-wires out of <wires> and adds them
|
||||
-- to <closed>, open wires remained after extraction are put
|
||||
-- into <open>.
|
||||
-- If <shared> is True extraction is performed only when
|
||||
-- edges share the same vertex.
|
||||
-- If <shared> is False connection is performed only when
|
||||
-- ends of the edges are at distance less than <toler>.
|
||||
|
||||
DispatchWires (myclass; wires : HSequenceOfShape from TopTools;
|
||||
closed: in out Compound from TopoDS;
|
||||
open : in out Compound from TopoDS);
|
||||
---Purpose: Dispatches sequence of <wires> into two compounds
|
||||
-- <closed> for closed wires and <open> for open wires.
|
||||
-- If a compound is not empty wires are added into it.
|
||||
|
||||
|
||||
---Level: Internal
|
||||
|
||||
SplitWires (me: in out) is private;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myWires: Compound from TopoDS;
|
||||
myEdges: Compound from TopoDS;
|
||||
|
||||
myTolerance : Real;
|
||||
myShared : Boolean;
|
||||
|
||||
mySplitClosed: Boolean;
|
||||
mySplitOpen : Boolean;
|
||||
|
||||
end FreeBounds;
|
501
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx
Executable file
501
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx
Executable file
@@ -0,0 +1,501 @@
|
||||
// File: ShapeAnalysis_FreeBounds.cxx
|
||||
// Created: Mon Apr 27 15:59:13 1998
|
||||
// Author: Daniel RISSER
|
||||
// <dan@sgi100>
|
||||
// Modified: Thu Sep 17 12:27:58 1998
|
||||
// Author: Roman LYGIN
|
||||
// <rln@kinox.nnov.matra-dtv.fr>
|
||||
// 25.12.98 pdn transmission from BRepTools_Sewing to BRepBuilderAPI_Sewing
|
||||
//szv#4 S4163
|
||||
// 11.01.00 svv #1: porting on DEC
|
||||
|
||||
#include <ShapeAnalysis_FreeBounds.ixx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_Sewing.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#include <TColStd_Array1OfBoolean.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <ShapeExtend_Explorer.hxx>
|
||||
#include <ShapeBuild_Vertex.hxx>
|
||||
#include <ShapeBuild_Edge.hxx>
|
||||
#include <ShapeAnalysis.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <ShapeAnalysis_Wire.hxx>
|
||||
#include <ShapeAnalysis_Shell.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx> //ied_modif_for_compil_Nov-19-1998
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
#include <TopoDS_Shell.hxx>
|
||||
#include <ShapeAnalysis_BoxBndTree.hxx>
|
||||
#include <NCollection_UBTreeFiller.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TopTools_HArray1OfShape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBounds
|
||||
//purpose : Empty constructor
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds() {}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen) :
|
||||
myTolerance (toler), myShared (Standard_False),
|
||||
mySplitClosed (splitclosed), mySplitOpen (splitopen)
|
||||
{
|
||||
BRepBuilderAPI_Sewing Sew(toler, Standard_False, Standard_False);
|
||||
for (TopoDS_Iterator S (shape); S.More(); S.Next()) Sew.Add(S.Value());
|
||||
Sew.Perform();
|
||||
//
|
||||
// Extract free edges.
|
||||
//
|
||||
Standard_Integer nbedge = Sew.NbFreeEdges();
|
||||
Handle(TopTools_HSequenceOfShape) edges = new TopTools_HSequenceOfShape;
|
||||
Handle(TopTools_HSequenceOfShape) wires;
|
||||
TopoDS_Edge anEdge;
|
||||
for (Standard_Integer iedge = 1 ; iedge <= nbedge ; iedge++) {
|
||||
anEdge = TopoDS::Edge (Sew.FreeEdge(iedge));
|
||||
if ( !BRep_Tool::Degenerated(anEdge) ) edges->Append (anEdge);
|
||||
}
|
||||
//
|
||||
// Chainage.
|
||||
//
|
||||
ConnectEdgesToWires (edges, toler, Standard_False, wires);
|
||||
DispatchWires (wires, myWires, myEdges);
|
||||
SplitWires ();
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen,
|
||||
const Standard_Boolean checkinternaledges) :
|
||||
myTolerance (0.), myShared (Standard_True),
|
||||
mySplitClosed (splitclosed), mySplitOpen (splitopen)
|
||||
{
|
||||
TopoDS_Shell aTmpShell;
|
||||
BRep_Builder aB;
|
||||
aB.MakeShell(aTmpShell);
|
||||
for(TopExp_Explorer aExpFace(shape,TopAbs_FACE);aExpFace.More(); aExpFace.Next())
|
||||
aB.Add(aTmpShell,aExpFace.Current());
|
||||
|
||||
ShapeAnalysis_Shell sas;
|
||||
sas.CheckOrientedShells (aTmpShell, Standard_True, checkinternaledges);
|
||||
|
||||
if (sas.HasFreeEdges()) {
|
||||
ShapeExtend_Explorer see;
|
||||
Handle(TopTools_HSequenceOfShape) edges = see.SeqFromCompound (sas.FreeEdges(), Standard_False);
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) wires;
|
||||
ConnectEdgesToWires (edges, Precision::Confusion(), Standard_True, wires);
|
||||
DispatchWires (wires, myWires, myEdges);
|
||||
SplitWires ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConnectEdgesToWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBounds::ConnectEdgesToWires(Handle(TopTools_HSequenceOfShape)& edges,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean shared,
|
||||
Handle(TopTools_HSequenceOfShape)& wires)
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) iwires = new TopTools_HSequenceOfShape;
|
||||
BRep_Builder B;
|
||||
|
||||
Standard_Integer i; // svv #1
|
||||
for (i = 1; i <= edges->Length(); i++) {
|
||||
TopoDS_Wire wire;
|
||||
B.MakeWire (wire);
|
||||
B.Add (wire, edges->Value (i));
|
||||
iwires->Append (wire);
|
||||
}
|
||||
|
||||
ConnectWiresToWires (iwires, toler, shared, wires);
|
||||
|
||||
for (i = 1; i <= edges->Length(); i++)
|
||||
if (iwires->Value(i).Orientation() == TopAbs_REVERSED)
|
||||
edges->ChangeValue(i).Reverse();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConnectWiresToWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBounds::ConnectWiresToWires(Handle(TopTools_HSequenceOfShape)& iwires,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean shared,
|
||||
Handle(TopTools_HSequenceOfShape)& owires)
|
||||
{
|
||||
TopTools_DataMapOfShapeShape map;
|
||||
ConnectWiresToWires (iwires, toler, shared, owires, map);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConnectWiresToWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBounds::ConnectWiresToWires(Handle(TopTools_HSequenceOfShape)& iwires,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean shared,
|
||||
Handle(TopTools_HSequenceOfShape)& owires,
|
||||
TopTools_DataMapOfShapeShape& vertices)
|
||||
{
|
||||
if (iwires.IsNull() || !iwires->Length()) return;
|
||||
Handle(TopTools_HArray1OfShape) arrwires = new TopTools_HArray1OfShape(1, iwires->Length());
|
||||
//amv
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= arrwires->Length(); i++)
|
||||
arrwires->SetValue(i, iwires->Value(i));
|
||||
owires = new TopTools_HSequenceOfShape;
|
||||
Standard_Real tolerance = Max (toler, Precision::Confusion());
|
||||
|
||||
Handle(ShapeExtend_WireData)
|
||||
sewd = new ShapeExtend_WireData (TopoDS::Wire (arrwires->Value (1)));
|
||||
|
||||
Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire;
|
||||
saw->Load (sewd);
|
||||
saw->SetPrecision (tolerance);
|
||||
|
||||
ShapeAnalysis_BoxBndTree aBBTree;
|
||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
|
||||
ShapeAnalysis_BoxBndTreeSelector aSel(arrwires, shared);
|
||||
aSel.LoadList(1);
|
||||
|
||||
for (Standard_Integer inbW = 2; inbW <= arrwires->Length(); inbW++){
|
||||
TopoDS_Wire trW = TopoDS::Wire (arrwires->Value (inbW));
|
||||
Bnd_Box aBox;
|
||||
TopoDS_Vertex trV1, trV2;
|
||||
ShapeAnalysis::FindBounds (trW, trV1, trV2);
|
||||
gp_Pnt trP1 = BRep_Tool::Pnt(trV1);
|
||||
gp_Pnt trP2 = BRep_Tool::Pnt(trV2);
|
||||
aBox.Set(trP1);
|
||||
aBox.Add(trP2);
|
||||
aBox.SetGap(tolerance);
|
||||
aTreeFiller.Add(inbW, aBox);
|
||||
}
|
||||
Standard_Integer nbFill;
|
||||
nbFill = aTreeFiller.Fill();
|
||||
Standard_Integer nsel;
|
||||
|
||||
ShapeAnalysis_Edge sae; //szv#4:S4163:12Mar99 moved
|
||||
Standard_Boolean done = Standard_False;
|
||||
|
||||
while (!done) {
|
||||
Standard_Boolean found = Standard_False, tail = Standard_False, direct = Standard_False;
|
||||
Standard_Integer lwire=0;
|
||||
aSel.SetStop();
|
||||
Bnd_Box FVBox, LVBox;
|
||||
TopoDS_Vertex Vf, Vl;
|
||||
Vf = sae.FirstVertex(sewd->Edge(1));
|
||||
Vl = sae.LastVertex(sewd->Edge(sewd->NbEdges()));
|
||||
gp_Pnt pf, pl;
|
||||
pf = BRep_Tool::Pnt(Vf);
|
||||
pl = BRep_Tool::Pnt(Vl);
|
||||
FVBox.Set(pf);
|
||||
FVBox.SetGap(tolerance);
|
||||
LVBox.Set(pl);
|
||||
LVBox.SetGap(tolerance);
|
||||
|
||||
aSel.DefineBoxes(FVBox, LVBox);
|
||||
|
||||
if (shared)
|
||||
aSel.DefineVertexes(Vf,Vl);
|
||||
else{
|
||||
aSel.DefinePnt(pf,pl);
|
||||
aSel.SetTolerance(tolerance);
|
||||
}
|
||||
|
||||
nsel = aBBTree.Select(aSel);
|
||||
|
||||
if (nsel != 0 && !aSel.LastCheckStatus(ShapeExtend_FAIL)) {
|
||||
found = Standard_True;
|
||||
lwire = aSel.GetNb();
|
||||
tail = aSel.LastCheckStatus (ShapeExtend_DONE1) ||
|
||||
aSel.LastCheckStatus (ShapeExtend_DONE2);
|
||||
direct = aSel.LastCheckStatus (ShapeExtend_DONE1) ||
|
||||
aSel.LastCheckStatus (ShapeExtend_DONE3);
|
||||
aSel.LoadList(lwire);
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if (!direct) arrwires->ChangeValue(lwire).Reverse();
|
||||
TopoDS_Wire aCurW = TopoDS::Wire (arrwires->Value (lwire));
|
||||
Handle(ShapeExtend_WireData) acurwd =
|
||||
new ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire)));
|
||||
sewd->Add (acurwd, (tail ? 0 : 1));
|
||||
}
|
||||
else {
|
||||
//making wire
|
||||
//1.providing connection (see ShapeFix_Wire::FixConnected())
|
||||
//Standard_Integer i; // svv #1
|
||||
for (/*Standard_Integer*/ i = 1; i <= saw->NbEdges(); i++) {
|
||||
if (saw->CheckConnected (i)) {
|
||||
Standard_Integer n2 = i;
|
||||
Standard_Integer n1 = (n2 > 1 ? n2 - 1 : saw->NbEdges());
|
||||
TopoDS_Edge E1 = sewd->Edge(n1);
|
||||
TopoDS_Edge E2 = sewd->Edge(n2);
|
||||
|
||||
TopoDS_Vertex Vprev, Vfol, V; //connection vertex
|
||||
Vprev = sae.LastVertex (E1);
|
||||
Vfol = sae.FirstVertex (E2);
|
||||
|
||||
if (saw->LastCheckStatus (ShapeExtend_DONE1)) //absolutely confused
|
||||
V = Vprev;
|
||||
else {
|
||||
ShapeBuild_Vertex sbv;
|
||||
V = sbv.CombineVertex (Vprev, Vfol);
|
||||
}
|
||||
vertices.Bind (Vprev, V);
|
||||
vertices.Bind (Vfol, V);
|
||||
|
||||
//replace vertices to a new one
|
||||
ShapeBuild_Edge sbe;
|
||||
if (saw->NbEdges() < 2)
|
||||
sewd->Set (sbe.CopyReplaceVertices (E2, V, V), n2);
|
||||
else {
|
||||
sewd->Set (sbe.CopyReplaceVertices (E2, V, TopoDS_Vertex()), n2);
|
||||
if (!saw->LastCheckStatus (ShapeExtend_DONE1))
|
||||
sewd->Set (sbe.CopyReplaceVertices (E1, TopoDS_Vertex(), V), n1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//2.making wire
|
||||
TopoDS_Wire wire = sewd->Wire();
|
||||
if (!saw->CheckConnected (1) && saw->LastCheckStatus (ShapeExtend_OK))
|
||||
wire.Closed (Standard_True);
|
||||
owires->Append (wire);
|
||||
sewd->Clear();
|
||||
|
||||
// Recherche de la premier edge non traitee pour un autre wire.
|
||||
//Searching for first edge for next wire
|
||||
lwire = -1;
|
||||
for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length() && lwire == -1; i++)
|
||||
if (!aSel.ContWire(i)) lwire = i; //szv#4:S4163:12Mar99 optimized
|
||||
|
||||
if (lwire == -1) done = 1;
|
||||
else {
|
||||
sewd->Add (TopoDS::Wire (arrwires->Value (lwire)));
|
||||
aSel.LoadList(lwire);
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( /*Standard_Integer*/ i = 1; i <= iwires->Length(); i++)
|
||||
iwires->SetValue (i, arrwires->Value(i));
|
||||
}
|
||||
|
||||
static void SplitWire(const TopoDS_Wire& wire,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean shared,
|
||||
Handle(TopTools_HSequenceOfShape)& closed,
|
||||
Handle(TopTools_HSequenceOfShape)& open)
|
||||
{
|
||||
closed = new TopTools_HSequenceOfShape;
|
||||
open = new TopTools_HSequenceOfShape;
|
||||
Standard_Real tolerance = Max (toler, Precision::Confusion());
|
||||
|
||||
BRep_Builder B;
|
||||
ShapeAnalysis_Edge sae;
|
||||
|
||||
Handle(ShapeExtend_WireData) sewd = new ShapeExtend_WireData (wire);
|
||||
Standard_Integer nbedges = sewd->NbEdges();
|
||||
|
||||
//ConnectedEdgeSequence - list of indices of connected edges to build a wire
|
||||
TColStd_SequenceOfInteger ces;
|
||||
//statuses - array of flags describing the edge:
|
||||
//0-free, 1-in CES, 2-already in wire,
|
||||
//3-no closed wire can be produced starting at this edge
|
||||
TColStd_Array1OfInteger statuses (1, nbedges);
|
||||
statuses.Init (0);
|
||||
|
||||
//building closed wires
|
||||
Standard_Integer i; // svv #1
|
||||
for (i = 1; i <= nbedges; i++)
|
||||
if (statuses.Value (i) == 0) {
|
||||
ces.Append (i); statuses.SetValue (i, 1); //putting into CES
|
||||
Standard_Boolean SearchBackward = Standard_True;
|
||||
|
||||
while (Standard_True) {
|
||||
Standard_Integer ei = ces.Last(); //ei-edge index, number of current edge analyzed for connection
|
||||
Standard_Boolean found;
|
||||
TopoDS_Edge edge;
|
||||
TopoDS_Vertex lvertex;
|
||||
gp_Pnt lpoint;
|
||||
|
||||
//searching for connection in ces
|
||||
if (SearchBackward) {
|
||||
SearchBackward = Standard_False;
|
||||
found = Standard_False;
|
||||
edge = sewd->Edge (ces.Last());
|
||||
lvertex = sae.LastVertex (edge);
|
||||
lpoint = BRep_Tool::Pnt (lvertex);
|
||||
Standard_Integer j; // svv #1
|
||||
for (j = ces.Length(); (j >= 1) && !found; j--) {
|
||||
TopoDS_Vertex fv = sae.FirstVertex (sewd->Edge (ces.Value (j)) );
|
||||
gp_Pnt fp = BRep_Tool::Pnt (fv);
|
||||
if ((shared && lvertex.IsSame (fv)) ||
|
||||
(!shared && lpoint.IsEqual (fp, tolerance)))
|
||||
found = Standard_True;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
j++;//because of decreasing last iteration
|
||||
//making closed wire
|
||||
TopoDS_Wire wire1;
|
||||
B.MakeWire (wire1);
|
||||
for (Standard_Integer cesindex = j; cesindex <= ces.Length(); cesindex++) {
|
||||
B.Add (wire1, sewd->Edge (ces.Value (cesindex)));
|
||||
statuses.SetValue (ces.Value (cesindex), 2);
|
||||
}
|
||||
wire1.Closed (Standard_True);
|
||||
closed->Append (wire1);
|
||||
ces.Remove (j, ces.Length());
|
||||
if (ces.IsEmpty()) break;
|
||||
}
|
||||
}
|
||||
|
||||
//searching for connection among free edges
|
||||
found = Standard_False;
|
||||
ei = ces.Last();
|
||||
edge = sewd->Edge (ces.Last());
|
||||
lvertex = sae.LastVertex (edge);
|
||||
lpoint = BRep_Tool::Pnt (lvertex);
|
||||
Standard_Integer j; // svv #1
|
||||
for (j = 1; (j <= nbedges) && !found; j++)
|
||||
if (statuses.Value (j) == 0) {
|
||||
TopoDS_Vertex fv = sae.FirstVertex (sewd->Edge (j));
|
||||
gp_Pnt fp = BRep_Tool::Pnt (fv);
|
||||
if ((shared && lvertex.IsSame (fv)) ||
|
||||
(!shared && lpoint.IsEqual (fp, tolerance)))
|
||||
found = Standard_True;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
j--;//because of last iteration
|
||||
ces.Append (j); statuses.SetValue (j, 1);//putting into CES
|
||||
SearchBackward = Standard_True;
|
||||
continue;
|
||||
}
|
||||
|
||||
//no edges found - mark the branch as open (use status 3)
|
||||
statuses.SetValue (ces.Last(), 3);
|
||||
ces.Remove (ces.Length());
|
||||
if (ces.IsEmpty()) break;
|
||||
}
|
||||
}
|
||||
|
||||
//building open wires
|
||||
Handle(TopTools_HSequenceOfShape) edges = new TopTools_HSequenceOfShape;
|
||||
for (i = 1; i <= nbedges; i++)
|
||||
if (statuses.Value (i) != 2) edges->Append (sewd->Edge(i));
|
||||
|
||||
ShapeAnalysis_FreeBounds::ConnectEdgesToWires (edges, toler, shared, open);
|
||||
}
|
||||
|
||||
void ShapeAnalysis_FreeBounds::SplitWires(const Handle(TopTools_HSequenceOfShape)& wires,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean shared,
|
||||
Handle(TopTools_HSequenceOfShape)& closed,
|
||||
Handle(TopTools_HSequenceOfShape)& open)
|
||||
{
|
||||
closed = new TopTools_HSequenceOfShape;
|
||||
open = new TopTools_HSequenceOfShape;
|
||||
|
||||
for (Standard_Integer i = 1; i <= wires->Length(); i++) {
|
||||
Handle(TopTools_HSequenceOfShape) tmpclosed, tmpopen;
|
||||
SplitWire (TopoDS::Wire (wires->Value (i)), toler, shared, tmpclosed, tmpopen);
|
||||
closed->Append (tmpclosed);
|
||||
open->Append (tmpopen);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DispatchWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBounds::DispatchWires(const Handle(TopTools_HSequenceOfShape)& wires,
|
||||
TopoDS_Compound& closed,
|
||||
TopoDS_Compound& open)
|
||||
{
|
||||
BRep_Builder B;
|
||||
if (closed.IsNull()) B.MakeCompound (closed);
|
||||
if (open.IsNull()) B.MakeCompound (open);
|
||||
if (wires.IsNull()) return;
|
||||
|
||||
for (Standard_Integer iw = 1 ; iw <= wires->Length(); iw++)
|
||||
if ( wires->Value (iw).Closed() )
|
||||
B.Add (closed, wires->Value (iw));
|
||||
else
|
||||
B.Add (open, wires->Value (iw));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SplitWires
|
||||
//purpose : Splits compounds of closed (myWires) and open (myEdges) wires
|
||||
// into small closed wires according to fields mySplitClosed and
|
||||
// mySplitOpen and rebuilds compounds
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBounds::SplitWires()
|
||||
{
|
||||
if (!mySplitClosed && !mySplitOpen) return; //nothing to do
|
||||
|
||||
ShapeExtend_Explorer see;
|
||||
Handle(TopTools_HSequenceOfShape) closedwires, cw1, cw2,
|
||||
openwires, ow1, ow2;
|
||||
closedwires = see.SeqFromCompound (myWires, Standard_False);
|
||||
openwires = see.SeqFromCompound (myEdges, Standard_False);
|
||||
|
||||
if (mySplitClosed) SplitWires (closedwires, myTolerance, myShared, cw1, ow1);
|
||||
else {cw1 = closedwires; ow1 = new TopTools_HSequenceOfShape;}
|
||||
|
||||
if (mySplitOpen) SplitWires (openwires, myTolerance, myShared, cw2, ow2);
|
||||
else {cw2 = new TopTools_HSequenceOfShape; ow2 = openwires;}
|
||||
|
||||
closedwires = cw1; closedwires->Append (cw2);
|
||||
openwires = ow1; openwires->Append (ow2);
|
||||
|
||||
//szv#4:S4163:12Mar99 SGI warns
|
||||
TopoDS_Shape compWires = see.CompoundFromSeq (closedwires);
|
||||
TopoDS_Shape compEdges = see.CompoundFromSeq (openwires);
|
||||
myWires = TopoDS::Compound (compWires);
|
||||
myEdges = TopoDS::Compound (compEdges);
|
||||
}
|
26
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.lxx
Executable file
26
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.lxx
Executable file
@@ -0,0 +1,26 @@
|
||||
// File: ShapeAnalysis_FreeBounds.lxx
|
||||
// Created: Wed Sep 16 13:18:12 1998
|
||||
// Author: data exchange team
|
||||
// <det@nnov.matra-dtv.fr>
|
||||
// 25.12.98 pdn renaming methods GetWires and GetEdges to GetClosedWires and GetOpenWires respectively
|
||||
|
||||
//=======================================================================
|
||||
//function : GetClosedWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const TopoDS_Compound& ShapeAnalysis_FreeBounds::GetClosedWires() const
|
||||
{
|
||||
return myWires;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetOpenWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const TopoDS_Compound& ShapeAnalysis_FreeBounds::GetOpenWires() const
|
||||
{
|
||||
return myEdges;
|
||||
}
|
||||
|
162
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cdl
Executable file
162
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cdl
Executable file
@@ -0,0 +1,162 @@
|
||||
-- File: ShapeAnalysis_FreeBoundsProperties.cdl
|
||||
-- Created: Thu Jul 30 16:28:40 1998
|
||||
-- Author: Pavel DURANDIN <pdn@nnov.matra-dtv.fr>
|
||||
-- Roman LYGIN <rln@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class FreeBoundsProperties from ShapeAnalysis
|
||||
|
||||
---Purpose: This class is intended to calculate shape free bounds
|
||||
-- properties.
|
||||
-- This class provides the following functionalities:
|
||||
-- - calculates area of the contour,
|
||||
-- - calculates perimeter of the contour,
|
||||
-- - calculates ratio of average length to average width of the
|
||||
-- contour,
|
||||
-- - estimates average width of contour,
|
||||
-- - finds the notches (narrow 'V'-like sub-contour) on the
|
||||
-- contour.
|
||||
--
|
||||
-- For getting free bounds this class uses
|
||||
-- ShapeAnalysis_FreeBounds class.
|
||||
--
|
||||
-- For description of parameters used for initializing this
|
||||
-- class refer to CDL of ShapeAnalysis_FreeBounds.
|
||||
--
|
||||
-- Properties of each contour are stored in the data structure
|
||||
-- ShapeAnalysis_FreeBoundData.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Wire from TopoDS,
|
||||
FreeBoundData from ShapeAnalysis,
|
||||
HSequenceOfFreeBounds from ShapeAnalysis
|
||||
|
||||
is
|
||||
|
||||
Create returns FreeBoundsProperties from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create (shape : Shape from TopoDS;
|
||||
tolerance : Real;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_False)
|
||||
returns FreeBoundsProperties from ShapeAnalysis;
|
||||
---Purpose: Creates the object and calls corresponding Init.
|
||||
-- <shape> should be a compound of faces.
|
||||
|
||||
Create (shape : Shape from TopoDS;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_False);
|
||||
---Purpose: Creates the object and calls corresponding Init.
|
||||
-- <shape> should be a compound of shells.
|
||||
|
||||
Init (me: in out; shape : Shape from TopoDS;
|
||||
tolerance : Real;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_False);
|
||||
---Purpose: Initializes the object with given parameters.
|
||||
-- <shape> should be a compound of faces.
|
||||
|
||||
Init (me: in out; shape : Shape from TopoDS;
|
||||
splitclosed: Boolean = Standard_False;
|
||||
splitopen : Boolean = Standard_False);
|
||||
---Purpose: Initializes the object with given parameters.
|
||||
-- <shape> should be a compound of shells.
|
||||
|
||||
|
||||
---Level: Public
|
||||
|
||||
Perform (me: in out) returns Boolean;
|
||||
---Purpose: Builds and analyzes free bounds of the shape.
|
||||
-- First calls ShapeAnalysis_FreeBounds for building free
|
||||
-- bounds.
|
||||
-- Then on each free bound computes its properties:
|
||||
-- - area of the contour,
|
||||
-- - perimeter of the contour,
|
||||
-- - ratio of average length to average width of the contour,
|
||||
-- - average width of contour,
|
||||
-- - notches on the contour and for each notch
|
||||
-- - maximum width of the notch.
|
||||
---Returns: True - if no fails and free bounds are found,
|
||||
-- False - if fail or no free bounds are found
|
||||
|
||||
IsLoaded (me) returns Boolean;
|
||||
---Purpose: Returns True if shape is loaded
|
||||
---C++: inline
|
||||
|
||||
Shape (me) returns Shape from TopoDS;
|
||||
---Purpose: Returns shape
|
||||
---C++: inline
|
||||
|
||||
Tolerance (me) returns Real;
|
||||
---Purpose: Returns tolerance
|
||||
---C++: inline
|
||||
|
||||
NbFreeBounds (me) returns Integer;
|
||||
---Purpose: Returns number of free bounds
|
||||
---C++: inline
|
||||
|
||||
NbClosedFreeBounds (me) returns Integer;
|
||||
---Purpose: Returns number of closed free bounds
|
||||
---C++: inline
|
||||
|
||||
NbOpenFreeBounds (me) returns Integer;
|
||||
---Purpose: Returns number of open free bounds
|
||||
---C++: inline
|
||||
|
||||
ClosedFreeBounds (me) returns HSequenceOfFreeBounds from ShapeAnalysis;
|
||||
---Purpose: Returns all closed free bounds
|
||||
---C++: inline
|
||||
|
||||
OpenFreeBounds (me) returns HSequenceOfFreeBounds from ShapeAnalysis;
|
||||
---Purpose: Returns all open free bounds
|
||||
---C++: inline
|
||||
|
||||
ClosedFreeBound (me; index: Integer) returns FreeBoundData from ShapeAnalysis;
|
||||
---Purpose: Returns properties of closed free bound specified by its rank
|
||||
-- number
|
||||
---C++: inline
|
||||
|
||||
OpenFreeBound (me; index: Integer) returns FreeBoundData from ShapeAnalysis;
|
||||
---Purpose: Returns properties of open free bound specified by its rank
|
||||
-- number
|
||||
---C++: inline
|
||||
|
||||
|
||||
---Level: Internal
|
||||
|
||||
DispatchBounds (me: in out) returns Boolean;
|
||||
|
||||
CheckContours (me: in out; prec: Real = 0.0) returns Boolean;
|
||||
|
||||
CheckNotches (me: in out; prec: Real = 0.0) returns Boolean;
|
||||
|
||||
CheckNotches(me: in out; fbData: in out FreeBoundData from ShapeAnalysis;
|
||||
prec : Real = 0.0)
|
||||
returns Boolean;
|
||||
|
||||
CheckNotches(me: in out; freebound: Wire from TopoDS;
|
||||
num : Integer;
|
||||
notch : out Wire from TopoDS;
|
||||
distMax : out Real;
|
||||
prec : Real = 0.0)
|
||||
returns Boolean;
|
||||
|
||||
FillProperties (me: in out; fbData: in out FreeBoundData from ShapeAnalysis;
|
||||
prec : Real = 0.0)
|
||||
returns Boolean;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myShape : Shape from TopoDS;
|
||||
myTolerance : Real;
|
||||
mySplitClosed : Boolean;
|
||||
mySplitOpen : Boolean;
|
||||
|
||||
myClosedFreeBounds: HSequenceOfFreeBounds from ShapeAnalysis;
|
||||
myOpenFreeBounds : HSequenceOfFreeBounds from ShapeAnalysis;
|
||||
|
||||
end FreeBoundsProperties;
|
394
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx
Executable file
394
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.cxx
Executable file
@@ -0,0 +1,394 @@
|
||||
// File: ShapeAnalysis_ShellBounds.cxx
|
||||
// Created: Tue Aug 4 14:03:19 1998
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@nnov.matra-dtv.fr>
|
||||
// 25.12.98 pdn renaming of ShapeAnalysis_FreeBounds and ShapeAnalysis_Wire methods
|
||||
//szv#4 S4163
|
||||
|
||||
#include <ShapeAnalysis_FreeBoundsProperties.ixx>
|
||||
#include <ShapeAnalysis_FreeBounds.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <ShapeAnalysis_Wire.hxx>
|
||||
#include <ShapeAnalysis_FreeBoundData.hxx>
|
||||
|
||||
#include <ShapeExtend_Explorer.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#define NbControl 23
|
||||
|
||||
static void ContourProperties(TopoDS_Wire wire,
|
||||
Standard_Real& countourArea,
|
||||
Standard_Real& countourLength)
|
||||
{
|
||||
Standard_Integer nbe = 0;
|
||||
Standard_Real length = 0.0;
|
||||
gp_XYZ area(.0,.0,.0);
|
||||
gp_XYZ prev, cont;
|
||||
|
||||
for (BRepTools_WireExplorer exp(wire); exp.More(); exp.Next()) {
|
||||
TopoDS_Edge Edge = exp.Current(); nbe++;
|
||||
|
||||
Standard_Real First, Last;
|
||||
Handle(Geom_Curve) c3d;
|
||||
ShapeAnalysis_Edge sae;
|
||||
if (!sae.Curve3d(Edge,c3d,First,Last)) continue;
|
||||
|
||||
Standard_Integer ibeg = 0;
|
||||
if ( nbe == 1 ) {
|
||||
gp_Pnt pntIni = c3d->Value(First);
|
||||
prev = pntIni.XYZ();
|
||||
cont = prev;
|
||||
ibeg = 1;
|
||||
}
|
||||
|
||||
for ( Standard_Integer i = ibeg; i < NbControl; i++) {
|
||||
Standard_Real prm = ((NbControl-1-i)*First + i*Last)/(NbControl-1);
|
||||
gp_Pnt pntCurr = c3d->Value(prm);
|
||||
gp_XYZ curr = pntCurr.XYZ();
|
||||
gp_XYZ delta = curr - prev;
|
||||
length += delta.Modulus();
|
||||
area += curr ^ prev;
|
||||
prev = curr;
|
||||
}
|
||||
}
|
||||
|
||||
area += cont ^ prev;
|
||||
countourArea = area.Modulus()/2;
|
||||
countourLength = length;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBoundsProperties
|
||||
//purpose : Empty constructor
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBoundsProperties::ShapeAnalysis_FreeBoundsProperties()
|
||||
{
|
||||
myClosedFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
myOpenFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
myTolerance = 0.;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBoundsProperties
|
||||
//purpose : Creates the object and calls corresponding Init.
|
||||
// <shape> should be a compound of faces.
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBoundsProperties::ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape,
|
||||
const Standard_Real tolerance,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen)
|
||||
{
|
||||
myClosedFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
myOpenFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
Init(shape, tolerance, splitclosed, splitopen);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_FreeBoundsProperties
|
||||
//purpose : Creates the object and calls corresponding Init.
|
||||
// <shape> should be a compound of shells.
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_FreeBoundsProperties::ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen)
|
||||
{
|
||||
myClosedFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
myOpenFreeBounds = new ShapeAnalysis_HSequenceOfFreeBounds();
|
||||
myTolerance =0.;
|
||||
Init(shape, splitclosed, splitopen);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : Initializes the object with given parameters.
|
||||
// <shape> should be a compound of faces.
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBoundsProperties::Init(const TopoDS_Shape& shape,
|
||||
const Standard_Real tolerance,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen)
|
||||
{
|
||||
Init(shape, splitclosed, splitopen);
|
||||
myTolerance = tolerance;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : Initializes the object with given parameters.
|
||||
// <shape> should be a compound of shells.
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_FreeBoundsProperties::Init(const TopoDS_Shape& shape,
|
||||
const Standard_Boolean splitclosed,
|
||||
const Standard_Boolean splitopen)
|
||||
{
|
||||
myShape = shape;
|
||||
mySplitClosed = splitclosed;
|
||||
mySplitOpen = splitopen;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose : Builds and analyzes free bounds of the shape.
|
||||
// First calls ShapeAnalysis_FreeBounds for building free
|
||||
// bounds.
|
||||
// Then on each free bound computes its properties:
|
||||
// - area of the contour,
|
||||
// - perimeter of the contour,
|
||||
// - ratio of average length to average width of the contour,
|
||||
// - average width of contour,
|
||||
// - notches on the contour and for each notch
|
||||
// - maximum width of the notch.
|
||||
//returns: True - if no fails and free bounds are found,
|
||||
// False - if fail or no free bounds are found
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::Perform()
|
||||
{
|
||||
Standard_Boolean result = Standard_False;
|
||||
result |= DispatchBounds();
|
||||
result |= CheckNotches();
|
||||
result |= CheckContours();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DispatchBounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::DispatchBounds()
|
||||
{
|
||||
if (!IsLoaded()) return Standard_False;
|
||||
|
||||
TopoDS_Compound tmpClosedBounds, tmpOpenBounds;
|
||||
if ( myTolerance > 0.) {
|
||||
ShapeAnalysis_FreeBounds safb(myShape, myTolerance, mySplitClosed, mySplitOpen);
|
||||
tmpClosedBounds = safb.GetClosedWires();
|
||||
tmpOpenBounds = safb.GetOpenWires();
|
||||
}
|
||||
else {
|
||||
ShapeAnalysis_FreeBounds safb(myShape, mySplitClosed, mySplitOpen);
|
||||
tmpClosedBounds = safb.GetClosedWires();
|
||||
tmpOpenBounds = safb.GetOpenWires();
|
||||
}
|
||||
|
||||
ShapeExtend_Explorer shexpl;
|
||||
Handle(TopTools_HSequenceOfShape) tmpSeq = shexpl.SeqFromCompound(tmpClosedBounds,Standard_False);
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for (i = 1; i<=tmpSeq->Length(); i++) {
|
||||
TopoDS_Wire wire = TopoDS::Wire(tmpSeq->Value(i));
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData= new ShapeAnalysis_FreeBoundData() ;
|
||||
fbData->SetFreeBound(wire);
|
||||
myClosedFreeBounds -> Append(fbData);
|
||||
}
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) tmpSeq2 = shexpl.SeqFromCompound(tmpOpenBounds,Standard_False);
|
||||
for(i = 1; i<=tmpSeq2->Length(); i++) {
|
||||
TopoDS_Wire wire = TopoDS::Wire(tmpSeq2->Value(i));
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData = new ShapeAnalysis_FreeBoundData;
|
||||
fbData->SetFreeBound(wire);
|
||||
myOpenFreeBounds -> Append(fbData);
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckNotches
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::CheckNotches(const Standard_Real prec)
|
||||
{
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for(i = 1; i <= myClosedFreeBounds->Length(); i++) {
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData = myClosedFreeBounds->Value(i);
|
||||
CheckNotches(fbData, prec);
|
||||
}
|
||||
for( i = 1; i <= myOpenFreeBounds->Length(); i++) {
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData = myOpenFreeBounds->Value(i);
|
||||
CheckNotches(fbData, prec);
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckNotches
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::CheckNotches(Handle(ShapeAnalysis_FreeBoundData)& fbData,
|
||||
const Standard_Real prec)
|
||||
{
|
||||
ShapeExtend_WireData swd(fbData->FreeBound());
|
||||
if (swd.NbEdges() > 1)
|
||||
for (Standard_Integer j=1; j <= swd.NbEdges(); j++) {
|
||||
TopoDS_Wire notch;
|
||||
Standard_Real dMax;
|
||||
if (CheckNotches(fbData->FreeBound(), j, notch, dMax, prec))
|
||||
fbData->AddNotch(notch, dMax);
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckContours
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::CheckContours(const Standard_Real prec)
|
||||
{
|
||||
Standard_Boolean status = Standard_False;
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for( i = 1; i <= myClosedFreeBounds->Length(); i++) {
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData = myClosedFreeBounds->Value(i);
|
||||
status |= FillProperties(fbData,prec);
|
||||
}
|
||||
for ( i = 1; i <= myOpenFreeBounds->Length(); i++) {
|
||||
Handle(ShapeAnalysis_FreeBoundData) fbData = myOpenFreeBounds->Value(i);
|
||||
status |= FillProperties(fbData,prec);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckNotches
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::CheckNotches(const TopoDS_Wire& wire,
|
||||
const Standard_Integer num,
|
||||
TopoDS_Wire& notch,
|
||||
Standard_Real& distMax,
|
||||
const Standard_Real /*prec*/)
|
||||
{
|
||||
Standard_Real tol = Max ( myTolerance, Precision::Confusion());
|
||||
Handle(ShapeExtend_WireData) wdt = new ShapeExtend_WireData(wire);
|
||||
BRep_Builder B;
|
||||
B.MakeWire(notch);
|
||||
|
||||
if ( (num <= 0)||(num > wdt->NbEdges()) ) return Standard_False;
|
||||
|
||||
Standard_Integer n1 = ( num > 0 ? num : wdt->NbEdges() );
|
||||
Standard_Integer n2 = ( n1 < wdt->NbEdges() ? n1+1 : 1 );
|
||||
|
||||
TopoDS_Edge E1 = wdt->Edge(n1);
|
||||
B.Add(notch,E1);
|
||||
|
||||
Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire;
|
||||
saw->Load(wdt);
|
||||
saw->SetPrecision(myTolerance);
|
||||
if ( saw->CheckSmall( n2, tol ) ) {
|
||||
B.Add(notch,wdt->Edge(n2));
|
||||
n2 = ( n2 < wdt->NbEdges() ? n2+1 : 1);
|
||||
}
|
||||
|
||||
TopoDS_Edge E2 = wdt->Edge(n2);
|
||||
B.Add(notch,E2);
|
||||
|
||||
Standard_Real First1, Last1, First2, Last2;
|
||||
Handle(Geom_Curve) c3d1, c3d2;
|
||||
ShapeAnalysis_Edge sae;
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ( !sae.Curve3d(E1, c3d1, First1, Last1) ||
|
||||
!sae.Curve3d(E2, c3d2, First2, Last2) ) return Standard_False;
|
||||
|
||||
gp_Pnt pnt;
|
||||
gp_Vec vec1, vec2;
|
||||
c3d1->D1(Last1, pnt, vec1);
|
||||
c3d2->D1(First2,pnt, vec2);
|
||||
if ( E1.Orientation() == TopAbs_REVERSED ) vec1.Reverse();
|
||||
if ( E2.Orientation() == TopAbs_REVERSED ) vec2.Reverse();
|
||||
|
||||
Standard_Real angl = Abs( vec1.Angle(vec2));
|
||||
if (angl > 0.95*PI) {
|
||||
distMax = .0;
|
||||
for (Standard_Integer i = 0; i < NbControl; i++) {
|
||||
Standard_Real prm = ((NbControl-1-i)*First1 + i*Last1)/(NbControl-1);
|
||||
gp_Pnt pntCurr = c3d1->Value(prm);
|
||||
|
||||
Standard_Real p1, p2;
|
||||
if ( First2 < Last2 ) {
|
||||
p1 = First2;
|
||||
p2 = Last2;
|
||||
}
|
||||
else {
|
||||
p1 = Last2;
|
||||
p2 = First2;
|
||||
}
|
||||
|
||||
//szv#4:S4163:12Mar99 warning
|
||||
GeomAPI_ProjectPointOnCurve ppc(pntCurr, c3d2, p1, p2);
|
||||
Standard_Real newDist = (ppc.NbPoints() ? ppc.LowerDistance() : 0);
|
||||
if ( newDist > distMax ) distMax = newDist;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FillProperties
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_FreeBoundsProperties::FillProperties(Handle(ShapeAnalysis_FreeBoundData)& fbData,
|
||||
const Standard_Real /*prec*/)
|
||||
{
|
||||
Standard_Real area, length;
|
||||
ContourProperties(fbData->FreeBound(), area, length);
|
||||
|
||||
Standard_Real r = 0;
|
||||
Standard_Real aver = 0;
|
||||
|
||||
if ( length != 0. ) { //szv#4:S4163:12Mar99 anti-exception
|
||||
Standard_Real k = area /(length*length); //szv#4:S4163:12Mar99
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ( k != 0. ) { //szv#4:S4163:12Mar99 anti-exception
|
||||
Standard_Real aux = 1. - 16.*k;
|
||||
if ( aux >= 0.) {
|
||||
r = (1. + sqrt(aux))/(8.*k);
|
||||
aver = length/(2.*r);
|
||||
r -= 1.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fbData->SetArea(area);
|
||||
fbData->SetPerimeter(length);
|
||||
fbData->SetRatio(r);
|
||||
fbData->SetWidth(aver);
|
||||
|
||||
return Standard_True;
|
||||
}
|
116
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.lxx
Executable file
116
src/ShapeAnalysis/ShapeAnalysis_FreeBoundsProperties.lxx
Executable file
@@ -0,0 +1,116 @@
|
||||
// File: ShapeAnalysis_FreeBoundsProperties.lxx
|
||||
// Created: Mon Aug 17 17:52:47 1998
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@nnov.matra-dtv.fr>
|
||||
|
||||
#include <ShapeAnalysis_HSequenceOfFreeBounds.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose : Returns shape
|
||||
//=======================================================================
|
||||
|
||||
inline TopoDS_Shape ShapeAnalysis_FreeBoundsProperties::Shape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLoaded
|
||||
//purpose : Returns True if shape is loaded
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_FreeBoundsProperties::IsLoaded() const
|
||||
{
|
||||
return !(myShape.IsNull());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Tolerance
|
||||
//purpose : Returns tolerance
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_FreeBoundsProperties::Tolerance() const
|
||||
{
|
||||
return myTolerance;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFreeBounds
|
||||
//purpose : Returns number of free bounds
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_FreeBoundsProperties::NbFreeBounds() const
|
||||
{
|
||||
return (myClosedFreeBounds->Length() + myOpenFreeBounds->Length());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbClosedFreeBounds
|
||||
//purpose : Returns number of closed free bounds
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_FreeBoundsProperties::NbClosedFreeBounds() const
|
||||
{
|
||||
return myClosedFreeBounds->Length();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbOpenFreeBounds
|
||||
//purpose : Returns number of open free bounds
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_FreeBoundsProperties::NbOpenFreeBounds() const
|
||||
{
|
||||
return myOpenFreeBounds->Length();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ClosedFreeBounds
|
||||
//purpose : Returns all closed free bounds
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(ShapeAnalysis_HSequenceOfFreeBounds) ShapeAnalysis_FreeBoundsProperties::ClosedFreeBounds() const
|
||||
{
|
||||
return myClosedFreeBounds;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenFreeBounds
|
||||
//purpose : Returns all open free bounds
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(ShapeAnalysis_HSequenceOfFreeBounds) ShapeAnalysis_FreeBoundsProperties::OpenFreeBounds() const
|
||||
{
|
||||
return myOpenFreeBounds;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClosedFreeBound
|
||||
//purpose : Returns properties of closed free bound specified by its rank
|
||||
// number
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(ShapeAnalysis_FreeBoundData) ShapeAnalysis_FreeBoundsProperties::ClosedFreeBound(const Standard_Integer index) const
|
||||
{
|
||||
return myClosedFreeBounds->Value(index);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OpenFreeBound
|
||||
//purpose : Returns properties of open free bound specified by its rank
|
||||
// number
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(ShapeAnalysis_FreeBoundData) ShapeAnalysis_FreeBoundsProperties::OpenFreeBound(const Standard_Integer index) const
|
||||
{
|
||||
return myOpenFreeBounds->Value(index);
|
||||
}
|
||||
|
||||
|
41
src/ShapeAnalysis/ShapeAnalysis_Geom.cdl
Executable file
41
src/ShapeAnalysis/ShapeAnalysis_Geom.cdl
Executable file
@@ -0,0 +1,41 @@
|
||||
-- File: ShapeAnalysis_Geom.cdl
|
||||
-- Created: Wed Jun 3 12:00:12 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Geom from ShapeAnalysis
|
||||
|
||||
---Purpose: Analyzing tool aimed to work on primitive geometrical objects
|
||||
|
||||
uses
|
||||
HArray2OfReal from TColStd,
|
||||
Trsf from gp,
|
||||
Pln from gp,
|
||||
Array1OfPnt from TColgp
|
||||
|
||||
raises
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
NearestPlane (myclass; Pnts: Array1OfPnt from TColgp;
|
||||
aPln: out Pln from gp;
|
||||
Dmax: out Real)
|
||||
returns Boolean;
|
||||
---Purpose : Builds a plane out of a set of points in array
|
||||
-- Returns in <dmax> the maximal distance between the produced
|
||||
-- plane and given points
|
||||
|
||||
PositionTrsf (myclass; coefs: HArray2OfReal from TColStd;
|
||||
trsf: out Trsf from gp;
|
||||
unit, prec : Real)
|
||||
returns Boolean
|
||||
---Purpose: Builds transfromation object out of matrix.
|
||||
-- Matrix must be 3 x 4.
|
||||
-- Unit is used as multiplier.
|
||||
raises OutOfRange from Standard;
|
||||
-- If numer of rows is greater than 3 or number of columns is
|
||||
-- greater than 4
|
||||
|
||||
end Geom;
|
179
src/ShapeAnalysis/ShapeAnalysis_Geom.cxx
Executable file
179
src/ShapeAnalysis/ShapeAnalysis_Geom.cxx
Executable file
@@ -0,0 +1,179 @@
|
||||
//szv#4 S4163
|
||||
#include <ShapeAnalysis_Geom.ixx>
|
||||
|
||||
#include <GProp_PGProps.hxx>
|
||||
#include <GProp_PrincipalProps.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : NearestPlane
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Geom::NearestPlane(const TColgp_Array1OfPnt& Pnts,
|
||||
gp_Pln& aPln, Standard_Real& Dmax)
|
||||
{
|
||||
//szv#4:S4163:12Mar99 warning
|
||||
GProp_PGProps Pmat(Pnts);
|
||||
gp_Pnt g = Pmat.CentreOfMass();
|
||||
Standard_Real Xg,Yg,Zg;
|
||||
g.Coord(Xg,Yg,Zg);
|
||||
|
||||
GProp_PrincipalProps Pp = Pmat.PrincipalProperties();
|
||||
gp_Vec V1 = Pp.FirstAxisOfInertia();
|
||||
Standard_Real Xv1,Yv1,Zv1;
|
||||
V1.Coord(Xv1,Yv1,Zv1);
|
||||
gp_Vec V2 = Pp.SecondAxisOfInertia();
|
||||
Standard_Real Xv2,Yv2,Zv2;
|
||||
V2.Coord(Xv2,Yv2,Zv2);
|
||||
gp_Vec V3 = Pp.ThirdAxisOfInertia();
|
||||
Standard_Real Xv3,Yv3,Zv3;
|
||||
V3.Coord(Xv3,Yv3,Zv3);
|
||||
|
||||
Standard_Real D,X,Y,Z;
|
||||
Standard_Real Dmx1 = RealFirst();
|
||||
Standard_Real Dmn1 = RealLast();
|
||||
Standard_Real Dmx2 = RealFirst();
|
||||
Standard_Real Dmn2 = RealLast();
|
||||
Standard_Real Dmx3 = RealFirst();
|
||||
Standard_Real Dmn3 = RealLast();
|
||||
|
||||
Standard_Integer ilow = Pnts.Lower(), iup = Pnts.Upper();
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for (i = ilow; i <= iup; i ++) {
|
||||
Pnts(i).Coord(X,Y,Z);
|
||||
D = (X-Xg)*Xv1 +(Y-Yg)*Yv1 + (Z-Zg)*Zv1;
|
||||
if (D > Dmx1) Dmx1 = D;
|
||||
if (D < Dmn1) Dmn1 = D;
|
||||
D = (X-Xg)*Xv2 +(Y-Yg)*Yv2 + (Z-Zg)*Zv2;
|
||||
if (D > Dmx2) Dmx2 = D;
|
||||
if (D < Dmn2) Dmn2 = D;
|
||||
D = (X-Xg)*Xv3 +(Y-Yg)*Yv3 + (Z-Zg)*Zv3;
|
||||
if (D > Dmx3) Dmx3 = D;
|
||||
if (D < Dmn3) Dmn3 = D;
|
||||
}
|
||||
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
Standard_Real Dev1 = Dmx1-Dmn1, Dev2 = Dmx2-Dmn2, Dev3 = Dmx3-Dmn3;
|
||||
Standard_Integer It = (Dev1 < Dev2)? ((Dev1 < Dev3)? 1 : 3) : ((Dev2 < Dev3)? 2 : 3);
|
||||
|
||||
switch (It) {
|
||||
case 1:
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ((2.*Dev1 > Dev2) || (2.*Dev1 > Dev3)) It = 0;
|
||||
else aPln = gp_Pln(g,V1);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ((2.*Dev2 > Dev1) || (2.*Dev2 > Dev3)) It = 0;
|
||||
else aPln = gp_Pln(g,V2);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ((2.*Dev3 > Dev2) || (2.*Dev3 > Dev1)) It = 0;
|
||||
else aPln = gp_Pln(g,V3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Dmax = RealFirst();
|
||||
if ( It != 0 ) //szv#4:S4163:12Mar99 anti-exception
|
||||
for (i = ilow; i <= iup; i ++) {
|
||||
D = aPln.Distance (Pnts(i));
|
||||
if (Dmax < D) Dmax = D;
|
||||
}
|
||||
|
||||
return (It != 0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PositionTrsf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Geom::PositionTrsf(const Handle(TColStd_HArray2OfReal)& coefs,gp_Trsf& trsf,
|
||||
const Standard_Real unit,const Standard_Real prec)
|
||||
{
|
||||
Standard_Boolean result = Standard_True;
|
||||
|
||||
trsf = gp_Trsf(); //szv#4:S4163:12Mar99 moved
|
||||
|
||||
if (coefs.IsNull()) return Standard_True; //szv#4:S4163:12Mar99 moved
|
||||
|
||||
gp_GTrsf gtrsf;
|
||||
for (Standard_Integer i = 1; i <= 3; i ++)
|
||||
for (Standard_Integer j = 1; j <= 4; j ++)
|
||||
gtrsf.SetValue (i,j, coefs->Value(i,j));
|
||||
|
||||
//try { //szv#4:S4163:12Mar99 waste try
|
||||
//// trsf = gtrsf.Trsf();
|
||||
// --- Prec et Unit ont ete lues suite aux StepFile_Read
|
||||
// Valables pour tous les composants d un assemblage transmis
|
||||
//trsf = gp_Trsf(); // Identite forcee au depart //szv#4:S4163:12Mar99 not needed
|
||||
// On prend le contenu de <gtrsf>. Attention a l adressage
|
||||
gp_XYZ v1 ( gtrsf.Value(1,1), gtrsf.Value(2,1), gtrsf.Value(3,1) );
|
||||
gp_XYZ v2 ( gtrsf.Value(1,2), gtrsf.Value(2,2), gtrsf.Value(3,2) );
|
||||
gp_XYZ v3 ( gtrsf.Value(1,3), gtrsf.Value(2,3), gtrsf.Value(3,3) );
|
||||
// A-t-on affaire a une similitude ?
|
||||
Standard_Real m1 = v1.Modulus();
|
||||
Standard_Real m2 = v2.Modulus();
|
||||
Standard_Real m3 = v3.Modulus();
|
||||
|
||||
// D abord est-elle singuliere cette matrice ?
|
||||
if (m1 < prec || m2 < prec || m3 < prec) return Standard_False;
|
||||
Standard_Real mm = (m1+m2+m3)/3.; // voici la Norme moyenne, cf Scale
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
Standard_Real pmm = prec*mm;
|
||||
if ( Abs(m1 - mm) > pmm || Abs(m2 - mm) > pmm || Abs(m3 - mm) > pmm )
|
||||
return Standard_False;
|
||||
//szv#4:S4163:12Mar99 warning
|
||||
v1.Divide(m1);
|
||||
v2.Divide(m2);
|
||||
v3.Divide(m3);
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if ( Abs(v1.Dot(v2)) > prec || Abs(v2.Dot(v3)) > prec || Abs(v3.Dot(v1)) > prec )
|
||||
return Standard_False;
|
||||
|
||||
// Ici, Orthogonale et memes normes. En plus on l a Normee
|
||||
// On isole le cas de l Identite (tellement facile et avantageux)
|
||||
if (v1.X() != 1 || v1.Y() != 0 || v1.Z() != 0 ||
|
||||
v2.X() != 0 || v2.Y() != 1 || v2.Z() != 0 ||
|
||||
v3.X() != 0 || v3.Y() != 0 || v3.Z() != 1 ) {
|
||||
// Pas Identite : vraie construction depuis un Ax3
|
||||
gp_Dir d1(v1);
|
||||
gp_Dir d2(v2);
|
||||
gp_Dir d3(v3);
|
||||
gp_Ax3 axes (gp_Pnt(0,0,0),d3,d1);
|
||||
d3.Cross(d1);
|
||||
if (d3.Dot(d2) < 0) axes.YReverse();
|
||||
trsf.SetTransformation(axes);
|
||||
}
|
||||
|
||||
// Restent les autres caracteristiques :
|
||||
if ( Abs(mm - 1.) > prec ) trsf.SetScale(gp_Pnt(0,0,0), mm); //szv#4:S4163:12Mar99 optimized
|
||||
gp_Vec tp (gtrsf.TranslationPart());
|
||||
if (unit != 1.) tp.Multiply(unit);
|
||||
if (tp.X() != 0 || tp.Y() != 0 || tp.Z() != 0) trsf.SetTranslationPart(tp);
|
||||
/* }
|
||||
catch(Standard_Failure) {
|
||||
trsf = gp_Trsf();
|
||||
result = Standard_False;
|
||||
} */
|
||||
|
||||
return result;
|
||||
}
|
212
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.cdl
Executable file
212
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.cdl
Executable file
@@ -0,0 +1,212 @@
|
||||
-- File: ShapeAnalysis_ShapeContents.cdl
|
||||
-- Created: Thu Feb 25 16:53:11 1999
|
||||
-- Author: Pavel DURANDIN
|
||||
-- <pdn@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class ShapeContents from ShapeAnalysis
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
|
||||
Shape from TopoDS,
|
||||
HSequenceOfShape from TopTools
|
||||
|
||||
is
|
||||
|
||||
Create returns ShapeContents from ShapeAnalysis;
|
||||
---Purpose: Initialize fields and call ClearFlags()
|
||||
|
||||
Clear(me:in out);
|
||||
---Purpose: Clears all accumulated statictics
|
||||
|
||||
ClearFlags(me:in out);
|
||||
---Purpose: Clears all flags
|
||||
|
||||
Perform(me: in out;shape: Shape from TopoDS);
|
||||
---Purpose: Counts quantities of sun-shapes in shape and
|
||||
-- stores sub-shapes according to flags
|
||||
|
||||
--Methods for setting parameters
|
||||
|
||||
ModifyBigSplineMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- with edges if its 3D curves has more than 8192 poles.
|
||||
---Default: False
|
||||
|
||||
ModifyIndirectMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- on indirect surfaces
|
||||
---Default: False
|
||||
|
||||
ModifyOffestSurfaceMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- on offset surfaces.
|
||||
---Default: False
|
||||
|
||||
ModifyTrimmed3dMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- with edges if ist 3D curves are trimmed curves
|
||||
---Default: False
|
||||
|
||||
ModifyOffsetCurveMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- with edges if its 3D curves and pcurves are offest curves
|
||||
---Default: False
|
||||
|
||||
ModifyTrimmed2dMode(me: in out) returns Boolean;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Returns (modifiable) the flag which defines whether to store faces
|
||||
-- with edges if its pcurves are trimmed curves
|
||||
---Default: False
|
||||
|
||||
-- Methods for fetching results
|
||||
|
||||
NbSolids(me) returns Integer;
|
||||
---C++: inline
|
||||
NbShells(me) returns Integer;
|
||||
---C++: inline
|
||||
NbFaces(me) returns Integer;
|
||||
---C++: inline
|
||||
NbWires(me) returns Integer;
|
||||
---C++: inline
|
||||
NbEdges(me) returns Integer;
|
||||
---C++: inline
|
||||
NbVertices(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSolidsWithVoids(me) returns Integer;
|
||||
---C++: inline
|
||||
NbBigSplines(me) returns Integer;
|
||||
---C++: inline
|
||||
NbC0Surfaces(me) returns Integer;
|
||||
---C++: inline
|
||||
NbC0Curves(me) returns Integer;
|
||||
---C++: inline
|
||||
NbOffsetSurf(me) returns Integer;
|
||||
---C++: inline
|
||||
NbIndirectSurf(me) returns Integer;
|
||||
---C++: inline
|
||||
NbOffsetCurves(me) returns Integer;
|
||||
---C++: inline
|
||||
NbTrimmedCurve2d(me) returns Integer;
|
||||
---C++: inline
|
||||
NbTrimmedCurve3d(me) returns Integer;
|
||||
---C++: inline
|
||||
NbBSplibeSurf(me) returns Integer;
|
||||
---C++: inline
|
||||
NbBezierSurf(me) returns Integer;
|
||||
---C++: inline
|
||||
NbTrimSurf(me) returns Integer;
|
||||
---C++: inline
|
||||
NbWireWitnSeam(me) returns Integer;
|
||||
---C++: inline
|
||||
NbWireWithSevSeams(me) returns Integer;
|
||||
---C++: inline
|
||||
NbFaceWithSevWires(me) returns Integer;
|
||||
---C++: inline
|
||||
NbNoPCurve(me) returns Integer;
|
||||
---C++: inline
|
||||
NbFreeFaces(me) returns Integer;
|
||||
---C++: inline
|
||||
NbFreeWires(me) returns Integer;
|
||||
---C++:inline
|
||||
NbFreeEdges(me) returns Integer;
|
||||
---C++: inline
|
||||
|
||||
NbSharedSolids(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedShells(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedFaces(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedWires(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedFreeWires(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedFreeEdges(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedEdges(me) returns Integer;
|
||||
---C++: inline
|
||||
NbSharedVertices(me) returns Integer;
|
||||
---C++: inline
|
||||
|
||||
-- Methods for obtaining sequenses of selected shapes
|
||||
|
||||
BigSplineSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
IndirectSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
OffsetSurfaceSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
Trimmed3dSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
OffsetCurveSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
Trimmed2dSec(me) returns HSequenceOfShape from TopTools;
|
||||
---C++: inline
|
||||
|
||||
fields
|
||||
|
||||
myNbSolids: Integer;
|
||||
myNbShells: Integer;
|
||||
myNbFaces : Integer;
|
||||
myNbWires : Integer;
|
||||
myNbEdges : Integer;
|
||||
myNbVertices : Integer;
|
||||
myNbSolidsWithVoids: Integer;
|
||||
myNbBigSplines : Integer;
|
||||
myNbC0Surfaces : Integer;
|
||||
myNbC0Curves : Integer;
|
||||
myNbOffsetSurf : Integer;
|
||||
myNbIndirectSurf : Integer;
|
||||
myNbOffsetCurves : Integer;
|
||||
myNbTrimmedCurve2d : Integer;
|
||||
myNbTrimmedCurve3d : Integer;
|
||||
myNbBSplibeSurf : Integer;
|
||||
myNbBezierSurf : Integer;
|
||||
myNbTrimSurf : Integer;
|
||||
myNbWireWitnSeam : Integer;
|
||||
myNbWireWithSevSeams: Integer;
|
||||
myNbFaceWithSevWires: Integer;
|
||||
myNbNoPCurve : Integer;
|
||||
myNbFreeFaces : Integer;
|
||||
myNbFreeWires : Integer;
|
||||
myNbFreeEdges : Integer;
|
||||
|
||||
myNbSharedSolids: Integer;
|
||||
myNbSharedShells: Integer;
|
||||
myNbSharedFaces : Integer;
|
||||
myNbSharedWires : Integer;
|
||||
myNbSharedFreeWires:Integer;
|
||||
myNbSharedFreeEdges:Integer;
|
||||
myNbSharedEdges :Integer;
|
||||
myNbSharedVertices :Integer;
|
||||
|
||||
myBigSplineMode : Boolean;
|
||||
myIndirectMode : Boolean;
|
||||
myOffestSurfaceMode: Boolean;
|
||||
myTrimmed3dMode : Boolean;
|
||||
myOffsetCurveMode : Boolean;
|
||||
myTrimmed2dMode : Boolean;
|
||||
|
||||
myBigSplineSec : HSequenceOfShape from TopTools;
|
||||
myIndirectSec : HSequenceOfShape from TopTools;
|
||||
myOffsetSurfaceSec: HSequenceOfShape from TopTools;
|
||||
myTrimmed3dSec : HSequenceOfShape from TopTools;
|
||||
myOffsetCurveSec : HSequenceOfShape from TopTools;
|
||||
myTrimmed2dSec : HSequenceOfShape from TopTools;
|
||||
|
||||
end ShapeContents;
|
279
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx
Executable file
279
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.cxx
Executable file
@@ -0,0 +1,279 @@
|
||||
// File: ShapeAnalysis_ShapeContents.cxx
|
||||
// Created: Thu Feb 25 17:04:39 1999
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@nnov.matra-dtv.fr>
|
||||
//szv#4 S4163
|
||||
|
||||
#include <ShapeAnalysis_ShapeContents.ixx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <ShapeAnalysis_Wire.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_ElementarySurface.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_OffsetCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom_OffsetCurve.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <TopoDS_Shell.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
|
||||
|
||||
|
||||
ShapeAnalysis_ShapeContents::ShapeAnalysis_ShapeContents()
|
||||
{
|
||||
myBigSplineSec = new TopTools_HSequenceOfShape;
|
||||
myIndirectSec = new TopTools_HSequenceOfShape;
|
||||
myOffsetSurfaceSec = new TopTools_HSequenceOfShape;
|
||||
myTrimmed3dSec = new TopTools_HSequenceOfShape;
|
||||
myOffsetCurveSec = new TopTools_HSequenceOfShape;
|
||||
myTrimmed2dSec = new TopTools_HSequenceOfShape;
|
||||
ClearFlags();
|
||||
}
|
||||
|
||||
void ShapeAnalysis_ShapeContents::Clear()
|
||||
{
|
||||
myNbSolids = 0;
|
||||
myNbShells = 0;
|
||||
myNbFaces = 0;
|
||||
myNbWires = 0;
|
||||
myNbEdges = 0;
|
||||
myNbVertices = 0;
|
||||
myNbSolidsWithVoids = 0;
|
||||
myNbBigSplines = 0;
|
||||
myNbC0Surfaces = 0;
|
||||
myNbC0Curves = 0;
|
||||
myNbOffsetSurf = 0;
|
||||
myNbIndirectSurf = 0;
|
||||
myNbOffsetCurves = 0;
|
||||
myNbTrimmedCurve2d = 0;
|
||||
myNbTrimmedCurve3d =0;
|
||||
myNbBSplibeSurf = 0;
|
||||
myNbBezierSurf = 0;
|
||||
myNbTrimSurf = 0;
|
||||
myNbWireWitnSeam = 0;
|
||||
myNbWireWithSevSeams = 0;
|
||||
myNbFaceWithSevWires = 0;
|
||||
myNbNoPCurve = 0;
|
||||
myNbFreeFaces = 0;
|
||||
myNbFreeWires = 0;
|
||||
myNbFreeEdges = 0;
|
||||
|
||||
myNbSharedSolids = 0;
|
||||
myNbSharedShells = 0;
|
||||
myNbSharedFaces = 0;
|
||||
myNbSharedWires = 0;
|
||||
myNbSharedFreeWires = 0;
|
||||
myNbSharedFreeEdges = 0;
|
||||
myNbSharedEdges = 0;
|
||||
myNbSharedVertices = 0;
|
||||
|
||||
myBigSplineSec->Clear();
|
||||
myIndirectSec->Clear();
|
||||
myOffsetSurfaceSec->Clear();
|
||||
myTrimmed3dSec->Clear();
|
||||
myOffsetCurveSec->Clear();
|
||||
myTrimmed2dSec->Clear();
|
||||
}
|
||||
|
||||
|
||||
void ShapeAnalysis_ShapeContents::ClearFlags()
|
||||
{
|
||||
myBigSplineMode = Standard_False;
|
||||
myIndirectMode = Standard_False;
|
||||
myOffestSurfaceMode = Standard_False;
|
||||
myTrimmed3dMode = Standard_False;
|
||||
myOffsetCurveMode = Standard_False;
|
||||
myTrimmed2dMode = Standard_False;
|
||||
}
|
||||
|
||||
|
||||
void ShapeAnalysis_ShapeContents::Perform(const TopoDS_Shape& Shape)
|
||||
{
|
||||
Clear();
|
||||
// On y va
|
||||
TopExp_Explorer exp;
|
||||
TopTools_MapOfShape mapsh;
|
||||
// On note pour les SOLIDES : ceux qui ont des trous (plus d un SHELL)
|
||||
|
||||
for (exp.Init (Shape,TopAbs_SOLID); exp.More(); exp.Next()) {
|
||||
TopoDS_Solid sol = TopoDS::Solid (exp.Current());
|
||||
sol.Location(TopLoc_Location());
|
||||
mapsh.Add(sol);
|
||||
Standard_Integer nbs = 0;
|
||||
for (TopExp_Explorer shel (sol,TopAbs_SHELL); shel.More(); shel.Next())
|
||||
nbs ++;
|
||||
if (nbs > 1) myNbSolidsWithVoids++;
|
||||
myNbSolids++;
|
||||
}
|
||||
myNbSharedSolids = mapsh.Extent();
|
||||
|
||||
// Pour les SHELLS, on compte les faces dans les SHELLS
|
||||
// Ensuite une soustraction, et on a les faces libres
|
||||
mapsh.Clear();
|
||||
Standard_Integer nbfaceshell = 0;
|
||||
for (exp.Init (Shape,TopAbs_SHELL); exp.More(); exp.Next()) {
|
||||
myNbShells++;
|
||||
TopoDS_Shell she = TopoDS::Shell(exp.Current());
|
||||
she.Location(TopLoc_Location());
|
||||
mapsh.Add(she);
|
||||
for (TopExp_Explorer shel (she,TopAbs_FACE); shel.More(); shel.Next())
|
||||
nbfaceshell ++;
|
||||
}
|
||||
myNbSharedShells = mapsh.Extent();
|
||||
// On note pour les FACES pas mal de choses (surface, topologie)
|
||||
// * Surface BSpline > 8192 poles
|
||||
// * Surface BSpline "OnlyC0" (not yet impl)
|
||||
// * Surface Offset
|
||||
// * Surface Elementaire INDIRECTE
|
||||
// * Presence de COUTURES; en particulier WIRE A PLUS D UNE COUTURE
|
||||
// * Edge : OffsetCurve
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init (Shape,TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
TopoDS_Face face = TopoDS::Face(exp.Current());
|
||||
myNbFaces++;
|
||||
TopLoc_Location loc;
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (face,loc);
|
||||
face.Location(TopLoc_Location());
|
||||
mapsh.Add(face);
|
||||
Handle(Geom_RectangularTrimmedSurface) trsu =
|
||||
Handle(Geom_RectangularTrimmedSurface)::DownCast (surf);
|
||||
if (!trsu.IsNull()) {
|
||||
myNbTrimSurf++;
|
||||
surf = trsu->BasisSurface();
|
||||
}
|
||||
//#10 rln 27/02/98 BUC50003 entity 56
|
||||
//C0 if at least in one direction (U or V)
|
||||
if (!surf.IsNull() && !(surf->IsCNu(1) && surf->IsCNv(1))) {
|
||||
myNbC0Surfaces++;
|
||||
}
|
||||
|
||||
Handle(Geom_BSplineSurface) bsps = Handle(Geom_BSplineSurface)::DownCast(surf);
|
||||
if (!bsps.IsNull()) {
|
||||
myNbBSplibeSurf++;
|
||||
if (bsps->NbUPoles() * bsps->NbVPoles() > 8192) {
|
||||
myNbBigSplines++;
|
||||
if (myBigSplineMode) myBigSplineSec->Append(face);
|
||||
}
|
||||
}
|
||||
Handle(Geom_ElementarySurface) els = Handle(Geom_ElementarySurface)::DownCast(surf);
|
||||
if (!els.IsNull()) {
|
||||
if (!els->Position().Direct()) {
|
||||
myNbIndirectSurf++;
|
||||
if (myIndirectMode) myIndirectSec->Append(face);
|
||||
}
|
||||
}
|
||||
if (surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
|
||||
myNbOffsetSurf++;
|
||||
if (myOffestSurfaceMode) myOffsetSurfaceSec->Append(face);
|
||||
}
|
||||
else if (surf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
|
||||
myNbBezierSurf++;
|
||||
}
|
||||
|
||||
Standard_Integer maxseam = 0, nbwires = 0;
|
||||
for (TopExp_Explorer wires(face,TopAbs_WIRE); wires.More(); wires.Next()) {
|
||||
TopoDS_Wire wire = TopoDS::Wire (wires.Current());
|
||||
Standard_Integer nbseam = 0;
|
||||
nbwires ++;
|
||||
for (TopExp_Explorer edg(wire,TopAbs_EDGE); edg.More(); edg.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge (edg.Current());
|
||||
Standard_Real first,last;
|
||||
if (BRep_Tool::IsClosed (edge,face)) nbseam ++;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve (edge,first,last);
|
||||
if (!c3d.IsNull()) {
|
||||
if (c3d->IsKind (STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
myNbTrimmedCurve3d++;
|
||||
if (myTrimmed3dMode) myTrimmed3dSec->Append(face);
|
||||
}
|
||||
}
|
||||
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface (edge,face,first,last);
|
||||
if (c2d.IsNull()) myNbNoPCurve++;
|
||||
else if (c2d->IsKind (STANDARD_TYPE(Geom2d_OffsetCurve))) {
|
||||
myNbOffsetCurves++;
|
||||
if (myOffsetCurveMode) myOffsetCurveSec->Append(face);
|
||||
}
|
||||
else if (c2d->IsKind (STANDARD_TYPE(Geom2d_TrimmedCurve))) {
|
||||
myNbTrimmedCurve2d++;
|
||||
if (myTrimmed2dMode) myTrimmed2dSec->Append(face);
|
||||
}
|
||||
}
|
||||
if (nbseam > maxseam) maxseam = nbseam;
|
||||
}
|
||||
if (maxseam == 1) myNbWireWitnSeam++;
|
||||
else if (maxseam > 1)
|
||||
myNbWireWithSevSeams++;
|
||||
if (nbwires > 1) myNbFaceWithSevWires++;
|
||||
}
|
||||
myNbSharedFaces = mapsh.Extent();
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init (Shape,TopAbs_WIRE); exp.More(); exp.Next()) {
|
||||
TopoDS_Wire wire = TopoDS::Wire(exp.Current());
|
||||
wire.Location(TopLoc_Location());
|
||||
mapsh.Add(wire);
|
||||
myNbWires++;
|
||||
}
|
||||
myNbSharedWires = mapsh.Extent();
|
||||
|
||||
// Ne pas oublier les FACES :
|
||||
myNbFreeFaces = myNbFaces - nbfaceshell;
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init (Shape,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge (exp.Current());
|
||||
edge.Location(TopLoc_Location());
|
||||
mapsh.Add (edge);
|
||||
TopLoc_Location loc;
|
||||
Standard_Real first,last;
|
||||
myNbEdges++;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve (edge,loc,first,last);
|
||||
if (!c3d.IsNull() && c3d->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) {
|
||||
myNbOffsetCurves++;
|
||||
if (myOffsetCurveMode) myOffsetCurveSec->Append(edge);
|
||||
}
|
||||
if (!c3d.IsNull() && !c3d->IsCN(1)) myNbC0Curves++;
|
||||
}
|
||||
myNbSharedEdges=mapsh.Extent();
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init (Shape,TopAbs_VERTEX); exp.More(); exp.Next()) {
|
||||
TopoDS_Vertex vert = TopoDS::Vertex(exp.Current());
|
||||
vert.Location(TopLoc_Location());
|
||||
myNbVertices++;
|
||||
mapsh.Add (vert);
|
||||
}
|
||||
myNbSharedVertices=mapsh.Extent();
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init(Shape, TopAbs_EDGE, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
TopoDS_Edge edge = TopoDS::Edge (exp.Current());
|
||||
edge.Location(TopLoc_Location());
|
||||
myNbFreeEdges++;
|
||||
mapsh.Add (edge);
|
||||
}
|
||||
myNbSharedFreeEdges=mapsh.Extent();
|
||||
|
||||
mapsh.Clear();
|
||||
for (exp.Init(Shape, TopAbs_WIRE, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
TopoDS_Wire wire = TopoDS::Wire(exp.Current());
|
||||
wire.Location(TopLoc_Location());
|
||||
myNbFreeWires++;
|
||||
mapsh.Add (wire);
|
||||
}
|
||||
myNbSharedFreeWires=mapsh.Extent();
|
||||
}
|
451
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.lxx
Executable file
451
src/ShapeAnalysis/ShapeAnalysis_ShapeContents.lxx
Executable file
@@ -0,0 +1,451 @@
|
||||
// File: ShapeAnalysis_ShapeContents.lxx
|
||||
// Created: Mon Mar 1 11:06:12 1999
|
||||
// Author: Pavel DURANDIN
|
||||
// <pdn@nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSolids
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSolids() const
|
||||
{
|
||||
return myNbSolids;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbShells
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbShells() const
|
||||
{
|
||||
return myNbShells;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbFaces() const
|
||||
{
|
||||
return myNbFaces;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbWires() const
|
||||
{
|
||||
return myNbWires;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbEdges() const
|
||||
{
|
||||
return myNbEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbVertices
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbVertices() const
|
||||
{
|
||||
return myNbVertices;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSolidsWithVoids
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSolidsWithVoids() const
|
||||
{
|
||||
return myNbSolidsWithVoids;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbBigSplines
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbBigSplines() const
|
||||
{
|
||||
return myNbBigSplines;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbC0Surfaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbC0Surfaces() const
|
||||
{
|
||||
return myNbC0Surfaces;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbC0Curves() const
|
||||
{
|
||||
return myNbC0Curves;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbOffsetSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbOffsetSurf() const
|
||||
{
|
||||
return myNbOffsetSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbIndirectSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbIndirectSurf() const
|
||||
{
|
||||
return myNbIndirectSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbOffsetCurves
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbOffsetCurves() const
|
||||
{
|
||||
return myNbOffsetCurves;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbTrimmedCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbTrimmedCurve2d() const
|
||||
{
|
||||
return myNbTrimmedCurve2d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbTrimmedCurve3d() const
|
||||
{
|
||||
return myNbTrimmedCurve3d;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbBSplibeSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbBSplibeSurf() const
|
||||
{
|
||||
return myNbBSplibeSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbBezierSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbBezierSurf() const
|
||||
{
|
||||
return myNbBezierSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbTrimSurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbTrimSurf() const
|
||||
{
|
||||
return myNbTrimSurf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbWireWitnSeam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbWireWitnSeam() const
|
||||
{
|
||||
return myNbWireWitnSeam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :NbWireWithSevSeams
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbWireWithSevSeams() const
|
||||
{
|
||||
return myNbWireWithSevSeams;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFaceWithSevWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbFaceWithSevWires() const
|
||||
{
|
||||
return myNbFaceWithSevWires;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbNoPCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbNoPCurve() const
|
||||
{
|
||||
return myNbNoPCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFreeFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbFreeFaces() const
|
||||
{
|
||||
return myNbFreeFaces;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFreeWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbFreeWires() const
|
||||
{
|
||||
return myNbFreeWires;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFreeEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbFreeEdges() const
|
||||
{
|
||||
return myNbFreeEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedSolids
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedSolids() const
|
||||
{
|
||||
return myNbSharedSolids;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedShells
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedShells() const
|
||||
{
|
||||
return myNbSharedShells;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedFaces
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedFaces() const
|
||||
{
|
||||
return myNbSharedFaces;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedWires
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedWires() const
|
||||
{
|
||||
return myNbSharedWires;
|
||||
}
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedFreeWires() const
|
||||
{
|
||||
return myNbSharedFreeWires;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedFreeEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedFreeEdges() const
|
||||
{
|
||||
return myNbSharedFreeEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedEdges() const
|
||||
{
|
||||
return myNbSharedEdges;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSharedVertices
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_ShapeContents::NbSharedVertices() const
|
||||
{
|
||||
return myNbSharedVertices;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BigSplineSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::BigSplineSec() const
|
||||
{
|
||||
return myBigSplineSec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IndirectSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::IndirectSec() const
|
||||
{
|
||||
return myIndirectSec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OffsetSurfaceSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::OffsetSurfaceSec() const
|
||||
{
|
||||
return myOffsetSurfaceSec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Trimmed3dSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::Trimmed3dSec() const
|
||||
{
|
||||
return myTrimmed3dSec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OffsetCurveSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::OffsetCurveSec() const
|
||||
{
|
||||
return myOffsetCurveSec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Trimmed2dSec
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeContents::Trimmed2dSec() const
|
||||
{
|
||||
return myTrimmed2dSec;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyBigSplineMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyBigSplineMode()
|
||||
{
|
||||
return myBigSplineMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyIndirectMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyIndirectMode()
|
||||
{
|
||||
return myIndirectMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyOffestSurfaceMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyOffestSurfaceMode()
|
||||
{
|
||||
return myOffestSurfaceMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyTrimmed3dMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyTrimmed3dMode()
|
||||
{
|
||||
return myTrimmed3dMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyOffsetCurveMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyOffsetCurveMode()
|
||||
{
|
||||
return myOffsetCurveMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ModifyTrimmed2dMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean& ShapeAnalysis_ShapeContents::ModifyTrimmed2dMode()
|
||||
{
|
||||
return myTrimmed2dMode;
|
||||
}
|
75
src/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cdl
Executable file
75
src/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cdl
Executable file
@@ -0,0 +1,75 @@
|
||||
-- File: ShapeAnalysis_ShapeTolerance.cdl
|
||||
-- Created: Wed Jun 3 12:06:59 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class ShapeTolerance from ShapeAnalysis
|
||||
|
||||
---Purpose: Tool for computing shape tolerances (minimal, maximal, average),
|
||||
-- finding shape with tolerance matching given criteria,
|
||||
-- setting or limitating tolerances.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
ShapeEnum from TopAbs,
|
||||
HSequenceOfShape from TopTools
|
||||
|
||||
is
|
||||
|
||||
Create returns ShapeTolerance from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Tolerance (me : in out; shape: Shape from TopoDS;
|
||||
mode : Integer;
|
||||
type : ShapeEnum from TopAbs = TopAbs_SHAPE)
|
||||
returns Real;
|
||||
---Purpose: Determines a tolerance from the ones stored in a shape
|
||||
-- Remark : calls InitTolerance and AddTolerance,
|
||||
-- hence, can be used to start a series for cumulating tolerance
|
||||
-- <mode> = 0 : returns the average value between sub-shapes,
|
||||
-- <mode> > 0 : returns the maximal found,
|
||||
-- <mode> < 0 : returns the minimal found.
|
||||
-- <type> defines what kinds of sub-shapes to consider:
|
||||
-- SHAPE (default) : all : VERTEX, EDGE, FACE,
|
||||
-- VERTEX : only vertices,
|
||||
-- EDGE : only edges,
|
||||
-- FACE : only faces,
|
||||
-- SHELL : combined SHELL + FACE, for each face (and containing
|
||||
-- shell), also checks EDGE and VERTEX
|
||||
|
||||
OverTolerance (me; shape: Shape from TopoDS;
|
||||
value: Real;
|
||||
type : ShapeEnum = TopAbs_SHAPE)
|
||||
returns HSequenceOfShape from TopTools;
|
||||
---Purpose: Determines which shapes have a tolerance over the given value
|
||||
-- <type> is interpreted as in the method Tolerance
|
||||
|
||||
InTolerance (me; shape : Shape from TopoDS;
|
||||
valmin, valmax: Real;
|
||||
type : ShapeEnum = TopAbs_SHAPE)
|
||||
returns HSequenceOfShape from TopTools;
|
||||
---Purpose: Determines which shapes have a tolerance within a given interval
|
||||
-- <type> is interpreted as in the method Tolerance
|
||||
|
||||
InitTolerance (me : in out);
|
||||
---Purpose: Initializes computation of cumulated tolerance
|
||||
|
||||
AddTolerance (me : in out; shape: Shape from TopoDS;
|
||||
type : ShapeEnum from TopAbs = TopAbs_SHAPE);
|
||||
---Purpose: Adds data on new Shape to compute Cumulated Tolerance
|
||||
-- (prepares three computations : maximal, average, minimal)
|
||||
|
||||
GlobalTolerance (me; mode: Integer) returns Real;
|
||||
---Purpose: Returns the computed tolerance according to the <mode>
|
||||
-- <mode> = 0 : average
|
||||
-- <mode> > 0 : maximal
|
||||
-- <mode> < 0 : minimal
|
||||
|
||||
fields
|
||||
|
||||
myTols : Real[3];
|
||||
myNbTol: Integer;
|
||||
|
||||
end ShapeTolerance;
|
252
src/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx
Executable file
252
src/ShapeAnalysis/ShapeAnalysis_ShapeTolerance.cxx
Executable file
@@ -0,0 +1,252 @@
|
||||
//#76 rln 11.03.99 S4135: compute average without weights according to tolerances
|
||||
//szv#4 S4163
|
||||
#include <ShapeAnalysis_ShapeTolerance.ixx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_ShapeTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_ShapeTolerance::ShapeAnalysis_ShapeTolerance() : myNbTol (0)
|
||||
{
|
||||
}
|
||||
|
||||
static void AddTol (const Standard_Real tol, Standard_Integer& nbt,
|
||||
Standard_Real& cmin, Standard_Real& cmoy, Standard_Real& cmax)
|
||||
{
|
||||
nbt ++;
|
||||
if (nbt == 1) cmin = cmoy = cmax = tol;
|
||||
else {
|
||||
if (cmin > tol) cmin = tol;
|
||||
if (cmax < tol) cmax = tol;
|
||||
// cmoy += tol;
|
||||
// Calcul en moyenne geometrique entre 1 et 1e-7
|
||||
Standard_Integer mult = 1;
|
||||
//#76 rln 11.03.99 S4135: compute average without weights according to tolerances
|
||||
/* if (tol < 1.e-07) mult = 10000;
|
||||
else if (tol < 1.e-06) mult = 3000;
|
||||
else if (tol < 1.e-05) mult = 1000;
|
||||
else if (tol < 1.e-04) mult = 300;
|
||||
else if (tol < 1.e-03) mult = 100;
|
||||
else if (tol < 1.e-02) mult = 30;
|
||||
else if (tol < 1.e-01) mult = 10;
|
||||
else if (tol < 1. ) mult = 3;
|
||||
*/
|
||||
nbt += (mult-1);
|
||||
cmoy += (tol * mult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Tolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_ShapeTolerance::Tolerance(const TopoDS_Shape& shape,const Standard_Integer mode,const TopAbs_ShapeEnum type)
|
||||
{
|
||||
InitTolerance();
|
||||
AddTolerance (shape, type);
|
||||
return GlobalTolerance (mode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : OverTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeTolerance::OverTolerance(const TopoDS_Shape& shape,const Standard_Real value,const TopAbs_ShapeEnum type) const
|
||||
{
|
||||
if (value >= 0) return InTolerance (shape,value,0.,type);
|
||||
else return InTolerance (shape,0.,value,type);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TopTools_HSequenceOfShape) ShapeAnalysis_ShapeTolerance::InTolerance(const TopoDS_Shape& shape,const Standard_Real valmin,const Standard_Real valmax,const TopAbs_ShapeEnum type) const
|
||||
{
|
||||
Standard_Real tol;
|
||||
Standard_Boolean over = (valmax < valmin); // pas de liminite max
|
||||
Handle(TopTools_HSequenceOfShape) sl = new TopTools_HSequenceOfShape ();
|
||||
|
||||
TopExp_Explorer myExp;
|
||||
|
||||
// Iteration sur les Faces
|
||||
|
||||
if (type == TopAbs_FACE || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_FACE);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Face(myExp.Current()));
|
||||
if (tol >= valmin && (over || (tol <= valmax)) ) sl->Append (myExp.Current());
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Iteration sur les Edges
|
||||
|
||||
if (type == TopAbs_EDGE || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_EDGE);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Edge(myExp.Current()));
|
||||
if (tol >= valmin && (over || (tol <= valmax)) ) sl->Append (myExp.Current());
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Iteration sur les Vertex
|
||||
|
||||
if (type == TopAbs_VERTEX || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_VERTEX);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Vertex(myExp.Current()));
|
||||
if (tol >= valmin && (over || (tol >= valmax)) ) sl->Append (myExp.Current());
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Iteration combinee (cumul) SHELL+FACE+EDGE+VERTEX, on retourne SHELL+FACE
|
||||
|
||||
if (type == TopAbs_SHELL) {
|
||||
// Exploration des shells
|
||||
TopTools_MapOfShape mapface;
|
||||
myExp.Init (shape, TopAbs_SHELL);
|
||||
while(myExp.More()) {
|
||||
Standard_Boolean iashell = Standard_False;
|
||||
TopoDS_Shape ash = myExp.Current();
|
||||
for (TopExp_Explorer face (ash,TopAbs_FACE); face.More(); face.Next()) {
|
||||
mapface.Add (face.Current());
|
||||
Handle(TopTools_HSequenceOfShape) fc =
|
||||
InTolerance (face.Current(),valmin,valmax,type);
|
||||
if (fc->Length() > 0) {
|
||||
sl->Append(fc);
|
||||
iashell = Standard_True;
|
||||
}
|
||||
}
|
||||
if (iashell) sl->Append (ash);
|
||||
myExp.Next();
|
||||
}
|
||||
|
||||
// Les faces (libres ou sous shell)
|
||||
myExp.Init (shape, TopAbs_FACE);
|
||||
for (; myExp.More(); myExp.Next()) {
|
||||
Standard_Boolean iaface = Standard_False;
|
||||
if (mapface.Contains (myExp.Current()) ) continue;
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Face(myExp.Current()));
|
||||
if (tol >= valmin && (over || (tol <= valmax)) ) iaface = Standard_True;
|
||||
else {
|
||||
// les edges contenues ?
|
||||
Handle(TopTools_HSequenceOfShape) fl =
|
||||
InTolerance (myExp.Current(),valmin,valmax,TopAbs_EDGE);
|
||||
if (fl->Length() > 0) iaface = Standard_True;
|
||||
else {
|
||||
fl = InTolerance (myExp.Current(),valmin,valmax,TopAbs_VERTEX);
|
||||
if (fl->Length() > 0) iaface = Standard_True;
|
||||
}
|
||||
}
|
||||
if (iaface) sl->Append (myExp.Current());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_ShapeTolerance::InitTolerance()
|
||||
{
|
||||
myNbTol = 0;
|
||||
myTols[1] = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_ShapeTolerance::AddTolerance(const TopoDS_Shape& shape,const TopAbs_ShapeEnum type)
|
||||
{
|
||||
Standard_Integer nbt = 0;
|
||||
Standard_Real tol, cmin,cmoy,cmax;
|
||||
|
||||
TopExp_Explorer myExp;
|
||||
|
||||
// Iteration sur les Faces
|
||||
|
||||
if (type == TopAbs_FACE || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_FACE);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Face(myExp.Current()));
|
||||
AddTol (tol,nbt,cmin,cmoy,cmax);
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Iteration sur les Edges
|
||||
|
||||
if (type == TopAbs_EDGE || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_EDGE);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Edge(myExp.Current()));
|
||||
AddTol (tol,nbt,cmin,cmoy,cmax);
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Iteration sur les Vertices
|
||||
|
||||
if (type == TopAbs_VERTEX || type == TopAbs_SHAPE) {
|
||||
myExp.Init(shape, TopAbs_VERTEX);
|
||||
while(myExp.More()) {
|
||||
tol = BRep_Tool::Tolerance(TopoDS::Vertex(myExp.Current()));
|
||||
AddTol (tol,nbt,cmin,cmoy,cmax);
|
||||
myExp.Next();
|
||||
}
|
||||
}
|
||||
|
||||
// Resultat : attention en mode cumul
|
||||
if (nbt == 0) return;
|
||||
if (myNbTol == 0 || myTols[0] > cmin) myTols[0] = cmin;
|
||||
if (myNbTol == 0 || myTols[2] < cmax) myTols[2] = cmax;
|
||||
myTols[1] += cmoy;
|
||||
myNbTol += nbt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GlobalTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_ShapeTolerance::GlobalTolerance(const Standard_Integer mode) const
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
Standard_Real result = 0.;
|
||||
if (myNbTol != 0.) {
|
||||
if (mode < 0) result = myTols[0];
|
||||
else if (mode == 0) {
|
||||
if (myTols[0] == myTols[2]) result = myTols[0];
|
||||
else result = myTols[1] / myNbTol;
|
||||
}
|
||||
else result = myTols[2];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
72
src/ShapeAnalysis/ShapeAnalysis_Shell.cdl
Executable file
72
src/ShapeAnalysis/ShapeAnalysis_Shell.cdl
Executable file
@@ -0,0 +1,72 @@
|
||||
-- File: ShapeAnalysis_Shell.cdl
|
||||
-- Created: Wed Jun 3 12:06:44 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Shell from ShapeAnalysis
|
||||
|
||||
---Purpose: This class provides operators to analyze edges orientation
|
||||
-- in the shell.
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Compound from TopoDS,
|
||||
IndexedMapOfShape from TopTools
|
||||
|
||||
is
|
||||
|
||||
Clear (me : in out);
|
||||
---Purpose: Clears data about loaded shells and performed checks
|
||||
|
||||
LoadShells (me : in out; shape : Shape from TopoDS);
|
||||
---Purpose: Adds shells contained in the <shape> to the list of loaded shells
|
||||
|
||||
CheckOrientedShells (me : in out; shape : Shape from TopoDS;
|
||||
alsofree: Boolean = Standard_False;
|
||||
checkinternaledges: Boolean = Standard_False)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if shells fulfill orientation condition, i.e. if each
|
||||
-- edge is, either present once (free edge) or twice (connected
|
||||
-- edge) but with different orientations (FORWARD/REVERSED)
|
||||
-- Edges which do not fulfill these conditions are bad
|
||||
--
|
||||
-- If <alsofree> is True free edges are considered.
|
||||
-- Free edges can be queried but are not bad
|
||||
|
||||
IsLoaded (me; shape : Shape from TopoDS) returns Boolean;
|
||||
---Purpose: Tells if a shape is loaded (only shells are checked)
|
||||
|
||||
NbLoaded (me) returns Integer;
|
||||
---Purpose: Returns the actual number of loaded shapes (i.e. shells)
|
||||
|
||||
Loaded (me; num : Integer) returns Shape from TopoDS;
|
||||
---Purpose: Returns a loaded shape specified by its rank number.
|
||||
-- Returns null shape if <num> is out of range
|
||||
|
||||
HasBadEdges (me) returns Boolean;
|
||||
---Purpose: Tells if at least one edge is recorded as bad
|
||||
|
||||
BadEdges (me) returns Compound from TopoDS;
|
||||
---Purpose: Returns the list of bad edges as a Compound
|
||||
-- It is empty (not null) if no edge are recorded as bad
|
||||
|
||||
HasFreeEdges (me) returns Boolean;
|
||||
---Purpose: Tells if at least one edge is recorded as free (not connected)
|
||||
|
||||
FreeEdges (me) returns Compound from TopoDS;
|
||||
---Purpose: Returns the list of free (not connected) edges as a Compound
|
||||
-- It is empty (not null) if no edge are recorded as free
|
||||
|
||||
HasConnectedEdges (me) returns Boolean;
|
||||
---Purpose: Tells if at least one edge is connected (shared twice or more)
|
||||
|
||||
fields
|
||||
|
||||
myShells: IndexedMapOfShape from TopTools;
|
||||
myBad : IndexedMapOfShape from TopTools;
|
||||
myFree : IndexedMapOfShape from TopTools;
|
||||
myConex : Boolean; -- are there or not
|
||||
|
||||
end Shell;
|
245
src/ShapeAnalysis/ShapeAnalysis_Shell.cxx
Executable file
245
src/ShapeAnalysis/ShapeAnalysis_Shell.cxx
Executable file
@@ -0,0 +1,245 @@
|
||||
//szv#4 S4163
|
||||
#include <ShapeAnalysis_Shell.ixx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_Shell::Clear()
|
||||
{
|
||||
myShells.Clear();
|
||||
myBad.Clear();
|
||||
myFree.Clear();
|
||||
myConex = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadShells
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_Shell::LoadShells(const TopoDS_Shape& shape)
|
||||
{
|
||||
if (shape.IsNull()) return;
|
||||
|
||||
if (shape.ShapeType() == TopAbs_SHELL) myShells.Add (shape); //szv#4:S4163:12Mar99 i =
|
||||
else {
|
||||
for (TopExp_Explorer exs (shape,TopAbs_SHELL); exs.More(); exs.Next()) {
|
||||
TopoDS_Shape sh = exs.Current();
|
||||
myShells.Add (sh); //szv#4:S4163:12Mar99 i =
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CheckOrientedShells : alimente BadEdges et FreeEdges
|
||||
// BadEdges : edges presentes plus d une fois dans une meme orientation
|
||||
// FreeEdges : edges presentes une seule fois
|
||||
// On utilise pour cela une fonction auxiliaire : CheckEdges
|
||||
// Qui alimente 2 maps auxiliaires : les edges directes et les inverses
|
||||
|
||||
static Standard_Boolean CheckEdges(const TopoDS_Shape& shape,
|
||||
TopTools_IndexedMapOfShape& bads,
|
||||
TopTools_IndexedMapOfShape& dirs,
|
||||
TopTools_IndexedMapOfShape& revs,
|
||||
TopTools_IndexedMapOfShape& ints)
|
||||
{
|
||||
Standard_Boolean res = Standard_False;
|
||||
|
||||
if (shape.ShapeType() != TopAbs_EDGE) {
|
||||
for (TopoDS_Iterator it(shape); it.More(); it.Next()) {
|
||||
if (CheckEdges (it.Value(),bads,dirs,revs,ints)) res = Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
TopoDS_Edge E = TopoDS::Edge(shape);
|
||||
if (BRep_Tool::Degenerated(E)) return Standard_False;
|
||||
|
||||
if (shape.Orientation() == TopAbs_FORWARD) {
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (dirs.FindIndex (shape) == 0) dirs.Add (shape);
|
||||
else { bads.Add (shape); res = Standard_True; }
|
||||
}
|
||||
if (shape.Orientation() == TopAbs_REVERSED) {
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (revs.FindIndex (shape) == 0) revs.Add (shape);
|
||||
else { bads.Add (shape); res = Standard_True; }
|
||||
}
|
||||
if (shape.Orientation() == TopAbs_INTERNAL) {
|
||||
if (ints.FindIndex (shape) == 0) ints.Add (shape);
|
||||
//else { bads.Add (shape); res = Standard_True; }
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckOrientedShells
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Shell::CheckOrientedShells(const TopoDS_Shape& shape,
|
||||
const Standard_Boolean alsofree,
|
||||
const Standard_Boolean checkinternaledges)
|
||||
{
|
||||
myConex = Standard_False;
|
||||
if (shape.IsNull()) return Standard_False;
|
||||
Standard_Boolean res = Standard_False;
|
||||
|
||||
TopTools_IndexedMapOfShape dirs, revs, ints;
|
||||
for (TopExp_Explorer exs(shape,TopAbs_SHELL); exs.More(); exs.Next()) {
|
||||
TopoDS_Shape sh = exs.Current();
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (CheckEdges (sh,myBad,dirs,revs,ints))
|
||||
if (myShells.Add (sh)) res = Standard_True;
|
||||
}
|
||||
|
||||
// Resteraient a faire les FreeEdges
|
||||
if (!alsofree) return res;
|
||||
|
||||
// Free Edges . Ce sont les edges d une map pas dans l autre
|
||||
// et lycee de Versailles (les maps dirs et revs)
|
||||
Standard_Integer nb = dirs.Extent();
|
||||
Standard_Integer i; // svv Jan11 2000 : porting on DEC
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
TopoDS_Shape sh = dirs.FindKey (i);
|
||||
if (!myBad.Contains(sh)) {
|
||||
if (!revs.Contains(sh)) {
|
||||
if(checkinternaledges) {
|
||||
if (!ints.Contains(sh)) {
|
||||
myFree.Add (sh);
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
else {
|
||||
myFree.Add (sh);
|
||||
}
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
|
||||
nb = revs.Extent();
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
TopoDS_Shape sh = revs.FindKey (i);
|
||||
if (!myBad.Contains(sh)) {
|
||||
if (!dirs.Contains(sh)) {
|
||||
if(checkinternaledges) {
|
||||
if (!ints.Contains(sh)) {
|
||||
myFree.Add (sh);
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
else {
|
||||
myFree.Add (sh);
|
||||
}
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
else myConex = Standard_True;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLoaded
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Shell::IsLoaded(const TopoDS_Shape& shape) const
|
||||
{
|
||||
if (shape.IsNull()) return Standard_False;
|
||||
return myShells.Contains (shape);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbLoaded
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_Shell::NbLoaded() const
|
||||
{
|
||||
return myShells.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Loaded
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ShapeAnalysis_Shell::Loaded(const Standard_Integer num) const
|
||||
{
|
||||
return myShells.FindKey (num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasBadEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Shell::HasBadEdges() const
|
||||
{
|
||||
return (myBad.Extent() > 0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BadEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Compound ShapeAnalysis_Shell::BadEdges() const
|
||||
{
|
||||
TopoDS_Compound C;
|
||||
BRep_Builder B;
|
||||
B.MakeCompound (C);
|
||||
Standard_Integer n = myBad.Extent();
|
||||
for (Standard_Integer i = 1; i <= n; i ++) B.Add (C,myBad.FindKey(i));
|
||||
return C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasFreeEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Shell::HasFreeEdges() const
|
||||
{
|
||||
return (myFree.Extent() > 0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FreeEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Compound ShapeAnalysis_Shell::FreeEdges() const
|
||||
{
|
||||
TopoDS_Compound C;
|
||||
BRep_Builder B;
|
||||
B.MakeCompound (C);
|
||||
Standard_Integer n = myFree.Extent();
|
||||
for (Standard_Integer i = 1; i <= n; i ++) B.Add (C,myFree.FindKey(i));
|
||||
return C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasConnectedEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_Shell::HasConnectedEdges() const
|
||||
{
|
||||
return myConex;
|
||||
}
|
394
src/ShapeAnalysis/ShapeAnalysis_Surface.cdl
Executable file
394
src/ShapeAnalysis/ShapeAnalysis_Surface.cdl
Executable file
@@ -0,0 +1,394 @@
|
||||
-- File: ShapeAnalysis_Surface.cdl
|
||||
-- Created: Wed Jun 3 12:01:25 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Surface from ShapeAnalysis inherits TShared from MMgt
|
||||
|
||||
---Purpose: Complements standard tool Geom_Surface by providing additional
|
||||
-- functionality for detection surface singularities, checking
|
||||
-- spatial surface closure and computing projections of 3D points
|
||||
-- onto a surface.
|
||||
--
|
||||
-- * The singularities
|
||||
-- Each singularity stores the precision with which corresponding
|
||||
-- surface iso-line is considered as degenerated.
|
||||
-- The number of singularities is determined by specifying precision
|
||||
-- and always not greater than 4.
|
||||
--
|
||||
-- * The spatial closure
|
||||
-- The check for spatial closure is performed with given precision
|
||||
-- (default value is Precision::Confusion).
|
||||
-- If Geom_Surface says that the surface is closed, this class
|
||||
-- also says this. Otherwise additional analysis is performed.
|
||||
--
|
||||
-- * The parameters of 3D point on the surface
|
||||
-- The projection of the point is performed with given precision.
|
||||
-- This class tries to find a solution taking into account possible
|
||||
-- singularities.
|
||||
-- Additional method for searching the solution from already built
|
||||
-- one is also provided.
|
||||
--
|
||||
-- This tool is optimised: computes most information only once
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Pnt2d from gp,
|
||||
Box from Bnd,
|
||||
Curve from Geom,
|
||||
Surface from Geom,
|
||||
Surface from GeomAdaptor,
|
||||
HSurface from GeomAdaptor,
|
||||
ExtPS from Extrema,
|
||||
Array1OfPnt from TColgp,
|
||||
Array1OfPnt2d from TColgp
|
||||
|
||||
is
|
||||
Create (S : Surface from Geom) returns mutable Surface from ShapeAnalysis;
|
||||
---Purpose: Creates an analyzer object on the basis of existing surface
|
||||
|
||||
Init (me : mutable; S: Surface from Geom);
|
||||
---Purpose: Loads existing surface
|
||||
|
||||
Init (me : mutable; other: Surface from ShapeAnalysis);
|
||||
---Purpose: Reads all the data from another Surface, without recomputing
|
||||
|
||||
SetDomain(me : mutable; U1, U2, V1, V2 : Real);
|
||||
|
||||
Surface (me) returns Surface from Geom;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns a surface being analyzed
|
||||
|
||||
Adaptor3d (me : mutable) returns HSurface from GeomAdaptor;
|
||||
---C++: return const &
|
||||
---Purpose: Returns the Adaptor.
|
||||
-- Creates it if not yet done.
|
||||
|
||||
TrueAdaptor3d (me) returns HSurface from GeomAdaptor;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns the Adaptor (may be Null if method Adaptor() was not called)
|
||||
|
||||
Gap (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns 3D distance found by one of the following methods.
|
||||
-- IsDegenerated, DegeneratedValues, ProjectDegenerated
|
||||
-- (distance between 3D point and found or last (if not found)
|
||||
-- singularity),
|
||||
-- IsUClosed, IsVClosed (minimum value of precision to consider
|
||||
-- the surface to be closed),
|
||||
-- ValueOfUV (distance between 3D point and found solution).
|
||||
|
||||
Value (me : mutable; u,v : Real) returns Pnt from gp;
|
||||
---C++: inline
|
||||
---Purpose: Returns a 3D point specified by parameters in surface
|
||||
-- parametrical space
|
||||
|
||||
Value (me : mutable; p2d : Pnt2d from gp) returns Pnt from gp;
|
||||
---C++: inline
|
||||
---Purpose: Returns a 3d point specified by a point in surface
|
||||
-- parametrical space
|
||||
|
||||
ComputeSingularities (me: mutable) is private;
|
||||
---Purpose: Computes singularities on the surface.
|
||||
-- Computes the sizes of boundaries or singular ares of the
|
||||
-- surface. Then each boundary or area is considered as
|
||||
-- degenerated with precision not less than its size.
|
||||
--
|
||||
-- The singularities and corresponding precisions are the
|
||||
-- following:
|
||||
-- - ConicalSurface - one degenerated point (apex of the cone),
|
||||
-- precision is 0.,
|
||||
-- - ToroidalSurface - two degenerated points, precision is
|
||||
-- Max (0, majorR-minorR),
|
||||
-- - SphericalSurface - two degenerated points (poles),
|
||||
-- precision is 0.
|
||||
-- - Bounded, Surface Of Revolution, Offset - four degenerated
|
||||
-- points, precisions are maximum distance between corners
|
||||
-- and middle point on the boundary
|
||||
--
|
||||
---Remark: Considers only boundaries of the surface (i.e. does not detect
|
||||
-- singularity if it is inside parametrical space)
|
||||
|
||||
HasSingularities (me: mutable; preci: Real) returns Boolean;
|
||||
---Purpose: Returns True if the surface has singularities for the given
|
||||
-- precision (i.e. if there are surface singularities with sizes
|
||||
-- not greater than precision).
|
||||
|
||||
NbSingularities (me: mutable; preci: Real) returns Integer;
|
||||
---Purpose: Returns the number of singularities for the given precision
|
||||
-- (i.e. number of surface singularities with sizes not greater
|
||||
-- than precision).
|
||||
|
||||
Singularity (me: mutable; num : Integer;
|
||||
preci : out Real;
|
||||
P3d : out Pnt from gp;
|
||||
firstP2d, lastP2d: out Pnt2d from gp;
|
||||
firstpar, lastpar: out Real;
|
||||
uisodeg : out Boolean)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the characteristics of the singularity specified by
|
||||
-- its rank number <num>.
|
||||
-- That means, that it is not neccessary for <num> to be in the
|
||||
-- range [1, NbSingularities] but must be not greater than
|
||||
-- possible (see ComputeSingularities).
|
||||
-- The returned characteristics are:
|
||||
-- preci: the smallest precision with which the iso-line is
|
||||
-- considered as degenerated,
|
||||
-- P3d: 3D point of singularity (middle point of the surface
|
||||
-- iso-line),
|
||||
-- firstP2d and lastP2d: first and last 2D points of the
|
||||
-- iso-line in parametrical surface,
|
||||
-- firstpar and lastpar: first and last parameters of the
|
||||
-- iso-line in parametrical surface,
|
||||
-- uisodeg: if the degenerated iso-line is U-iso (True) or
|
||||
-- V-iso (False).
|
||||
-- Returns False if <num> is out of range, else returns True.
|
||||
---Remarks - all the singularities are sorted in ascending order by
|
||||
-- precision
|
||||
-- - firstP2d and lastP2d are such to define left-hand passing of
|
||||
-- parametrical space
|
||||
|
||||
IsDegenerated (me: mutable; P3d : Pnt from gp;
|
||||
preci: Real)
|
||||
returns Boolean;
|
||||
---Purpose: Returns True if there is at least one surface boundary which
|
||||
-- is considered as degenerated with <preci> and distance
|
||||
-- between P3d and corresponding singular point is less than
|
||||
-- <preci>
|
||||
|
||||
DegeneratedValues (me: mutable; P3d : Pnt from gp;
|
||||
preci : Real;
|
||||
firstP2d, lastP2d: out Pnt2d from gp;
|
||||
firstpar, lastpar: out Real;
|
||||
forward : Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Returns True if there is at least one surface iso-line which
|
||||
-- is considered as degenerated with <preci> and distance
|
||||
-- between P3d and corresponding singular point is less than
|
||||
-- <preci> (like IsDegenerated).
|
||||
-- Returns characteristics of the first found boundary matching
|
||||
-- those criteria.
|
||||
---Remark : <forward> is not used
|
||||
|
||||
ProjectDegenerated (me: mutable; P3d : Pnt from gp;
|
||||
preci : Real;
|
||||
neighbour: Pnt2d from gp;
|
||||
result : in out Pnt2d from gp)
|
||||
returns Boolean;
|
||||
---Purpose: Projects a point <P3d> on a singularity by computing
|
||||
-- one of the coordinates of preliminary computed <result>.
|
||||
--
|
||||
-- Finds the iso-line which is considered as degenerated with
|
||||
-- <preci> and
|
||||
-- a. distance between P3d and corresponding singular point is
|
||||
-- less than <preci> (like IsDegenerated) or
|
||||
-- b. difference between already computed <result>'s coordinate
|
||||
-- and iso-coordinate of the boundary is less than 2D
|
||||
-- resolution (computed from <preci> by Geom_Adaptor).
|
||||
-- Then sets not yet computed <result>'s coordinate taking it
|
||||
-- from <neighbour> and returns True.
|
||||
---Example: U-iso at Ufirst=0 is degenerated with 1e-03,
|
||||
-- <neighbour> = (0, 0.5),
|
||||
-- <result> = (1e-06, ?); (1e-06 - already computed, ? - not yet)
|
||||
-- After, <result> will be (1e-06, 0.5): 0.5 is taken from <neighbour>
|
||||
--
|
||||
---Remark : This is only one method to compute the coordinate taking it
|
||||
-- from neighbour point. Other methods are also possible (by
|
||||
-- using tangent or C2, etc).
|
||||
--
|
||||
-- If the P3d is not on a singularity, no computation is done,
|
||||
-- returns False and <result> remains unchanged
|
||||
|
||||
ProjectDegenerated (me: mutable; nbrPnt: Integer;
|
||||
points: Array1OfPnt from TColgp;
|
||||
pnt2d : in out Array1OfPnt2d from TColgp;
|
||||
preci : Real;
|
||||
direct: Boolean)
|
||||
returns Boolean;
|
||||
---Purpose: Checks points at the beginning (direct is True) or end
|
||||
-- (direct is False) of array <points> to lie in singularity of
|
||||
-- surface, and if yes, adjusts the indeterminate 2d coordinate
|
||||
-- of these points by nearest point which is not in singularity.
|
||||
-- Returns True if some points were adjusted.
|
||||
|
||||
IsDegenerated (me: mutable; p2d1, p2d2: Pnt2d from gp; tol, ratio: Real)
|
||||
returns Boolean;
|
||||
---Purpose: Returns True if straight pcurve going from point p2d1 to p2d2
|
||||
-- is degenerate, i.e. lies in the singularity of the surface.
|
||||
-- NOTE: it uses another method of detecting singularity than
|
||||
-- used by ComputeSingularities() et al.!
|
||||
-- For that, maximums of distances between points p2d1, p2d2
|
||||
-- and 0.5*(p2d1+p2d2) and between corresponding 3d points are
|
||||
-- computed.
|
||||
-- The pcurve (p2d1, p2d2) is considered as degenerate if:
|
||||
-- - max distance in 3d is less than <tol>
|
||||
-- - max distance in 2d is at least <ratio> times greather than
|
||||
-- the Resolution computed from max distance in 3d
|
||||
-- (max3d < tol && max2d > ratio * Resolution(max3d))
|
||||
-- NOTE: <ratio> should be >1 (e.g. 10)
|
||||
|
||||
Bounds (me; ufirst, ulast, vfirst, vlast: out Real);
|
||||
---C++: inline
|
||||
---Purpose: Returns the bounds of the surface
|
||||
-- (from Bounds from Surface, but buffered)
|
||||
|
||||
ComputeBoundIsos(me : mutable);
|
||||
---Purpose: Computes bound isos (protected against exceptions)
|
||||
|
||||
UIso (me: mutable; U: Real) returns Curve from Geom;
|
||||
---Purpose: Returns a U-Iso. Null if not possible or failed
|
||||
-- Remark : bound isos are buffered
|
||||
|
||||
VIso (me: mutable; V: Real) returns Curve from Geom;
|
||||
---Purpose: Returns a V-Iso. Null if not possible or failed
|
||||
-- Remark : bound isos are buffered
|
||||
|
||||
IsUClosed (me: mutable; preci: Real = -1) returns Boolean;
|
||||
---Purpose: Tells if the Surface is spatially closed in U with given
|
||||
-- precision. If <preci> < 0 then Precision::Confusion is used.
|
||||
-- If Geom_Surface says that the surface is U-closed, this method
|
||||
-- also says this. Otherwise additional analysis is performed,
|
||||
-- comparing given precision with the following distances:
|
||||
-- - periodic B-Splines are closed,
|
||||
-- - polinomial B-Spline with boundary multiplicities degree+1
|
||||
-- and Bezier - maximum distance between poles,
|
||||
-- - rational B-Spline or one with boundary multiplicities not
|
||||
-- degree+1 - maximum distance computed at knots and their
|
||||
-- middles,
|
||||
-- - surface of extrusion - distance between ends of basis
|
||||
-- curve,
|
||||
-- - other (RectangularTrimmed and Offset) - maximum distance
|
||||
-- computed at 100 equi-distanted points.
|
||||
|
||||
IsVClosed (me: mutable; preci: Real = -1) returns Boolean;
|
||||
---Purpose: Tells if the Surface is spatially closed in V with given
|
||||
-- precision. If <preci> < 0 then Precision::Confusion is used.
|
||||
-- If Geom_Surface says that the surface is V-closed, this method
|
||||
-- also says this. Otherwise additional analysis is performed,
|
||||
-- comparing given precision with the following distances:
|
||||
-- - periodic B-Splines are closed,
|
||||
-- - polinomial B-Spline with boundary multiplicities degree+1
|
||||
-- and Bezier - maximum distance between poles,
|
||||
-- - rational B-Spline or one with boundary multiplicities not
|
||||
-- degree+1 - maximum distance computed at knots and their
|
||||
-- middles,
|
||||
-- - surface of revolution - distance between ends of basis
|
||||
-- curve,
|
||||
-- - other (RectangularTrimmed and Offset) - maximum distance
|
||||
-- computed at 100 equi-distanted points.
|
||||
|
||||
ValueOfUV (me: mutable; P3D: Pnt from gp;
|
||||
preci : Real)
|
||||
returns Pnt2d from gp;
|
||||
---Purpose: Computes the parameters in the surface parametrical space of
|
||||
-- 3D point.
|
||||
-- The result is parameters of the point projected onto the
|
||||
-- surface.
|
||||
-- This method enhances functionality provided by the standard
|
||||
-- tool GeomAPI_ProjectPointOnSurface by treatment of cases when
|
||||
-- the projected point is near to the surface boundaries and
|
||||
-- when this standard tool fails.
|
||||
|
||||
NextValueOfUV (me: mutable; p2dPrev: Pnt2d from gp;
|
||||
P3D : Pnt from gp;
|
||||
preci : Real;
|
||||
maxpreci:Real = -1.0)
|
||||
returns Pnt2d from gp;
|
||||
---Purpose: Projects a point P3D on the surface.
|
||||
-- Does the same thing as ValueOfUV but tries to optimize
|
||||
-- computations by taking into account previous point <p2dPrev>:
|
||||
-- makes a step by UV and tries Newton algorithm.
|
||||
-- If <maxpreci> >0. and distance between solution and
|
||||
-- P3D is greater than <maxpreci>, that solution is considered
|
||||
-- as bad, and ValueOfUV() is used.
|
||||
-- If not succeded, calls ValueOfUV()
|
||||
|
||||
UVFromIso (me: mutable; P3D : Pnt from gp;
|
||||
preci : Real;
|
||||
U, V : in out Real)
|
||||
returns Real;
|
||||
---Purpose: Tries a refinement of an already computed couple (U,V) by
|
||||
-- using projecting 3D point on iso-lines:
|
||||
-- 1. boundaries of the surface,
|
||||
-- 2. iso-lines passing through (U,V)
|
||||
-- 3. iteratively received iso-lines passing through new U and
|
||||
-- new V (number of iterations is limited by 5 in each
|
||||
-- direction)
|
||||
-- Returns the best resulting distance between P3D and Value(U,V)
|
||||
-- in the case of success. Else, returns a very great value
|
||||
|
||||
UCloseVal (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns minimum value to consider the surface as U-closed
|
||||
|
||||
VCloseVal (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns minimum value to consider the surface as V-closed
|
||||
|
||||
GetBoxUF(me: mutable) returns Box from Bnd;
|
||||
---C++: return const&
|
||||
|
||||
GetBoxUL(me: mutable) returns Box from Bnd;
|
||||
---C++: return const&
|
||||
|
||||
GetBoxVF(me: mutable) returns Box from Bnd;
|
||||
---C++: return const&
|
||||
|
||||
GetBoxVL(me: mutable) returns Box from Bnd;
|
||||
---C++: return const&
|
||||
|
||||
ComputeBoxes(me: mutable) is private;
|
||||
|
||||
SurfaceNewton (me: mutable; p2dPrev: Pnt2d from gp;
|
||||
P3D : Pnt from gp;
|
||||
preci : Real;
|
||||
sol :in out Pnt2d from gp)
|
||||
returns Boolean is private;
|
||||
|
||||
SortSingularities (me: mutable) is private;
|
||||
|
||||
fields
|
||||
|
||||
mySurf : Surface from Geom is protected;
|
||||
myAdSur : HSurface from GeomAdaptor is protected;
|
||||
|
||||
myExtPS : ExtPS from Extrema is protected; -- speed optimization
|
||||
myExtSrf : Surface from GeomAdaptor is protected; -- for extrema
|
||||
myExtOK : Boolean is protected; -- is theExtPS initialized?
|
||||
|
||||
myNbDeg : Integer is protected; -- < 0 means not yet computed
|
||||
myPreci : Real [4] is protected;
|
||||
myP3d : Pnt from gp [4] is protected;
|
||||
myFirstP2d : Pnt2d from gp [4] is protected;
|
||||
myLastP2d : Pnt2d from gp [4] is protected;
|
||||
myFirstPar : Real [4] is protected;
|
||||
myLastPar : Real [4] is protected;
|
||||
myUIsoDeg : Boolean [4] is protected; -- True if U-iso is degenerated, False if V-iso
|
||||
|
||||
myIsos : Boolean is protected; -- are bound isos computed
|
||||
myUF : Real is protected;
|
||||
myUL : Real is protected;
|
||||
myVF : Real is protected;
|
||||
myVL : Real is protected;
|
||||
myIsoUF : Curve from Geom is protected;
|
||||
myIsoUL : Curve from Geom is protected;
|
||||
myIsoVF : Curve from Geom is protected;
|
||||
myIsoVL : Curve from Geom is protected;
|
||||
myIsoBoxes : Boolean is protected; -- are boxes for bound isos computed
|
||||
myBndUF : Box from Bnd is protected;
|
||||
myBndUL : Box from Bnd is protected;
|
||||
myBndVF : Box from Bnd is protected;
|
||||
myBndVL : Box from Bnd is protected;
|
||||
|
||||
myGap : Real is protected;
|
||||
myUDelt : Real is protected; -- what overparametrisation to have good ValueOfUV
|
||||
myVDelt : Real is protected;
|
||||
|
||||
myUCloseVal: Real is protected; -- minimum value to consider the surface as U-closed
|
||||
myVCloseVal: Real is protected; -- minimum value to consider the surface as V-closed
|
||||
|
||||
end Surface;
|
1401
src/ShapeAnalysis/ShapeAnalysis_Surface.cxx
Executable file
1401
src/ShapeAnalysis/ShapeAnalysis_Surface.cxx
Executable file
File diff suppressed because it is too large
Load Diff
93
src/ShapeAnalysis/ShapeAnalysis_Surface.lxx
Executable file
93
src/ShapeAnalysis/ShapeAnalysis_Surface.lxx
Executable file
@@ -0,0 +1,93 @@
|
||||
#include <Geom_Surface.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const Handle(Geom_Surface)& ShapeAnalysis_Surface::Surface() const
|
||||
{
|
||||
return mySurf;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TrueAdaptor3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const Handle(GeomAdaptor_HSurface)& ShapeAnalysis_Surface::TrueAdaptor3d() const
|
||||
{
|
||||
return myAdSur;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Gap
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Surface::Gap() const
|
||||
{
|
||||
return myGap;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline gp_Pnt ShapeAnalysis_Surface::Value (const Standard_Real u,
|
||||
const Standard_Real v)
|
||||
{
|
||||
return mySurf->Value ( u, v );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline gp_Pnt ShapeAnalysis_Surface::Value(const gp_Pnt2d& p2d)
|
||||
{
|
||||
return mySurf->Value ( p2d.X(), p2d.Y() );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Bounds
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void ShapeAnalysis_Surface::Bounds (Standard_Real& ufirst,
|
||||
Standard_Real& ulast,
|
||||
Standard_Real& vfirst,
|
||||
Standard_Real& vlast) const
|
||||
{
|
||||
ufirst = myUF;
|
||||
ulast = myUL;
|
||||
vfirst = myVF;
|
||||
vlast = myVL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UCloseVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Surface::UCloseVal() const
|
||||
{
|
||||
return myUCloseVal;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VCloseVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Surface::VCloseVal() const
|
||||
{
|
||||
return myVCloseVal;
|
||||
}
|
77
src/ShapeAnalysis/ShapeAnalysis_TransferParameters.cdl
Executable file
77
src/ShapeAnalysis/ShapeAnalysis_TransferParameters.cdl
Executable file
@@ -0,0 +1,77 @@
|
||||
-- File: ShapeAnalysis_TransferPrameters.cdl
|
||||
-- Created: Mon Jun 21 09:44:37 1999
|
||||
-- Author: Galina KULIKOVA
|
||||
-- <gka@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class TransferParameters from ShapeAnalysis inherits TShared from MMgt
|
||||
|
||||
---Purpose: This tool is used for transferring parameters
|
||||
-- from 3d curve of the edge to pcurve and vice versa.
|
||||
--
|
||||
-- Default behaviour is to trsnafer parameters with help
|
||||
-- of linear transformation:
|
||||
--
|
||||
-- T2d = myShift + myScale * T3d
|
||||
-- where
|
||||
-- myScale = ( Last2d - First2d ) / ( Last3d - First3d )
|
||||
-- myShift = First2d - First3d * myScale
|
||||
-- [First3d, Last3d] and [First2d, Last2d] are ranges of
|
||||
-- edge on curve and pcurve
|
||||
--
|
||||
-- This behaviour can be redefined in derived classes, for example,
|
||||
-- using projection.
|
||||
|
||||
uses
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
HSequenceOfReal from TColStd,
|
||||
HArray1OfReal from TColStd
|
||||
|
||||
is
|
||||
Create returns mutable TransferParameters from ShapeAnalysis;
|
||||
---Purpose: Creates empty tool with myShift = 0 and myScale = 1
|
||||
|
||||
Create(E : Edge from TopoDS; F : Face from TopoDS)
|
||||
returns mutable TransferParameters from ShapeAnalysis;
|
||||
---Purpose: Creates a tool and initializes it with edge and face
|
||||
|
||||
Init(me : mutable;E : Edge from TopoDS; F : Face from TopoDS ) is virtual;
|
||||
---Purpose: Initialize a tool with edge and face
|
||||
|
||||
SetMaxTolerance(me:mutable; maxtol: Real);
|
||||
---Purpose: Sets maximal tolerance to use linear recomputation of
|
||||
-- parameters.
|
||||
|
||||
Perform(me : mutable; Params: HSequenceOfReal from TColStd; To2d : Boolean)
|
||||
returns HSequenceOfReal from TColStd is virtual;
|
||||
---Purpose: Transfers parameters given by sequence Params from 3d curve
|
||||
-- to pcurve (if To2d is True) or back (if To2d is False)
|
||||
|
||||
Perform(me : mutable;Param : Real; To2d : Boolean) returns Real from Standard is virtual;
|
||||
---Purpose: Transfers parameter given by sequence Params from 3d curve
|
||||
-- to pcurve (if To2d is True) or back (if To2d is False)
|
||||
|
||||
TransferRange(me: mutable; newEdge : in out Edge from TopoDS; prevPar,currPar : Real;
|
||||
To2d : Boolean) is virtual;
|
||||
---Purpose:Recomputes range of curves from NewEdge.
|
||||
-- If Is2d equals True parameters are recomputed by curve2d else by curve3d.
|
||||
|
||||
IsSameRange (me) returns Boolean is virtual;
|
||||
---Purpose: Returns True if 3d curve of edge and pcurve are SameRange
|
||||
-- (in default implementation, if myScale == 1 and myShift == 0)
|
||||
|
||||
fields
|
||||
|
||||
myShift : Real;
|
||||
myScale : Real;
|
||||
myFirst : Real is protected;
|
||||
myLast : Real is protected;
|
||||
myFirst2d : Real;
|
||||
myLast2d : Real;
|
||||
myEdge : Edge from TopoDS is protected;
|
||||
myFace : Face from TopoDS;
|
||||
myMaxTolerance: Real is protected;
|
||||
|
||||
end TransferParameters;
|
155
src/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx
Executable file
155
src/ShapeAnalysis/ShapeAnalysis_TransferParameters.cxx
Executable file
@@ -0,0 +1,155 @@
|
||||
#include <ShapeAnalysis_TransferParameters.ixx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <ShapeBuild_Edge.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_TransferParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_TransferParameters::ShapeAnalysis_TransferParameters()
|
||||
{
|
||||
myScale = 1.;
|
||||
myShift = 0.;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_TransferParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_TransferParameters::ShapeAnalysis_TransferParameters(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F)
|
||||
{
|
||||
Init(E,F);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_TransferParameters::Init(const TopoDS_Edge& E, const TopoDS_Face& F)
|
||||
{
|
||||
myScale = 1.;
|
||||
myShift = 0.;
|
||||
Standard_Real l,f,l2d,f2d;
|
||||
TopLoc_Location L;
|
||||
myEdge = E;
|
||||
ShapeAnalysis_Edge sae;
|
||||
Handle(Geom_Curve) curve3d;// = BRep_Tool::Curve (E,f,l);
|
||||
sae.Curve3d ( E, curve3d, f, l ,Standard_False);
|
||||
myFirst = f;
|
||||
myLast = l;
|
||||
Handle(Geom2d_Curve) curve2d;// = BRep_Tool::CurveOnSurface (E, F, f2d,l2d);
|
||||
// ShapeAnalysis_Edge sae;
|
||||
if (! F.IsNull() ) { // process free edges
|
||||
sae.PCurve ( E, F, curve2d, f2d, l2d,Standard_False );
|
||||
}
|
||||
myFirst2d = f2d;
|
||||
myLast2d = l2d;
|
||||
myFace = F;
|
||||
if ( curve3d.IsNull() || curve2d.IsNull() ) return;
|
||||
|
||||
Standard_Real ln2d = l2d - f2d;
|
||||
Standard_Real ln3d = l - f;
|
||||
myScale = ( ln3d <= gp::Resolution() ? 1. : ln2d / ln3d );
|
||||
myShift = f2d - f * myScale;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaxTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_TransferParameters::SetMaxTolerance( const Standard_Real maxtol )
|
||||
{
|
||||
myMaxTolerance = maxtol;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
Handle(TColStd_HSequenceOfReal) ShapeAnalysis_TransferParameters::Perform
|
||||
(const Handle(TColStd_HSequenceOfReal)& Params,
|
||||
const Standard_Boolean To2d)
|
||||
{
|
||||
Handle(TColStd_HSequenceOfReal) res = new TColStd_HSequenceOfReal;
|
||||
for (Standard_Integer i = 1 ; i <= Params->Length(); i++)
|
||||
res->Append(Perform(Params->Value(i),To2d));
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_TransferParameters::Perform(const Standard_Real Param,
|
||||
const Standard_Boolean To2d)
|
||||
{
|
||||
Standard_Real NewParam;
|
||||
if(To2d)
|
||||
NewParam = myShift + Param*myScale;
|
||||
else
|
||||
NewParam = -myShift/myScale + Param*1./myScale;
|
||||
return NewParam;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TransferRange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_TransferParameters::TransferRange(TopoDS_Edge& newEdge,
|
||||
const Standard_Real prevPar,
|
||||
const Standard_Real currPar,
|
||||
const Standard_Boolean Is2d)
|
||||
{
|
||||
ShapeBuild_Edge sbe;
|
||||
if(Is2d) {
|
||||
Standard_Real span2d = myLast2d - myFirst2d;
|
||||
Standard_Real tmp1,tmp2;
|
||||
if(prevPar > currPar) {
|
||||
tmp1 = currPar;
|
||||
tmp2 = prevPar;
|
||||
}
|
||||
else {
|
||||
tmp1 = prevPar;
|
||||
tmp2 = currPar;
|
||||
}
|
||||
Standard_Real alpha = (tmp1-myFirst2d) / span2d;
|
||||
Standard_Real beta = (tmp2 - myFirst2d) / span2d;
|
||||
sbe.CopyRanges(newEdge,myEdge, alpha, beta);
|
||||
}
|
||||
else {
|
||||
Standard_Real alpha = (prevPar-myFirst)/(myLast - myFirst);
|
||||
Standard_Real beta = (currPar - myFirst)/(myLast - myFirst);
|
||||
sbe.CopyRanges(newEdge,myEdge, alpha, beta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSameRange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_TransferParameters::IsSameRange() const
|
||||
{
|
||||
return myShift == 0. && myScale == 1.;
|
||||
}
|
92
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cdl
Executable file
92
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cdl
Executable file
@@ -0,0 +1,92 @@
|
||||
-- File: ShapeAnalysis_TransferParametersProj.cdl
|
||||
-- Created: Mon Jun 21 12:53:37 1999
|
||||
-- Author: Galina KULIKOVA
|
||||
-- <gka@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class TransferParametersProj from ShapeAnalysis inherits TransferParameters from ShapeAnalysis
|
||||
|
||||
---Purpose: This tool is used for transferring parameters
|
||||
-- from 3d curve of the edge to pcurve and vice versa.
|
||||
-- This tool transfers parameters with help of
|
||||
-- projection points from curve 3d on curve 2d and
|
||||
-- vice versa
|
||||
uses
|
||||
|
||||
Edge from TopoDS,
|
||||
Face from TopoDS,
|
||||
HSequenceOfReal from TColStd,
|
||||
Location from TopLoc,
|
||||
Curve from Geom,
|
||||
Curve from Geom2d,
|
||||
CurveOnSurface from Adaptor3d,
|
||||
Vertex from TopoDS
|
||||
is
|
||||
|
||||
Create returns mutable TransferParametersProj from ShapeAnalysis;
|
||||
---Purpose: Creats empty constructor.
|
||||
|
||||
Create(E: Edge from TopoDS; F: Face from TopoDS)
|
||||
returns mutable TransferParametersProj from ShapeAnalysis;
|
||||
---Purpose:
|
||||
|
||||
Init(me: mutable; E: Edge from TopoDS; F: Face from TopoDS ) is redefined;
|
||||
---Purpose:
|
||||
|
||||
Perform(me: mutable; Papams: HSequenceOfReal from TColStd; To2d: Boolean)
|
||||
returns HSequenceOfReal from TColStd is redefined;
|
||||
---Purpose: Transfers parameters given by sequence Params from 3d curve
|
||||
-- to pcurve (if To2d is True) or back (if To2d is False)
|
||||
|
||||
Perform(me: mutable; Param: Real; To2d: Boolean)
|
||||
returns Real is redefined;
|
||||
---Purpose:Transfers parameter given by Param from 3d curve
|
||||
-- to pcurve (if To2d is True) or back (if To2d is False)
|
||||
|
||||
ForceProjection (me: mutable) returns Boolean;
|
||||
---Purpose: Returns modifiable flag forcing projection
|
||||
-- If it is False (default), projection is done only
|
||||
-- if edge is not SameParameter or if tolerance of edge
|
||||
-- is greater than MaxTolerance()
|
||||
---C++: return &
|
||||
|
||||
TransferRange(me: mutable; newEdge: in out Edge from TopoDS;
|
||||
prevPar: Real;
|
||||
currPar: Real;
|
||||
Is2d : Boolean) is redefined;
|
||||
---Purpose: Recomputes range of curves from NewEdge.
|
||||
-- If Is2d equals True parameters are recomputed by curve2d else by curve3d.
|
||||
|
||||
IsSameRange(me) returns Boolean is redefined;
|
||||
---Purpose: Returns False;
|
||||
--
|
||||
|
||||
PreformSegment(me: mutable;Param :Real; To2d :Boolean;
|
||||
First :Real; Last :Real)
|
||||
returns Real is private;
|
||||
|
||||
CopyNMVertex(myclass; theVert: Vertex from TopoDS;
|
||||
toedge: Edge from TopoDS;
|
||||
fromedge: Edge from TopoDS ) returns Vertex from TopoDS;
|
||||
---Purpose: Make a copy of non-manifold vertex theVert
|
||||
-- (i.e. create new TVertex and replace PointRepresentations for this vertex
|
||||
-- from fromedge to toedge. Other representations were copied)
|
||||
|
||||
CopyNMVertex(myclass; theVert: Vertex from TopoDS;
|
||||
toFace: Face from TopoDS;
|
||||
fromFace: Face from TopoDS ) returns Vertex from TopoDS;
|
||||
---Purpose: Make a copy of non-manifold vertex theVert
|
||||
-- (i.e. create new TVertex and replace PointRepresentations for this vertex
|
||||
-- from fromFace to toFace. Other representations were copied)
|
||||
fields
|
||||
|
||||
myCurve : Curve from Geom;
|
||||
myCurve2d : Curve from Geom2d;
|
||||
myAC3d : CurveOnSurface from Adaptor3d;
|
||||
myPrecision : Real;
|
||||
myLocation : Location from TopLoc;
|
||||
myForceProj : Boolean;
|
||||
myInitOK : Boolean;
|
||||
|
||||
end TransferParametersProj;
|
656
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx
Executable file
656
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx
Executable file
@@ -0,0 +1,656 @@
|
||||
#include <ShapeAnalysis_TransferParametersProj.ixx>
|
||||
#include <Geom2dAdaptor_HCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Adaptor3d_CurveOnSurface.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <GeomAdaptor_HSurface.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
#include <TColgp_SequenceOfPnt.hxx>
|
||||
#include <ShapeAnalysis_Curve.hxx>
|
||||
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRep_GCurve.hxx>
|
||||
#include <BRep_ListOfCurveRepresentation.hxx>
|
||||
#include <BRep_ListOfCurveRepresentation.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ShapeBuild_Edge.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <ShapeAnalysis.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2d_OffsetCurve.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <BRep_ListOfPointRepresentation.hxx>
|
||||
#include <BRep_TVertex.hxx>
|
||||
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
|
||||
#include <BRep_PointRepresentation.hxx>
|
||||
#include <BRep_PointOnSurface.hxx>
|
||||
#include <BRep_PointOnCurve.hxx>
|
||||
#include <BRep_PointOnCurveOnSurface.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <ShapeAnalysis_Surface.hxx>
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_TransferParametersProj
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_TransferParametersProj::ShapeAnalysis_TransferParametersProj()
|
||||
{
|
||||
myMaxTolerance = 1; //Precision::Infinite(); ?? pdn
|
||||
myForceProj = Standard_False;
|
||||
myInitOK = Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_TransferParametersProj
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_TransferParametersProj::ShapeAnalysis_TransferParametersProj(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F)
|
||||
{
|
||||
myMaxTolerance = 1; //Precision::Infinite(); ?? pdn
|
||||
myForceProj = Standard_False;
|
||||
Init(E,F);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_TransferParametersProj::Init(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F)
|
||||
{
|
||||
myInitOK = Standard_False;
|
||||
ShapeAnalysis_TransferParameters::Init(E,F);
|
||||
myEdge = E;
|
||||
myPrecision = BRep_Tool::Tolerance(E); // it is better - skl OCC2851
|
||||
//myPrecision = Precision::Confusion();
|
||||
|
||||
myCurve = BRep_Tool::Curve (E, myFirst, myLast);
|
||||
if ( myCurve.IsNull() ) { myFirst = 0.; myLast = 1.; return;}
|
||||
|
||||
if ( F.IsNull() ) return;
|
||||
|
||||
Standard_Real f2d, l2d;
|
||||
ShapeAnalysis_Edge sae;
|
||||
if(sae.PCurve (E, F, myCurve2d, f2d, l2d, Standard_False)) {
|
||||
|
||||
Handle(Geom2dAdaptor_HCurve) AC2d = new Geom2dAdaptor_HCurve(myCurve2d,f2d,l2d);
|
||||
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(F,myLocation);
|
||||
Handle(GeomAdaptor_HSurface) AdS = new GeomAdaptor_HSurface(aSurface);
|
||||
|
||||
Adaptor3d_CurveOnSurface Ad1(AC2d,AdS);
|
||||
myAC3d = Ad1;//new Adaptor3d_CurveOnSurface(AC2d,AdS);
|
||||
myInitOK = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TColStd_HSequenceOfReal) ShapeAnalysis_TransferParametersProj::Perform
|
||||
(const Handle(TColStd_HSequenceOfReal)& Knots,
|
||||
const Standard_Boolean To2d)
|
||||
{
|
||||
//pdn
|
||||
if( !myInitOK ||
|
||||
(! myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge)))
|
||||
return ShapeAnalysis_TransferParameters::Perform(Knots,To2d);
|
||||
|
||||
Handle(TColStd_HSequenceOfReal) resKnots = new TColStd_HSequenceOfReal;
|
||||
|
||||
Standard_Integer len = Knots->Length();
|
||||
Standard_Real preci = 2*Precision::PConfusion();
|
||||
|
||||
Standard_Real first = (To2d ? myAC3d.FirstParameter() : myFirst);
|
||||
Standard_Real last = (To2d ? myAC3d.LastParameter() : myLast);
|
||||
Standard_Real maxPar = first;
|
||||
Standard_Real lastPar = last;
|
||||
Standard_Real prevPar = maxPar;
|
||||
|
||||
Standard_Integer j; // svv Jan 10 2000 : porting on DEC
|
||||
for(j = 1; j <= len; j++) {
|
||||
Standard_Real par = PreformSegment(Knots->Value(j),To2d,prevPar,lastPar);
|
||||
prevPar = par;
|
||||
if(prevPar > lastPar)
|
||||
prevPar -= preci;
|
||||
resKnots->Append(par);
|
||||
if(par > maxPar)
|
||||
maxPar = par;
|
||||
}
|
||||
|
||||
//pdn correcting on periodic
|
||||
if(myCurve->IsClosed())
|
||||
for(j = len; j >=1; j--)
|
||||
if(resKnots->Value(j) < maxPar)
|
||||
resKnots->SetValue(j,(To2d ? myAC3d.LastParameter() : myCurve->LastParameter())-(len-j)*preci);
|
||||
else
|
||||
break;
|
||||
//pdn correction on range
|
||||
for ( j=1; j <= len; j++ ) {
|
||||
if ( resKnots->Value (j) < first ) resKnots->SetValue ( j, first );
|
||||
if ( resKnots->Value (j) > last ) resKnots->SetValue ( j, last );
|
||||
}
|
||||
|
||||
return resKnots;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PreformSegment
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_TransferParametersProj::PreformSegment(const Standard_Real Param,
|
||||
const Standard_Boolean To2d,
|
||||
const Standard_Real First,
|
||||
const Standard_Real Last)
|
||||
{
|
||||
Standard_Real linPar = ShapeAnalysis_TransferParameters::Perform(Param, To2d);
|
||||
if( !myInitOK ||
|
||||
(! myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge)))
|
||||
return linPar;
|
||||
|
||||
Standard_Real linDev, projDev;
|
||||
|
||||
ShapeAnalysis_Curve sac;
|
||||
gp_Pnt pproj;
|
||||
Standard_Real ppar;
|
||||
if(To2d) {
|
||||
gp_Pnt p1 = myCurve->Value(Param).Transformed(myLocation.Inverted());
|
||||
Handle(Adaptor3d_HSurface) AdS = myAC3d.GetSurface();
|
||||
Handle(Geom2dAdaptor_HCurve) AC2d = new Geom2dAdaptor_HCurve(myCurve2d,First,Last);
|
||||
Adaptor3d_CurveOnSurface Ad1(AC2d,AdS);
|
||||
projDev = sac.Project(Ad1,p1,myPrecision,pproj,ppar);//pdn
|
||||
linDev = p1.Distance(Ad1.Value(linPar));
|
||||
}
|
||||
else {
|
||||
gp_Pnt p1 = myAC3d.Value(Param).Transformed(myLocation);
|
||||
projDev = sac.Project(myCurve,p1,myPrecision,pproj,ppar,First,Last,Standard_False);
|
||||
linDev = p1.Distance(myCurve->Value(linPar));
|
||||
}
|
||||
|
||||
if ( linDev <= projDev || (linDev < myPrecision && linDev <= 2 * projDev ) )
|
||||
ppar = linPar;
|
||||
return ppar;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_TransferParametersProj::Perform(const Standard_Real Knot,
|
||||
const Standard_Boolean To2d)
|
||||
{
|
||||
if( !myInitOK ||
|
||||
(! myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge)))
|
||||
return ShapeAnalysis_TransferParameters::Perform(Knot, To2d);
|
||||
|
||||
Standard_Real res;
|
||||
if(To2d)
|
||||
res = PreformSegment(Knot,To2d,myAC3d.FirstParameter(),myAC3d.LastParameter());
|
||||
else
|
||||
res = PreformSegment(Knot,To2d,myFirst,myLast);
|
||||
|
||||
//pdn correction on range
|
||||
Standard_Real first = (To2d ? myAC3d.FirstParameter() : myFirst);
|
||||
Standard_Real last = (To2d ? myAC3d.LastParameter() : myLast);
|
||||
if ( res < first ) res = first;
|
||||
if ( res > last ) res = last;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CorrectParameter
|
||||
//purpose : auxilary
|
||||
//=======================================================================
|
||||
static Standard_Real CorrectParameter(const Handle(Geom2d_Curve) crv,
|
||||
const Standard_Real param)
|
||||
{
|
||||
if(crv->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
|
||||
Handle(Geom2d_TrimmedCurve) tmp = Handle(Geom2d_TrimmedCurve)::DownCast (crv);
|
||||
return CorrectParameter(tmp->BasisCurve(),param);
|
||||
}
|
||||
else if(crv->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) {
|
||||
Handle(Geom2d_OffsetCurve) tmp = Handle(Geom2d_OffsetCurve)::DownCast (crv);
|
||||
return CorrectParameter(tmp->BasisCurve(),param);
|
||||
}
|
||||
else if(crv->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) {
|
||||
Handle(Geom2d_BSplineCurve) bspline = Handle(Geom2d_BSplineCurve)::DownCast (crv);
|
||||
for(Standard_Integer j = bspline->FirstUKnotIndex(); j <= bspline->LastUKnotIndex(); j++) {
|
||||
Standard_Real valknot = bspline->Knot(j);
|
||||
if( Abs(valknot-param)<Precision::PConfusion() )
|
||||
return valknot;
|
||||
}
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TransferRange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge,
|
||||
const Standard_Real prevPar,
|
||||
const Standard_Real currPar,
|
||||
const Standard_Boolean Is2d)
|
||||
{
|
||||
if( !myInitOK ||
|
||||
(! myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge))) {
|
||||
ShapeAnalysis_TransferParameters::TransferRange(newEdge,prevPar,currPar,Is2d);
|
||||
return;
|
||||
}
|
||||
|
||||
BRep_Builder B;
|
||||
Standard_Boolean samerange = Standard_True;
|
||||
ShapeBuild_Edge sbe;
|
||||
sbe.CopyRanges(newEdge,myEdge);
|
||||
gp_Pnt p1;
|
||||
gp_Pnt p2;
|
||||
Standard_Real alpha = 0, beta = 1;
|
||||
Standard_Real preci = Precision::PConfusion();
|
||||
Standard_Real firstPar, lastPar;
|
||||
if(prevPar < currPar) {
|
||||
firstPar = prevPar;
|
||||
lastPar = currPar;
|
||||
}
|
||||
else {
|
||||
firstPar = currPar;
|
||||
lastPar = prevPar;
|
||||
}
|
||||
if(Is2d) {
|
||||
p1 = myAC3d.Value(firstPar).Transformed(myLocation);
|
||||
p2 = myAC3d.Value(lastPar).Transformed(myLocation);
|
||||
Standard_Real fact = myAC3d.LastParameter() - myAC3d.FirstParameter();
|
||||
if( fact > Epsilon(myAC3d.LastParameter()) ) {
|
||||
alpha = ( firstPar - myAC3d.FirstParameter() ) / fact;
|
||||
beta = ( lastPar - myAC3d.FirstParameter() ) / fact;
|
||||
}
|
||||
}
|
||||
else {
|
||||
p1 = myCurve->Value(firstPar);
|
||||
p2 = myCurve->Value(lastPar);
|
||||
Standard_Real fact = myLast - myFirst;
|
||||
if( fact > Epsilon(myLast) ) {
|
||||
alpha = ( firstPar - myFirst ) / fact;
|
||||
beta = ( lastPar - myFirst ) / fact;
|
||||
}
|
||||
}
|
||||
const Standard_Boolean useLinearFirst = (alpha < preci);
|
||||
const Standard_Boolean useLinearLast = (1-beta < preci);
|
||||
TopLoc_Location EdgeLoc = myEdge.Location();
|
||||
ShapeAnalysis_Curve sac;
|
||||
gp_Pnt pproj;
|
||||
Standard_Real ppar1,ppar2;
|
||||
BRep_ListOfCurveRepresentation& tolist = (*((Handle(BRep_TEdge)*)&newEdge.TShape()))->ChangeCurves();
|
||||
Handle(BRep_GCurve) toGC;
|
||||
for (BRep_ListIteratorOfListOfCurveRepresentation toitcr (tolist); toitcr.More(); toitcr.Next()) {
|
||||
toGC = Handle(BRep_GCurve)::DownCast(toitcr.Value());
|
||||
if ( toGC.IsNull() ) continue;
|
||||
TopLoc_Location loc = ( EdgeLoc * toGC->Location() ).Inverted();
|
||||
if ( toGC->IsCurve3D() ) {
|
||||
if (!Is2d) {
|
||||
ppar1 = firstPar;
|
||||
ppar2 = lastPar;
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Curve) C3d = toGC->Curve3D();
|
||||
if (C3d.IsNull()) continue;
|
||||
Standard_Real first = toGC->First();
|
||||
Standard_Real last = toGC->Last();
|
||||
Standard_Real len = last -first;
|
||||
gp_Pnt ploc1 = p1.Transformed(loc);
|
||||
gp_Pnt ploc2 = p2.Transformed(loc);
|
||||
GeomAdaptor_Curve GAC(C3d,first,last);
|
||||
// CATIA bplseitli.model FAC1155 - Copy: protection for degenerated edges(3d case for symmetry)
|
||||
Standard_Real linFirst = first+alpha*len;
|
||||
Standard_Real linLast = first+beta*len;
|
||||
Standard_Real dist1 = sac.NextProject(linFirst,GAC,ploc1,myPrecision,pproj,ppar1);
|
||||
Standard_Real dist2 = sac.NextProject(linLast,GAC,ploc2,myPrecision,pproj,ppar2);
|
||||
Standard_Boolean useLinear = Abs(ppar1-ppar2) < preci;
|
||||
|
||||
gp_Pnt pos1 = C3d->Value ( linFirst );
|
||||
gp_Pnt pos2 = C3d->Value ( linLast );
|
||||
Standard_Real d01 = pos1.Distance ( ploc1 );
|
||||
Standard_Real d02 = pos2.Distance ( ploc2 );
|
||||
if ( useLinearFirst || useLinear || d01 <= dist1 || ( d01 < myPrecision && d01 <= 2 * dist1 ) )
|
||||
ppar1 = linFirst;
|
||||
if ( useLinearLast || useLinear || d02 <= dist2 || ( d02 < myPrecision && d02 <= 2 * dist2 ) )
|
||||
ppar2 = linLast;
|
||||
}
|
||||
if(ppar1 > ppar2) {
|
||||
Standard_Real tmpP = ppar2; ppar2 = ppar1; ppar1 = tmpP;
|
||||
}
|
||||
if(ppar2-ppar1 < preci) {
|
||||
if(ppar1-toGC->First() < preci)
|
||||
ppar2+=2*preci;
|
||||
else if(toGC->Last()-ppar2 < preci)
|
||||
ppar1-=2*preci;
|
||||
else {
|
||||
ppar1 -= preci;
|
||||
ppar2 += preci;
|
||||
}
|
||||
}
|
||||
toGC->SetRange ( ppar1, ppar2);
|
||||
//if(fabs(ppar1- firstPar) > Precision::PConfusion() ||
|
||||
// fabs(ppar2 - lastPar) >Precision::PConfusion()) // by LSS
|
||||
if(ppar1!=firstPar || ppar2!=lastPar)
|
||||
samerange = Standard_False;
|
||||
|
||||
}
|
||||
else if (toGC->IsCurveOnSurface()) { //continue; ||
|
||||
|
||||
Standard_Boolean localLinearFirst = useLinearFirst;
|
||||
Standard_Boolean localLinearLast = useLinearLast;
|
||||
Handle(Geom2d_Curve) C2d = toGC->PCurve();
|
||||
Standard_Real first = toGC->First();
|
||||
Standard_Real last = toGC->Last();
|
||||
Standard_Real len = last -first;
|
||||
Handle(Geom2dAdaptor_HCurve) AC2d = new Geom2dAdaptor_HCurve(toGC->PCurve(),first,last);
|
||||
Handle(GeomAdaptor_HSurface) AdS = new GeomAdaptor_HSurface( toGC->Surface());
|
||||
Adaptor3d_CurveOnSurface Ad1(AC2d,AdS);
|
||||
ShapeAnalysis_Curve sac1;
|
||||
|
||||
//gp_Pnt p1 = Ad1.Value(prevPar);
|
||||
//gp_Pnt p2 = Ad1.Value(currPar);
|
||||
gp_Pnt ploc1 = p1.Transformed(loc);
|
||||
gp_Pnt ploc2 = p2.Transformed(loc);
|
||||
// CATIA bplseitli.model FAC1155 - Copy: protection for degenerated edges
|
||||
Standard_Real linFirst = first+alpha*len;
|
||||
Standard_Real linLast = first+beta*len;
|
||||
Standard_Real dist1 = sac1.NextProject(linFirst, Ad1, ploc1, myPrecision,pproj,ppar1);
|
||||
Standard_Real dist2 = sac1.NextProject(linLast, Ad1, ploc2, myPrecision,pproj,ppar2);
|
||||
|
||||
Standard_Boolean isFirstOnEnd = (ppar1-first)/len < Precision::PConfusion();
|
||||
Standard_Boolean isLastOnEnd = (last-ppar2)/len < Precision::PConfusion();
|
||||
Standard_Boolean useLinear = Abs(ppar1-ppar2) < Precision::PConfusion();
|
||||
if(isFirstOnEnd && ! localLinearFirst)
|
||||
localLinearFirst = Standard_True;
|
||||
if(isLastOnEnd && ! localLinearLast)
|
||||
localLinearLast = Standard_True;
|
||||
|
||||
gp_Pnt pos1 = Ad1.Value ( linFirst );
|
||||
gp_Pnt pos2 = Ad1.Value ( linLast );
|
||||
Standard_Real d01 = pos1.Distance ( ploc1 );
|
||||
Standard_Real d02 = pos2.Distance ( ploc2 );
|
||||
if ( localLinearFirst || useLinear || d01 <= dist1 || ( d01 < myPrecision && d01 <= 2 * dist1 ) )
|
||||
ppar1 = linFirst;
|
||||
if ( localLinearLast || useLinear || d02 <= dist2 || ( d02 < myPrecision && d02 <= 2 * dist2 ) )
|
||||
ppar2 = linLast;
|
||||
|
||||
if(ppar1 > ppar2) {
|
||||
Standard_Real tmpP = ppar2; ppar2 = ppar1; ppar1 = tmpP;
|
||||
}
|
||||
ppar1 = CorrectParameter(C2d,ppar1);
|
||||
ppar2 = CorrectParameter(C2d,ppar2);
|
||||
if(ppar2-ppar1 < preci) {
|
||||
if(ppar1-toGC->First() < preci)
|
||||
ppar2+=2*preci;
|
||||
else if(toGC->Last()-ppar2 < preci)
|
||||
ppar1-=2*preci;
|
||||
else {
|
||||
ppar1 -= preci;
|
||||
ppar2 += preci;
|
||||
}
|
||||
}
|
||||
toGC->SetRange ( ppar1, ppar2);
|
||||
//if(fabs(ppar1 - firstPar) > Precision::PConfusion() ||
|
||||
// fabs(ppar2 -lastPar) > Precision::PConfusion())// by LSS
|
||||
if(ppar1 != firstPar || ppar2 != lastPar)
|
||||
samerange = Standard_False;
|
||||
}
|
||||
}
|
||||
B.SameRange(newEdge, samerange);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSameRange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_TransferParametersProj::IsSameRange() const
|
||||
{
|
||||
|
||||
if( !myInitOK ||
|
||||
(! myForceProj && myPrecision < myMaxTolerance && BRep_Tool::SameParameter(myEdge)))
|
||||
return ShapeAnalysis_TransferParameters::IsSameRange();
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ForceProjection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean& ShapeAnalysis_TransferParametersProj::ForceProjection()
|
||||
{
|
||||
return myForceProj;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CopyNMVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex (const TopoDS_Vertex& theV,
|
||||
const TopoDS_Edge& toedge,
|
||||
const TopoDS_Edge& fromedge)
|
||||
{
|
||||
TopoDS_Vertex anewV;
|
||||
if(theV.Orientation() != TopAbs_INTERNAL &&
|
||||
theV.Orientation() != TopAbs_EXTERNAL)
|
||||
return anewV;
|
||||
|
||||
TopLoc_Location fromLoc;
|
||||
Standard_Real f1,l1;
|
||||
const Handle(Geom_Curve)& C1 = BRep_Tool::Curve(fromedge,fromLoc,f1,l1);
|
||||
fromLoc = fromLoc.Predivided(theV.Location());
|
||||
|
||||
Standard_Real f2,l2;
|
||||
Handle(Geom_Curve) C2 = BRep_Tool::Curve(toedge,f2,l2);
|
||||
|
||||
anewV = TopoDS::Vertex(theV.EmptyCopied());
|
||||
gp_Pnt apv = BRep_Tool::Pnt(anewV);
|
||||
|
||||
BRep_ListOfPointRepresentation& alistrep =
|
||||
(*((Handle(BRep_TVertex)*)&anewV.TShape()))->ChangePoints();
|
||||
|
||||
BRep_ListIteratorOfListOfPointRepresentation itpr
|
||||
((*((Handle(BRep_TVertex)*) &theV.TShape()))->Points());
|
||||
|
||||
Standard_Real aOldPar = RealLast();
|
||||
Standard_Boolean hasRepr = Standard_False;
|
||||
for ( ;itpr.More(); itpr.Next()) {
|
||||
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
|
||||
if(pr.IsNull())
|
||||
continue;
|
||||
if(pr->IsPointOnCurve(C1,fromLoc)) {
|
||||
aOldPar = pr->Parameter();
|
||||
hasRepr =Standard_True;
|
||||
continue;
|
||||
}
|
||||
else if(pr->IsPointOnSurface()) {
|
||||
Handle(BRep_PointOnSurface) aOld = Handle(BRep_PointOnSurface)::DownCast(pr);
|
||||
Handle(BRep_PointOnSurface) aPS = new BRep_PointOnSurface(aOld->Parameter(),
|
||||
aOld->Parameter2(),
|
||||
aOld->Surface(),
|
||||
aOld->Location());
|
||||
alistrep.Append(aPS);
|
||||
continue;
|
||||
}
|
||||
else if(pr->IsPointOnCurveOnSurface()) {
|
||||
Standard_Boolean found = Standard_False;
|
||||
BRep_ListIteratorOfListOfCurveRepresentation fromitcr
|
||||
((*((Handle(BRep_TEdge)*)&fromedge.TShape()))->ChangeCurves());
|
||||
|
||||
for( ;fromitcr.More() && !found; fromitcr.Next()) {
|
||||
Handle(BRep_GCurve) fromGC = Handle(BRep_GCurve)::DownCast(fromitcr.Value());
|
||||
if ( fromGC.IsNull() || !fromGC->IsCurveOnSurface()) continue;
|
||||
|
||||
TopLoc_Location aL = fromGC->Location();
|
||||
aL.Predivided(theV.Location());
|
||||
Handle(Geom_Surface) surface1 = fromGC->Surface();
|
||||
Handle(Geom2d_Curve) ac2d1 = fromGC->PCurve();
|
||||
if (pr->IsPointOnCurveOnSurface(ac2d1,surface1,aL)) {
|
||||
found = Standard_True;
|
||||
if(!hasRepr) {
|
||||
aOldPar = pr->Parameter();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found) continue;
|
||||
}
|
||||
if(pr->IsPointOnCurve()) {
|
||||
Handle(BRep_PointOnCurve) aPRep = new BRep_PointOnCurve(pr->Parameter(),pr->Curve(),pr->Location());
|
||||
alistrep.Append(aPRep);
|
||||
}
|
||||
else if(pr->IsPointOnCurveOnSurface() ) {
|
||||
Handle(BRep_PointOnCurveOnSurface) aPonCS =
|
||||
new BRep_PointOnCurveOnSurface(pr->Parameter(),pr->PCurve(),pr->Surface(),pr->Location());
|
||||
alistrep.Append(aPonCS);
|
||||
}
|
||||
}
|
||||
Standard_Real apar = aOldPar;
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(theV);
|
||||
if(!hasRepr || (fabs(f1-f2) > Precision::PConfusion() || fabs(l1-l2)> Precision::PConfusion())) {
|
||||
gp_Pnt projP;
|
||||
ShapeAnalysis_Curve sae;
|
||||
Standard_Real adist = sae.Project(C2,apv,Precision::Confusion(),projP,apar);
|
||||
if(aTol < adist)
|
||||
aTol = adist;
|
||||
}
|
||||
BRep_Builder aB;
|
||||
aB.UpdateVertex(anewV,apar,toedge,aTol);
|
||||
|
||||
//update tolerance
|
||||
Standard_Boolean needUpdate = Standard_False;
|
||||
gp_Pnt aPV = (*((Handle(BRep_TVertex)*)&anewV.TShape()))->Pnt();
|
||||
TopLoc_Location toLoc = toedge.Location();
|
||||
BRep_ListIteratorOfListOfCurveRepresentation toitcr
|
||||
((*((Handle(BRep_TEdge)*)&toedge.TShape()))->ChangeCurves());
|
||||
|
||||
for( ;toitcr.More() ; toitcr.Next()) {
|
||||
Handle(BRep_GCurve) toGC = Handle(BRep_GCurve)::DownCast(toitcr.Value());
|
||||
if ( toGC.IsNull() || !toGC->IsCurveOnSurface()) continue;
|
||||
|
||||
TopLoc_Location aL = (toLoc*toGC->Location()).Predivided(theV.Location());
|
||||
//aL.Predivided(theV.Location());
|
||||
Handle(Geom_Surface) surface1 = toGC->Surface();
|
||||
Handle(Geom2d_Curve) ac2d1 = toGC->PCurve();
|
||||
gp_Pnt2d aP2d = ac2d1->Value(apar);
|
||||
gp_Pnt aP3d = surface1->Value(aP2d.X(),aP2d.Y());
|
||||
aP3d.Transform(aL.Transformation());
|
||||
Standard_Real adist = aPV.Distance(aP3d);
|
||||
if(adist > aTol) {
|
||||
aTol = adist;
|
||||
needUpdate = Standard_True;
|
||||
}
|
||||
|
||||
}
|
||||
if(needUpdate)
|
||||
aB.UpdateVertex(anewV,aTol);
|
||||
return anewV;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CopyNMVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Vertex ShapeAnalysis_TransferParametersProj::CopyNMVertex (const TopoDS_Vertex& theV,
|
||||
const TopoDS_Face& toFace,
|
||||
const TopoDS_Face& fromFace)
|
||||
{
|
||||
TopoDS_Vertex anewV;
|
||||
if(theV.Orientation() != TopAbs_INTERNAL &&
|
||||
theV.Orientation() != TopAbs_EXTERNAL)
|
||||
return anewV;
|
||||
|
||||
|
||||
TopLoc_Location fromLoc;
|
||||
TopLoc_Location toLoc;
|
||||
Handle(Geom_Surface) fromSurf = BRep_Tool::Surface(fromFace,fromLoc);
|
||||
Handle(Geom_Surface) toSurf = BRep_Tool::Surface(toFace,toLoc);
|
||||
fromLoc = fromLoc.Predivided(theV.Location());
|
||||
|
||||
anewV = TopoDS::Vertex(theV.EmptyCopied());
|
||||
gp_Pnt apv = BRep_Tool::Pnt(anewV);
|
||||
|
||||
|
||||
BRep_ListOfPointRepresentation& alistrep =
|
||||
(*((Handle(BRep_TVertex)*)&anewV.TShape()))->ChangePoints();
|
||||
|
||||
BRep_ListIteratorOfListOfPointRepresentation itpr
|
||||
((*((Handle(BRep_TVertex)*) &theV.TShape()))->Points());
|
||||
|
||||
Standard_Boolean hasRepr = Standard_False;
|
||||
Standard_Real apar1=0., apar2=0.;
|
||||
for ( ;itpr.More(); itpr.Next()) {
|
||||
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
|
||||
if(pr.IsNull())
|
||||
continue;
|
||||
TopLoc_Location aLoc = pr->Location();
|
||||
if( pr->IsPointOnCurveOnSurface()) {
|
||||
Handle(BRep_PointOnCurveOnSurface) aPonCS =
|
||||
new BRep_PointOnCurveOnSurface(pr->Parameter(),pr->PCurve(),pr->Surface(),aLoc);
|
||||
alistrep.Append(aPonCS);
|
||||
}
|
||||
else if(pr->IsPointOnCurve()) {
|
||||
Handle(BRep_PointOnCurve) aPRep = new BRep_PointOnCurve(pr->Parameter(),pr->Curve(),aLoc);
|
||||
alistrep.Append(aPRep);
|
||||
}
|
||||
else if(pr->IsPointOnSurface()) {
|
||||
Handle(BRep_PointOnSurface) aOld = Handle(BRep_PointOnSurface)::DownCast(pr);
|
||||
|
||||
if(pr->IsPointOnSurface(fromSurf,fromLoc)) {
|
||||
apar1= aOld->Parameter();
|
||||
apar2 = aOld->Parameter2();
|
||||
hasRepr = Standard_True;
|
||||
}
|
||||
else {
|
||||
Handle(BRep_PointOnSurface) aPS = new BRep_PointOnSurface(aOld->Parameter(),
|
||||
aOld->Parameter2(),
|
||||
aOld->Surface(),
|
||||
aOld->Location());
|
||||
alistrep.Append(aPS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(anewV);
|
||||
if(!hasRepr || (fromSurf != toSurf || fromLoc != toLoc)) {
|
||||
Handle(Geom_Surface) aS = BRep_Tool::Surface(toFace);
|
||||
Handle(ShapeAnalysis_Surface) aSurfTool = new ShapeAnalysis_Surface(aS);
|
||||
gp_Pnt2d aP2d = aSurfTool->ValueOfUV(apv,Precision::Confusion());
|
||||
apar1 = aP2d.X();
|
||||
apar2 = aP2d.Y();
|
||||
|
||||
if(aTol < aSurfTool->Gap())
|
||||
aTol = aSurfTool->Gap() + 0.1*Precision::Confusion();
|
||||
//Handle(BRep_PointOnSurface) aPS = new BRep_PointOnSurface(aP2d.X(),aP2d.Y(),toSurf,toLoc);
|
||||
//alistrep.Append(aPS);
|
||||
}
|
||||
|
||||
BRep_Builder aB;
|
||||
aB.UpdateVertex(anewV,apar1,apar2,toFace,aTol);
|
||||
return anewV;
|
||||
}
|
||||
|
629
src/ShapeAnalysis/ShapeAnalysis_Wire.cdl
Executable file
629
src/ShapeAnalysis/ShapeAnalysis_Wire.cdl
Executable file
@@ -0,0 +1,629 @@
|
||||
-- File: ShapeAnalysis_Wire.cdl
|
||||
-- Created: Wed Jun 3 12:06:13 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Wire from ShapeAnalysis inherits TShared from MMgt
|
||||
|
||||
---Purpose: This class provides analysis of a wire to be compliant to
|
||||
-- CAS.CADE requirements.
|
||||
--
|
||||
-- The functionalities provided are the following:
|
||||
-- 1. consistency of 2d and 3d edge curve senses
|
||||
-- 2. connection of adjacent edges regarding to:
|
||||
-- a. their vertices
|
||||
-- b. their pcurves
|
||||
-- c. their 3d curves
|
||||
-- 3. adjacency of the edge vertices to its pcurve and 3d curve
|
||||
-- 4. if a wire is closed or not (considering its 3d and 2d
|
||||
-- contour)
|
||||
-- 5. if a wire is outer on its face (considering pcurves)
|
||||
--
|
||||
--
|
||||
-- This class can be used in conjunction with class
|
||||
-- ShapeFix_Wire, which will fix the problems detected by this class.
|
||||
--
|
||||
-- The methods of the given class match to ones of the class
|
||||
-- ShapeFix_Wire, e.g., CheckSmall and FixSmall.
|
||||
-- This class also includes some auxilary methods
|
||||
-- (e.g., CheckOuterBound, etc.),
|
||||
-- which have no pair in ShapeFix_Wire.
|
||||
--
|
||||
-- Like methods of ShapeFix_Wire the ones of this class are
|
||||
-- grouped into two levels:
|
||||
-- - Public which are recommended for use (the most global
|
||||
-- method is Perform),
|
||||
-- - Advanced, for optional use only
|
||||
--
|
||||
-- For analyzing result of Public API checking methods use
|
||||
-- corresponding Status... method.
|
||||
-- The 'advanced' functions share the single status field which
|
||||
-- contains the result of the last performed 'advanced' method.
|
||||
-- It is quried by the method LastCheckStatus().
|
||||
--
|
||||
-- In order to prepare an analyzer, it is necessary to load a wire,
|
||||
-- set face and precision.
|
||||
|
||||
uses
|
||||
|
||||
Pnt2d from gp,
|
||||
Curve from Geom2d,
|
||||
Surface from Geom,
|
||||
Location from TopLoc,
|
||||
Shape from TopoDS,
|
||||
Wire from TopoDS,
|
||||
Face from TopoDS,
|
||||
SequenceOfIntersectionPoint from IntRes2d,
|
||||
SequenceOfPnt from TColgp,
|
||||
SequenceOfReal from TColStd,
|
||||
Status from ShapeExtend,
|
||||
WireData from ShapeExtend,
|
||||
WireOrder from ShapeAnalysis,
|
||||
Surface from ShapeAnalysis,
|
||||
IndexedMapOfShape from TopTools,
|
||||
DataMapOfShapeListOfShape from TopTools,
|
||||
MapOfShape from TopTools
|
||||
is
|
||||
|
||||
Create returns Wire from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create (wire : Wire from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
precision: Real)
|
||||
returns Wire from ShapeAnalysis;
|
||||
---Purpose: Creates object with standard TopoDS_Wire, face
|
||||
-- and precision
|
||||
|
||||
Create (sbwd : WireData from ShapeExtend;
|
||||
face : Face from TopoDS;
|
||||
precision: Real)
|
||||
returns Wire from ShapeAnalysis;
|
||||
---Purpose: Creates the object with WireData object, face
|
||||
-- and precision
|
||||
|
||||
Init (me: mutable; wire : Wire from TopoDS;
|
||||
face : Face from TopoDS;
|
||||
precision: Real);
|
||||
---Purpose: Initializes the object with standard TopoDS_Wire, face
|
||||
-- and precision
|
||||
|
||||
Init (me: mutable; sbwd : WireData from ShapeExtend;
|
||||
face : Face from TopoDS;
|
||||
precision: Real);
|
||||
---Purpose: Initializes the object with WireData object, face
|
||||
-- and precision
|
||||
|
||||
Load (me: mutable; wire: Wire from TopoDS);
|
||||
---Purpose: Loads the object with standard TopoDS_Wire
|
||||
|
||||
Load (me: mutable; sbwd: WireData from ShapeExtend);
|
||||
---Purpose: Loads the object with WireData object
|
||||
---Remark : Single WireData object will be shared
|
||||
|
||||
SetFace (me: mutable; face : Face from TopoDS);
|
||||
---Purpose: Loads the face the wire lies on
|
||||
|
||||
SetSurface (me: mutable; surface : Surface from Geom);
|
||||
---Purpose: Loads the surface the wire lies on
|
||||
|
||||
SetSurface (me: mutable; surface : Surface from Geom;
|
||||
location: Location from TopLoc);
|
||||
---Purpose: Loads the surface the wire lies on
|
||||
|
||||
SetPrecision (me: mutable; precision: Real);
|
||||
---Precision: Set the precision value
|
||||
|
||||
ClearStatuses (me: mutable);
|
||||
---Purpose: Unsets all the status and distance fields
|
||||
-- wire, face and precision are not cleared
|
||||
|
||||
IsLoaded (me) returns Boolean;
|
||||
---C++: inline
|
||||
---Purpose: Returns True if wire is loaded and has number of edges >0
|
||||
|
||||
IsReady (me) returns Boolean;
|
||||
---C++: inline
|
||||
---Purpose: Returns True if IsLoaded and underlying face is not null
|
||||
|
||||
Precision (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the value of precision
|
||||
|
||||
WireData (me) returns WireData from ShapeExtend;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns wire object being analyzed
|
||||
|
||||
NbEdges (me) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Returns the number of edges in the wire, or 0 if it is not loaded
|
||||
|
||||
Face (me) returns Face from TopoDS;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns the working face
|
||||
|
||||
Surface (me) returns Surface from ShapeAnalysis;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns the working surface
|
||||
|
||||
|
||||
---Checking methods:
|
||||
|
||||
---Level: Public
|
||||
|
||||
---Return: Check..() methods return True when and only when the situation was
|
||||
-- analyzed and the specific case detected.
|
||||
-- This corresponds to the flag DONE (or one of DONE#i) set in Status.
|
||||
|
||||
Perform (me : mutable) returns Boolean;
|
||||
---Purpose: Performs all the checks in the following order :
|
||||
-- CheckOrder, CheckSmall, CheckConected, CheckEdgeCurves,
|
||||
-- CheckDegenerated, CheckSelfIntersection, CheckLacking,
|
||||
-- CheckClosed
|
||||
-- Returns: True if at least one method returned True;
|
||||
-- For deeper analysis use Status...(status) methods
|
||||
|
||||
CheckOrder (me: mutable; isClosed: Boolean = Standard_True;
|
||||
mode3d: Boolean = Standard_True) returns Boolean;
|
||||
---Purpose: Calls CheckOrder and returns False if wire is already
|
||||
-- ordered (tail-to-head), True otherwise
|
||||
-- Flag <isClosed> defines if the wire is closed or not
|
||||
-- Flag <mode3d> defines which mode is used (3d or 2d)
|
||||
|
||||
CheckConnected (me : mutable; prec : Real = 0.0) returns Boolean;
|
||||
---Purpose: Calls to CheckConnected for each edge
|
||||
-- Returns: True if at least one pair of disconnected edges (not sharing the
|
||||
-- same vertex) was detected
|
||||
|
||||
CheckSmall (me : mutable; precsmall : Real = 0.0) returns Boolean;
|
||||
---Purpose: Calls to CheckSmall for each edge
|
||||
-- Returns: True if at least one small edge was detected
|
||||
|
||||
CheckEdgeCurves (me : mutable) returns Boolean;
|
||||
---Purpose: Checks edges geometry (consitency of 2d and 3d senses, adjasment
|
||||
-- of curves to the vertices, etc.).
|
||||
-- The order of the checks :
|
||||
-- Call ShapeAnalysis_Wire to check:
|
||||
-- ShapeAnalysis_Edge::CheckCurve3dWithPCurve (1),
|
||||
-- ShapeAnalysis_Edge::CheckVertcesWithPCurve (2),
|
||||
-- ShapeAnalysis_Edge::CheckVertcesWithCurve3d (3),
|
||||
-- CheckSeam (4)
|
||||
-- Additional:
|
||||
-- CheckGap3d (5),
|
||||
-- CheckGap2d (6),
|
||||
-- ShapeAnalysis_Edge::CheckSameParameter (7)
|
||||
-- Returns: True if at least one check returned True
|
||||
-- Remark: The numbers in brackets show with what DONEi or FAILi
|
||||
-- the status can be queried
|
||||
|
||||
CheckDegenerated (me : mutable) returns Boolean;
|
||||
---Purpose: Calls to CheckDegenerated for each edge
|
||||
-- Returns: True if at least one incorrect degenerated edge was detected
|
||||
|
||||
CheckClosed (me : mutable; prec : Real = 0.0) returns Boolean;
|
||||
---Purpose: Checks if wire is closed, performs CheckConnected,
|
||||
-- CheckDegenerated and CheckLacking for the first and the last edges
|
||||
-- Returns: True if at least one check returned True
|
||||
-- Status:
|
||||
-- FAIL1 or DONE1: see CheckConnected
|
||||
-- FAIL2 or DONE2: see CheckDegenerated
|
||||
|
||||
CheckSelfIntersection (me : mutable) returns Boolean;
|
||||
---Purpose: Checks self-intersection of the wire (considering pcurves)
|
||||
-- Looks for self-intersecting edges and each pair of intersecting
|
||||
-- edges.
|
||||
-- Warning: It does not check each edge with any other one (only each two
|
||||
-- adjacent edges)
|
||||
-- The order of the checks :
|
||||
-- CheckSelfIntersectingEdge, CheckIntersectingEdges
|
||||
-- Returns: True if at least one check returned True
|
||||
-- Status: FAIL1 or DONE1 - see CheckSelfIntersectingEdge
|
||||
-- FAIL2 or DONE2 - see CheckIntersectingEdges
|
||||
|
||||
CheckLacking (me : mutable) returns Boolean;
|
||||
---Purpose: Calls to CheckLacking for each edge
|
||||
-- Returns: True if at least one lacking edge was detected
|
||||
|
||||
CheckGaps3d (me : mutable) returns Boolean;
|
||||
---Purpose:
|
||||
---Returns:
|
||||
|
||||
CheckGaps2d (me : mutable) returns Boolean;
|
||||
---Purpose:
|
||||
---Returns:
|
||||
|
||||
CheckCurveGaps (me : mutable) returns Boolean;
|
||||
---Purpose:
|
||||
---Returns:
|
||||
|
||||
|
||||
---Level: Advanced
|
||||
|
||||
---Status: For analyzing the status of the last performed method use method
|
||||
-- Status(status)
|
||||
--
|
||||
-- All the Check...() methods below return False if the problem was
|
||||
-- not detected. If so, Status(ShapeExtend_OK) returns True.
|
||||
|
||||
CheckOrder (me: mutable; sawo: out WireOrder from ShapeAnalysis;
|
||||
isClosed: Boolean = Standard_True;
|
||||
mode3d: Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Analyzes the order of the edges in the wire,
|
||||
-- uses class WireOrder for that purpose.
|
||||
-- Flag <isClosed> defines if the wire is closed or not
|
||||
-- Flag <mode3d> defines which mode is used (3d or 2d)
|
||||
-- Returns False if wire is already ordered (tail-to-head),
|
||||
-- True otherwise.
|
||||
-- Use returned WireOrder object for deeper analysis.
|
||||
-- Status:
|
||||
-- OK : the same edges orientation, the same edges sequence
|
||||
-- DONE1: the same edges orientation, not the same edges sequence
|
||||
-- DONE2: as DONE1 and gaps more than myPrecision
|
||||
-- DONE3: not the same edges orientation (some need to be reversed)
|
||||
-- DONE4: as DONE3 and gaps more than myPrecision
|
||||
-- FAIL : algorithm failed (could not detect order)
|
||||
|
||||
CheckConnected (me : mutable; num: Integer; prec: Real = 0.0) returns Boolean;
|
||||
---Purpose: Checks connected edges (num-th and preceeding).
|
||||
-- Tests with starting preci from <SBWD> or with <prec> if
|
||||
-- it is greater.
|
||||
-- Considers Vertices.
|
||||
-- Returns: False if edges are connected by the common vertex, else True
|
||||
-- Status :
|
||||
-- OK : Vertices (end of num-1 th edge and start on num-th one)
|
||||
-- are already the same
|
||||
-- DONE1 : Absolutely confused (gp::Resolution)
|
||||
-- DONE2 : Confused at starting <preci> from <SBWD>
|
||||
-- DONE3 : Confused at <prec> but not <preci>
|
||||
-- FAIL1 : Not confused
|
||||
-- FAIL2 : Not confused but confused with <preci> if reverse num-th edge
|
||||
|
||||
CheckSmall (me : mutable; num : Integer;
|
||||
precsmall: Real = 0.0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if an edge has a length not greater than myPreci or
|
||||
-- precsmall (if it is smaller)
|
||||
-- Returns: False if its length is greater than precision
|
||||
-- Status:
|
||||
-- OK : edge is not small or degenerated
|
||||
-- DONE1: edge is small, vertices are the same
|
||||
-- DONE2: edge is small, vertices are not the same
|
||||
-- FAIL : no 3d curve and pcurve
|
||||
|
||||
CheckSeam (me : mutable; num : Integer;
|
||||
C1, C2: out Curve from Geom2d;
|
||||
cf, cl: out Real)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if a seam pcurves are correct oriented
|
||||
-- Returns: False (status OK) if given edge is not a seam or if it is OK
|
||||
-- C1 - current pcurve for FORWARD edge,
|
||||
-- C2 - current pcurve for REVERSED edge (if returns True they
|
||||
-- should be swapped for the seam),
|
||||
-- cf, cl - first and last parameters on curves
|
||||
-- Status:
|
||||
-- OK : Pcurves are correct or edge is not seam
|
||||
-- DONE : Seam pcurves should be swapped
|
||||
|
||||
CheckSeam (me : mutable; num: Integer) returns Boolean;
|
||||
---Purpose: Checks if a seam pcurves are correct oriented
|
||||
-- See previous functions for details
|
||||
|
||||
CheckDegenerated (me: mutable; num: Integer; dgnr1, dgnr2: out Pnt2d from gp)
|
||||
returns Boolean;
|
||||
---Purpose: Checks for degenerated edge between two adjacent ones.
|
||||
-- Fills parameters dgnr1 and dgnr2 with points in paramterical
|
||||
-- space that correspond to the singularity (either gap that
|
||||
-- needs to be filled by degenerated edge or that already filled)
|
||||
-- Returns: False if no singularity or edge is already degenerated,
|
||||
-- otherwise True
|
||||
-- Status:
|
||||
-- OK : No surface singularity, or edge is already degenerated
|
||||
-- DONE1: Degenerated edge should be inserted (gap in 2D)
|
||||
-- DONE2: Edge <num> should be made degenerated (recompute pcurve
|
||||
-- and set the flag)
|
||||
-- FAIL1: One of edges neighbouring to degenerated one has
|
||||
-- no pcurve
|
||||
-- FAIL2: Edge marked as degenerated and has no pcurve
|
||||
-- but singularity is not detected
|
||||
|
||||
CheckDegenerated (me: mutable; num: Integer)
|
||||
returns Boolean;
|
||||
---Purpose: Checks for degenerated edge between two adjacent ones.
|
||||
-- Remark : Calls previous function
|
||||
-- Status : See the function above for details
|
||||
|
||||
CheckGap3d (me : mutable; num : Integer = 0) returns Boolean;
|
||||
---Purpose: Checks gap between edges in 3D (3d curves).
|
||||
-- Checks the distance between ends of 3d curves of the num-th
|
||||
-- and preceeding edge.
|
||||
-- The distance can be queried by MinDistance3d.
|
||||
--
|
||||
-- Returns: True if status is DONE
|
||||
-- Status:
|
||||
-- OK : Gap is less than myPrecision
|
||||
-- DONE : Gap is greater than myPrecision
|
||||
-- FAIL : No 3d curve(s) on the edge(s)
|
||||
|
||||
CheckGap2d (me : mutable; num : Integer = 0) returns Boolean;
|
||||
---Purpose: Checks gap between edges in 2D (pcurves).
|
||||
-- Checks the distance between ends of pcurves of the num-th
|
||||
-- and preceeding edge.
|
||||
-- The distance can be queried by MinDistance2d.
|
||||
--
|
||||
-- Returns: True if status is DONE
|
||||
-- Status:
|
||||
-- OK : Gap is less than parametric precision out of myPrecision
|
||||
-- DONE : Gap is greater than parametric precision out of myPrecision
|
||||
-- FAIL : No pcurve(s) on the edge(s)
|
||||
|
||||
CheckCurveGap (me : mutable; num : Integer = 0) returns Boolean;
|
||||
---Purpose: Checks gap between points on 3D curve and points on surface
|
||||
-- generated by pcurve of the num-th edge.
|
||||
-- The distance can be queried by MinDistance3d.
|
||||
--
|
||||
-- Returns: True if status is DONE
|
||||
-- Status:
|
||||
-- OK : Gap is less than myPrecision
|
||||
-- DONE : Gap is greater than myPrecision
|
||||
-- FAIL : No 3d curve(s) on the edge(s)
|
||||
|
||||
CheckSelfIntersectingEdge (me: mutable; num: Integer;
|
||||
points2d: out SequenceOfIntersectionPoint from IntRes2d;
|
||||
points3d: out SequenceOfPnt from TColgp)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if num-th edge is self-intersecting.
|
||||
-- Self-intersection is reported only if intersection point lies outside
|
||||
-- of both end vertices of the edge.
|
||||
-- Returns: True if edge is self-intersecting.
|
||||
-- If returns True it also fills the sequences of intersection points
|
||||
-- and corresponding 3d points (only that are not enclosed by a vertices)
|
||||
-- Status:
|
||||
-- FAIL1 : No pcurve
|
||||
-- FAIL2 : No vertices
|
||||
-- DONE1 : Self-intersection found
|
||||
|
||||
CheckSelfIntersectingEdge (me: mutable; num: Integer)
|
||||
returns Boolean;
|
||||
-- Purpose: Checks num-th edge to be self-intersecting.
|
||||
-- Remark : Calls the previous method
|
||||
-- Status : See the function above for details
|
||||
|
||||
CheckIntersectingEdges (me : mutable; num: Integer;
|
||||
points2d: out SequenceOfIntersectionPoint from IntRes2d;
|
||||
points3d: out SequenceOfPnt from TColgp;
|
||||
errors: out SequenceOfReal from TColStd)
|
||||
returns Boolean;
|
||||
---Purpose: Checks two adjacent edges for intersecting.
|
||||
-- Intersection is reported only if intersection point is not enclosed
|
||||
-- by the common end vertex of the edges.
|
||||
-- Returns: True if intersection is found.
|
||||
-- If returns True it also fills the sequences of intersection points,
|
||||
-- corresponding 3d points, and errors for them (half-distances between
|
||||
-- intersection points in 3d calculated from one and from another edge)
|
||||
-- Status:
|
||||
-- FAIL1 : No pcurve
|
||||
-- FAIL2 : No vertices
|
||||
-- DONE1 : Self-intersection found
|
||||
|
||||
CheckIntersectingEdges (me: mutable; num: Integer)
|
||||
returns Boolean;
|
||||
---Purpose: Checks two adjacent edges for intersecting.
|
||||
-- Remark : Calls the previous method
|
||||
-- Status : See the function above for details
|
||||
|
||||
CheckIntersectingEdges(me: mutable; num1: Integer; num2: Integer;
|
||||
points2d: out SequenceOfIntersectionPoint from IntRes2d;
|
||||
points3d: out SequenceOfPnt from TColgp;
|
||||
errors: out SequenceOfReal from TColStd)
|
||||
returns Boolean;
|
||||
---Purpose: Checks i-th and j-th edges for intersecting.
|
||||
-- Remark : See the previous method for details
|
||||
|
||||
CheckIntersectingEdges(me: mutable; num1: Integer; num2: Integer)
|
||||
returns Boolean;
|
||||
---Purpose: Checks i-th and j-th edges for intersecting.
|
||||
-- Remark : Calls previous method.
|
||||
-- Status : See the function above for details
|
||||
|
||||
CheckLacking (me: mutable; num: Integer; Tolerance: Real;
|
||||
p2d1, p2d2: out Pnt2d from gp) returns Boolean;
|
||||
---Purpose: Checks if there is a gap in 2d between edges, not comprised by
|
||||
-- the tolerance of their common vertex.
|
||||
-- If <Tolerance> is greater than 0. and less than tolerance of
|
||||
-- the vertex, then this value is used for check.
|
||||
-- Returns: True if not closed gap was detected
|
||||
-- p2d1 and p2d2 are the endpoint of <num-1>th edge and start of
|
||||
-- the <num>th edge in 2d.
|
||||
-- Status:
|
||||
-- OK: No edge is lacking (3d and 2d connection)
|
||||
-- FAIL1: edges have no vertices (at least one of them)
|
||||
-- FAIL2: edges are neither connected by common vertex, nor have
|
||||
-- coincided vertices
|
||||
-- FAIL1: edges have no pcurves
|
||||
-- DONE1: the gap is detected which cannot be closed by the tolerance
|
||||
-- of the common vertex (or with value of <Tolerance>)
|
||||
-- DONE2: is set (together with DONE1) if gap is detected and the
|
||||
-- vector (p2d2 - p2d1) goes in direction opposite to the pcurves
|
||||
-- of the edges (if angle is more than 0.9*PI).
|
||||
|
||||
CheckLacking (me : mutable; num: Integer; Tolerance: Real = 0.0) returns Boolean;
|
||||
---Purpose: Checks if there is a gap in 2D between edges and not comprised by vertex tolerance
|
||||
-- The value of SBWD.thepreci is used.
|
||||
-- Returns: False if no edge should be inserted
|
||||
-- Status:
|
||||
-- OK : No edge is lacking (3d and 2d connection)
|
||||
-- DONE1 : The vertex tolerance should be increased only (2d gap is
|
||||
-- small)
|
||||
-- DONE2 : Edge can be inserted (3d and 2d gaps are large enough)
|
||||
|
||||
CheckOuterBound (me: mutable; APIMake: Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if wire defines an outer bound on the face
|
||||
-- Uses ShapeAnalysis::IsOuterBound for analysis
|
||||
-- If <APIMake> is True uses BRepAPI_MakeWire to build the
|
||||
-- wire, if False (to be used only when edges share common
|
||||
-- vertices) uses BRep_Builder to build the wire
|
||||
--
|
||||
---Returns: False if wire is an outer bound, else returns True
|
||||
-- Status:
|
||||
-- OK : If it is an outer wire
|
||||
-- DONE : If not
|
||||
|
||||
CheckNotchedEdges(me : mutable; num : Integer;
|
||||
shortNum : out Integer;
|
||||
param : out Real;
|
||||
Tolerance: Real = 0.0) returns Boolean;
|
||||
---Purpose: Detects a notch
|
||||
|
||||
CheckSmallArea (me: mutable; prec2d : Real = 0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks if wire has parametric area less than prec2d.
|
||||
|
||||
CheckShapeConnect (me : mutable; shape : Shape from TopoDS; prec: Real = 0.0)
|
||||
returns Boolean;
|
||||
---Purpose: Checks with what orientation <shape> (wire or edge) can be
|
||||
-- connected to the wire.
|
||||
-- Tests distances with starting <preci> from <SBWD> (close confusion),
|
||||
-- but if given <prec> is greater, tests with <prec> (coarse confusion).
|
||||
-- The smallest found distance can be returned by MinDistance3d
|
||||
--
|
||||
-- Returns: False if status is FAIL (see below)
|
||||
-- Status:
|
||||
-- DONE1 : If <shape> follows <SBWD>, direct sense (normal)
|
||||
-- DONE2 : If <shape> follows <SBWD>, but if reversed
|
||||
-- DONE3 : If <shape> preceeds <SBWD>, direct sense
|
||||
-- DONE4 : If <shape> preceeds <SBWD>, but if reversed
|
||||
-- FAIL1 : If <shape> is neither an edge nor a wire
|
||||
-- FAIL2 : If <shape> cannot be connected to <SBWD>
|
||||
--
|
||||
-- DONE5 : To the tail of <SBWD> the <shape> is closer with
|
||||
-- direct sense
|
||||
-- DONE6 : To the head of <SBWD> the <shape> is closer with
|
||||
-- direct sense
|
||||
--
|
||||
-- Remark: Statuses DONE1 - DONE4, FAIL1 - FAIL2 are basic and
|
||||
-- describe the nearest connection of the <shape> to <SBWD>.
|
||||
-- Statuses DONE5 and DONE6 are advanced and are to be used when
|
||||
-- analyzing with what sense (direct or reversed) the <shape>
|
||||
-- should be connected to <SBWD>:
|
||||
-- For tail of <SBWD> if DONE4 is True <shape> should be direct,
|
||||
-- otherwise reversed.
|
||||
-- For head of <SBWD> if DONE5 is True <shape> should be direct,
|
||||
-- otherwise reversed.
|
||||
|
||||
CheckShapeConnect (me : mutable; tailhead: out Real;
|
||||
tailtail: out Real;
|
||||
headtail: out Real;
|
||||
headhead: out Real;
|
||||
shape : Shape from TopoDS;
|
||||
prec : Real = 0.0)
|
||||
returns Boolean;
|
||||
---Purpose: The same as previous CheckShapeConnect but is more advanced.
|
||||
-- It returns the distances between each end of <sbwd> and each
|
||||
-- end of <shape>. For example, <tailhead> stores distance
|
||||
-- between tail of <sbwd> and head of <shape>
|
||||
-- Remark: First method CheckShapeConnect calls this one
|
||||
|
||||
CheckLoop (me : mutable; aMapLoopVertices : out IndexedMapOfShape from TopTools;
|
||||
aMapVertexEdges :out DataMapOfShapeListOfShape from TopTools;
|
||||
aMapSmallEdges : out MapOfShape from TopTools;
|
||||
aMapSeemEdges : out MapOfShape from TopTools) returns Boolean;
|
||||
---Purpose: Checks existance of loop on wire and return vertices wich are loop vertices
|
||||
-- (vertices belonging to a few pairs of edges)
|
||||
|
||||
|
||||
---Status after checking :
|
||||
|
||||
---Level : Public
|
||||
|
||||
-- Querying the status of perfomed API checking procedures
|
||||
StatusOrder (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusConnected (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusEdgeCurves (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusDegenerated (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusClosed (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusSmall (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusSelfIntersection (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusLacking (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusGaps3d (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusGaps2d (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
StatusCurveGaps (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
|
||||
StatusLoop (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
---Level : Advanced
|
||||
|
||||
LastCheckStatus (me; Status: Status from ShapeExtend) returns Boolean;
|
||||
---C++: inline
|
||||
---Purpose: Querying the status of the LAST perfomed 'Advanced' checking procedure
|
||||
|
||||
---Querying fields
|
||||
|
||||
MinDistance3d (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the last lowest distance in 3D computed by
|
||||
-- CheckOrientation, CheckConnected, CheckContinuity3d,
|
||||
-- CheckVertex, CheckNewVertex
|
||||
|
||||
MinDistance2d (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the last lowest distance in 2D-UV computed by
|
||||
-- CheckContinuity2d
|
||||
|
||||
MaxDistance3d (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the last maximal distance in 3D computed by
|
||||
-- CheckOrientation, CheckConnected, CheckContinuity3d,
|
||||
-- CheckVertex, CheckNewVertex, CheckSameParameter
|
||||
|
||||
MaxDistance2d (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the last maximal distance in 2D-UV computed by
|
||||
-- CheckContinuity2d
|
||||
|
||||
fields
|
||||
|
||||
myWire: WireData from ShapeExtend is protected;
|
||||
myFace: Face from TopoDS is protected;
|
||||
mySurf: Surface from ShapeAnalysis is protected;
|
||||
myPrecision : Real is protected;
|
||||
|
||||
myMin3d: Real is protected; -- lower computed distance 3d
|
||||
myMin2d: Real is protected; -- lower computed distance 2d
|
||||
myMax3d: Real is protected; -- upper computed distance 3d
|
||||
myMax2d: Real is protected; -- upper computed distance 2d
|
||||
|
||||
-- statuses corresponding to API methods, queried by Status..(status) methods
|
||||
myStatusOrder: Integer is protected;
|
||||
myStatusConnected: Integer is protected;
|
||||
myStatusEdgeCurves: Integer is protected;
|
||||
myStatusDegenerated: Integer is protected;
|
||||
myStatusClosed: Integer is protected;
|
||||
myStatusSmall: Integer is protected;
|
||||
myStatusSelfIntersection: Integer is protected;
|
||||
myStatusLacking: Integer is protected;
|
||||
myStatusGaps3d: Integer is protected; -- szvsh
|
||||
myStatusGaps2d: Integer is protected; -- szvsh
|
||||
myStatusCurveGaps: Integer is protected; -- szvsh
|
||||
myStatusLoop : Integer is protected;
|
||||
|
||||
myStatus: Integer is protected; -- for internal use, queried by LastCheckStatus(status) method
|
||||
|
||||
end Wire;
|
1859
src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
Executable file
1859
src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
Executable file
File diff suppressed because it is too large
Load Diff
265
src/ShapeAnalysis/ShapeAnalysis_Wire.lxx
Executable file
265
src/ShapeAnalysis/ShapeAnalysis_Wire.lxx
Executable file
@@ -0,0 +1,265 @@
|
||||
//:pdn 05.01.99: renaming method ...Little to ...Small
|
||||
#include <ShapeExtend.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLoaded
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::IsLoaded() const
|
||||
{
|
||||
return ! myWire.IsNull() && myWire->NbEdges() >0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsReady
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::IsReady() const
|
||||
{
|
||||
return IsLoaded() && !myFace.IsNull();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Precision
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Wire::Precision() const
|
||||
{
|
||||
return myPrecision;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : WireData
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const Handle(ShapeExtend_WireData)& ShapeAnalysis_Wire::WireData() const
|
||||
{
|
||||
return myWire;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer ShapeAnalysis_Wire::NbEdges() const
|
||||
{
|
||||
return myWire.IsNull() ? 0 : myWire->NbEdges();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Face
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const TopoDS_Face& ShapeAnalysis_Wire::Face() const
|
||||
{
|
||||
return myFace;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Surface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const Handle(ShapeAnalysis_Surface)& ShapeAnalysis_Wire::Surface() const
|
||||
{
|
||||
return mySurf;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusOrder
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusOrder (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusOrder, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusConnected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusConnected (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusConnected, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusEdgeCurves
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusEdgeCurves (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusEdgeCurves, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusDegenerated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusDegenerated (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusDegenerated, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusClosed (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusClosed, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusSmall
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusSmall (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusSmall, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusSelfIntersection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusSelfIntersection (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusSelfIntersection, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusLacking
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusLacking (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusLacking, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusGaps3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusGaps3d(const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusGaps3d, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusGaps2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusGaps2d(const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusGaps2d, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusCurveGaps
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusCurveGaps(const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusCurveGaps, Status );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StatusLoop
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::StatusLoop(const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatusLoop, Status );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Status
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean ShapeAnalysis_Wire::LastCheckStatus (const ShapeExtend_Status Status) const
|
||||
{
|
||||
return ShapeExtend::DecodeStatus ( myStatus, Status );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MinDistance3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Wire::MinDistance3d() const
|
||||
{
|
||||
return myMin3d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MinDistance2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Wire::MinDistance2d() const
|
||||
{
|
||||
return myMin2d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxDistance3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Wire::MaxDistance3d() const
|
||||
{
|
||||
return myMax3d;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxDistance2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real ShapeAnalysis_Wire::MaxDistance2d() const
|
||||
{
|
||||
return myMax2d;
|
||||
}
|
145
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cdl
Executable file
145
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cdl
Executable file
@@ -0,0 +1,145 @@
|
||||
-- File: ShapeAnalysis_WireOrder.cdl
|
||||
-- Created: Wed Jun 3 12:06:27 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class WireOrder from ShapeAnalysis
|
||||
|
||||
---Purpose: This class is intended to control and, if possible, redefine
|
||||
-- the order of a list of edges which define a wire
|
||||
-- Edges are not given directly, but as their bounds (start,end)
|
||||
--
|
||||
-- This allows to use this tool, either on existing wire, or on
|
||||
-- data just taken from a file (coordinates are easy to get)
|
||||
--
|
||||
-- It can work, either in 2D, or in 3D, but not miscible
|
||||
-- Warning about tolerance : according to the mode (2D/3D), it
|
||||
-- must be given as 2D or 3D (i.e. metric) tolerance, uniform
|
||||
-- on the whole list
|
||||
--
|
||||
-- Two phases : firstly add the couples (start,end)
|
||||
-- secondly perform then get the result
|
||||
|
||||
uses
|
||||
XY from gp,
|
||||
XYZ from gp,
|
||||
HSequenceOfXYZ from TColgp,
|
||||
HArray1OfInteger from TColStd
|
||||
|
||||
raises
|
||||
TypeMismatch from Standard
|
||||
|
||||
is
|
||||
|
||||
Create returns WireOrder from ShapeAnalysis;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create(mode3d: Boolean; tol: Real) returns WireOrder from ShapeAnalysis;
|
||||
---Purpose : Creates a WireOrder in 3D (if mode3d is True) or 2D (if False)
|
||||
-- with a tolerance
|
||||
|
||||
SetMode(me : in out; mode3d: Boolean; tol : Real);
|
||||
---Purpose : Sets new values. Clears the connexion list
|
||||
-- If <mode3d> changes, also clears the edge list (else, doesnt)
|
||||
|
||||
Tolerance(me) returns Real;
|
||||
---Purpose : Returns the working tolerance
|
||||
|
||||
Clear(me: in out);
|
||||
---Purpose : Clears the list of edges, but not mode and tol
|
||||
|
||||
Add(me: in out; start3d, end3d: XYZ from gp)
|
||||
---Purpose : Adds a couple of points 3D (start,end)
|
||||
raises TypeMismatch;
|
||||
-- Error if initial mode was 2D
|
||||
|
||||
Add(me: in out; start2d, end2d: XY from gp)
|
||||
---Purpose : Adds a couple of points 2D (start,end)
|
||||
raises TypeMismatch;
|
||||
-- Error if initial mode was 3D
|
||||
|
||||
NbEdges(me) returns Integer;
|
||||
---Purpose : Returns the count of added couples of points (one per edges)
|
||||
|
||||
KeepLoopsMode(me: in out) returns Boolean;
|
||||
---C++: return&
|
||||
---Purpose : If this mode is True method perform does not sort edges of
|
||||
-- different loops. The resulting order is first loop, second
|
||||
-- one etc...
|
||||
|
||||
Perform(me: in out; closed: Boolean = Standard_True);
|
||||
---Purpose : Computes the better order
|
||||
-- If <closed> is True (D) considers also closure
|
||||
-- Optimised if the couples were already in order
|
||||
-- The criterium is : two couples in order if distance between
|
||||
-- end-prec and start-cur is less then starting tolerance <tol>
|
||||
-- Else, the smallest distance is reached
|
||||
-- Gap corresponds to a smallest distance greater than <tol>
|
||||
|
||||
IsDone(me) returns Boolean;
|
||||
---Purpose : Tells if Perform has been done
|
||||
-- Else, the following methods returns original values
|
||||
|
||||
Status(me) returns Integer;
|
||||
---Purpose : Returns the status of the order (0 if not done) :
|
||||
-- 0 : all edges are direct and in sequence
|
||||
-- 1 : all edges are direct but some are not in sequence
|
||||
-- 2 : in addition, unresolved gaps remain
|
||||
-- -1 : some edges are reversed, but no gap remain
|
||||
-- -2 : some edges are reversed and some gaps remain
|
||||
-- -10 : COULD NOT BE RESOLVED, Failure on Reorder
|
||||
-- gap : regarding starting <tol>
|
||||
|
||||
Ordered(me; n: Integer) returns Integer;
|
||||
---Purpose : Returns the number of original edge which correspond to the
|
||||
-- newly ordered number <n>
|
||||
-- Warning : the returned value is NEGATIVE if edge should be reversed
|
||||
|
||||
XYZ(me; num: Integer; start3d, end3d : out XYZ from gp);
|
||||
---Purpose : Returns the values of the couple <num>, as 3D values
|
||||
|
||||
XY(me; num: Integer; start2d, end2d: out XY from gp);
|
||||
---Purpose : Returns the values of the couple <num>, as 2D values
|
||||
|
||||
Gap(me; num : Integer = 0) returns Real;
|
||||
---Purpose : Returns the gap between a couple and its preceeding
|
||||
-- <num> is considered ordered
|
||||
-- If <num> = 0 (D), returns the greatest gap found
|
||||
|
||||
SetChains(me : in out; gap : Real);
|
||||
---Purpose : Determines the chains inside which successive edges have a gap
|
||||
-- less than a given value. Queried by NbChains and Chain
|
||||
|
||||
NbChains(me) returns Integer;
|
||||
---Purpose : Returns the count of computed chains
|
||||
|
||||
Chain(me; num: Integer; n1,n2: out Integer);
|
||||
---Purpose : Returns, for the chain n0 num, starting and ending numbers of
|
||||
-- edges. In the list of ordered edges (see Ordered for originals)
|
||||
|
||||
SetCouples(me: in out; gap: Real);
|
||||
---Purpose : Determines the couples of edges for which end and start fit
|
||||
-- inside a given gap. Queried by NbCouples and Couple
|
||||
|
||||
NbCouples(me) returns Integer;
|
||||
---Purpose : Returns the count of computed couples
|
||||
|
||||
Couple(me; num: Integer; n1, n2: out Integer);
|
||||
---Purpose : Returns, for the couple n0 num, the two implied edges
|
||||
-- In the list of ordered edges
|
||||
|
||||
fields
|
||||
|
||||
myKeepLoops : Boolean from Standard;
|
||||
myOrd : HArray1OfInteger from TColStd;
|
||||
myChains : HArray1OfInteger from TColStd;
|
||||
myCouples : HArray1OfInteger from TColStd;
|
||||
myXYZ : HSequenceOfXYZ from TColgp;
|
||||
myTol : Real;
|
||||
myGap : Real;
|
||||
myStat : Integer;
|
||||
myMode : Boolean;
|
||||
|
||||
end WireOrder;
|
551
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx
Executable file
551
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx
Executable file
@@ -0,0 +1,551 @@
|
||||
//:o4 abv 17.02.99: r0301_db.stp #53082: treatment of open wires implemented
|
||||
// pdn 11.03.99 S4135 changing reordering algorithm in order to make it independent on tolerance
|
||||
//szv#4 S4163
|
||||
// pdn 09.05.99: S4174: preserve order of edges for complete torus
|
||||
#include <ShapeAnalysis_WireOrder.ixx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <Standard_TypeMismatch.hxx>
|
||||
|
||||
#include <TColgp_Array1OfXYZ.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <TColStd_Array1OfBoolean.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TColStd_SequenceOfTransient.hxx>
|
||||
#include <TColStd_HSequenceOfInteger.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_WireOrder
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_WireOrder::ShapeAnalysis_WireOrder()
|
||||
: myKeepLoops(Standard_False) , myGap (0.) , myStat (0) , myMode (Standard_True)
|
||||
{
|
||||
myTol = Precision::Confusion();
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_WireOrder
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_WireOrder::ShapeAnalysis_WireOrder(const Standard_Boolean mode3d,
|
||||
const Standard_Real tol)
|
||||
: myKeepLoops(Standard_False), myTol (tol), myGap (0.), myStat (0), myMode (mode3d)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::SetMode(const Standard_Boolean mode3d,const Standard_Real tol)
|
||||
{
|
||||
if (mode3d != myMode) Clear();
|
||||
myOrd.Nullify(); myStat = 0; myGap = 0.;
|
||||
myMode = mode3d;
|
||||
myTol = (tol > 0.)? tol : 1.e-08; //szv#4:S4163:12Mar99 optimized
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Tolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_WireOrder::Tolerance() const
|
||||
{
|
||||
return myTol;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::Clear()
|
||||
{
|
||||
myXYZ = new TColgp_HSequenceOfXYZ();
|
||||
myStat = 0;
|
||||
myGap = 0.;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::Add(const gp_XYZ& start3d,const gp_XYZ& end3d)
|
||||
{
|
||||
//szv#4:S4163:12Mar99 waste raise
|
||||
//if (!myMode)
|
||||
//Standard_TypeMismatch::Raise("ShapeAnalysis_WireOrder : AddXYZ");
|
||||
if (myMode) {
|
||||
myXYZ->Append (start3d); myXYZ->Append (end3d);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::Add(const gp_XY& start2d,const gp_XY& end2d)
|
||||
{
|
||||
//szv#4:S4163:12Mar99 waste raise
|
||||
//if ( myMode)
|
||||
//Standard_TypeMismatch::Raise("ShapeAnalysis_WireOrder : AddXY");
|
||||
if (!myMode) {
|
||||
gp_XYZ val;
|
||||
val.SetCoord (start2d.X(),start2d.Y(),0.);
|
||||
myXYZ->Append (val);
|
||||
val.SetCoord (end2d.X(),end2d.Y(),0.);
|
||||
myXYZ->Append (val);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireOrder::NbEdges() const
|
||||
{
|
||||
return myXYZ->Length() / 2;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Real DISTABS (const gp_XYZ& v1, const gp_XYZ& v2)
|
||||
{
|
||||
return Abs (v1.X() - v2.X()) + Abs (v1.Y() - v2.Y()) + Abs (v1.Z() - v2.Z());
|
||||
}
|
||||
|
||||
// La routine qui suit gere les boucles internes a un wire. Questce a dire ?
|
||||
// Un wire normalement chaine (meme pas dans l ordre et avec des inverses)
|
||||
// balaie toutes ses edges au moins une fois dans une seule liste
|
||||
// En 3D il peut y avoir des COUTURES ... une, mais evt plusieurs ...
|
||||
// En ce cas le critere fin-debut peut definir des sous-parties fermees du
|
||||
// wire, ce sont les boucles en question
|
||||
// Exemple (cylindre gentil) : la couture (balayee deux fois) : 1 boucle
|
||||
// chaque limite (haute et basse) definit aussi une boucle (1 edge ou +)
|
||||
|
||||
// En cours de chainage, il faut donc :
|
||||
// 1/ sauter la boucle, pour ne pas la rebalayer 36 fois : NextFree y pourvoit
|
||||
// en notant les tetes de boucles, on n a pas le droit de les revoir
|
||||
// NB: ca marche car en cours de constitution de liste, on s interdit de
|
||||
// repasser plus d une fois sur chaque edge (test fol-pre non nul)
|
||||
// 2/ reprendre les boucles pour les fusionner : pas encore fait
|
||||
// (pour l instant, on imprime un petit message, c est tout)
|
||||
|
||||
static Standard_Integer NextFree
|
||||
(const Standard_Integer i, const Standard_Integer nb,
|
||||
Standard_Integer& nbloops, TColStd_Array1OfInteger& loops,
|
||||
TColStd_Array1OfInteger& loopord,
|
||||
const Handle(TColStd_HArray1OfInteger)& ord)
|
||||
{
|
||||
if (i < 0) return -NextFree (-i, nb,nbloops,loops,loopord,ord);
|
||||
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
Standard_Integer j; // svv Jan11 2000 : porting on DEC
|
||||
for (j = 1; j <= nbloops; j ++) if (i == loops(j)) break;
|
||||
if ( j > nbloops ) return i; // OK
|
||||
|
||||
// sinon, une boucle de plus, et chercher le prochain libre
|
||||
nbloops ++;
|
||||
for (j = 1; j <= nb; j ++)
|
||||
if (loopord.Value(j) == 0) { loops(nbloops) = j; return j; }
|
||||
nbloops --; // finalement il n ya plus rien
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : KeepLoopsMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean& ShapeAnalysis_WireOrder::KeepLoopsMode()
|
||||
{
|
||||
return myKeepLoops;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean IsBetter(const Standard_Integer first,
|
||||
const Standard_Integer second)
|
||||
{
|
||||
//rln 23.03.99 bm4_al_eye.stp, entity 5281
|
||||
//Order in the file is better even if another order has the same distance
|
||||
//Lexicograhical order of preference: 0 > 2 > 1 > 3
|
||||
if (first == 0 && second > 0 ) return Standard_True;
|
||||
if (first == 2 && (second == 1 || second == 3)) return Standard_True;
|
||||
if (first == 1 && second == 3 ) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
void ShapeAnalysis_WireOrder::Perform(const Standard_Boolean /*closed*/)
|
||||
{
|
||||
Standard_Integer i, nb = myXYZ->Length() / 2;
|
||||
myOrd = new TColStd_HArray1OfInteger(1,nb); myOrd->Init(0);
|
||||
|
||||
Handle(TColStd_HSequenceOfInteger) seq = new TColStd_HSequenceOfInteger;
|
||||
TColStd_SequenceOfTransient loops;
|
||||
|
||||
TColgp_Array1OfXYZ debs(0,nb);
|
||||
TColgp_Array1OfXYZ fins(0,nb);
|
||||
|
||||
TColStd_Array1OfBoolean idone (1, nb);
|
||||
idone.Init (Standard_False);
|
||||
|
||||
// Calcul des precedents-suivants
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
debs(i) = myXYZ->Value(2*i-1);
|
||||
fins(i) = myXYZ->Value(2*i);
|
||||
}
|
||||
|
||||
Standard_Real tol2 = Precision::Confusion()*Precision::Confusion();
|
||||
idone(1) = Standard_True;
|
||||
gp_Pnt wireFirst = debs(1);
|
||||
gp_Pnt wireLast = fins(1);
|
||||
seq->Append(1);
|
||||
Standard_Boolean done = Standard_False;
|
||||
|
||||
//pdn 11.03.99 S4135 constructing closed loops of edges
|
||||
while(!done) {
|
||||
Standard_Integer resultType = 3;
|
||||
Standard_Real distmin = RealLast();
|
||||
Standard_Integer ledge;
|
||||
Standard_Boolean found = Standard_False;
|
||||
Standard_Real closeDist = wireFirst.SquareDistance(wireLast);
|
||||
|
||||
for(Standard_Integer iedge = 1; (iedge <= nb) && (distmin||resultType||(resultType!=2)); iedge++)
|
||||
if(!idone(iedge)) {
|
||||
Standard_Real tailhead = wireLast.SquareDistance(debs(iedge));
|
||||
Standard_Real tailtail = wireLast.SquareDistance(fins(iedge));
|
||||
Standard_Real headtail = wireFirst.SquareDistance(fins(iedge));
|
||||
Standard_Real headhead = wireFirst.SquareDistance(debs(iedge));
|
||||
Standard_Real dm1 = tailhead, dm2 = headtail;
|
||||
Standard_Integer res1 = 0, res2 = 2;
|
||||
|
||||
if (tailhead > tailtail) {res1 = 1; dm1 = tailtail;}
|
||||
if (headtail > headhead) {res2 = 3; dm2 = headhead;}
|
||||
Standard_Integer result =0;
|
||||
Standard_Real myMin3d = Min (dm1, dm2);
|
||||
if(fabs(dm1 - dm2) < tol2 ) {
|
||||
Standard_Boolean isB = IsBetter(res1,res2);
|
||||
result = (isB ? res1 : res2);
|
||||
}
|
||||
else
|
||||
result = ((dm1 > dm2) ? res2 : res1); // 0 > 2 > 1 > 3
|
||||
|
||||
if (distmin > tol2 || IsBetter(result,resultType))
|
||||
if (myMin3d < distmin || ((myMin3d == distmin || myMin3d < tol2) && IsBetter(result,resultType))) {
|
||||
found = Standard_True;
|
||||
distmin = myMin3d;
|
||||
ledge = iedge;
|
||||
resultType = result;
|
||||
}
|
||||
}
|
||||
if(found) {
|
||||
if (distmin == 0 || distmin < closeDist) {
|
||||
switch(resultType){
|
||||
case 0: seq->Append(ledge); wireLast = fins(ledge); break;
|
||||
case 1: seq->Append(-ledge); wireLast = debs(ledge); break;
|
||||
case 2: seq->Prepend(ledge); wireFirst = debs(ledge); break;
|
||||
case 3: seq->Prepend(-ledge); wireFirst = fins(ledge); break;
|
||||
}
|
||||
} else {
|
||||
//pdn 11.03.99 S4135 closing loop and creating new one
|
||||
loops.Append(seq);
|
||||
seq = new TColStd_HSequenceOfInteger;
|
||||
wireFirst = debs(ledge);
|
||||
wireLast = fins(ledge);
|
||||
seq->Append(ledge);
|
||||
}
|
||||
idone(ledge) = Standard_True;
|
||||
} else {
|
||||
ledge = -1;
|
||||
for (i = 1 ; i <= nb && ledge == -1; i++)
|
||||
ledge = idone(i) ? ledge : i;
|
||||
if (ledge == -1)
|
||||
done = 1;
|
||||
else {
|
||||
wireFirst = debs(ledge);
|
||||
wireLast = fins(ledge);
|
||||
seq->Append(ledge);
|
||||
idone(ledge) = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
loops.Append(seq);
|
||||
|
||||
Handle(TColStd_HSequenceOfInteger) mainSeq;
|
||||
if (myKeepLoops) {
|
||||
|
||||
//pdn Keeping the loops, adding one after another.
|
||||
mainSeq = new TColStd_HSequenceOfInteger;
|
||||
for (Standard_Integer ii = 1; ii <= loops.Length(); ii++) {
|
||||
Handle(TColStd_HSequenceOfInteger) subLoop =
|
||||
Handle(TColStd_HSequenceOfInteger)::DownCast(loops(ii));
|
||||
for (Standard_Integer j = 1; j<= subLoop->Length(); j++)
|
||||
mainSeq->Append(subLoop->Value(j));
|
||||
}
|
||||
}
|
||||
else {
|
||||
//pdn 11.03.99 S4135 connecting loops.
|
||||
mainSeq = Handle(TColStd_HSequenceOfInteger)::DownCast(loops.First());
|
||||
loops.Remove(1);
|
||||
while(loops.Length()) {
|
||||
Standard_Real minLoopDist = RealLast();
|
||||
Standard_Integer loopNum=0;
|
||||
Standard_Integer loopShift=0;
|
||||
Standard_Boolean loopDirect=0;
|
||||
Standard_Integer numInLoop=0;
|
||||
for(i = 1; i <= loops.Length(); i++) {
|
||||
Handle(TColStd_HSequenceOfInteger) loop = Handle(TColStd_HSequenceOfInteger)::DownCast(loops.Value(i));
|
||||
Standard_Integer num = loop->Length();
|
||||
Standard_Integer LocShift=0;
|
||||
Standard_Integer LocNumInLoop=0;
|
||||
Standard_Boolean LocDirect = Standard_False;
|
||||
Standard_Real minLocDist = RealLast();
|
||||
for(Standard_Integer ibegin = 1; ibegin <= loop->Length(); ibegin++) {
|
||||
Standard_Integer iend = (ibegin==1 ? num : ibegin -1);
|
||||
gp_Pnt loopFirst = (loop->Value(ibegin) > 0 ? debs(loop->Value(ibegin)) : fins(-loop->Value(ibegin)));
|
||||
gp_Pnt loopLast = (loop->Value(iend) > 0 ? fins(loop->Value(iend)) : debs(-loop->Value(iend)));
|
||||
Standard_Real distmin = RealLast();
|
||||
Standard_Integer lloop=0;
|
||||
Standard_Boolean direct = Standard_False;
|
||||
for(Standard_Integer j = 1; (j <= mainSeq->Length())&& distmin; j++) {
|
||||
Standard_Integer k = (j == mainSeq->Length()? 1 : j+1);
|
||||
gp_Pnt first = (mainSeq->Value(j) > 0 ? fins(mainSeq->Value(j)) : debs(-mainSeq->Value(j)));
|
||||
gp_Pnt last = (mainSeq->Value(k) > 0 ? debs(mainSeq->Value(k)) : fins(-mainSeq->Value(k)));
|
||||
Standard_Real dirDist = loopFirst.SquareDistance(first)+loopLast.SquareDistance(last);
|
||||
Standard_Real revDist = loopFirst.SquareDistance(last)+loopLast.SquareDistance(first);
|
||||
Standard_Real minDist;
|
||||
if((dirDist<tol2)||(dirDist < 2.*revDist)) {
|
||||
minDist = dirDist;
|
||||
revDist = dirDist;
|
||||
}
|
||||
else
|
||||
minDist = revDist;
|
||||
if(minDist < distmin) {
|
||||
distmin = minDist;
|
||||
direct = (dirDist <= revDist);
|
||||
lloop = j;
|
||||
}
|
||||
}
|
||||
if(distmin<minLocDist) {
|
||||
minLocDist = distmin;
|
||||
LocDirect = direct;
|
||||
LocNumInLoop = lloop;
|
||||
LocShift = ibegin;
|
||||
}
|
||||
|
||||
}
|
||||
if(minLocDist < minLoopDist) {
|
||||
minLoopDist = minLocDist;
|
||||
loopNum = i;
|
||||
loopDirect = LocDirect;
|
||||
numInLoop = LocNumInLoop;
|
||||
loopShift = LocShift;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfInteger) loop = Handle(TColStd_HSequenceOfInteger)::DownCast(loops.Value(loopNum));
|
||||
Standard_Integer factor = (loopDirect ? 1: -1);
|
||||
// skl : in the next block for{} I change "i" to "ii"
|
||||
for(Standard_Integer ii = 1; ii <= loop->Length(); ii++) {
|
||||
Standard_Integer num = (ii+loopShift-1>loop->Length() ? ii+loopShift-1-loop->Length() : ii+loopShift-1);
|
||||
mainSeq->InsertAfter(numInLoop+ii-1,loop->Value(num)*factor);
|
||||
}
|
||||
loops.Remove(loopNum);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer stTmp=0;
|
||||
for(i = 1; i <= mainSeq->Length(); i++) {
|
||||
if(i!=mainSeq->Value(i))
|
||||
if(stTmp>=0) stTmp = (mainSeq->Value(i) > 0 ? 1 : -1);
|
||||
myOrd->SetValue(i,mainSeq->Value(i));
|
||||
}
|
||||
myStat = stTmp;
|
||||
return;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_WireOrder::IsDone() const
|
||||
{
|
||||
return !myOrd.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Status
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireOrder::Status() const
|
||||
{
|
||||
return myStat;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Ordered
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireOrder::Ordered(const Standard_Integer n) const
|
||||
{
|
||||
if (myOrd.IsNull() || myOrd->Upper() < n) return n;
|
||||
Standard_Integer ord = myOrd->Value(n);
|
||||
return (ord == 0 ? n : ord);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : XYZ
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::XYZ(const Standard_Integer num,gp_XYZ& start3d,gp_XYZ& end3d) const
|
||||
{
|
||||
if (num > 0) {
|
||||
start3d = myXYZ->Value (2*num-1);
|
||||
end3d = myXYZ->Value (2*num);
|
||||
} else {
|
||||
start3d = myXYZ->Value (-2*num);
|
||||
end3d = myXYZ->Value (-2*num-1);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : XY
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::XY(const Standard_Integer num,gp_XY& start2d,gp_XY& end2d) const
|
||||
{
|
||||
const gp_XYZ& st2d = myXYZ->Value ( (num > 0 ? 2*num-1 : -2*num) );
|
||||
start2d.SetCoord (st2d.X(),st2d.Y());
|
||||
const gp_XYZ& en2d = myXYZ->Value ( (num > 0 ? 2*num : -2*num -1) );
|
||||
end2d.SetCoord (en2d.X(),en2d.Y());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Gap
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_WireOrder::Gap(const Standard_Integer num) const
|
||||
{
|
||||
if (num == 0) return myGap;
|
||||
Standard_Integer n1 = Ordered (num);
|
||||
Standard_Integer n0 = Ordered (num == 1 ? NbEdges() : num-1);
|
||||
// Distance entre fin (n0) et debut (n1)
|
||||
return DISTABS (myXYZ->Value( (n0 > 0 ? 2*n0 : -2*n0 -1) ) ,
|
||||
myXYZ->Value( (n1 > 0 ? 2*n1-1 : -2*n1 ) ) );
|
||||
//// return (myXYZ->Value(2*n0)).Distance (myXYZ->Value(2*n1-1));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetChains
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::SetChains(const Standard_Real gap)
|
||||
{
|
||||
Standard_Integer n0 = 0, n1, n2, nb = NbEdges(); //szv#4:S4163:12Mar99 o0,o1,o2 not needed
|
||||
if (nb == 0) return;
|
||||
TColStd_SequenceOfInteger chain;
|
||||
n0 = 0;
|
||||
chain.Append (1); // On demarre la partie
|
||||
gp_XYZ f3d, l3d, f13d, l13d; //szv#4:S4163:12Mar99 f03d,l03d unused
|
||||
for (n1 = 1; n1 <= nb; n1 ++) {
|
||||
if (n0 == 0) { // nouvelle boucle
|
||||
n0 = n1;
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
XYZ ( Ordered(n0), f13d, l13d );
|
||||
}
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
n2 = (n1 == nb)? n0 : (n1 + 1);
|
||||
XYZ ( Ordered(n2), f3d, l3d );
|
||||
if (!f3d.IsEqual (l13d,gap)) { chain.Append (n2); n0 = 0; }
|
||||
f13d = f3d; l13d = l3d;
|
||||
}
|
||||
nb = chain.Length();
|
||||
if (nb == 0) return;
|
||||
myChains = new TColStd_HArray1OfInteger (1,nb);
|
||||
for (n1 = 1; n1 <= nb; n1 ++) myChains->SetValue (n1,chain.Value(n1));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbChains
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireOrder::NbChains() const
|
||||
{
|
||||
return (myChains.IsNull() ? 0 : myChains->Length());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Chain
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::Chain(const Standard_Integer num,Standard_Integer& n1,Standard_Integer& n2) const
|
||||
{
|
||||
n1 = n2 = 0;
|
||||
if (myChains.IsNull()) return;
|
||||
Standard_Integer nb = myChains->Upper();
|
||||
if (num == 0 || num > nb) return;
|
||||
n1 = myChains->Value (num);
|
||||
if (num == nb) n2 = NbEdges();
|
||||
else n2 = myChains->Value (num+1) - 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCouples
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::SetCouples(const Standard_Real /*gap*/)
|
||||
{
|
||||
cout<<"ShapeAnalysis_WireOrder:SetCouple not yet implemented"<<endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbCouples
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireOrder::NbCouples() const
|
||||
{
|
||||
return (myCouples.IsNull() ? 0 : myCouples->Length());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Couple
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireOrder::Couple(const Standard_Integer num,Standard_Integer& n1,Standard_Integer& n2) const
|
||||
{
|
||||
n1 = n2 = 0;
|
||||
if (myCouples.IsNull()) return;
|
||||
Standard_Integer nb = myCouples->Upper();
|
||||
if (num == 0 || num*2 > nb) return;
|
||||
n1 = myCouples->Value (2*num-1);
|
||||
n2 = myCouples->Value (2*num);
|
||||
}
|
||||
|
148
src/ShapeAnalysis/ShapeAnalysis_WireVertex.cdl
Executable file
148
src/ShapeAnalysis/ShapeAnalysis_WireVertex.cdl
Executable file
@@ -0,0 +1,148 @@
|
||||
-- File: ShapeAnalysis_WireVertex.cdl
|
||||
-- Created: Wed Jun 3 12:01:40 1998
|
||||
-- Author: data exchange team
|
||||
-- <det@nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
-- szv#4 S4163
|
||||
|
||||
class WireVertex from ShapeAnalysis
|
||||
|
||||
---Purpose: Analyzes and records status of vertices in a Wire
|
||||
--
|
||||
-- The Wire has formerly been loaded in a ShapeExtend_WireData
|
||||
-- For each Vertex, a status and some data can be attached
|
||||
-- (case found, position and parameters)
|
||||
-- Then, these informations can be used to fix problems
|
||||
|
||||
uses
|
||||
XYZ from gp,
|
||||
HArray1OfXYZ from TColgp,
|
||||
HArray1OfInteger from TColStd,
|
||||
HArray1OfReal from TColStd,
|
||||
Wire from TopoDS,
|
||||
WireData from ShapeExtend
|
||||
|
||||
is
|
||||
Create returns WireVertex;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Init (me: in out; wire: Wire from TopoDS; preci : Real);
|
||||
|
||||
Init (me: in out; swbd: WireData from ShapeExtend; preci : Real);
|
||||
|
||||
Load (me: in out; wire: Wire from TopoDS);
|
||||
|
||||
Load (me: in out; sbwd: WireData from ShapeExtend);
|
||||
|
||||
SetPrecision (me: in out; preci: Real);
|
||||
---Purpose: Sets the precision for work
|
||||
-- Analysing: for each Vertex, comparison between the end of the
|
||||
-- preceeding edge and the start of the following edge
|
||||
-- Each Vertex rank corresponds to the End Vertex of the Edge of
|
||||
-- same rank, in the ShapeExtend_WireData. I.E. for Vertex <num>,
|
||||
-- Edge <num> is the preceeding one, <num+1> is the following one
|
||||
|
||||
Analyze (me: in out);
|
||||
|
||||
SetSameVertex (me: in out; num: Integer);
|
||||
---Purpose: Records status "Same Vertex" (logically) on Vertex <num>
|
||||
|
||||
SetSameCoords (me: in out; num: Integer);
|
||||
---Purpose: Records status "Same Coords" (at the Vertices Tolerances)
|
||||
|
||||
SetClose (me: in out; num: Integer);
|
||||
---Purpose: Records status "Close Coords" (at the Precision of <me>)
|
||||
|
||||
SetEnd (me: in out; num : Integer;
|
||||
pos : XYZ from gp;
|
||||
ufol: Real);
|
||||
---Purpose: <num> is the End of preceeding Edge, and its projection on the
|
||||
-- following one lies on it at the Precision of <me>
|
||||
-- <ufol> gives the parameter on the following edge
|
||||
|
||||
SetStart (me: in out; num : Integer;
|
||||
pos : XYZ from gp;
|
||||
upre: Real);
|
||||
---Purpose: <num> is the Start of following Edge, its projection on the
|
||||
-- preceeding one lies on it at the Precision of <me>
|
||||
-- <upre> gives the parameter on the preceeding edge
|
||||
|
||||
SetInters (me: in out; num : Integer;
|
||||
pos : XYZ from gp;
|
||||
upre,ufol: Real);
|
||||
---Purpose: <num> is the Intersection of both Edges
|
||||
-- <upre> is the parameter on preceeding edge, <ufol> on
|
||||
-- following edge
|
||||
|
||||
SetDisjoined (me: in out; num: Integer);
|
||||
---Purpose: <num> cannot be said as same vertex
|
||||
|
||||
|
||||
IsDone (me) returns Boolean;
|
||||
---Purpose: Returns True if analysis was performed, else returns False
|
||||
|
||||
Precision (me) returns Real;
|
||||
---Purpose: Returns precision value used in analysis
|
||||
|
||||
NbEdges (me) returns Integer;
|
||||
---Purpose: Returns the number of edges in analyzed wire (i.e. the
|
||||
-- length of all arrays)
|
||||
|
||||
WireData (me) returns WireData from ShapeExtend;
|
||||
---Purpose: Returns analyzed wire
|
||||
---C++ : return const &
|
||||
|
||||
Status (me; num: Integer) returns Integer;
|
||||
---Purpose: Returns the recorded status for a vertex
|
||||
-- More detail by method Data
|
||||
|
||||
Position (me; num: Integer) returns XYZ from gp;
|
||||
|
||||
UPrevious(me; num: Integer) returns Real; --szv#4:S4163:12Mar99 was Interger
|
||||
|
||||
UFollowing(me; num: Integer) returns Real; --szv#4:S4163:12Mar99 was Interger
|
||||
|
||||
Data(me; num : Integer;
|
||||
pos : out XYZ from gp;
|
||||
upre,ufol: out Real)
|
||||
returns Integer;
|
||||
---Purpose: Returns the recorded status for a vertex
|
||||
-- With its recorded position and parameters on both edges
|
||||
-- These values are relevant regarding the status:
|
||||
-- Status Meaning Position Preceeding Following
|
||||
-- 0 Same no no no
|
||||
-- 1 SameCoord no no no
|
||||
-- 2 Close no no no
|
||||
-- 3 End yes no yes
|
||||
-- 4 Start yes yes no
|
||||
-- 5 Inters yes yes yes
|
||||
-- -1 Disjoined no no no
|
||||
|
||||
NextStatus (me; stat: Integer; num : Integer = 0) returns Integer;
|
||||
---Purpose: For a given status, returns the rank of the vertex which
|
||||
-- follows <num> and has the same status. 0 if no more
|
||||
-- Acts as an iterator, starts on the first one
|
||||
|
||||
NextCriter(me; crit: Integer; num : Integer = 0) returns Integer;
|
||||
---Purpose: For a given criter, returns the rank of the vertex which
|
||||
-- follows <num> and has the same status. 0 if no more
|
||||
-- Acts as an iterator, starts on the first one
|
||||
-- Criters are:
|
||||
-- 0: same vertex (status 0)
|
||||
-- 1: a solution exists (status >= 0)
|
||||
-- 2: same coords (i.e. same params) (status 0 1 2)
|
||||
-- 3: same coods but not same vertex (status 1 2)
|
||||
-- 4: redefined coords (status 3 4 5)
|
||||
-- -1: no solution (status -1)
|
||||
|
||||
fields
|
||||
|
||||
myWire: WireData from ShapeExtend;
|
||||
myStat: HArray1OfInteger from TColStd;
|
||||
myPos : HArray1OfXYZ from TColgp;
|
||||
myUPre: HArray1OfReal from TColStd;
|
||||
myUFol: HArray1OfReal from TColStd;
|
||||
myPreci: Real;
|
||||
myDone: Boolean;
|
||||
|
||||
end WireVertex;
|
354
src/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx
Executable file
354
src/ShapeAnalysis/ShapeAnalysis_WireVertex.cxx
Executable file
@@ -0,0 +1,354 @@
|
||||
//szv#4 S4163
|
||||
#include <ShapeAnalysis_WireVertex.ixx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
#include <ShapeAnalysis_Curve.hxx>
|
||||
#include <ShapeAnalysis_Edge.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx> //ied_modif_for_compil_Nov-19-1998
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeAnalysis_WireVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ShapeAnalysis_WireVertex::ShapeAnalysis_WireVertex()
|
||||
{
|
||||
myDone = Standard_False;
|
||||
myPreci = Precision::Confusion();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::Init(const TopoDS_Wire& wire, const Standard_Real preci)
|
||||
{
|
||||
Init (new ShapeExtend_WireData (wire), preci);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::Init(const Handle(ShapeExtend_WireData)& sbwd, const Standard_Real /*preci*/)
|
||||
{
|
||||
Standard_Integer nb = sbwd->NbEdges();
|
||||
if (nb == 0) return;
|
||||
myDone = Standard_False;
|
||||
myWire = sbwd;
|
||||
myStat = new TColStd_HArray1OfInteger (1,nb); myStat->Init(0);
|
||||
myPos = new TColgp_HArray1OfXYZ (1,nb);
|
||||
myUPre = new TColStd_HArray1OfReal (1,nb); myUPre->Init(0.0);
|
||||
myUFol = new TColStd_HArray1OfReal (1,nb); myUFol->Init(0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::Load(const TopoDS_Wire& wire)
|
||||
{
|
||||
Init (wire, myPreci);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::Load(const Handle(ShapeExtend_WireData)& sbwd)
|
||||
{
|
||||
Init (sbwd, myPreci);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPrecision
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetPrecision(const Standard_Real preci)
|
||||
{
|
||||
myPreci = preci;
|
||||
myDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Analyze
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::Analyze()
|
||||
{
|
||||
if (myStat.IsNull()) return;
|
||||
myDone = Standard_True;
|
||||
// Analyse des vertex qui se suivent
|
||||
Handle(Geom_Curve) c1, c2;
|
||||
Standard_Real cf, cl, upre, ufol;
|
||||
Standard_Integer i, j, nb = myStat->Length(), stat;
|
||||
ShapeAnalysis_Edge EA;
|
||||
for (i = 1; i <= nb; i ++) {
|
||||
stat = -1; // au depart
|
||||
|
||||
j = (i == nb ? 1 : i+1);
|
||||
TopoDS_Edge E1 = myWire->Edge (i);
|
||||
TopoDS_Edge E2 = myWire->Edge (j);
|
||||
TopoDS_Vertex V1 = EA.LastVertex (myWire->Edge (i));
|
||||
TopoDS_Vertex V2 = EA.FirstVertex (myWire->Edge (j));
|
||||
gp_Pnt PV1 = BRep_Tool::Pnt (V1);
|
||||
gp_Pnt PV2 = BRep_Tool::Pnt (V2);
|
||||
Standard_Real tol1 = BRep_Tool::Tolerance (V1);
|
||||
Standard_Real tol2 = BRep_Tool::Tolerance (V2);
|
||||
EA.Curve3d (myWire->Edge (i),c1,cf,upre);
|
||||
EA.Curve3d (myWire->Edge (j),c2,ufol,cl);
|
||||
if (c1.IsNull() || c2.IsNull()) continue; // on ne peut rien faire ...
|
||||
gp_Pnt P1 = c1->Value (upre);
|
||||
gp_Pnt P2 = c2->Value (ufol);
|
||||
|
||||
// Est-ce que le jeu de vertex convient ? (meme si V1 == V2, on verifie)
|
||||
Standard_Real d1 = PV1.Distance (P1);
|
||||
Standard_Real d2 = PV2.Distance (P2);
|
||||
Standard_Real dd = PV1.Distance (PV2);
|
||||
if (d1 <= tol1 && d2 <= tol2 && dd <= (tol1+tol2)) stat = 1;
|
||||
else if (d1 <= myPreci && d2 <= myPreci && dd <= myPreci) stat = 2;
|
||||
myStat->SetValue (i,-1); // par defaut
|
||||
if (stat > 0) { if (V1 == V2) stat = 0; }
|
||||
if (stat >= 0) { myStat->SetValue (i,stat); continue; }
|
||||
// Restent les autres cas !
|
||||
|
||||
// Une edge se termine sur l autre : il faudra simplement relimiter
|
||||
// Projection calculee sur une demi-edge (pour eviter les pbs de couture)
|
||||
gp_Pnt PJ1,PJ2;
|
||||
Standard_Real U1,U2;
|
||||
Standard_Real dj1 = ShapeAnalysis_Curve().Project (c1,P2,myPreci,PJ1,U1,(cf+upre)/2,upre);
|
||||
Standard_Real dj2 = ShapeAnalysis_Curve().Project (c2,P1,myPreci,PJ2,U2,ufol,(ufol+cl)/2);
|
||||
if (dj1 <= myPreci) { SetStart (i,PJ1.XYZ(),U1); continue; }
|
||||
else if (dj2 <= myPreci) { SetEnd (i,PJ2.XYZ(),U2); continue; }
|
||||
|
||||
// Restent a verifier les intersections et prolongations !
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetSameVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetSameVertex(const Standard_Integer num)
|
||||
{
|
||||
myStat->SetValue (num,0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetSameCoords
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetSameCoords(const Standard_Integer num)
|
||||
{
|
||||
myStat->SetValue (num,1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetClose
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetClose(const Standard_Integer num)
|
||||
{
|
||||
myStat->SetValue (num,2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetEnd
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetEnd(const Standard_Integer num,const gp_XYZ& pos,const Standard_Real ufol)
|
||||
{
|
||||
myStat->SetValue (num,3);
|
||||
myPos->SetValue (num,pos);
|
||||
myUFol->SetValue (num,ufol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetStart
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetStart(const Standard_Integer num,const gp_XYZ& pos,const Standard_Real upre)
|
||||
{
|
||||
myStat->SetValue (num,4);
|
||||
myPos->SetValue (num,pos);
|
||||
myUFol->SetValue (num,upre);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetInters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetInters(const Standard_Integer num, const gp_XYZ& pos,
|
||||
const Standard_Real upre, const Standard_Real ufol)
|
||||
{
|
||||
myStat->SetValue (num,5);
|
||||
myPos->SetValue (num,pos);
|
||||
myUPre->SetValue (num,upre);
|
||||
myUFol->SetValue (num,ufol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDisjoined
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ShapeAnalysis_WireVertex::SetDisjoined(const Standard_Integer num)
|
||||
{
|
||||
myStat->SetValue (num,-1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean ShapeAnalysis_WireVertex::IsDone() const
|
||||
{
|
||||
return myDone;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Precision
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real ShapeAnalysis_WireVertex::Precision() const
|
||||
{
|
||||
return myPreci;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireVertex::NbEdges() const
|
||||
{
|
||||
return myWire->NbEdges();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WireData
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Handle(ShapeExtend_WireData)& ShapeAnalysis_WireVertex::WireData() const
|
||||
{
|
||||
return myWire;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Status
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireVertex::Status(const Standard_Integer num) const
|
||||
{
|
||||
return myStat->Value(num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Position
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_XYZ ShapeAnalysis_WireVertex::Position(const Standard_Integer num) const
|
||||
{
|
||||
return myPos->Value(num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UPrevious
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//szv#4:S4163:12Mar99 was bug: returned Integer
|
||||
Standard_Real ShapeAnalysis_WireVertex::UPrevious(const Standard_Integer num) const
|
||||
{
|
||||
return myUPre->Value(num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UFollowing
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//szv#4:S4163:12Mar99 was bug: returned Integer
|
||||
Standard_Real ShapeAnalysis_WireVertex::UFollowing(const Standard_Integer num) const
|
||||
{
|
||||
return myUFol->Value(num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Data
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireVertex::Data(const Standard_Integer num, gp_XYZ& pos,
|
||||
Standard_Real& upre, Standard_Real& ufol) const
|
||||
{
|
||||
pos = myPos->Value(num);
|
||||
upre = myUPre->Value(num);
|
||||
ufol = myUFol->Value(num);
|
||||
return myStat->Value(num);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NextStatus
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireVertex::NextStatus(const Standard_Integer stat,
|
||||
const Standard_Integer num) const
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (!myStat.IsNull()) {
|
||||
Standard_Integer i,nb = myStat->Length();
|
||||
for (i = num+1; i <= nb; i ++) if (myStat->Value(i) == stat) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NextCriter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer ShapeAnalysis_WireVertex::NextCriter(const Standard_Integer crit,
|
||||
const Standard_Integer num) const
|
||||
{
|
||||
//szv#4:S4163:12Mar99 optimized
|
||||
if (!myStat.IsNull()) {
|
||||
Standard_Integer i,nb = myStat->Length();
|
||||
for (i = num+1; i <= nb; i ++) {
|
||||
Standard_Integer stat = myStat->Value(i);
|
||||
if ((crit == -1 && stat < 0) ||
|
||||
(crit == 0 && stat == 0) ||
|
||||
(crit == 1 && stat > 0) ||
|
||||
(crit == 2 && (stat >= 0 && stat <= 2)) ||
|
||||
(crit == 3 && (stat == 1 || stat == 2)) ||
|
||||
(crit == 4 && stat > 2)) return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user