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

Integration of OCCT 6.5.0 from SVN

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

132
src/BRepCheck/BRepCheck.cdl Executable file
View File

@@ -0,0 +1,132 @@
-- File: BRepCheck.cdl
-- Created: Wed Dec 6 17:09:10 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
package BRepCheck
---Purpose: This package provides tools to check the validity
-- of the BRep.
uses MMgt,
StdFail,
TCollection,
TopAbs,
Adaptor3d,
TopoDS,
BRep,
TopTools
is
deferred class Result; -- inherits TShared from MMgt
class Vertex; -- inherits Shape
class Edge; -- inherits Shape
class Wire; -- inherits Shape
class Face; -- inherits Shape
class Shell; -- inherits Shape
-- class Solid; -- inherits Shape
class Analyzer;
enumeration Status is
NoError,
-- for vertices
InvalidPointOnCurve,
InvalidPointOnCurveOnSurface,
InvalidPointOnSurface,
-- for edges
No3DCurve,
Multiple3DCurve,
Invalid3DCurve,
NoCurveOnSurface,
InvalidCurveOnSurface,
InvalidCurveOnClosedSurface,
InvalidSameRangeFlag,
InvalidSameParameterFlag,
InvalidDegeneratedFlag,
FreeEdge,
InvalidMultiConnexity,
InvalidRange,
-- for wires
EmptyWire,
RedundantEdge,
SelfIntersectingWire, -- on a face
-- for faces
NoSurface,
InvalidWire,
RedundantWire,
IntersectingWires,
InvalidImbricationOfWires,
-- for shells
EmptyShell,
RedundantFace,
-- for shapes
UnorientableShape,
NotClosed,
NotConnected,
SubshapeNotInShape,
BadOrientation,
BadOrientationOfSubshape,
InvalidToleranceValue,
-- for exception
CheckFail
end Status;
class ListOfStatus instantiates List from TCollection
(Status from BRepCheck);
class DataMapOfShapeListOfStatus instantiates DataMap from TCollection
(Shape from TopoDS,
ListOfStatus from BRepCheck,
ShapeMapHasher from TopTools);
class DataMapOfShapeResult instantiates DataMap from TCollection
(Shape from TopoDS,
Result from BRepCheck,
OrientedShapeMapHasher from TopTools);
-- Package method
Add(List: in out ListOfStatus from BRepCheck;
Stat: Status from BRepCheck);
Print(Stat: Status from BRepCheck;
OS: in out OStream from Standard);
SelfIntersection(W : Wire from TopoDS;
F : Face from TopoDS;
E1 : out Edge from TopoDS;
E2 : out Edge from TopoDS)
returns Boolean from Standard;
end BRepCheck;

175
src/BRepCheck/BRepCheck.cxx Executable file
View File

