// Created on: 2000-03-16
-// Created by: Peter KURNEV
-// Copyright (c) 2000-2012 OPEN CASCADE SAS
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-
-#include <BOPTest.ixx>
-#include <stdio.h>
-#include <TCollection_AsciiString.hxx>
-#include <TColStd_IndexedMapOfTransient.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <Draw.hxx>
+#include <BOPTest.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_ListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_TFace.hxx>
+#include <BRep_Tool.hxx>
+#include <BRep_TVertex.hxx>
+#include <BRepLib.hxx>
#include <DBRep.hxx>
-#include <gp_Pnt2d.hxx>
-
-#include <Geom_Curve.hxx>
+#include <Draw.hxx>
#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
-
+#include <gp_Pnt2d.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_IndexedMapOfTransient.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
-
-#include <TopAbs_Orientation.hxx>
-
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-
-#include <BRep_TVertex.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_ListOfCurveRepresentation.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRep_TFace.hxx>
-
-#include <TopLoc_Location.hxx>
-
-#include <BRepLib.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-static
- Standard_Integer breducetolerance (Draw_Interpretor&, Standard_Integer, const char** );
-static
- Standard_Integer btolx (Draw_Interpretor&, Standard_Integer, const char** );
-static
- Standard_Integer bopaddpcs (Draw_Interpretor&, Standard_Integer, const char** );
+#include <stdio.h>
//
static
void ProcessVertex(const TopoDS_Vertex&,
- const TopTools_ListOfShape&,
- const TopTools_ListOfShape&);
+ const TopTools_ListOfShape&,
+ const TopTools_ListOfShape&);
static
void ProcessEdge(const TopoDS_Edge&, const Standard_Real);
void ReduceFaceTolerance (const TopoDS_Shape&);
static
- void ReduceEdgeTolerance (const TopoDS_Shape&, const Standard_Real);
-
+ void ReduceEdgeTolerance (const TopoDS_Shape&,
+ const Standard_Real);
+static
+ void PreparePCurves(const TopoDS_Shape& ,
+ Draw_Interpretor& di);
+//
+static Standard_Integer breducetolerance (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer btolx (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer bopaddpcs (Draw_Interpretor&, Standard_Integer, const char** );
//=======================================================================
//function : TolerCommands
//purpose :
done = Standard_True;
// Chapter's name
- const char* g = "CCR commands";
- //
- theCommands.Add("breducetolerance" , "Use >breducetolerance Shape [maxTol=0.01]", __FILE__, breducetolerance, g);
- theCommands.Add("btolx" , "Use >btolx Shape [minTol=1.e-7]", __FILE__, btolx, g);
- theCommands.Add("bopaddpcs" , "Use >bopaddpcs Shape" , __FILE__, bopaddpcs, g);
+ const char* g = "BOPTest commands";
+ //
+ theCommands.Add("breducetolerance" , "use breducetolerance Shape",
+ __FILE__, breducetolerance, g);
+ theCommands.Add("btolx" , "use btolx Shape [minTol=1.e-7]",
+ __FILE__, btolx, g);
+ theCommands.Add("bopaddpcs" , "Use >bopaddpcs Shape",
+ __FILE__, bopaddpcs, g);
}
-
//=======================================================================
//function : btolx
//purpose :
//=======================================================================
-Standard_Integer btolx(Draw_Interpretor& di, Standard_Integer n, const char** a)
+Standard_Integer btolx(Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
{
if (n<2) {
- di << " Use >btolx Shape [minTol=1.e-7]\n";
+ di << " use btolx Shape [minTol=1.e-7]\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
- di << " Null shape is not allowed \n";
+ di << " Null shape is not allowed\n";
return 1;
}
//
//function : ReduceEdgeTolerance
//purpose :
//=======================================================================
-void ReduceEdgeTolerance (const TopoDS_Shape& aS, const Standard_Real aTolTreshold)
+void ReduceEdgeTolerance (const TopoDS_Shape& aS,
+ const Standard_Real aTolTreshold)
{
Standard_Integer i, aNbE;
TopTools_IndexedMapOfShape aEMap;
const TopoDS_Edge& aE= TopoDS::Edge(aEMap(j));
aTolE =BRep_Tool::Tolerance(aE);
if (aTolE<aTolx) {
- aTolx=aTolE;
+ aTolx=aTolE;
}
}
aTolE=(aTolx>aTolEMin) ? aTolx : aTolEMin;
{
Standard_Integer i, aNbV;
TopTools_IndexedDataMapOfShapeListOfShape aVEMap, aVFMap;
-
+
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aVFMap);
void ProcessEdge(const TopoDS_Edge& aE, const Standard_Real aTolTreshold)
{
Standard_Integer i, aNb=23;
- Standard_Real aTolE, aD2, aTolMax2, aT1, aT2, aT, dT;
+ Standard_Real aD2, aTolMax2, aT1, aT2, aT, dT;
gp_Pnt aPC3D, aP3D;
gp_Pnt2d aPC2D;
else if (cr->IsCurveOnSurface()) {
const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
if (aC2D.IsNull()) {
- continue;
+ continue;
}
// Surface
const Handle(Geom_Surface)& aS=cr->Surface();
//
// 2D-point treatment
for (i=0; i<=aNb; ++i) {
- aT=aT1+i*dT;
- if (i==aNb) {
- aT=aT2;
- }
- aPC3D=aC3D->Value(aT);
- aPC2D=aC2D->Value(aT);
- aS->D0(aPC2D.X(), aPC2D.Y(), aP3D);
- aP3D.Transform(L.Transformation());
- aD2=aPC3D.SquareDistance(aP3D);
- if (aD2 > aTolMax2) {
- aTolMax2=aD2;
- }
+ aT=aT1+i*dT;
+ if (i==aNb) {
+ aT=aT2;
+ }
+ aPC3D=aC3D->Value(aT);
+ aPC2D=aC2D->Value(aT);
+ aS->D0(aPC2D.X(), aPC2D.Y(), aP3D);
+ aP3D.Transform(L.Transformation());
+ aD2=aPC3D.SquareDistance(aP3D);
+ if (aD2 > aTolMax2) {
+ aTolMax2=aD2;
+ }
}
} //if (cr->IsCurveOnSurface())
}//for (; itcr.More(); itcr.Next())
return;
}
//
- aTolE =BRep_Tool::Tolerance(aE);
//
aTolMax2=sqrt(aTolMax2);
//purpose :
//=======================================================================
void ProcessVertex(const TopoDS_Vertex& aV,
- const TopTools_ListOfShape& aLE,
- const TopTools_ListOfShape& aLF)
+ const TopTools_ListOfShape& aLE,
+ const TopTools_ListOfShape& aLF)
{
- Standard_Real aTol, aTol2, aD2, aTolMax2, aTolE, aParam;
+ Standard_Real aTol, aD2, aTolMax2, aTolE, aParam;
gp_Pnt aPC3D;
gp_Pnt2d aPC2D;
TopAbs_Orientation anOrV;
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &aV.TShape());
const gp_Pnt& aPV3D = TV->Pnt();
aTol =BRep_Tool::Tolerance(aV);
- aTol2=aTol*aTol;
//
anIt.Initialize(aLE);
for (; anIt.More(); anIt.Next()) {
if (aProcessedEdges.Contains(aE)) {
continue;
}
- aProcessedEdges.Add(aE);
+ aProcessedEdges.Add(aE);
//
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape());
const TopLoc_Location& Eloc = aE.Location();
const TopoDS_Vertex& aVx=TopoDS::Vertex(aVExp.Current());
//
if (!aVx.IsSame(aV)) {
- continue;
+ continue;
}
//
anOrV=aVx.Orientation();
if (!(anOrV==TopAbs_FORWARD || anOrV==TopAbs_REVERSED)) {
- continue;
+ continue;
}
//
const BRep_ListOfCurveRepresentation& aLCR=TE->Curves();
itcr.Initialize(aLCR);
for (; itcr.More(); itcr.Next()) {
- const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
- const TopLoc_Location& loc = cr->Location();
- TopLoc_Location L = (Eloc * loc).Predivided(aV.Location());
- //
- // 3D-Curve
- if (cr->IsCurve3D()) {
- const Handle(Geom_Curve)& aC3D = cr->Curve3D();
- //
- if (aC3D.IsNull()) {
- continue;
- }
- // 3D-point treatment
- aParam=BRep_Tool::Parameter(aVx, aE);
- aPC3D= aC3D->Value(aParam);
- aPC3D.Transform(L.Transformation());
- aD2=aPV3D.SquareDistance(aPC3D);
- if (aD2 > aTolMax2) {
- aTolMax2=aD2;
- }
- //
- }//if (cr->IsCurve3D())
- //
- // 2D-Curve
- else if (cr->IsCurveOnSurface()) {
- const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
- if (aC2D.IsNull()) {
- continue;
- }
- // Surface
- const Handle(Geom_Surface)& aS=cr->Surface();
- //
- // 2D-point treatment
- aParam=BRep_Tool::Parameter(aVx, aE, aS, L);
- aPC2D=aC2D->Value(aParam);
- aS->D0(aPC2D.X(), aPC2D.Y(), aPC3D);
- aPC3D.Transform(L.Transformation());
- aD2=aPV3D.SquareDistance(aPC3D);
- if (aD2 > aTolMax2) {
- aTolMax2=aD2;
- }
- } //if (cr->IsCurveOnSurface())
-
+ const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ const TopLoc_Location& loc = cr->Location();
+ TopLoc_Location L = (Eloc * loc).Predivided(aV.Location());
+ //
+ // 3D-Curve
+ if (cr->IsCurve3D()) {
+ const Handle(Geom_Curve)& aC3D = cr->Curve3D();
+ //
+ if (aC3D.IsNull()) {
+ continue;
+ }
+ // 3D-point treatment
+ aParam=BRep_Tool::Parameter(aVx, aE);
+ aPC3D= aC3D->Value(aParam);
+ aPC3D.Transform(L.Transformation());
+ aD2=aPV3D.SquareDistance(aPC3D);
+ if (aD2 > aTolMax2) {
+ aTolMax2=aD2;
+ }
+ //
+ }//if (cr->IsCurve3D())
+ //
+ // 2D-Curve
+ else if (cr->IsCurveOnSurface()) {
+ const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
+ if (aC2D.IsNull()) {
+ continue;
+ }
+ // Surface
+ const Handle(Geom_Surface)& aS=cr->Surface();
+ //
+ // 2D-point treatment
+ aParam=BRep_Tool::Parameter(aVx, aE, aS, L);
+ aPC2D=aC2D->Value(aParam);
+ aS->D0(aPC2D.X(), aPC2D.Y(), aPC3D);
+ aPC3D.Transform(L.Transformation());
+ aD2=aPV3D.SquareDistance(aPC3D);
+ if (aD2 > aTolMax2) {
+ aTolMax2=aD2;
+ }
+ } //if (cr->IsCurveOnSurface())
+
}//for (; itcr.More(); itcr.Next())
}//for (; aVExp.More(); aVExp.Next())
}//for (; anIt.More(); anIt.Next())
//purpose :
//=======================================================================
Standard_Integer breducetolerance(Draw_Interpretor& di,
- Standard_Integer n,
- const char** a)
+ Standard_Integer n,
+ const char** a)
{
if (n<2) {
- di << " Use >bupdatetolerance Shape\n";
+ di << " use bupdatetolerance Shape\n";
return 1;
}
return 0;
}
//
-//
-static
- void PreparePCurves(const TopoDS_Shape& aShape, Draw_Interpretor& di);
-
//=======================================================================
//function : bopaddpcs
-//purpose : Some Edgesdo not contain P-Curveson Faces to which they belong to.
+//purpose : Some Edges do not contain P-Curves on Faces to which
+// they belong to.
// These faces usually based on Geom_Plane surface.
// To prevent sophisticated treatment the Command "bopaddpcs:
// adds P-Curves for the edges .
//=======================================================================
-Standard_Integer bopaddpcs(Draw_Interpretor& di, Standard_Integer n, const char** a)
+Standard_Integer bopaddpcs(Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
{
if (n<2) {
di << " Use >bopaddpcs Shape\n";
DBRep::Set (a[1], aS);
return 0;
}
-
//=======================================================================
//function : PreparePCurves
//purpose :
BRep_ListIteratorOfListOfCurveRepresentation itcr;
itcr.Initialize(aLCR);
for (; itcr.More(); itcr.Next()) {
- const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
- //
- if (cr->IsCurveOnSurface()) {
- const Handle(Geom_Surface)& aSCR=cr->Surface();
- aSCRMap.Add(aSCR);
- }
- //
+ const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ //
+ if (cr->IsCurveOnSurface()) {
+ const Handle(Geom_Surface)& aSCR=cr->Surface();
+ aSCRMap.Add(aSCR);
+ }
+ //
}
//
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF, aLoc);
if (!aSCRMap.Contains(aS)) {
- // try to obtain 2D curve
- aC2D=BRep_Tool::CurveOnSurface(aE, aS, aLoc, aT1, aT2);
- if (aC2D.IsNull()) {
- di << " Warning: Can not obtain P-Curve\n";
- continue;
- }
- else {
- aBB.UpdateEdge(aE, aC2D, aF, aTolE);
- }
+ // try to obtain 2D curve
+ aC2D=BRep_Tool::CurveOnSurface(aE, aS, aLoc, aT1, aT2);
+ if (aC2D.IsNull()) {
+ di << " Warning: Can not obtain P-Curve\n";
+ continue;
+ }
+ else {
+ aBB.UpdateEdge(aE, aC2D, aF, aTolE);
+ }
}
}
}