@@ -0,0 +1,175 @@
// File: BRepCheck.cxx
// Created: Fri Dec 8 15:03:28 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck.ixx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void BRepCheck::Add(BRepCheck_ListOfStatus& lst, const BRepCheck_Status stat)
{
BRepCheck_ListIteratorOfListOfStatus it(lst);
while (it.More()) {
if (it.Value() == BRepCheck_NoError && stat != BRepCheck_NoError) {
lst.Remove(it);
}
else {
if (it.Value() == stat) {
return;
}
it.Next();
}
}
lst.Append(stat);
}
//=======================================================================
//function : SelfIntersection
//purpose :
//=======================================================================
Standard_Boolean BRepCheck::SelfIntersection(const TopoDS_Wire& W,
const TopoDS_Face& myFace,
TopoDS_Edge& RetE1,
TopoDS_Edge& RetE2)
{
Handle(BRepCheck_Wire) chkw = new BRepCheck_Wire(W);
BRepCheck_Status stat = chkw->SelfIntersect(myFace,RetE1,RetE2);
return (stat == BRepCheck_SelfIntersectingWire);
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void BRepCheck::Print(const BRepCheck_Status stat,
Standard_OStream& OS)
{
switch (stat) {
case BRepCheck_NoError:
OS << "BRepCheck_NoError\n";
break;
case BRepCheck_InvalidPointOnCurve:
OS << "BRepCheck_InvalidPointOnCurve\n";
break;
case BRepCheck_InvalidPointOnCurveOnSurface:
OS << "BRepCheck_InvalidPointOnCurveOnSurface\n";
break;
case BRepCheck_InvalidPointOnSurface:
OS << "BRepCheck_InvalidPointOnSurface\n";
break;
case BRepCheck_No3DCurve:
OS << "BRepCheck_No3DCurve\n";
break;
case BRepCheck_Multiple3DCurve:
OS << "BRepCheck_Multiple3DCurve\n";
break;
case BRepCheck_Invalid3DCurve:
OS << "BRepCheck_Invalid3DCurve\n";
break;
case BRepCheck_NoCurveOnSurface:
OS << "BRepCheck_NoCurveOnSurface\n";
break;
case BRepCheck_InvalidCurveOnSurface:
OS << "BRepCheck_InvalidCurveOnSurface\n";
break;
case BRepCheck_InvalidCurveOnClosedSurface:
OS << "BRepCheck_InvalidCurveOnClosedSurface\n";
break;
case BRepCheck_InvalidSameRangeFlag:
OS << "BRepCheck_InvalidSameRangeFlag\n";
break;
case BRepCheck_InvalidSameParameterFlag:
OS << "BRepCheck_InvalidSameParameterFlag\n";
break;
case BRepCheck_InvalidDegeneratedFlag:
OS << "BRepCheck_InvalidDegeneratedFlag\n";
break;
case BRepCheck_FreeEdge:
OS << "BRepCheck_FreeEdge\n";
break;
case BRepCheck_InvalidMultiConnexity:
OS << "BRepCheck_InvalidMultiConnexity\n";
break;
case BRepCheck_InvalidRange:
OS << "BRepCheck_InvalidRange\n";
break;
case BRepCheck_EmptyWire:
OS << "BRepCheck_EmptyWire\n";
break;
case BRepCheck_RedundantEdge:
OS << "BRepCheck_RedundantEdge\n";
break;
case BRepCheck_SelfIntersectingWire:
OS << "BRepCheck_SelfIntersectingWire\n";
break;
case BRepCheck_NoSurface:
OS << "BRepCheck_NoSurface\n";
break;
case BRepCheck_InvalidWire:
OS << "BRepCheck_InvalidWire\n";
break;
case BRepCheck_RedundantWire:
OS << "BRepCheck_RedundantWire\n";
break;
case BRepCheck_IntersectingWires:
OS << "BRepCheck_IntersectingWires\n";
break;
case BRepCheck_InvalidImbricationOfWires:
OS << "BRepCheck_InvalidImbricationOfWires\n";
break;
case BRepCheck_EmptyShell:
OS << "BRepCheck_EmptyShell\n";
break;
case BRepCheck_RedundantFace:
OS << "BRepCheck_RedundantFace\n";
break;
case BRepCheck_UnorientableShape:
OS << "BRepCheck_UnorientableShape\n";
break;
case BRepCheck_NotClosed:
OS << "BRepCheck_NotClosed\n";
break;
case BRepCheck_NotConnected:
OS << "BRepCheck_NotConnected\n";
break;
case BRepCheck_SubshapeNotInShape:
OS << "BRepCheck_SubshapeNotInShape\n";
break;
case BRepCheck_BadOrientation:
OS << "BRepCheck_BadOrientation\n";
break;
case BRepCheck_BadOrientationOfSubshape:
OS << "BRepCheck_BadOrientationOfSubshape\n";
break;
case BRepCheck_CheckFail:
OS << "BRepCheck_CheckFail\n";
break;
#ifndef DEB
default:
break;
#endif
}
}

View File

@@ -0,0 +1,165 @@
-- File: BRepCheck_Analyzer.cdl
-- Created: Fri Dec 8 15:57:56 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
class Analyzer from BRepCheck
---Purpose: A framework to check the overall
-- validity of a shape. For a shape to be valid in Open
-- CASCADE, it - or its component subshapes - must respect certain
-- criteria. These criteria are checked by the function IsValid.
-- Once you have determined whether a shape is valid or not, you can
-- diagnose its specific anomalies and correct them using the services of
-- the ShapeAnalysis, ShapeUpgrade, and ShapeFix packages.
uses Shape from TopoDS,
ShapeEnum from TopAbs,
Result from BRepCheck,
DataMapOfShapeResult from BRepCheck
raises NullObject from Standard,
NoSuchObject from Standard
is
Create(S: Shape from TopoDS;
GeomControls : Boolean from Standard = Standard_True)
---Purpose: Constructs a shape validation object defined by the shape S.
-- <S> is the shape to control. <GeomControls> If
-- False only topological informaions are checked.
-- The geometricals controls are
-- For a Vertex :
-- BRepCheck_InvalidToleranceValue NYI
-- For an Edge :
-- BRepCheck_InvalidCurveOnClosedSurface,
-- BRepCheck_InvalidCurveOnSurface,
-- BRepCheck_InvalidSameParameterFlag,
-- BRepCheck_InvalidToleranceValue NYI
-- For a face :
-- BRepCheck_UnorientableShape,
-- BRepCheck_IntersectingWires,
-- BRepCheck_InvalidToleranceValue NYI
-- For a wire :
-- BRepCheck_SelfIntersectingWire
---C++: inline
returns Analyzer from BRepCheck
raises NullObject from Standard;
Init(me: in out; S: Shape from TopoDS;
GeomControls : Boolean from Standard = Standard_True)
---Purpose: <S> is the shape to control. <GeomControls> If
-- False only topological informaions are checked.
-- The geometricals controls are
-- For a Vertex :
-- BRepCheck_InvalidTolerance NYI
-- For an Edge :
-- BRepCheck_InvalidCurveOnClosedSurface,
-- BRepCheck_InvalidCurveOnSurface,
-- BRepCheck_InvalidSameParameterFlag,
-- BRepCheck_InvalidTolerance NYI
-- For a face :
-- BRepCheck_UnorientableShape,
-- BRepCheck_IntersectingWires,
-- BRepCheck_InvalidTolerance NYI
-- For a wire :
-- BRepCheck_SelfIntersectingWire
raises NullObject from Standard
is static;
IsValid(me; S: Shape from TopoDS)
---Purpose: <S> is a subshape of the original shape. Returns
-- <STandard_True> if no default has been detected on
-- <S> and any of its subshape.
returns Boolean from Standard
raises NoSuchObject from Standard
is static;
IsValid(me)
---Purpose: Returns true if no defect is
-- detected on the shape S or any of its subshapes.
-- Returns true if the shape S is valid.
-- This function checks whether a given shape is valid by checking that:
-- - the topology is correct
-- - parameterization of edges in particular is correct.
-- For the topology to be correct, the following conditions must be satisfied:
-- - edges should have at least two vertices if they are not
-- degenerate edges. The vertices should be within the range of
-- the bounding edges at the tolerance specified in the vertex,
-- - edges should share at least one face. The representation of
-- the edges should be within the tolerance criterion assigned to them.
-- - wires defining a face should not self-intersect and should be closed,
-- - there should be one wire which contains all other wires inside a face,
-- - wires should be correctly oriented with respect to each of the edges,
-- - faces should be correctly oriented, in particular with
-- respect to adjacent faces if these faces define a solid,
-- - shells defining a solid should be closed. There should
-- be one enclosing shell if the shape is a solid;
-- To check parameterization of edge, there are 2 approaches depending on
-- the edge?s contextual situation.
-- - if the edge is either single, or it is in the context
-- of a wire or a compound, its parameterization is defined by
-- the parameterization of its 3D curve and is considered as valid.
-- - If the edge is in the context of a face, it should
-- have SameParameter and SameRange flags set to Standard_True. To
-- check these flags, you should call the function
-- BRep_Tool::SameParameter and BRep_Tool::SameRange for an
-- edge. If at least one of these flags is set to Standard_False,
-- the edge is considered as invalid without any additional check.
-- If the edge is contained by a face, and it has SameParameter and
-- SameRange flags set to Standard_True, IsValid checks
-- whether representation of the edge on face, in context of which the
-- edge is considered, has the same parameterization up to the
-- tolerance value coded on the edge. For a given parameter t on the edge
-- having C as a 3D curve and one PCurve P on a surface S (base
-- surface of the reference face), this checks that |C(t) - S(P(t))|
-- is less than or equal to tolerance, where tolerance is the tolerance
-- value coded on the edge.
---C++: inline
returns Boolean from Standard
is static;
Result(me; SubS: Shape from TopoDS)
---C++: return const&
---C++: inline
returns any Result from BRepCheck
raises NoSuchObject from Standard
is static;
--- Private implementation method
Put(me: in out; S: Shape from TopoDS; Gctrl: Boolean from Standard)
is static private;
Perform(me: in out; S: Shape from TopoDS)
is static private;
ValidSub(me; S: Shape from TopoDS; SubType: ShapeEnum from TopAbs)
returns Boolean from Standard
is static private;
fields
myShape : Shape from TopoDS;
myMap : DataMapOfShapeResult from BRepCheck;
end Analyzer;

View File

@@ -0,0 +1,505 @@
// File: BRepCheck_Analyzer.cxx
// Created: Fri Dec 8 16:15:28 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Analyzer.ixx>
#include <BRepCheck_Vertex.hxx>
#include <BRepCheck_Edge.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRepCheck_Face.hxx>
#include <BRepCheck_Shell.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BRepCheck_Analyzer::Init(const TopoDS_Shape& S,
const Standard_Boolean B)
{
if (S.IsNull()) {
Standard_NullObject::Raise();
}
myShape = S;
myMap.Clear();
Put(S,B);
Perform(S);
}
//=======================================================================
//function : Put
//purpose :
//=======================================================================
void BRepCheck_Analyzer::Put(const TopoDS_Shape& S,
const Standard_Boolean B)
{
if (!myMap.IsBound(S)) {
Handle(BRepCheck_Result) HR;
switch (S.ShapeType()) {
case TopAbs_VERTEX:
HR = new BRepCheck_Vertex(TopoDS::Vertex(S));
break;
case TopAbs_EDGE:
HR = new BRepCheck_Edge(TopoDS::Edge(S));
Handle(BRepCheck_Edge)::DownCast(HR)->GeometricControls(B);
break;
case TopAbs_WIRE:
HR = new BRepCheck_Wire(TopoDS::Wire(S));
Handle(BRepCheck_Wire)::DownCast(HR)->GeometricControls(B);
break;
case TopAbs_FACE:
HR = new BRepCheck_Face(TopoDS::Face(S));
Handle(BRepCheck_Face)::DownCast(HR)->GeometricControls(B);
break;
case TopAbs_SHELL:
HR = new BRepCheck_Shell(TopoDS::Shell(S));
break;
case TopAbs_SOLID:
case TopAbs_COMPSOLID:
case TopAbs_COMPOUND:
break;
#ifndef DEB
default:
break;
#endif
}
myMap.Bind(S,HR);
for(TopoDS_Iterator theIterator(S);theIterator.More();theIterator.Next()) {
Put(theIterator.Value(),B); // performs minimum on each shape
}
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S)
{
for(TopoDS_Iterator theIterator(S);theIterator.More();theIterator.Next()) {
Perform(theIterator.Value());
}
//
TopAbs_ShapeEnum styp;
TopExp_Explorer exp;
//
styp = S.ShapeType();
switch (styp) {
case TopAbs_VERTEX:
// modified by NIZHNY-MKK Wed May 19 16:56:16 2004.BEGIN
// There is no need to check anything.
// if (myShape.IsSame(S)) {
// myMap(S)->Blind();
// }
// modified by NIZHNY-MKK Wed May 19 16:56:23 2004.END
break;
case TopAbs_EDGE: {
// Modified by skv - Tue Apr 27 11:38:08 2004 Begin
// There is no need to check anything except vertices on single edge.
// if (myShape.IsSame(S)) {
// myMap(S)->Blind();
// }
// Modified by skv - Tue Apr 27 11:38:09 2004 End
TopTools_MapOfShape MapS;
for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) {
const TopoDS_Shape& aVertex = exp.Current();
try {
OCC_CATCH_SIGNALS
if (MapS.Add(aVertex)) {
myMap(aVertex)->InContext(S);
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(aVertex);
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(aVertex);
aRes->SetFailStatus(S);
}
}
}
}
break;
case TopAbs_WIRE:
// Modified by Sergey KHROMOV - Mon May 6 15:53:39 2002 Begin
// There is no need to check the orientation of a single wire
// (not in context of face).
// {
// if (myShape.IsSame(S)) {
// Handle(BRepCheck_Wire)::DownCast(myMap(S))->Orientation(TopoDS_Face(),
// Standard_True);
// }
// }
// Modified by Sergey KHROMOV - Mon May 6 15:53:40 2002 End
break;
case TopAbs_FACE:
{
TopTools_MapOfShape MapS;
for (exp.Init(S,TopAbs_VERTEX);exp.More(); exp.Next()) {
try {
OCC_CATCH_SIGNALS
if (MapS.Add(exp.Current())) {
myMap(exp.Current())->InContext(S);
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}
}
Standard_Boolean performwire = Standard_True;
MapS.Clear();
for (exp.Init(S,TopAbs_EDGE);exp.More(); exp.Next()) {
try {
OCC_CATCH_SIGNALS
if (MapS.Add(exp.Current())) {
Handle(BRepCheck_Result)& res = myMap(exp.Current());
res->InContext(S);
if (performwire) {
for (res->InitContextIterator();
res->MoreShapeInContext();
res->NextShapeInContext()) {
if(res->ContextualShape().IsSame(S)) {
break;
}
}
BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape());
for (; itl.More(); itl.Next()) {
BRepCheck_Status ste = itl.Value();
if (ste == BRepCheck_NoCurveOnSurface ||
ste == BRepCheck_InvalidCurveOnSurface ||
ste == BRepCheck_InvalidRange ||
ste == BRepCheck_InvalidCurveOnClosedSurface) {
performwire = Standard_False;
break;
}
}
}
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}
}
Standard_Boolean orientofwires = performwire;
for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) {
try {
OCC_CATCH_SIGNALS
Handle(BRepCheck_Result)& res = myMap(exp.Current());
res->InContext(S);
if (orientofwires) {
for (res->InitContextIterator();
res->MoreShapeInContext();
res->NextShapeInContext()) {
if(res->ContextualShape().IsSame(S)) {
break;
}
}
BRepCheck_ListIteratorOfListOfStatus itl(res->StatusOnShape());
for (; itl.More(); itl.Next()) {
BRepCheck_Status ste = itl.Value();
if (ste != BRepCheck_NoError) {
orientofwires = Standard_False;
break;
}
}
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}
}
try {
OCC_CATCH_SIGNALS
if (performwire) {
if (orientofwires) {
Handle(BRepCheck_Face)::DownCast(myMap(S))->
OrientationOfWires(Standard_True);// on enregistre
}
// else {
// Handle(BRepCheck_Face)::DownCast(myMap(S))->
// IntersectWires(Standard_True); // on enregistre
// }
else {
Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable();
}
}
else {
Handle(BRepCheck_Face)::DownCast(myMap(S))->SetUnorientable();
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
for (exp.Init(S,TopAbs_WIRE);exp.More(); exp.Next()) {
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
myMap(S)->SetFailStatus(exp.Current());
}
}
}
}
break;
case TopAbs_SHELL:
//modified by NIZNHY-PKV Mon Oct 13 14:23:53 2008f
/* {
Standard_Boolean VerifyOrientation, bFlag;
//
VerifyOrientation = Standard_True;
//
exp.Init(S,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
const TopoDS_Shape& aF=exp.Current();
try {
OCC_CATCH_SIGNALS
bFlag= !(Handle(BRepCheck_Face)::DownCast(myMap(aF))->IsUnorientable());
VerifyOrientation = (VerifyOrientation && bFlag);
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}
} //
try {
OCC_CATCH_SIGNALS
if (VerifyOrientation) {
Handle(BRepCheck_Shell)::DownCast(myMap(S))->Orientation(Standard_True);
}
else {
Handle(BRepCheck_Shell)::DownCast(myMap(S))->SetUnorientable();
}
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
exp.Init(S,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
Handle(BRepCheck_Result) aRes = myMap(exp.Current());
if ( ! aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
myMap(S)->SetFailStatus(exp.Current());
}
}
}
}
*/
//modified by NIZNHY-PKV Mon Oct 13 14:24:04 2008t
break;
//
case TopAbs_SOLID: {
exp.Init(S,TopAbs_SHELL);
for (; exp.More(); exp.Next()) {
const TopoDS_Shape& aShell=exp.Current();
try {
OCC_CATCH_SIGNALS
myMap(aShell)->InContext(S);
}
catch(Standard_Failure) {
#ifdef DEB
cout<<"BRepCheck_Analyzer : ";
Standard_Failure::Caught()->Print(cout);
cout<<endl;
#endif
if ( ! myMap(S).IsNull() ) {
myMap(S)->SetFailStatus(S);
}
//
Handle(BRepCheck_Result) aRes = myMap(aShell);
if (!aRes.IsNull() ) {
aRes->SetFailStatus(exp.Current());
aRes->SetFailStatus(S);
}
}
}
}
break;//case TopAbs_SOLID
default:
break;
}//switch (styp) {
}
//=======================================================================
//function : IsValid
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Analyzer::IsValid(const TopoDS_Shape& S) const
{
if (!myMap(S).IsNull()) {
BRepCheck_ListIteratorOfListOfStatus itl;
itl.Initialize(myMap(S)->Status());
if (itl.Value() != BRepCheck_NoError) { // a voir
return Standard_False;
}
}
for(TopoDS_Iterator theIterator(S);theIterator.More();theIterator.Next()) {
if (!IsValid(theIterator.Value())) {
return Standard_False;
}
}
switch (S.ShapeType()) {
case TopAbs_EDGE:
{
return ValidSub(S,TopAbs_VERTEX);
}
// break;
case TopAbs_FACE:
{
Standard_Boolean valid = ValidSub(S,TopAbs_WIRE);
valid = valid && ValidSub(S,TopAbs_EDGE);
valid = valid && ValidSub(S,TopAbs_VERTEX);
return valid;
}
// break;
case TopAbs_SHELL:
// return ValidSub(S,TopAbs_FACE);
break;
case TopAbs_SOLID:
// return ValidSub(S,TopAbs_EDGE);
// break;
return ValidSub(S,TopAbs_SHELL);
break;
default:
break;
}
return Standard_True;
}
//=======================================================================
//function : ValidSub
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Analyzer::ValidSub
(const TopoDS_Shape& S,
const TopAbs_ShapeEnum SubType) const
{
BRepCheck_ListIteratorOfListOfStatus itl;
TopExp_Explorer exp;
for (exp.Init(S,SubType);exp.More(); exp.Next()) {
// for (TopExp_Explorer exp(S,SubType);exp.More(); exp.Next()) {
const Handle(BRepCheck_Result)& RV = myMap(exp.Current());
for (RV->InitContextIterator();
RV->MoreShapeInContext();
RV->NextShapeInContext()) {
if (RV->ContextualShape().IsSame(S)) {
break;
}
}
if(!RV->MoreShapeInContext()) break;
for (itl.Initialize(RV->StatusOnShape()); itl.More(); itl.Next()) {
if (itl.Value() != BRepCheck_NoError) {
return Standard_False;
}
}
}
return Standard_True ;
}

View File

@@ -0,0 +1,40 @@
// File: BRepCheck_Analyzer.lxx
// Created: Fri Dec 8 16:11:47 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
//=======================================================================
//function : BRepCheck_Analyzer
//purpose :
//=======================================================================
inline BRepCheck_Analyzer::BRepCheck_Analyzer (const TopoDS_Shape& S,
const Standard_Boolean B)
{
Init(S,B);
}
//=======================================================================
//function : Result
//purpose :
//=======================================================================
inline const Handle(BRepCheck_Result)& BRepCheck_Analyzer::Result
(const TopoDS_Shape& S) const
{
return myMap(S);
}
//=======================================================================
//function : IsValid
//purpose :
//=======================================================================
inline Standard_Boolean BRepCheck_Analyzer::IsValid() const
{
return IsValid(myShape);
}

View File

@@ -0,0 +1,55 @@
-- File: BRepCheck_Edge.cdl
-- Created: Mon Dec 11 13:41:22 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
class Edge from BRepCheck inherits Result from BRepCheck
---Purpose:
uses Shape from TopoDS,
Edge from TopoDS,
CurveRepresentation from BRep,
HCurve from Adaptor3d
is
Create(E: Edge from TopoDS)
returns mutable Edge from BRepCheck;
InContext(me: mutable; ContextShape: Shape from TopoDS);
Minimum(me: mutable);
Blind(me: mutable);
GeometricControls(me)
returns Boolean from Standard
is static;
GeometricControls(me: mutable; B: Boolean from Standard)
is static;
Tolerance(me: mutable) returns Real from Standard
is static;
fields
myCref : CurveRepresentation from BRep;
myHCurve : HCurve from Adaptor3d;
myGctrl : Boolean from Standard;
end Edge;

627
src/BRepCheck/BRepCheck_Edge.cxx Executable file
View File

@@ -0,0 +1,627 @@
// File: BRepCheck_Edge.cxx
// Created: Mon Dec 11 13:42:44 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Edge.ixx>
#include <TColStd_Array1OfTransient.hxx>
#include <BRepCheck_ListOfStatus.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_CurveOnSurface.hxx>
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom_Surface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <GeomProjLib.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <BRepCheck.hxx>
#include <Geom2dAdaptor.hxx>
#include <TopoDS.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Face.hxx>
#include <Precision.hxx>
static Standard_Boolean Validate(const Adaptor3d_Curve&,
const Adaptor3d_Curve&,
const Standard_Real,
const Standard_Boolean);
#define NCONTROL 23
//=======================================================================
//function : BRepCheck_Edge
//purpose :
//=======================================================================
BRepCheck_Edge::BRepCheck_Edge(const TopoDS_Edge& E)
{
Init(E);
myGctrl = Standard_True;
}
//=======================================================================
//function : Minimum
//purpose :
//=======================================================================
void BRepCheck_Edge::Minimum()
{
if (!myMin) {
BRepCheck_ListOfStatus thelist;
myMap.Bind(myShape, thelist);
BRepCheck_ListOfStatus& lst = myMap(myShape);
myCref.Nullify();
// Existence et unicite d`une representation 3D
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
Standard_Boolean exist = Standard_False;
Standard_Boolean unique = Standard_True;
// Search for a 3D reference. If no existent one, creates it with the
// first encountered CurveOnSurf; if multiple, chooses the first one...
Standard_Boolean Degenerated = TE->Degenerated();
Standard_Boolean SameParameter = TE->SameParameter();
Standard_Boolean SameRange = TE->SameRange();
if (!SameRange && SameParameter) {
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
// Handle(Geom_Curve) C3d;
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurve3D()) {
if (!exist) {
exist = Standard_True;
}
else {
unique = Standard_False;
}
if (myCref.IsNull() && !cr->Curve3D().IsNull()) {
myCref = cr;
}
}
itcr.Next();
}
if (!exist) {
BRepCheck::Add(lst,BRepCheck_No3DCurve);
// myCref est nulle
}
else if (!unique) {
BRepCheck::Add(lst,BRepCheck_Multiple3DCurve);
}
if (myCref.IsNull() && !Degenerated) {
itcr.Initialize(TE->Curves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface()) {
myCref = cr;
break;
}
itcr.Next();
}
}
else if (!myCref.IsNull() && Degenerated){
BRepCheck::Add(lst,BRepCheck_InvalidDegeneratedFlag);
}
if (!myCref.IsNull()) {
const Handle(BRep_GCurve)& GCref = *((Handle(BRep_GCurve)*)&myCref);
Standard_Real First,Last;
GCref->Range(First,Last);
if (Last<=First) {
myCref.Nullify();
BRepCheck::Add(lst,BRepCheck_InvalidRange);
}
else {
if (myCref->IsCurve3D()) {
// eap 6 Jun 2002 occ332
// better transform C3d instead of transforming Surf upto C3d initial location,
// on transformed BSpline surface 'same parameter' may seem wrong
TopLoc_Location L = myShape.Location() * myCref->Location();
Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
(myCref->Curve3D()->Transformed
(/*myCref->Location()*/L.Transformation()));
GeomAdaptor_Curve GAC3d(C3d,First,Last);
myHCurve = new GeomAdaptor_HCurve(GAC3d);
}
else { // curve on surface
Handle(Geom_Surface) Sref = myCref->Surface();
Sref = Handle(Geom_Surface)::DownCast
(Sref->Transformed(myCref->Location().Transformation()));
const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref =
new Geom2dAdaptor_HCurve(PCref,First,Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
}
}
}
if (lst.IsEmpty()) {
lst.Append(BRepCheck_NoError);
}
myMin = Standard_True;
}
}
//=======================================================================
//function : InContext
//purpose :
//=======================================================================
void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
{
if (myMap.IsBound(S)) {
return;
}
BRepCheck_ListOfStatus thelist;
myMap.Bind(S, thelist);
BRepCheck_ListOfStatus& lst = myMap(S);
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));
TopAbs_ShapeEnum styp = S.ShapeType();
// for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) {
TopExp_Explorer exp(S,TopAbs_EDGE) ;
for ( ; exp.More(); exp.Next()) {
if (exp.Current().IsSame(myShape)) {
break;
}
}
if (!exp.More()) {
BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
return;
}
switch (styp) {
case TopAbs_FACE:
if (!myCref.IsNull()) {
Standard_Boolean SameParameter = TE->SameParameter();
Standard_Boolean SameRange = TE->SameRange();
// Modified by skv - Tue Apr 27 11:48:13 2004 Begin
if (!SameParameter || !SameRange) {
if (!SameParameter)
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
if (!SameRange)
BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
return;
}
// Modified by skv - Tue Apr 27 11:48:14 2004 End
Standard_Real First = myHCurve->FirstParameter();
Standard_Real Last = myHCurve->LastParameter();
Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
const TopLoc_Location& Floc = S.Location();
const TopLoc_Location& TFloc = TF->Location();
const Handle(Geom_Surface)& Su = TF->Surface();
TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
Standard_Boolean pcurvefound = Standard_False;
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
pcurvefound = Standard_True;
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
Standard_Real f,l;
GC->Range(f,l);
// gka OCC
// Modified by skv - Tue Apr 27 11:50:35 2004 Begin
// if (SameRange && (fabs(f-First) > Precision::PConfusion() || fabs(l-Last)> Precision::PConfusion())) { //f != First || l != Last)) { gka OCC
if (fabs(f-First) > Precision::PConfusion() ||
fabs(l-Last) > Precision::PConfusion()) {
BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
// if (SameParameter) {
// BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
// }
}
// Modified by skv - Tue Apr 27 11:50:37 2004 End
if (myGctrl) {
Handle(Geom_Surface) Sb = cr->Surface();
Sb = Handle(Geom_Surface)::DownCast
// (Su->Transformed(L.Transformation()));
(Su->Transformed(/*L*/(Floc * TFloc).Transformation()));
Handle(Geom2d_Curve) PC = cr->PCurve();
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb);
Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
Standard_Boolean ok =
Validate(myHCurve->Curve(),ACS,Tol,SameParameter);
if (!ok) {
if (cr->IsCurveOnClosedSurface()) {
BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
}
else {
BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
}
// Modified by skv - Tue Apr 27 11:53:00 2004 Begin
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
// if (SameParameter) {
// BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
// }
// Modified by skv - Tue Apr 27 11:53:01 2004 End
}
if (cr->IsCurveOnClosedSurface()) {
GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds
ACS.Load(GAHS); // sans doute inutile
ACS.Load(GHPC); // meme remarque...
ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter);
if (!ok) {
BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
// Modified by skv - Tue Apr 27 11:53:20 2004 Begin
if (SameParameter) {
BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
// Modified by skv - Tue Apr 27 11:53:23 2004 End
}
}
}
}
itcr.Next();
}
if (!pcurvefound) {
Handle(Geom_Plane) P;
Handle(Standard_Type) dtyp = Su->DynamicType();
if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
P = Handle(Geom_Plane)::DownCast
(Handle(Geom_RectangularTrimmedSurface)::
DownCast(Su)->BasisSurface());
}
else {
P = Handle(Geom_Plane)::DownCast(Su);
}
if (P.IsNull()) { // not a plane
BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface);
}
else { // on fait la projection a la volee, comme BRep_Tool
// plan en position
if (myGctrl) {
P = Handle(Geom_Plane)::
DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332
//on projette Cref sur ce plan
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P);
// Dub - Normalement myHCurve est une GeomAdaptor_HCurve
GeomAdaptor_Curve& Gac =
Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve();
Handle(Geom_Curve) C3d = Gac.Curve();
Handle(Geom_Curve) ProjOnPlane =
GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last),
P, P->Position().Direction(),
Standard_True);
Handle(GeomAdaptor_HCurve) aHCurve =
new GeomAdaptor_HCurve(ProjOnPlane);
ProjLib_ProjectedCurve proj(GAHS,aHCurve);
Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
Handle(Geom2dAdaptor_HCurve) GHPC =
new Geom2dAdaptor_HCurve(PC,
myHCurve->FirstParameter(),
myHCurve->LastParameter());
Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
Standard_Boolean ok = Validate(myHCurve->Curve(),ACS,
Tol,Standard_True); // voir dub...
if (!ok) {
BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
}
}
}
}
}
break;
case TopAbs_SOLID:
{
// on verifie que l`edge est bien connectee 2 fois (pas de bord libre)
Standard_Integer nbconnection = 0;
//TopExp_Explorer exp;
for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
const TopoDS_Face& fac = TopoDS::Face(exp.Current());
TopExp_Explorer exp2;
for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) {
if (exp2.Current().IsSame(myShape)) {
nbconnection++;
}
}
}
if (nbconnection < 2 && !TE->Degenerated()) {
BRepCheck::Add(myMap(S),BRepCheck_FreeEdge);
}
else if (nbconnection > 2) {
BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity);
}
else {
BRepCheck::Add(myMap(S),BRepCheck_NoError);
}
}
break;
default:
break;
}
if (myMap(S).IsEmpty()) {
myMap(S).Append(BRepCheck_NoError);
}
}
//=======================================================================
//function : Blind
//purpose :
//=======================================================================
void BRepCheck_Edge::Blind()
{
// Modified by skv - Tue Apr 27 11:36:01 2004 Begin
// The body of this function is removed because of its useless.
if (!myBlind) {
myBlind = Standard_True;
}
// Modified by skv - Tue Apr 27 11:36:02 2004 End
}
//=======================================================================
//function : GeometricControls
//purpose :
//=======================================================================
void BRepCheck_Edge::GeometricControls(const Standard_Boolean B)
{
myGctrl = B;
}
//=======================================================================
//function : GeometricControls
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Edge::GeometricControls() const
{
return myGctrl;
}
//=======================================================================
//function : Validate
//purpose :
//=======================================================================
static Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
const Standard_Real Tol,
const Standard_Boolean SameParameter)
{
Standard_Boolean Status = Standard_True;
gp_Pnt problematic_point ;
Standard_Real First = CRef.FirstParameter();
Standard_Real Last = CRef.LastParameter();
//gka OCC
Standard_Boolean proj = (!SameParameter ||
fabs(Other.FirstParameter()-First) > Precision::PConfusion() ||
fabs( Other.LastParameter()-Last) > Precision::PConfusion());//First != Other.FirstParameter() ||Last != Other.LastParameter()); gka OCC
Standard_Real Error = 0;
if (!proj) {
Standard_Real Tol2 = Tol*Tol;
for (Standard_Integer i = 0; i< NCONTROL; i++) {
Standard_Real prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
gp_Pnt pref = CRef.Value(prm);
gp_Pnt pother = Other.Value(prm);
if (pref.SquareDistance(pother) > Tol2) {
problematic_point = pref ;
Status = Standard_False;
Error = pref.Distance(pother);
goto FINISH ;
}
}
}
else {
Extrema_LocateExtPC refd,otherd;
Standard_Real OFirst = Other.FirstParameter();
Standard_Real OLast = Other.LastParameter();
gp_Pnt pd = CRef.Value(First);
gp_Pnt pdo = Other.Value(OFirst);
Standard_Real distt = pd.SquareDistance(pdo);
if (distt > Tol*Tol) {
problematic_point = pd ;
Status = Standard_False ;
Error = Sqrt(distt);
goto FINISH ;
}
pd = CRef.Value(Last);
pdo = Other.Value(OLast);
distt = pd.SquareDistance(pdo);
if (distt > Tol*Tol) {
problematic_point = pd ;
Status = Standard_False ;
Error = Sqrt(distt);
goto FINISH ;
}
refd.Initialize(CRef,First,Last,CRef.Resolution(Tol));
otherd.Initialize(Other,OFirst,OLast,Other.Resolution(Tol));
for (Standard_Integer i = 2; i< NCONTROL-1; i++) {
Standard_Real rprm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
gp_Pnt pref = CRef.Value(rprm);
Standard_Real oprm = ((NCONTROL-1-i)*OFirst + i*OLast)/(NCONTROL-1);
gp_Pnt pother = Other.Value(oprm);
refd.Perform(pother,rprm);
if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) {
problematic_point = pref ;
Status = Standard_False ;
if (refd.IsDone()) {
Error = sqrt (refd.SquareDistance());
}
else {
Error = RealLast();
}
goto FINISH ;
}
otherd.Perform(pref,oprm);
if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) {
problematic_point = pref ;
Status = Standard_False ;
if (otherd.IsDone()) {
Error = sqrt (otherd.SquareDistance());
}
else {
Error = RealLast();
}
goto FINISH ;
}
}
}
FINISH :
#ifdef DEB
if (! Status) {
cout << " **** probleme de SameParameter au point :" << endl;
cout << " " << problematic_point.Coord(1) << " "
<< problematic_point.Coord(2) << " "
<< problematic_point.Coord(3) << endl ;
cout << " Erreur detectee :" << Error << " Tolerance :" << Tol << endl;
}
#endif
return Status ;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
Standard_Real BRepCheck_Edge::Tolerance()
{
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
Standard_Integer it, iRep=1, nbRep=(TE->Curves()).Extent();
if (nbRep<=1) {
return Precision::Confusion();
}
TColStd_Array1OfTransient theRep(1, nbRep*2);
Standard_Real First, Last;
if (!myHCurve.IsNull()) {
First = myHCurve->FirstParameter();
Last= myHCurve->LastParameter();
}
else {
BRep_Tool::Range(TopoDS::Edge(myShape), First, Last);
}
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
for (; itcr.More(); itcr.Next()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurve3D() && !TE->Degenerated()) {
//// modified by jgv, 20.03.03 ////
TopLoc_Location Loc = myShape.Location() * cr->Location();
Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
(cr->Curve3D()->Transformed( Loc.Transformation() ));
///////////////////////////////////
GeomAdaptor_Curve GAC3d(C3d,First,Last);
it=iRep;
if (iRep>1) {
theRep(iRep)=theRep(1);
it=1;
}
theRep(it) = new GeomAdaptor_HCurve(GAC3d);
iRep++;
}
else if (cr->IsCurveOnSurface()) {
{
Handle(Geom_Surface) Sref = cr->Surface();
//// modified by jgv, 20.03.03 ////
TopLoc_Location Loc = myShape.Location() * cr->Location();
Sref = Handle(Geom_Surface)::DownCast
(Sref->Transformed( Loc.Transformation() ));
///////////////////////////////////
const Handle(Geom2d_Curve)& PCref = cr->PCurve();
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref =
new Geom2dAdaptor_HCurve(PCref,First,Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
iRep++;
}
if (cr->IsCurveOnClosedSurface()) {
Handle(Geom_Surface) Sref = cr->Surface();
Sref = Handle(Geom_Surface)::DownCast
(Sref->Transformed(cr->Location().Transformation()));
const Handle(Geom2d_Curve)& PCref = cr->PCurve2();
Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
Handle(Geom2dAdaptor_HCurve) GHPCref =
new Geom2dAdaptor_HCurve(PCref,First,Last);
Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
iRep++;
nbRep++;
}
}
else {
nbRep--;
}
}
Standard_Real dist2, tol2, tolCal=0., prm;
gp_Pnt center, othP;
Standard_Integer i, imax;
for (i= 0; i< NCONTROL; i++) {
prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
tol2=dist2=0.;
center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm);
for (iRep=2; iRep<=nbRep; iRep++) {
othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm);
dist2=center.SquareDistance(othP);
if (dist2>tolCal) tolCal=dist2;
}
if (tol2>tolCal) {
tolCal=tol2;
imax=i;
}
}
// On prend 5% de marge car au dessus on crontrole severement
return sqrt(tolCal)*1.05;
}

View File

@@ -0,0 +1,90 @@
-- File: BRepCheck_Face.cdl
-- Created: Fri Dec 15 11:48:23 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
class Face from BRepCheck inherits Result from BRepCheck
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Status from BRepCheck,
DataMapOfShapeListOfShape from TopTools
is
Create(F: Face from TopoDS)
returns mutable Face from BRepCheck;
InContext(me: mutable; ContextShape: Shape from TopoDS);
Minimum(me: mutable);
Blind(me: mutable);
IntersectWires(me: mutable; Update: Boolean from Standard = Standard_False)
returns Status from BRepCheck
is static;
ClassifyWires(me: mutable; Update: Boolean from Standard = Standard_False)
returns Status from BRepCheck
is static;
OrientationOfWires(me: mutable;
Update: Boolean from Standard = Standard_False)
returns Status from BRepCheck
is static;
SetUnorientable(me: mutable)
is static;
IsUnorientable(me)
returns Boolean from Standard
is static;
GeometricControls(me)
returns Boolean from Standard
is static;
GeometricControls(me: mutable; B: Boolean from Standard)
is static;
fields
myIntdone : Boolean from Standard;
myIntres : Status from BRepCheck;
myImbdone : Boolean from Standard;
myImbres : Status from BRepCheck;
myOridone : Boolean from Standard;
myOrires : Status from BRepCheck;
myMapImb : DataMapOfShapeListOfShape from TopTools;
myGctrl : Boolean from Standard;
end Face;

760
src/BRepCheck/BRepCheck_Face.cxx Executable file
View File

@@ -0,0 +1,760 @@
// File: BRepCheck_Face.cxx
// Created: Fri Dec 15 11:49:58 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Face.ixx>
#include <BRepCheck_ListOfStatus.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
//#include <BRepAdaptor_Curve2d.hxx>
#include <BRepClass_FaceClassifier.hxx>
//#include <Geom2dInt_GInter.hxx>
#include <Geom2d_Curve.hxx>
#include <GProp_GProps.hxx>
#include <IntRes2d_Domain.hxx>
#include <Geom2dInt_GInter.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepCheck.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <TopAbs_State.hxx>
#include <Bnd_Box2d.hxx>
#include <BndLib_Add2dCurve.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TopoDS_Vertex.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <BRepAdaptor_HSurface.hxx>
static Standard_Boolean Intersect(const TopoDS_Wire&,
const TopoDS_Wire&,
const TopoDS_Face&);
static Standard_Boolean IsInside(const TopoDS_Wire& wir,
const Standard_Boolean Inside,
const BRepTopAdaptor_FClass2d& FClass2d,
const TopoDS_Face& F);
static Standard_Boolean CheckThin(const TopoDS_Shape& w,
const TopoDS_Shape& f);
//=======================================================================
//function : BRepCheck_Face
//purpose :
//=======================================================================
BRepCheck_Face::BRepCheck_Face (const TopoDS_Face& F)
{
Init(F);
myIntdone = Standard_False;
myImbdone = Standard_False;
myOridone = Standard_False;
myGctrl = Standard_True;
}
//=======================================================================
//function : Minimum
//purpose :
//=======================================================================
void BRepCheck_Face::Minimum()
{
if (!myMin) {
BRepCheck_ListOfStatus thelist;
myMap.Bind(myShape, thelist);
BRepCheck_ListOfStatus& lst = myMap(myShape);
Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &myShape.TShape());
if (TF->Surface().IsNull()) {
BRepCheck::Add(lst,BRepCheck_NoSurface);
}
else {
// Flag natural restriction???
}
if (lst.IsEmpty()) {
lst.Append(BRepCheck_NoError);
}
myMin = Standard_True;
}
}
//=======================================================================
//function : InContext
//purpose :
//=======================================================================
void BRepCheck_Face::InContext(const TopoDS_Shape& S)
{
if (myMap.IsBound(S)) {
return;
}
BRepCheck_ListOfStatus thelist;
myMap.Bind(S, thelist);
BRepCheck_ListOfStatus& lst = myMap(S);
TopExp_Explorer exp(S,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
if (exp.Current().IsSame(myShape)) {
break;
}
}
if (!exp.More()) {
BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
return;
}
if (lst.IsEmpty()) {
lst.Append(BRepCheck_NoError);
}
}
//=======================================================================
//function : Blind
//purpose :
//=======================================================================
void BRepCheck_Face::Blind()
{
if (!myBlind) {
// rien de plus que dans le minimum
myBlind = Standard_True;
}
}
//=======================================================================
//function : IntersectWires
//purpose :
//=======================================================================
BRepCheck_Status BRepCheck_Face::IntersectWires(const Standard_Boolean Update)
{
if (myIntdone) {
if (Update) {
BRepCheck::Add(myMap(myShape),myIntres);
}
return myIntres;
}
myIntdone = Standard_True;
myIntres = BRepCheck_NoError;
// This method has to be called by an analyzer. It is assumed that
// each edge has a correct 2d representation on the face.
TopExp_Explorer exp1,exp2;
// on mape les wires
exp1.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
TopTools_ListOfShape theListOfShape;
while (exp1.More()) {
if (!myMapImb.IsBound(exp1.Current())) {
myMapImb.Bind(exp1.Current(), theListOfShape);
}
else { // on a 2 fois le meme wire...
myIntres = BRepCheck_RedundantWire;
if (Update) {
BRepCheck::Add(myMap(myShape),myIntres);
}
return myIntres;
}
exp1.Next();
}
Standard_Integer Nbwire, Index,Indexbis;
Nbwire = myMapImb.Extent();
Index = 1;
while (Index < Nbwire) {
for (exp1.Init(myShape,TopAbs_WIRE),Indexbis = 0;
exp1.More();exp1.Next()) {
Indexbis++;
if (Indexbis == Index) {
break;
}
}
TopoDS_Wire wir1 = TopoDS::Wire(exp1.Current());
exp1.Next();
for (; exp1.More(); exp1.Next()) {
const TopoDS_Wire& wir2 = TopoDS::Wire(exp1.Current());
if (Intersect(wir1,wir2,TopoDS::Face(myShape))) {
myIntres = BRepCheck_IntersectingWires;
if (Update) {
BRepCheck::Add(myMap(myShape),myIntres);
}
return myIntres;
}
}
Index++;
}
if (Update) {
BRepCheck::Add(myMap(myShape),myIntres);
}
return myIntres;
}
//=======================================================================
//function : ClassifyWires
//purpose :
//=======================================================================
BRepCheck_Status BRepCheck_Face::ClassifyWires(const Standard_Boolean Update)
{
// It is assumed that each wire does not intersect any other one.
if (myImbdone) {
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
myImbdone = Standard_True;
myImbres = IntersectWires();
if (myImbres != BRepCheck_NoError) {
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
Standard_Integer Nbwire = myMapImb.Extent();
if (Nbwire < 1) {
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
BRep_Builder B;
TopExp_Explorer exp1,exp2;
TopTools_ListOfShape theListOfShape;
for (exp1.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
exp1.More();exp1.Next()) {
const TopoDS_Wire& wir1 = TopoDS::Wire(exp1.Current());
TopoDS_Shape aLocalShape = myShape.EmptyCopied();
TopoDS_Face newFace = TopoDS::Face(aLocalShape);
// TopoDS_Face newFace = TopoDS::Face(myShape.EmptyCopied());
#ifdef DEB
TopAbs_Orientation orWire =
#endif
wir1.Orientation();
newFace.Orientation(TopAbs_FORWARD);
B.Add(newFace,wir1);
BRepTopAdaptor_FClass2d FClass2d(newFace,Precision::PConfusion());
Standard_Boolean WireBienOriente = Standard_False;
if(FClass2d.PerformInfinitePoint() != TopAbs_OUT) {
WireBienOriente=Standard_True;
//le wire donne definit un trou
myMapImb.UnBind(wir1);
myMapImb.Bind(wir1.Reversed(), theListOfShape);
}
for (exp2.Init(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
exp2.More();exp2.Next()) {
const TopoDS_Wire& wir2 = TopoDS::Wire(exp2.Current());
if (!wir2.IsSame(wir1)) {
if (IsInside(wir2,WireBienOriente,FClass2d,newFace)) {
myMapImb(wir1).Append(wir2);
}
}
}
}
// On doit avoir 1 wire qui contient tous les autres, et les autres
// ne contenant rien (cas solide fini) ou
// que des wires ne contenant rien : dans ce cas les wires doivent etre
// des trous dans une face infinie.
TopoDS_Wire Wext;
for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(myMapImb);
itm.More();
itm.Next()) {
if (!itm.Value().IsEmpty()) {
if (Wext.IsNull()) {
Wext = TopoDS::Wire(itm.Key());
}
else {
myImbres = BRepCheck_InvalidImbricationOfWires;
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
}
}
if (!Wext.IsNull()) {
// verifies that the list contains nbwire-1 elements
if (myMapImb(Wext).Extent() != Nbwire-1) {
myImbres = BRepCheck_InvalidImbricationOfWires;
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
}
// sortie sans erreurs
if (Update) {
BRepCheck::Add(myMap(myShape),myImbres);
}
return myImbres;
}
//=======================================================================
//function : OrientationOfWires
//purpose :
//=======================================================================
BRepCheck_Status BRepCheck_Face::OrientationOfWires
(const Standard_Boolean Update)
{
// WARNING : it is assumed that the edges of a wire are correctly oriented
Standard_Boolean Infinite = myShape.Infinite();
if (myOridone) {
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
myOridone = Standard_True;
myOrires = ClassifyWires();
if (myOrires != BRepCheck_NoError) {
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
Standard_Integer Nbwire = myMapImb.Extent();
TopoDS_Wire Wext;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(myMapImb);
if (Nbwire == 1) {
if (!Infinite) {
Wext = TopoDS::Wire(itm.Key());
}
}
else {
for (;itm.More();itm.Next()) {
if (!itm.Value().IsEmpty()) {
Wext = TopoDS::Wire(itm.Key());
}
}
}
if (Wext.IsNull() && !Infinite) {
if (Nbwire>0) myOrires = BRepCheck_InvalidImbricationOfWires;
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
// BRep_Builder B;
TopExp_Explorer exp(myShape.Oriented(TopAbs_FORWARD),TopAbs_WIRE);
for (; exp.More(); exp.Next()) {
const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
if (!Wext.IsNull() && wir.IsSame(Wext)) {
if (wir.Orientation() != Wext.Orientation()) {
//le wire exterieur definit un trou
if( CheckThin(wir,myShape.Oriented(TopAbs_FORWARD)) )
return myOrires;
myOrires = BRepCheck_BadOrientationOfSubshape;
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
}
else {
for (itm.Reset(); itm.More(); itm.Next()) {
if (itm.Key().IsSame(wir)) {
break;
}
}
// Pas de controle sur More()
if (itm.Key().Orientation() == wir.Orientation()) {
//le wire donne ne definit pas un trou
myOrires = BRepCheck_BadOrientationOfSubshape;
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
}
}
// sortie sans erreur
if (Update) {
BRepCheck::Add(myMap(myShape),myOrires);
}
return myOrires;
}
//=======================================================================
//function : SetUnorientable
//purpose :
//=======================================================================
void BRepCheck_Face::SetUnorientable()
{
BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape);
}
//=======================================================================
//function : IsUnorientable
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Face::IsUnorientable() const
{
if (myOridone) {
return (myOrires != BRepCheck_NoError);
}
for (BRepCheck_ListIteratorOfListOfStatus itl(myMap(myShape));
itl.More();
itl.Next()) {
if (itl.Value() == BRepCheck_UnorientableShape) {
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : GeometricControls
//purpose :
//=======================================================================
void BRepCheck_Face::GeometricControls(const Standard_Boolean B)
{
if (myGctrl != B) {
if (B) {
myIntdone = Standard_False;
myImbdone = Standard_False;
myOridone = Standard_False;
}
myGctrl = B;
}
}
//=======================================================================
//function : GeometricControls
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Face::GeometricControls() const
{
return myGctrl;
}
//=======================================================================
//function : Intersect
//purpose :
//=======================================================================
static Standard_Boolean Intersect(const TopoDS_Wire& wir1,
const TopoDS_Wire& wir2,
const TopoDS_Face& F)
{
Standard_Real Inter2dTol = 1.e-10;
TopExp_Explorer exp1,exp2;
// BRepAdaptor_Curve2d cur1,cur2;
//Find common vertices of two wires - non-manifold case
TopTools_MapOfShape MapW1;
TopTools_SequenceOfShape CommonVertices;
for (exp1.Init( wir1, TopAbs_VERTEX ); exp1.More(); exp1.Next())
MapW1.Add( exp1.Current() );
for (exp2.Init( wir2, TopAbs_VERTEX ); exp2.More(); exp2.Next())
{
TopoDS_Shape V = exp2.Current();
if (MapW1.Contains( V ))
CommonVertices.Append( V );
}
// MSV 03.04.2002: create pure surface adaptor to avoid UVBounds computation
// due to performance problem
BRepAdaptor_Surface Surf(F,Standard_False);
TColgp_SequenceOfPnt PntSeq;
Standard_Integer i;
for (i = 1; i <= CommonVertices.Length(); i++)
{
TopoDS_Vertex V = TopoDS::Vertex( CommonVertices(i) );
gp_Pnt2d P2d = BRep_Tool::Parameters( V, F );
gp_Pnt P = Surf.Value( P2d.X(), P2d.Y() );
PntSeq.Append( P );
}
Geom2dAdaptor_Curve C1,C2;
gp_Pnt2d pfirst1,plast1,pfirst2,plast2;
Standard_Real first1,last1,first2,last2;
Geom2dInt_GInter Inter;
IntRes2d_Domain myDomain1,myDomain2;
Bnd_Box2d Box1, Box2;
for (exp1.Init(wir1,TopAbs_EDGE); exp1.More(); exp1.Next())
{
const TopoDS_Edge& edg1 = TopoDS::Edge(exp1.Current());
// cur1.Initialize(edg1,F);
C1.Load( BRep_Tool::CurveOnSurface(edg1,F,first1,last1) );
// To avoid exeption in Segment if C1 is BSpline - IFV
if(C1.FirstParameter() > first1) first1 = C1.FirstParameter();
if(C1.LastParameter() < last1 ) last1 = C1.LastParameter();
BRep_Tool::UVPoints(edg1,F,pfirst1,plast1);
myDomain1.SetValues( pfirst1, first1, Inter2dTol, plast1, last1, Inter2dTol );
Box1.SetVoid();
BndLib_Add2dCurve::Add( C1, first1, last1, 0., Box1 );
for (exp2.Init(wir2,TopAbs_EDGE); exp2.More(); exp2.Next())
{
const TopoDS_Edge& edg2 = TopoDS::Edge(exp2.Current());
if (!edg1.IsSame(edg2))
{
//cur2.Initialize(edg2,F);
C2.Load( BRep_Tool::CurveOnSurface(edg2,F,first2,last2) );
// To avoid exeption in Segment if C2 is BSpline - IFV
if(C2.FirstParameter() > first2) first2 = C2.FirstParameter();
if(C2.LastParameter() < last2 ) last2 = C2.LastParameter();
Box2.SetVoid();
BndLib_Add2dCurve::Add( C2, first2, last2, 0., Box2 );
if (! Box1.IsOut( Box2 ))
{
BRep_Tool::UVPoints(edg2,F,pfirst2,plast2);
myDomain2.SetValues( pfirst2, first2, Inter2dTol, plast2, last2, Inter2dTol );
Inter.Perform( C1, myDomain1, C2, myDomain2, Inter2dTol, Inter2dTol );
if (!Inter.IsDone())
return Standard_True;
if (Inter.NbSegments() > 0)
{
if (PntSeq.IsEmpty())
return Standard_True;
else
{
Standard_Integer NbCoinc = 0;
for (i = 1; i <= Inter.NbSegments(); i++)
{
if (!Inter.Segment(i).HasFirstPoint() || !Inter.Segment(i).HasLastPoint())
return Standard_True;
gp_Pnt2d FirstP2d = Inter.Segment(i).FirstPoint().Value();
gp_Pnt2d LastP2d = Inter.Segment(i).LastPoint().Value();
gp_Pnt FirstP = Surf.Value( FirstP2d.X(), FirstP2d.Y() );
gp_Pnt LastP = Surf.Value( LastP2d.X(), LastP2d.Y() );
for (Standard_Integer j = 1; j <= PntSeq.Length(); j++)
{
Standard_Real tolv = BRep_Tool::Tolerance( TopoDS::Vertex(CommonVertices(j)) );
if (FirstP.IsEqual( PntSeq(j), tolv ) || LastP.IsEqual( PntSeq(j), tolv ))
{
NbCoinc++;
break;
}
}
}
if (NbCoinc == Inter.NbSegments())
return Standard_False;
return Standard_True;
}
}
if (Inter.NbPoints() > 0)
{
if (PntSeq.IsEmpty())
return Standard_True;
else
{
Standard_Integer NbCoinc = 0;
for (i = 1; i <= Inter.NbPoints(); i++)
{
gp_Pnt2d P2d = Inter.Point(i).Value();
gp_Pnt P = Surf.Value( P2d.X(), P2d.Y() );
for (Standard_Integer j = 1; j <= PntSeq.Length(); j++)
{
Standard_Real tolv = BRep_Tool::Tolerance( TopoDS::Vertex(CommonVertices(j)) );
if (P.IsEqual( PntSeq(j), tolv ))
{
NbCoinc++;
break;
}
}
}
if (NbCoinc == Inter.NbPoints())
return Standard_False;
return Standard_True;
}
}
}
}
}
}
return Standard_False;
}
//=======================================================================
//function : IsInside
//purpose :
//=======================================================================
static Standard_Boolean IsInside(const TopoDS_Wire& wir,
const Standard_Boolean WireBienOriente,
const BRepTopAdaptor_FClass2d& FClass2d,
const TopoDS_Face& F)
{
// Standard_Real U,V;
TopExp_Explorer exp;
for (exp.Init(wir,TopAbs_EDGE);
exp.More();
exp.Next()) {
const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
Standard_Real f,l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edg,F,f,l);
Standard_Real prm;
if (!Precision::IsNegativeInfinite(f) &&
!Precision::IsPositiveInfinite(l)) {
prm = (f+l)/2.;
}
else {
if (Precision::IsNegativeInfinite(f) &&
Precision::IsPositiveInfinite(l)){
prm = 0.;
}
else if (Precision::IsNegativeInfinite(f)) {
prm = l-1.;
}
else {
prm = f+1.;
}
}
gp_Pnt2d pt2d(C2d->Value(prm));
#ifdef DEB
TopAbs_State st2=
#endif
FClass2d.Perform(pt2d,Standard_False);
//-- if(st1!=st2) {
//-- static int p=0;
//-- printf("\n point p%d %g %g \n",++p,pt2d.X(),pt2d.Y());
//-- }
if(WireBienOriente) {
#ifndef DEB
return(FClass2d.Perform(pt2d,Standard_False) == TopAbs_OUT);
}
else {
return(FClass2d.Perform(pt2d,Standard_False) == TopAbs_IN);
}
#else
return(st2 == TopAbs_OUT);
}
else {
return(st2 == TopAbs_IN);
}
#endif
}
return Standard_False;
}
Standard_Boolean CheckThin(const TopoDS_Shape& w, const TopoDS_Shape& f)
{
TopoDS_Face aF = TopoDS::Face(f);
TopoDS_Wire aW = TopoDS::Wire(w);
Standard_Integer nbE = 0;
TopTools_ListOfShape lE;
TopExp_Explorer exp(aW,TopAbs_EDGE);
for(; exp.More(); exp.Next()) {
const TopoDS_Shape& s = exp.Current();
lE.Append(s);
nbE++;
}
if( nbE != 2 ) return Standard_False;
TopoDS_Edge e1 = TopoDS::Edge(lE.First());
TopoDS_Edge e2 = TopoDS::Edge(lE.Last());
TopoDS_Vertex v1, v2, v3, v4;
TopExp::Vertices(e1,v1,v2);
TopExp::Vertices(e2,v3,v4);
if( v1.IsNull() || v2.IsNull() ||
v3.IsNull() || v4.IsNull() ) return Standard_False;
if( v1.IsSame(v2) || v3.IsSame(v4) )
return Standard_False;
Standard_Boolean sF = Standard_False, sL = Standard_False;
if( v1.IsSame(v3) || v1.IsSame(v4) ) sF = Standard_True;
if( v2.IsSame(v3) || v2.IsSame(v4) ) sL = Standard_True;
if( !sF || !sL ) return Standard_False;
TopAbs_Orientation e1or = e1.Orientation();
TopAbs_Orientation e2or = e2.Orientation();
Standard_Real f1 = 0., l1 = 0., f2 = 0., l2 = 0.;
Handle(Geom2d_Curve) pc1 = BRep_Tool::CurveOnSurface(e1,aF,f1,l1);
Handle(Geom2d_Curve) pc2 = BRep_Tool::CurveOnSurface(e2,aF,f2,l2);
if( pc1.IsNull() || pc2.IsNull() ) return Standard_False;
Standard_Real d1 = Abs(l1-f1)/100.;
Standard_Real d2 = Abs(l2-f2)/100.;
Standard_Real m1 = (l1+f1)*0.5;
Standard_Real m2 = (l2+f2)*0.5;
gp_Pnt2d p1f(pc1->Value(m1-d1));
gp_Pnt2d p1l(pc1->Value(m1+d1));
gp_Pnt2d p2f(pc2->Value(m2-d2));
gp_Pnt2d p2l(pc2->Value(m2+d2));
gp_Vec2d vc1(p1f,p1l);
gp_Vec2d vc2(p2f,p2l);
if( (vc1*vc2) >= 0. && e1or == e2or ) return Standard_False;
return Standard_True;
}

View File

@@ -0,0 +1,120 @@
-- File: BRepCheck_Result.cdl
-- Created: Thu Dec 7 08:55:04 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
deferred class Result from BRepCheck inherits TShared from MMgt
---Purpose:
uses Shape from TopoDS,
ListOfStatus from BRepCheck,
DataMapOfShapeListOfStatus from BRepCheck,
DataMapIteratorOfDataMapOfShapeListOfStatus from BRepCheck
raises NoSuchObject from Standard
is
Initialize;
Init(me: mutable; S: Shape from TopoDS);
InContext(me: mutable; ContextShape: Shape from TopoDS)
is deferred;
Minimum(me: mutable)
is deferred;
Blind(me: mutable)
is deferred;
SetFailStatus(me: mutable; S: Shape from TopoDS);
Status(me)
returns ListOfStatus from BRepCheck
---C++: return const&
---C++: inline
is static;
IsMinimum(me)
returns Boolean from Standard
---C++: inline
is static;
IsBlind(me)
returns Boolean from Standard
---C++: inline
is static;
StatusOnShape(me: mutable; S: Shape from TopoDS)
---Purpose: If not already done, performs the InContext
-- control and returns the list of status.
returns ListOfStatus from BRepCheck
---C++: return const&
raises
NoSuchObject from Standard
is static;
InitContextIterator(me: mutable)
is static;
MoreShapeInContext(me)
returns Boolean from Standard
---C++: inline
is static;
ContextualShape(me)
returns Shape from TopoDS
---C++: return const&
---C++: inline
raises
NoSuchObject from Standard
is static;
StatusOnShape(me)
returns ListOfStatus from BRepCheck
---C++: return const&
---C++: inline
raises
NoSuchObject from Standard
is static;
NextShapeInContext(me: mutable)
is static;
fields
myShape : Shape from TopoDS is protected;
myMin : Boolean from Standard is protected;
myBlind : Boolean from Standard is protected;
myMap : DataMapOfShapeListOfStatus from BRepCheck is protected;
myIter : DataMapIteratorOfDataMapOfShapeListOfStatus from BRepCheck;
end Result;

View File

@@ -0,0 +1,91 @@
// File: BRepCheck_Result.cxx
// Created: Thu Dec 7 10:41:49 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Result.ixx>
#include <BRepCheck.hxx>
//=======================================================================
//function : BRepCheck_Result
//purpose :
//=======================================================================
BRepCheck_Result::BRepCheck_Result() :
myMin(Standard_False),myBlind(Standard_False)
{
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BRepCheck_Result::Init(const TopoDS_Shape& S)
{
myShape = S;
myMin = Standard_False;
myBlind = Standard_False;
myMap.Clear();
Minimum();
}
//=======================================================================
//function : SetFailStatus
//purpose :
//=======================================================================
void BRepCheck_Result::SetFailStatus(const TopoDS_Shape& S)
{
if(!myMap.IsBound(S)) {
BRepCheck_ListOfStatus thelist;
myMap.Bind(S, thelist);
}
BRepCheck::Add(myMap(S), BRepCheck_CheckFail);
}
//=======================================================================
//function : StatusOnShape
//purpose :
//=======================================================================
const BRepCheck_ListOfStatus& BRepCheck_Result::StatusOnShape
(const TopoDS_Shape& S)
{
if (!myMap.IsBound(S)) {
InContext(S);
}
return myMap(S);
}
//=======================================================================
//function : InitContextIterator
//purpose :
//=======================================================================
void BRepCheck_Result::InitContextIterator()
{
myIter.Initialize(myMap);
// Au minimum 1 element : le Shape lui meme
if (myIter.Key().IsSame(myShape)) {
myIter.Next();
}
}
//=======================================================================
//function : NextShapeInContext
//purpose :
//=======================================================================
void BRepCheck_Result::NextShapeInContext()
{
myIter.Next();
if (myIter.More() && myIter.Key().IsSame(myShape)) {
myIter.Next();
}
}

View File

@@ -0,0 +1,69 @@
// File: BRepCheck_Result.lxx
// Created: Thu Dec 7 10:49:37 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
//=======================================================================
//function : Status
//purpose :
//=======================================================================
inline const BRepCheck_ListOfStatus& BRepCheck_Result::Status() const
{
return myMap(myShape);
}
//=======================================================================
//function : IsMinimum
//purpose :
//=======================================================================
inline Standard_Boolean BRepCheck_Result::IsMinimum() const
{
return myMin;
}
//=======================================================================
//function : IsBlind
//purpose :
//=======================================================================
inline Standard_Boolean BRepCheck_Result::IsBlind() const
{
return myBlind;
}
//=======================================================================
//function : MoreShapeInContext
//purpose :
//=======================================================================
inline Standard_Boolean BRepCheck_Result::MoreShapeInContext () const
{
return myIter.More();
}
//=======================================================================
//function : ContextualShape
//purpose :
//=======================================================================
inline const TopoDS_Shape& BRepCheck_Result::ContextualShape () const
{
return myIter.Key();
}
//=======================================================================
//function : StatusOnShape
//purpose :
//=======================================================================
inline const BRepCheck_ListOfStatus& BRepCheck_Result::StatusOnShape () const
{
return myIter.Value();
}

View File

@@ -0,0 +1,79 @@
-- File: BRepCheck_Shell.cdl
-- Created: Tue Jan 2 14:26:45 1996
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1996
class Shell from BRepCheck inherits Result from BRepCheck
---Purpose:
uses Shape from TopoDS,
Shell from TopoDS,
ListOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
Status from BRepCheck
is
Create(S: Shell from TopoDS)
returns mutable Shell from BRepCheck;
InContext(me: mutable; ContextShape: Shape from TopoDS);
Minimum(me: mutable);
Blind(me: mutable);
Closed(me: mutable; Update: Boolean from Standard = Standard_False)
---Purpose: Checks if the oriented faces of the shell give a
-- closed shell. If the wire is closed, returns
-- BRepCheck_NoError.If <Update> is set to
-- Standard_True, registers the status in the list.
returns Status from BRepCheck
is static;
Orientation(me: mutable; Update: Boolean from Standard = Standard_False)
---Purpose: Checks if the oriented faces of the shell are
-- correctly oriented. An internal call is made to
-- the method Closed. If <Update> is set to
-- Standard_True, registers the status in the list.
returns Status from BRepCheck
is static;
SetUnorientable(me: mutable)
is static;
IsUnorientable(me)
returns Boolean from Standard
is static;
NbConnectedSet (me: mutable; theSets : in out ListOfShape from TopTools)
returns Integer from Standard;
fields
myNbori : Integer from Standard;
myCdone : Boolean from Standard;
myCstat : Status from BRepCheck;
myOdone : Boolean from Standard;
myOstat : Status from BRepCheck;
myMapEF : IndexedDataMapOfShapeListOfShape from TopTools;
end Shell;

887
src/BRepCheck/BRepCheck_Shell.cxx Executable file
View File

@@ -0,0 +1,887 @@
// File: BRepCheck_Shell.cxx
// Created: Tue Dec 12 17:49:08 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Shell.ixx>
#include <BRepCheck_ListOfStatus.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepCheck.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopExp.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
Standard_EXPORT Standard_Integer BRepCheck_Trace(const Standard_Integer phase) {
static int BRC_Trace = 0;
if (phase < 0) BRC_Trace =0;
else if (phase > 0) BRC_Trace=phase;
return BRC_Trace;
}
void PrintShape(const TopoDS_Shape& theShape, const Standard_Integer upper) {
if (!theShape.IsNull()) {
Standard_Integer code = theShape.HashCode(upper);
switch (theShape.ShapeType()) {
case TopAbs_COMPOUND :
cout << "COMPOUND";
break;
case TopAbs_COMPSOLID :
cout << "COMPSOLID";
break;
case TopAbs_SOLID :
cout << "SOLID";
break;
case TopAbs_SHELL :
cout << "SHELL";
break;
case TopAbs_FACE :
cout << "FACE";
break;
case TopAbs_WIRE :
cout << "WIRE";
break;
case TopAbs_EDGE :
cout << "EDGE";
break;
case TopAbs_VERTEX :
cout << "VERTEX";
break;
case TopAbs_SHAPE :
cout << "SHAPE";
break;
}
cout << " : " << code << " ";
switch (theShape.Orientation()) {
case TopAbs_FORWARD :
cout << "FORWARD";
break;
case TopAbs_REVERSED :
cout << "REVERSED";
break;
case TopAbs_INTERNAL :
cout << "INTERNAL";
break;
case TopAbs_EXTERNAL :
cout << "EXTERNAL";
break;
}
cout << endl;
}
}
static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape&,
const TopoDS_Shape&, // Face
TopTools_MapOfShape&); // mapofface
#ifdef DEB
static TopAbs_Orientation GetOrientation(const TopoDS_Face&,
const TopoDS_Shape&);
#endif
inline Standard_Boolean IsOriented(const TopoDS_Shape& S)
{
return (S.Orientation() == TopAbs_FORWARD ||
S.Orientation() == TopAbs_REVERSED);
}
//=======================================================================
//function : BRepCheck_Shell
//purpose :
//=======================================================================
BRepCheck_Shell::BRepCheck_Shell(const TopoDS_Shell& S)
{
Init(S);
}
//=======================================================================
//function : Minimum
//purpose :
//=======================================================================
void BRepCheck_Shell::Minimum()
{
myCdone = Standard_False;
myOdone = Standard_False;
if (!myMin) {
BRepCheck_ListOfStatus thelist;
myMap.Bind(myShape, thelist);
BRepCheck_ListOfStatus& lst = myMap(myShape);
// it is checked if the shell is "connected"
TopExp_Explorer exp(myShape,TopAbs_FACE);
Standard_Integer nbface = 0;
myMapEF.Clear();
for (; exp.More(); exp.Next()) {
nbface++;
TopExp_Explorer expe;
for (expe.Init(exp.Current(),TopAbs_EDGE);
expe.More(); expe.Next()) {
const TopoDS_Shape& edg = expe.Current();
Standard_Integer index = myMapEF.FindIndex(edg);
if (index == 0) {
TopTools_ListOfShape thelist1;
index = myMapEF.Add(edg, thelist1);
}
myMapEF(index).Append(exp.Current());
}
}
if (nbface == 0) {
BRepCheck::Add(lst,BRepCheck_EmptyShell);
}
else if (nbface >= 2) {
TopTools_MapOfShape mapF;
exp.ReInit();
Propagate(myMapEF,exp.Current(),mapF);
if (mapF.Extent() != nbface) {
BRepCheck::Add(lst,BRepCheck_NotConnected);
}
}
if (lst.IsEmpty()) {
lst.Append(BRepCheck_NoError);
}
myMapEF.Clear();
myMin = Standard_True;
}
}
//=======================================================================
//function : InContext
//purpose :
//=======================================================================
void BRepCheck_Shell::InContext(const TopoDS_Shape& S)
{
if (myMap.IsBound(S)) {
return;
}
BRepCheck_ListOfStatus thelist;
myMap.Bind(S, thelist);
BRepCheck_ListOfStatus& lst = myMap(S);
// for (TopExp_Explorer exp(S,TopAbs_SHELL); exp.More(); exp.Next()) {
TopExp_Explorer exp(S,TopAbs_SHELL) ;
for ( ; exp.More(); exp.Next()) {
if (exp.Current().IsSame(myShape)) {
break;
}
}
if (!exp.More()) {
BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
return;
}
TopAbs_ShapeEnum styp = S.ShapeType();
switch (styp) {
case TopAbs_SOLID:
{
BRepCheck_Status fst = Closed();
if ((fst == BRepCheck_NotClosed && S.Closed()) ||
(fst != BRepCheck_NoError)) {
BRepCheck::Add(lst,fst);
}
else if (!IsUnorientable()) {
fst = Orientation();
BRepCheck::Add(lst,fst);
}
}
break;
default:
break;
}
if (lst.IsEmpty()) {
lst.Append(BRepCheck_NoError);
}
}
//=======================================================================
//function : Blind
//purpose :
//=======================================================================
void BRepCheck_Shell::Blind()
{
if (!myBlind) {
// nothing more than in the minimum
myBlind = Standard_True;
}
}
//=======================================================================
//function : Closed
//purpose :
//=======================================================================
BRepCheck_Status BRepCheck_Shell::Closed(const Standard_Boolean Update)
{
if (myCdone) {
if (Update) {
BRepCheck::Add(myMap(myShape), myCstat);
}
return myCstat;
}
myCdone = Standard_True; // it will be done...
BRepCheck_ListIteratorOfListOfStatus itl(myMap(myShape));
if (itl.Value() != BRepCheck_NoError) {
myCstat = itl.Value();
return myCstat; // already saved
}
myCstat = BRepCheck_NoError;
//
Standard_Integer index, aNbF;
TopExp_Explorer exp, ede;
TopTools_MapOfShape mapS, aMEToAvoid;
myMapEF.Clear();
// Checks if the oriented faces of the shell give a "closed" shell,
// i-e if each oriented edge on oriented faces is found 2 times.
//
//modified by NIZNHY-PKV Mon Jun 4 13:59:21 2007f
exp.Init(myShape,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
const TopoDS_Shape& aF=exp.Current();
if (IsOriented(aF)) {
ede.Init(exp.Current(),TopAbs_EDGE);
for (; ede.More(); ede.Next()) {
const TopoDS_Shape& aE=ede.Current();
if (!IsOriented(aE)) {
aMEToAvoid.Add(aE);
}
}
}
}
//modified by NIZNHY-PKV Mon Jun 4 13:59:23 2007t
//
exp.Init(myShape,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
const TopoDS_Shape& aF=exp.Current();
if (IsOriented(aF)) {
if (!mapS.Add(aF)) {
myCstat = BRepCheck_RedundantFace;
if (Update) {
BRepCheck::Add(myMap(myShape),myCstat);
}
return myCstat;
}
//
ede.Init(exp.Current(),TopAbs_EDGE);
for (; ede.More(); ede.Next()) {
const TopoDS_Shape& aE=ede.Current();
//modified by NIZNHY-PKV Mon Jun 4 14:07:57 2007f
//if (IsOriented(aE)) {
if (!aMEToAvoid.Contains(aE)) {
//modified by NIZNHY-PKV Mon Jun 4 14:08:01 2007
index = myMapEF.FindIndex(aE);
if (!index) {
TopTools_ListOfShape thelist;
index = myMapEF.Add(aE, thelist);
}
myMapEF(index).Append(aF);
}
}
}
}
//
myNbori = mapS.Extent();
if (myNbori >= 2) {
mapS.Clear();
// Search for the first oriented face
TopoDS_Shape aF;
exp.Init(myShape, TopAbs_FACE);
for (;exp.More(); exp.Next()) {
aF=exp.Current();
if (IsOriented(aF)) {
break;
}
}
//
Propagate(myMapEF, aF, mapS);
}
//
//
aNbF=mapS.Extent();
if (myNbori != aNbF) {
myCstat = BRepCheck_NotConnected;
if (Update) {
BRepCheck::Add(myMap(myShape),myCstat);
}
return myCstat;
}
//
//
Standard_Integer i, Nbedges, nboc, nbSet;
//
Nbedges = myMapEF.Extent();
for (i = 1; i<=Nbedges; ++i) {
nboc = myMapEF(i).Extent();
if (nboc == 0 || nboc >= 3) {
TopTools_ListOfShape theSet;
nbSet=NbConnectedSet(theSet);
// If there is more than one closed cavity the shell is considered invalid
// this corresponds to the criteria of a solid (not those of a shell)
if (nbSet>1) {
myCstat = BRepCheck_InvalidMultiConnexity;
if (Update) {
BRepCheck::Add(myMap(myShape),myCstat);
}
return myCstat;
}
}
else if (nboc == 1) {
if (!BRep_Tool::Degenerated(TopoDS::Edge(myMapEF.FindKey(i)))) {
myCstat=BRepCheck_NotClosed;
if (Update) {
BRepCheck::Add(myMap(myShape),myCstat);
}
return myCstat;
}
}
}
if (Update) {
BRepCheck::Add(myMap(myShape),myCstat);
}
return myCstat;
}
//=======================================================================
//function : Orientation
//purpose :
//=======================================================================
BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
{
if (myOdone) {
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
return myOstat;
}
myOdone = Standard_True;
myOstat = Closed();
if (myOstat != BRepCheck_NotClosed && myOstat != BRepCheck_NoError) {
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
return myOstat;
}
myOstat = BRepCheck_NoError;
// First the orientation of each face in relation to the shell is found.
// It is used to check BRepCheck_RedundantFace
TopTools_DataMapOfShapeInteger MapOfShapeOrientation;
TopExp_Explorer exp,ede;
for (exp.Init(myShape,TopAbs_FACE); exp.More(); exp.Next()) {
if (!MapOfShapeOrientation.Bind(exp.Current(), (Standard_Integer)(exp.Current().Orientation()))) {
myOstat = BRepCheck_RedundantFace;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
else {
return myOstat;
}
}
}
#ifdef DEB
if (BRepCheck_Trace(0) > 1) {
TopTools_DataMapIteratorOfDataMapOfShapeInteger itt(MapOfShapeOrientation);
Standard_Integer upper = MapOfShapeOrientation.NbBuckets();
Standard_Integer code = 0;
cout << "La map shape Orientation :" << endl;
for (; itt.More(); itt.Next()) {
PrintShape(itt.Key(), upper);
}
cout << endl;
}
#endif
// Then the orientation of faces by their connectivity is checked
// BRepCheck_BadOrientationOfSubshape and
// BRepCheck_SubshapeNotInShape are checked;
Standard_Integer Nbedges = myMapEF.Extent();
TopoDS_Face Fref;
TopAbs_Orientation orf;
for (Standard_Integer i = 1; i<= Nbedges; i++) {
const TopoDS_Edge& edg = TopoDS::Edge(myMapEF.FindKey(i));
if (BRep_Tool::Degenerated(edg)) continue;
TopTools_ListOfShape& lface = myMapEF(i);
TopTools_ListIteratorOfListOfShape lite(lface);
if (lface.Extent() <= 2)
{
lite.Initialize(lface);
Fref = TopoDS::Face(lite.Value());
if (!MapOfShapeOrientation.IsBound(Fref)) {
myOstat = BRepCheck_SubshapeNotInShape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
// quit because no workaround for the incoherence is possible
return myOstat;
}
lite.Next();
if (lite.More()) { // Edge of connectivity
//JR/Hp :
Standard_Integer iorf = MapOfShapeOrientation.Find(Fref);
orf = (TopAbs_Orientation) iorf;
//orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fref);
Fref.Orientation(orf);
// edge is examined
if (!lite.Value().IsSame(Fref)) { // edge non "closed"
for (ede.Init(Fref,TopAbs_EDGE); ede.More(); ede.Next()) {
if (ede.Current().IsSame(edg)) {
break;
}
}
TopAbs_Orientation orient = ede.Current().Orientation();
TopoDS_Face Fcur= TopoDS::Face(lite.Value());
if (!MapOfShapeOrientation.IsBound(Fcur)) {
myOstat = BRepCheck_SubshapeNotInShape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
// quit because no workaround for the incoherence is possible
return myOstat;
}
//JR/Hp :
Standard_Integer iorf = MapOfShapeOrientation.Find(Fcur) ;
orf = (TopAbs_Orientation) iorf ;
// orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
for (ede.Init(Fcur, TopAbs_EDGE); ede.More(); ede.Next()) {
if (ede.Current().IsSame(edg)) {
break;
}
}
if (ede.Current().Orientation() == orient) {
// The loop is continued on the edges as many times
// as the same edge is present in the wire
// modified by NIZHNY-MKK Tue Sep 30 11:11:42 2003
Standard_Boolean bfound = Standard_False;
ede.Next();
for (; ede.More(); ede.Next()) {
if (ede.Current().IsSame(edg)) {
// modified by NIZHNY-MKK Tue Sep 30 11:12:03 2003
bfound = Standard_True;
break;
}
}
// if (ede.Current().Orientation() == orient) {
// modified by NIZHNY-MKK Thu Oct 2 17:56:47 2003
if (!bfound || (ede.Current().Orientation() == orient)) {
myOstat = BRepCheck_BadOrientationOfSubshape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
break;
}
return myOstat;
}
}
}
}
}
else //more than two faces
{
Standard_Integer numF = 0, numR = 0;
TopTools_MapOfShape Fmap;
for (lite.Initialize(lface); lite.More(); lite.Next())
{
TopoDS_Face Fcur= TopoDS::Face(lite.Value());
if (!MapOfShapeOrientation.IsBound(Fcur))
{
myOstat = BRepCheck_SubshapeNotInShape;
if (Update)
BRepCheck::Add(myMap(myShape), myOstat);
// quit because no workaround for the incoherence is possible
return myOstat;
}
Standard_Integer iorf = MapOfShapeOrientation.Find(Fcur);
orf = (TopAbs_Orientation) iorf;
//orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
for (ede.Init(Fcur,TopAbs_EDGE); ede.More(); ede.Next())
if (ede.Current().IsSame(edg))
break;
if (Fmap.Contains(Fcur)) //edge is "closed" on Fcur, we meet Fcur twice
{
ede.Next();
for (; ede.More(); ede.Next())
if (ede.Current().IsSame(edg))
break;
}
TopAbs_Orientation orient = ede.Current().Orientation();
if (orient == TopAbs_FORWARD)
numF++;
else
numR++;
Fmap.Add(Fcur);
}
if (numF != numR)
{
myOstat = BRepCheck_BadOrientationOfSubshape;
if (Update)
{
BRepCheck::Add(myMap(myShape), myOstat);
break;
}
return myOstat;
}
}
}
// If at least one incorrectly oriented face has been found, it is checked if the shell can be oriented.
// i.e. : if by modification of the orientation of a face it is possible to find
// a coherent orientation. (it is not possible on a Moebius band)
// BRepCheck_UnorientableShape is checked
if (myOstat == BRepCheck_BadOrientationOfSubshape) {
if (!Fref.IsNull()) {
if (Nbedges > 0) {
TopTools_MapOfShape alre;
TopTools_ListOfShape voisin;
voisin.Append(Fref);
alre.Clear();
while (!voisin.IsEmpty()) {
Fref=TopoDS::Face(voisin.First());
voisin.RemoveFirst();
if (!MapOfShapeOrientation.IsBound(Fref)) {
myOstat = BRepCheck_SubshapeNotInShape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
// quit because no workaround for the incoherence is possible
return myOstat;
}
//JR/Hp :
Standard_Integer iorf = MapOfShapeOrientation.Find(Fref) ;
orf = (TopAbs_Orientation) iorf ;
// orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fref);
Fref.Orientation(orf);
#ifdef DEB
if (BRepCheck_Trace(0) > 3) {
cout << "Fref : " ;
PrintShape(Fref, MapOfShapeOrientation.NbBuckets());
}
#endif
TopExp_Explorer edFcur;
alre.Add(Fref);
for (ede.Init(Fref,TopAbs_EDGE); ede.More(); ede.Next()) {
const TopoDS_Edge& edg = TopoDS::Edge(ede.Current());
TopAbs_Orientation orient = edg.Orientation();
TopTools_ListOfShape& lface = myMapEF.ChangeFromKey(edg);
TopTools_ListIteratorOfListOfShape lite(lface);
TopoDS_Face Fcur= TopoDS::Face(lite.Value());
if (Fcur.IsSame(Fref)) {
lite.Next();
if (lite.More()) {
Fcur=TopoDS::Face(lite.Value());
}
else {
// from the free border one goes to the next edge
continue;
}
}
if (!MapOfShapeOrientation.IsBound(Fcur)) {
myOstat = BRepCheck_SubshapeNotInShape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
// quit because no workaround for the incoherence is possible
return myOstat;
}
//JR/Hp :
Standard_Integer iorf = MapOfShapeOrientation.Find(Fcur) ;
orf = (TopAbs_Orientation) iorf ;
// orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
#ifdef DEB
if (BRepCheck_Trace(0) > 3) {
cout << " Fcur : " ;
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
}
#endif
for (edFcur.Init(Fcur, TopAbs_EDGE); edFcur.More(); edFcur.Next()) {
if (edFcur.Current().IsSame(edg)) {
break;
}
}
if (edFcur.Current().Orientation() == orient) {
if (alre.Contains(Fcur)) {
// It is necessary to return a face that has been already examined or returned
// if one gets nowhere, the shell cannot be oriented.
myOstat = BRepCheck_UnorientableShape;
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
// quit, otherwise there is a risk of taking too much time.
#ifdef DEB
if (BRepCheck_Trace(0) > 3) {
orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
cout << " Error : this face has been already examined " << endl;
cout << " Imposible to return it ";
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
}
#endif
return myOstat;
}
orf = TopAbs::Reverse(orf);
MapOfShapeOrientation(Fcur)=orf;
#ifdef DEB
if (BRepCheck_Trace(0) > 3) {
orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
cout << " Resulting Fcur is returned : " ;
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
}
#endif
}
if (alre.Add(Fcur)) {
voisin.Append(Fcur);
}
}
}
}
}
}
if (Update) {
BRepCheck::Add(myMap(myShape), myOstat);
}
return myOstat;
}
//=======================================================================
//function : SetUnorientable
//purpose :
//=======================================================================
void BRepCheck_Shell::SetUnorientable()
{
BRepCheck::Add(myMap(myShape),BRepCheck_UnorientableShape);
}
//=======================================================================
//function : IsUnorientable
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_Shell::IsUnorientable() const
{
if (myOdone) {
return (myOstat != BRepCheck_NoError);
}
for (BRepCheck_ListIteratorOfListOfStatus itl(myMap(myShape));
itl.More();
itl.Next()) {
if (itl.Value() == BRepCheck_UnorientableShape) {
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : NbConnectedSet
//purpose :
//=======================================================================
Standard_Integer BRepCheck_Shell::NbConnectedSet(TopTools_ListOfShape& theSets)
{
// The connections are found
TopTools_IndexedDataMapOfShapeListOfShape parents;
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, parents);
// All faces are taken
TopTools_MapOfShape theFaces;
TopExp_Explorer exsh(myShape, TopAbs_FACE);
for (; exsh.More(); exsh.Next()) theFaces.Add(exsh.Current());
// The edges that are not oriented or have more than 2 connections are missing
Standard_Integer iCur;
TopTools_MapOfShape theMultiEd;
TopTools_MapOfShape theUnOriEd;
for (iCur=1; iCur<=parents.Extent(); iCur++) {
const TopoDS_Edge& Ed = TopoDS::Edge(parents.FindKey(iCur));
if (parents(iCur).Extent()> 2) theMultiEd.Add(Ed);
if (Ed.Orientation()!=TopAbs_REVERSED &&
Ed.Orientation()!=TopAbs_FORWARD) theUnOriEd.Add(Ed);
}
// Starting from multiconnected edges propagation by simple connections
TopTools_ListIteratorOfListOfShape lconx1, lconx2;
TopTools_MapIteratorOfMapOfShape itmsh(theMultiEd);
TopoDS_Shell CurShell;
TopoDS_Shape adFac;
TopTools_ListOfShape lesCur;
BRep_Builder BRB;
Standard_Boolean newCur=Standard_True;
BRB.MakeShell(CurShell);
for (; itmsh.More(); itmsh.Next()) {
const TopoDS_Shape& Ed = itmsh.Key();
if (!theUnOriEd.Contains(Ed)) {
for (lconx1.Initialize(parents.FindFromKey(Ed)); lconx1.More(); lconx1.Next()) {
if (theFaces.Contains(lconx1.Value())) {
adFac=lconx1.Value();
BRB.Add(CurShell, adFac);
theFaces.Remove(adFac);
newCur=Standard_False;
if (theFaces.IsEmpty()) break;
lesCur.Append(adFac);
while (!lesCur.IsEmpty()) {
adFac=lesCur.First();
lesCur.RemoveFirst();
for (exsh.Init(adFac, TopAbs_EDGE); exsh.More(); exsh.Next()) {
const TopoDS_Shape& ced = exsh.Current();
if (!theMultiEd.Contains(ced)) {
for (lconx2.Initialize(parents.FindFromKey(ced)); lconx2.More(); lconx2.Next()) {
if (theFaces.Contains(lconx2.Value())) {
adFac=lconx2.Value();
BRB.Add(CurShell, adFac);
theFaces.Remove(adFac);
newCur=Standard_False;
if (theFaces.IsEmpty()) break;
lesCur.Append(adFac);
}
}
}
if (theFaces.IsEmpty()) break;
}
}
if (!newCur) {
theSets.Append(CurShell);
CurShell.Nullify();
newCur=Standard_True;
BRB.MakeShell(CurShell);
}
}
if (theFaces.IsEmpty()) break;
}
}
if (theFaces.IsEmpty()) break;
}
return theSets.Extent();
}
//=======================================================================
//function : GetOrientation
//purpose :
//=======================================================================
#ifdef DEB
static TopAbs_Orientation GetOrientation(const TopoDS_Face& F,
const TopoDS_Shape& S)
{
TopExp_Explorer exp;
for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
if (exp.Current().IsSame(F)) {
return exp.Current().Orientation();
}
}
return TopAbs_FORWARD; // for compilation
}
#endif
//=======================================================================
//function : Propagate
//purpose :
//=======================================================================
static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape& mapEF,
const TopoDS_Shape& fac,
TopTools_MapOfShape& mapF)
{
if (mapF.Contains(fac)) {
return;
}
mapF.Add(fac); // attention, if oriented == Standard_True, fac should
// be FORWARD or REVERSED. It is not checked.
TopExp_Explorer ex;
for (ex.Init(fac,TopAbs_EDGE); ex.More(); ex.Next()) {
const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
// test if the edge is in the map (only orienteed edges are present)
if (mapEF.Contains(edg)) {
for (TopTools_ListIteratorOfListOfShape itl(mapEF.FindFromKey(edg));
itl.More(); itl.Next()) {
if (!itl.Value().IsSame(fac) &&
!mapF.Contains(itl.Value())) {
Propagate(mapEF,itl.Value(),mapF);
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
-- File: BRepCheck_Vertex.cdl
-- Created: Thu Dec 7 11:07:45 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
class Vertex from BRepCheck inherits Result from BRepCheck
---Purpose:
uses Shape from TopoDS,
Vertex from TopoDS
is
Create(V: Vertex from TopoDS)
returns mutable Vertex from BRepCheck;
InContext(me: mutable; ContextShape: Shape from TopoDS);
Minimum(me: mutable);
Blind(me: mutable);
Tolerance(me: mutable) returns Real from Standard
is static;
end Vertex;

View File

@@ -0,0 +1,360 @@
// File: BRepCheck_Vertex.cxx
// Created: Thu Dec 7 11:12:16 1995
// Author: Jacques GOUSSARD
// <jag@bravox>
#include <BRepCheck_Vertex.ixx>
#include <BRepCheck_ListOfStatus.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_PointRepresentation.hxx>
#include <BRep_ListOfPointRepresentation.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt2d.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRepCheck.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
//=======================================================================
//function : BRepCheck_Vertex
//purpose :
//=======================================================================
BRepCheck_Vertex::BRepCheck_Vertex(const TopoDS_Vertex& V)
{
Init(V);
}
//=======================================================================
//function : Minimum
//purpose :
//=======================================================================
void BRepCheck_Vertex::Minimum()
{
if (!myMin) {
// consisterait a verifier l`existence d`un point 3D
BRepCheck_ListOfStatus thelist;
myMap.Bind(myShape, thelist);
myMap(myShape).Append(BRepCheck_NoError);
myMin = Standard_True;
}
}
//=======================================================================
//function : InContext
//purpose :
//=======================================================================
void BRepCheck_Vertex::InContext(const TopoDS_Shape& S)
{
if (myMap.IsBound(S)) {
return;
}
BRepCheck_ListOfStatus thelist;
myMap.Bind(S, thelist);
// for (TopExp_Explorer exp(S,TopAbs_VERTEX); exp.More(); exp.Next()) {
TopExp_Explorer exp(S,TopAbs_VERTEX) ;
for ( ; exp.More(); exp.Next()) {
if (exp.Current().IsSame(myShape)) {
break;
}
}
if (!exp.More()) {
BRepCheck::Add(myMap(S),BRepCheck_SubshapeNotInShape);
return; // on sort
}
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &myShape.TShape());
const gp_Pnt& prep = TV->Pnt();
gp_Pnt Controlp;
TopAbs_ShapeEnum styp = S.ShapeType();
switch (styp) {
case TopAbs_EDGE:
{
// On essaie de retrouver le vertex sur l`edge
const TopoDS_Edge& E = TopoDS::Edge(S);
TopoDS_Iterator itv(E.Oriented(TopAbs_FORWARD));
TopoDS_Vertex VFind;
Standard_Boolean multiple = Standard_False;
while (itv.More()) {
const TopoDS_Vertex& VF = TopoDS::Vertex(itv.Value());
if (itv.Value().IsSame(myShape)) {
if (VFind.IsNull()) {
VFind = VF;
}
else {
if ((VFind.Orientation() == TopAbs_FORWARD &&
VF.Orientation() == TopAbs_REVERSED) ||
(VFind.Orientation() == TopAbs_REVERSED &&
VF.Orientation() == TopAbs_FORWARD)) {
// on a le vertex a la fois F et R sur l`edge
multiple = Standard_True;
}
if (VFind.Orientation() != TopAbs_FORWARD &&
VFind.Orientation() != TopAbs_REVERSED) {
if (VF.Orientation() == TopAbs_FORWARD ||
VF.Orientation() == TopAbs_REVERSED) {
VFind = VF;
}
}
}
}
itv.Next();
}
// on est sur que VFind n`est pas nul
TopAbs_Orientation orv = VFind.Orientation();
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Vertex(myShape));
Tol = Max(Tol,BRep_Tool::Tolerance(E)); // a voir
Tol *= Tol;
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
const TopLoc_Location& Eloc = E.Location();
BRep_ListIteratorOfListOfPointRepresentation itpr;
while (itcr.More()) {
// Pour chaque CurveRepresentation, on verifie le parametre fourni
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
const TopLoc_Location& loc = cr->Location();
TopLoc_Location L = (Eloc * loc).Predivided(myShape.Location());
if (cr->IsCurve3D()) {
const Handle(Geom_Curve)& C = cr->Curve3D();
if (!C.IsNull()) { // edge non degenere
itpr.Initialize(TV->Points());
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
if (pr->IsPointOnCurve(C,L)) {
Controlp = C->Value(pr->Parameter());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),BRepCheck_InvalidPointOnCurve);
}
}
itpr.Next();
}
if (orv == TopAbs_FORWARD || orv == TopAbs_REVERSED) {
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
if (orv == TopAbs_FORWARD || multiple) {
Controlp = C->Value(GC->First());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),BRepCheck_InvalidPointOnCurve);
}
}
if (orv == TopAbs_REVERSED || multiple) {
Controlp = C->Value(GC->Last());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),BRepCheck_InvalidPointOnCurve);
}
}
}
}
}
else if (cr->IsCurveOnSurface()) {
const Handle(Geom_Surface)& Su = cr->Surface();
const Handle(Geom2d_Curve)& PC = cr->PCurve();
Handle(Geom2d_Curve) PC2;
if (cr->IsCurveOnClosedSurface()) {
PC2 = cr->PCurve2();
}
itpr.Initialize(TV->Points());
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
if (pr->IsPointOnCurveOnSurface(PC,Su,L)) {
gp_Pnt2d p2d = PC->Value(pr->Parameter());
Controlp = Su->Value(p2d.X(),p2d.Y());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),
BRepCheck_InvalidPointOnCurveOnSurface);
}
}
if (!PC2.IsNull() && pr->IsPointOnCurveOnSurface(PC2,Su,L)) {
gp_Pnt2d p2d = PC2->Value(pr->Parameter());
Controlp = Su->Value(p2d.X(),p2d.Y());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),
BRepCheck_InvalidPointOnCurveOnSurface);
}
}
itpr.Next();
}
}
itcr.Next();
}
if (myMap(S).IsEmpty()) {
myMap(S).Append(BRepCheck_NoError);
}
}
break;
case TopAbs_FACE:
{
Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
const TopLoc_Location& Floc = S.Location();
const TopLoc_Location& TFloc = TF->Location();
const Handle(Geom_Surface)& Su = TF->Surface();
TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Vertex(myShape));
Tol = Max(Tol,BRep_Tool::Tolerance(TopoDS::Face(S))); // a voir
Tol *= Tol;
BRep_ListIteratorOfListOfPointRepresentation itpr(TV->Points());
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
if (pr->IsPointOnSurface(Su,L)) {
Controlp = Su->Value(pr->Parameter(),pr->Parameter2());
Controlp.Transform(L.Transformation());
if (prep.SquareDistance(Controlp)> Tol) {
BRepCheck::Add(myMap(S),BRepCheck_InvalidPointOnSurface);
}
}
itpr.Next();
}
if (myMap(S).IsEmpty()) {
myMap(S).Append(BRepCheck_NoError);
}
}
default:
break;
}
}
//=======================================================================
//function : Blind
//purpose :
//=======================================================================
void BRepCheck_Vertex::Blind()
{
if (myBlind) {
return;
}
// modified by NIZHNY-MKK Fri May 7 16:43:38 2004.BEGIN
// The body of this function is removed because of its useless
// (see specification "Substitution existing set of evaluation DRAW commands to one").
// Check all the representations of the vertex. (i-e checks the TVertex
// BRepCheck_ListOfStatus& lst = myMap(myShape);
// lst.Clear(); // there was NoError...
// Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &myShape.TShape());
// const gp_Pnt& prep = TV->Pnt();
// Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Vertex(myShape));
// Tol *= Tol;
// gp_Pnt Controlp;
// BRep_ListIteratorOfListOfPointRepresentation itpr(TV->Points());
// BRepCheck_Status stat=BRepCheck_NoError;
// while (itpr.More()) {
// const Handle(BRep_PointRepresentation)& pr = itpr.Value();
// const TopLoc_Location& loc = pr->Location();
// if (pr->IsPointOnCurve()) {
// Controlp = pr->Curve()->Value(pr->Parameter());
// stat = BRepCheck_InvalidPointOnCurve;
// }
// else if (pr->IsPointOnCurveOnSurface()) {
// gp_Pnt2d Puv = pr->PCurve()->Value(pr->Parameter());
// Controlp = pr->Surface()->Value(Puv.X(),Puv.Y());
// stat = BRepCheck_InvalidPointOnCurveOnSurface;
// }
// else if (pr->IsPointOnSurface()) {
// Controlp = pr->Surface()->Value(pr->Parameter(),pr->Parameter2());
// stat = BRepCheck_InvalidPointOnSurface;
// }
// Controlp.Transform(loc.Transformation());
// if (prep.SquareDistance(Controlp) > Tol) {
// BRepCheck::Add(lst,stat);
// }
// itpr.Next();
// }
// if (lst.IsEmpty()) {
// lst.Append(BRepCheck_NoError);
// }
// modified by NIZHNY-MKK Fri May 7 16:43:45 2004.END
myBlind = Standard_True;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
Standard_Real BRepCheck_Vertex::Tolerance()
{
// Check all the representations of the vertex. (i-e checks the TVertex
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &myShape.TShape());
const gp_Pnt& prep = TV->Pnt();
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Vertex(myShape));
Tol *= Tol;
gp_Pnt Controlp;
Controlp = prep;
BRep_ListIteratorOfListOfPointRepresentation itpr(TV->Points());
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
const TopLoc_Location& loc = pr->Location();
if (pr->IsPointOnCurve()) {
if (!pr->Curve().IsNull())
Controlp = pr->Curve()->Value(pr->Parameter());
}
else if (pr->IsPointOnCurveOnSurface()) {
gp_Pnt2d Puv = pr->PCurve()->Value(pr->Parameter());
Controlp = pr->Surface()->Value(Puv.X(),Puv.Y());
}
else if (pr->IsPointOnSurface()) {
Controlp = pr->Surface()->Value(pr->Parameter(),pr->Parameter2());
}
Controlp.Transform(loc.Transformation());
if (prep.SquareDistance(Controlp) > Tol) {
Tol = prep.SquareDistance(Controlp);
}
itpr.Next();
}
return sqrt(Tol*1.05);
}

128
src/BRepCheck/BRepCheck_Wire.cdl Executable file
View File

@@ -0,0 +1,128 @@
-- File: BRepCheck_Wire.cdl
-- Created: Tue Dec 12 17:47:00 1995
-- Author: Jacques GOUSSARD
-- <jag@bravox>
---Copyright: Matra Datavision 1995
--
-- modified by eap Fri Dec 21 12:17:40 2001 (bug OCC35)
-- Closed2d() added
class Wire from BRepCheck inherits Result from BRepCheck
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Wire from TopoDS,
Edge from TopoDS,
IndexedDataMapOfShapeListOfShape from TopTools,
Status from BRepCheck
is
Create(W: Wire from TopoDS)
returns mutable Wire from BRepCheck;
InContext(me: mutable; ContextShape: Shape from TopoDS);
---Purpose: if <ContextShape> is a face, consequently checks
-- SelfIntersect(), Closed(), Orientation() and
-- Closed2d until faulty is found
Minimum(me: mutable);
---Purpose: checks that the wire is not empty and "connex".
-- Called by constructor
Blind(me: mutable);
---Purpose: Does nothing
Closed(me: mutable; Update: Boolean from Standard = Standard_False)
---Purpose: Checks if the oriented edges of the wire give a
-- closed wire. If the wire is closed, returns
-- BRepCheck_NoError. Warning : if the first and
-- last edge are infinite, the wire will be
-- considered as a closed one. If <Update> is set to
-- Standard_True, registers the status in the list.
-- May return (and registers):
-- **BRepCheck_NotConnected, if wire is not
-- topologically closed
-- **BRepCheck_RedundantEdge, if an edge is in wire
-- more than 3 times or in case of 2 occurences if
-- not with FORWARD and REVERSED orientation.
-- **BRepCheck_NoError
returns Status from BRepCheck
is static;
Closed2d(me: mutable; F : Face from TopoDS;
Update: Boolean from Standard = Standard_False)
---Purpose: Checks if edges of the wire give a wire closed in
-- 2d space.
-- Returns BRepCheck_NoError, or BRepCheck_NotClosed
-- If <Update> is set to Standard_True, registers the
-- status in the list.
returns Status from BRepCheck
is static;
Orientation(me: mutable; F : Face from TopoDS;
Update: Boolean from Standard = Standard_False)
---Purpose: Checks if the oriented edges of the wire are
-- correctly oriented. An internal call is made to
-- the method Closed. If no face exists, call the
-- method with a null face (TopoDS_face()). If
-- <Update> is set to Standard_True, registers the
-- status in the list.
-- May return (and registers):
-- BRepCheck_InvalidDegeneratedFlag,
-- BRepCheck_BadOrientationOfSubshape,
-- BRepCheck_NotClosed,
-- BRepCheck_NoError
returns Status from BRepCheck
is static;
SelfIntersect(me: mutable; F : Face from TopoDS;
E1,E2 : out Edge from TopoDS;
Update: Boolean from Standard = Standard_False)
---Purpose: Checks if the wire intersect itself on the face
-- <F>. <E1> and <E2> are the first intersecting
-- edges found. <E2> may be a null edge when a
-- self-intersecting edge is found.If <Update> is set
-- to Standard_True, registers the status in the
-- list.
-- May return (and register):
-- BRepCheck_EmptyWire,
-- BRepCheck_SelfIntersectingWire,
-- BRepCheck_NoCurveOnSurface,
-- BRepCheck_NoError
returns Status from BRepCheck
is static;
GeometricControls(me)
---Purpose: report SelfIntersect() check would be (is) done
returns Boolean from Standard
is static;
GeometricControls(me: mutable; B: Boolean from Standard)
---Purpose: set SelfIntersect() to be checked
is static;
fields
-- myNbori : Integer from Standard; -- not used (eap)
myCdone : Boolean from Standard; -- Closed() or Oriented() is done
myCstat : Status from BRepCheck; -- result of Closed() or Oriented()
myMapVE : IndexedDataMapOfShapeListOfShape from TopTools;
myGctrl : Boolean from Standard; -- do check SelfIntersect() or not
end Wire;

1780
src/BRepCheck/BRepCheck_Wire.cxx Executable file

File diff suppressed because it is too large Load Diff