StdPrs_ToolRFace no skips curves with NULL curves.
Code has been cleaned up from duplicated checks, redundant casts
and dummy Adaptor2d_Curve2dPtr typedef.
StdSelect_BRepSelectionTool::GetSensitiveForFace() now catches
Standard_NullObject exception to skip invalid Edges.
+++ /dev/null
-// Created on: 1992-10-08
-// Created by: Isabelle GRIGNON
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// 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.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Adaptor2d_Curve2dPtr_HeaderFile
-#define _Adaptor2d_Curve2dPtr_HeaderFile
-
-class Adaptor2d_Curve2d;
-typedef Adaptor2d_Curve2d* Adaptor2d_Curve2dPtr;
-
-#endif // _Adaptor2d_Curve2dPtr_HeaderFile
Adaptor2d_Curve2d.cxx
Adaptor2d_Curve2d.hxx
-Adaptor2d_Curve2dPtr.hxx
Adaptor2d_GenHCurve2d.gxx
Adaptor2d_GenHCurve2d.lxx
Adaptor2d_HCurve2d.cxx
Initialize(E,F);
}
+//=======================================================================
+//function : Reset
+//purpose :
+//=======================================================================
+void BRepAdaptor_Curve::Reset()
+{
+ myCurve.Reset();
+ myConSurf.Nullify();
+ myEdge.Nullify();
+ myTrsf = gp_Trsf();
+}
+
//=======================================================================
//function : Initialize
//purpose :
//! is raised if the edge does not have a pcurve on
//! the face.
Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F);
-
+
+ //! Reset currently loaded curve (undone Load()).
+ Standard_EXPORT void Reset();
+
//! Sets the Curve <me> to acces to the geometry of
//! edge <E>.
Standard_EXPORT void Initialize (const TopoDS_Edge& E);
Load(theCrv, theUFirst, theULast);
}
+//=======================================================================
+//function : Reset
+//purpose :
+//=======================================================================
+void Geom2dAdaptor_Curve::Reset()
+{
+ myTypeCurve = GeomAbs_OtherCurve;
+ myCurve.Nullify();
+ myCurveCache.Nullify();
+ myNestedEvaluator.Nullify();
+ myBSplineCurve.Nullify();
+ myFirst = myLast = 0.0;
+}
//=======================================================================
//function : Load
//! ConstructionError is raised if Ufirst>Ulast
Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
-
+
+ //! Reset currently loaded curve (undone Load()).
+ Standard_EXPORT void Reset();
+
void Load (const Handle(Geom2d_Curve)& C);
//! ConstructionError is raised if Ufirst>Ulast
}
}
+//=======================================================================
+//function : Reset
+//purpose :
+//=======================================================================
+void GeomAdaptor_Curve::Reset()
+{
+ myTypeCurve = GeomAbs_OtherCurve;
+ myCurve.Nullify();
+ myNestedEvaluator.Nullify();
+ myBSplineCurve.Nullify();
+ myCurveCache.Nullify();
+ myFirst = myLast = 0.0;
+}
//=======================================================================
//function : Load
//! ConstructionError is raised if Ufirst>Ulast
GeomAdaptor_Curve(const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
-
+
+ //! Reset currently loaded curve (undone Load()).
+ Standard_EXPORT void Reset();
+
void Load (const Handle(Geom_Curve)& C);
//! ConstructionError is raised if Ufirst>Ulast
for (anEdgeTool.Init(); anEdgeTool.More(); anEdgeTool.Next())
{
TopAbs_Orientation anOrientation = anEdgeTool.Orientation();
- if (anOrientation != TopAbs_FORWARD && anOrientation != TopAbs_REVERSED)
- {
- continue;
- }
-
- Adaptor2d_Curve2dPtr anEdgeCurve = anEdgeTool.Value();
+ const Adaptor2d_Curve2d* anEdgeCurve = &anEdgeTool.Value();
if (anEdgeCurve->GetType() != GeomAbs_Line)
{
GCPnts_QuasiUniformDeflection aSampler (*anEdgeCurve, aSamplerDeflection);
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <StdPrs_ToolRFace.hxx>
#include <Adaptor2d_Curve2d.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_HSurface.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <StdPrs_ToolRFace.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : StdPrs_ToolRFace
-//purpose :
+//purpose :
//=======================================================================
StdPrs_ToolRFace::StdPrs_ToolRFace()
+: myHasNullCurves (Standard_False)
{
}
//=======================================================================
//function : StdPrs_ToolRFace
-//purpose :
+//purpose :
//=======================================================================
-
-StdPrs_ToolRFace::StdPrs_ToolRFace(const Handle(BRepAdaptor_HSurface)& aSurface) :
- myFace(((BRepAdaptor_Surface*)&(aSurface->Surface()))->Face())
+StdPrs_ToolRFace::StdPrs_ToolRFace (const Handle(BRepAdaptor_HSurface)& theSurface)
+: myFace (theSurface->ChangeSurface().Face()),
+ myHasNullCurves (Standard_False)
{
myFace.Orientation(TopAbs_FORWARD);
}
//=======================================================================
-//function : IsOriented
-//purpose :
-//=======================================================================
-
-Standard_Boolean StdPrs_ToolRFace::IsOriented () const {
-
- return Standard_True;
-
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-void StdPrs_ToolRFace::Init()
-{
- myExplorer.Init(myFace,TopAbs_EDGE);
- if (myExplorer.More()) {
- Standard_Real U1,U2;
- const Handle(Geom2d_Curve)& C =
- BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
- myFace,
- U1,U2);
- DummyCurve.Load(C,U1,U2);
- }
-}
-
-//=======================================================================
-//function : More
-//purpose :
-//=======================================================================
-
-Standard_Boolean StdPrs_ToolRFace::More() const
-{
- return myExplorer.More();
-}
-
-//=======================================================================
-//function : Next
-//purpose :
+//function : next
+//purpose :
//=======================================================================
-
-void StdPrs_ToolRFace::Next()
+void StdPrs_ToolRFace::next()
{
- myExplorer.Next();
-
- if (myExplorer.More()) {
+ Standard_Real aParamU1, aParamU2;
+ for (; myExplorer.More(); myExplorer.Next())
+ {
// skip INTERNAL and EXTERNAL edges
- while (myExplorer.More() && (myExplorer.Current().Orientation() == TopAbs_INTERNAL
- || myExplorer.Current().Orientation() == TopAbs_EXTERNAL))
- myExplorer.Next();
- if (myExplorer.More()) {
- Standard_Real U1,U2;
- const Handle(Geom2d_Curve)& C =
- BRep_Tool::CurveOnSurface(TopoDS::Edge(myExplorer.Current()),
- myFace,
- U1,U2);
- if ( !C.IsNull() )
- DummyCurve.Load(C,U1,U2);
+ if (myExplorer.Current().Orientation() != TopAbs_FORWARD
+ && myExplorer.Current().Orientation() != TopAbs_REVERSED)
+ {
+ continue;
}
- }
-}
-
-//=======================================================================
-//function : Value
-//purpose :
-//=======================================================================
-Adaptor2d_Curve2dPtr StdPrs_ToolRFace::Value() const
-{
- return (Adaptor2d_Curve2dPtr)&DummyCurve;
-}
-
-//=======================================================================
-//function : Orientation
-//purpose :
-//=======================================================================
+ if (Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface (TopoDS::Edge (myExplorer.Current()), myFace, aParamU1, aParamU2))
+ {
+ myCurve.Load (aCurve, aParamU1, aParamU2);
+ return;
+ }
+ else
+ {
+ myHasNullCurves = Standard_True;
+ }
+ }
-TopAbs_Orientation StdPrs_ToolRFace::Orientation () const {
- return myExplorer.Current().Orientation();
+ myCurve.Reset();
}
-
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom2dAdaptor_Curve.hxx>
-#include <Standard_Boolean.hxx>
-#include <Adaptor2d_Curve2dPtr.hxx>
#include <TopAbs_Orientation.hxx>
class BRepAdaptor_HSurface;
-
-
+//! Iterator over 2D curves restricting a face (skipping internal/external edges).
+//! In addition, the algorithm skips NULL curves - IsInvalidGeometry() can be checked if this should be handled within algorithm.
class StdPrs_ToolRFace
{
public:
DEFINE_STANDARD_ALLOC
-
+ //! Empty constructor.
Standard_EXPORT StdPrs_ToolRFace();
-
+
+ //! Constructor with initialization.
Standard_EXPORT StdPrs_ToolRFace(const Handle(BRepAdaptor_HSurface)& aSurface);
- Standard_EXPORT Standard_Boolean IsOriented() const;
+ //! Return TRUE indicating that iterator looks only for oriented edges.
+ Standard_Boolean IsOriented() const { return Standard_True; }
- Standard_EXPORT void Init();
-
- Standard_EXPORT Standard_Boolean More() const;
-
- Standard_EXPORT void Next();
-
- Standard_EXPORT Adaptor2d_Curve2dPtr Value() const;
-
- Standard_EXPORT TopAbs_Orientation Orientation() const;
-
+ //! Move iterator to the first element.
+ void Init()
+ {
+ myExplorer.Init (myFace, TopAbs_EDGE);
+ next();
+ }
+ //! Return TRUE if iterator points to the curve.
+ Standard_Boolean More() const { return myExplorer.More(); }
+ //! Go to the next curve in the face.
+ void Next()
+ {
+ myExplorer.Next();
+ next();
+ }
-protected:
-
-
+ //! Return current curve.
+ const Adaptor2d_Curve2d& Value() const { return myCurve; }
+ //! Return current edge orientation.
+ TopAbs_Orientation Orientation() const { return myExplorer.Current().Orientation(); }
+ //! Return TRUE if NULL curves have been skipped.
+ Standard_Boolean IsInvalidGeometry() const { return myHasNullCurves; }
private:
+ //! Find nearest valid item for the iterator.
+ Standard_EXPORT void next();
+private:
TopoDS_Face myFace;
TopExp_Explorer myExplorer;
- Geom2dAdaptor_Curve DummyCurve;
-
+ Geom2dAdaptor_Curve myCurve;
+ Standard_Boolean myHasNullCurves;
};
-
-
-
-
-
-
#endif // _StdPrs_ToolRFace_HeaderFile
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
- if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
+ const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
if (TheRCurve->GetType() != GeomAbs_Line) {
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, ddefle);
if (UDP.IsDone()) {
tabP.Append(P1);
}
}
- }
}
#ifdef OCCT_DEBUG
else {
UMax = VMax = RealFirst();
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
+ const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
u = TheRCurve->FirstParameter();
v = TheRCurve->LastParameter();
step = ( v - u) / nbPoints;
gp_Pnt dummypnt;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
- if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
+ const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, Deflection);
if (UDP.IsDone()) {
Standard_Integer NumberOfPoints = UDP.NbPoints();
cout << "Cannot evaluate curve on surface"<<endl;
}
#endif
- }
}
// draw the isos
for (aToolRst.Init(); aToolRst.More(); aToolRst.Next())
{
- Adaptor2d_Curve2dPtr aRCurve = aToolRst.Value();
- BndLib_Add2dCurve::Add(*aRCurve, Precision::PConfusion(), aBndBox);
+ const Adaptor2d_Curve2d& aRCurve = aToolRst.Value();
+ BndLib_Add2dCurve::Add(aRCurve, Precision::PConfusion(), aBndBox);
}
if (!aBndBox.IsVoid())
aBndBox.Get(aUMin, aVMin, aUMax, aVMax);
for (aToolRst.Init(); aToolRst.More(); aToolRst.Next())
{
TopAbs_Orientation anOrientation = aToolRst.Orientation();
- if (anOrientation == TopAbs_FORWARD || anOrientation == TopAbs_REVERSED)
+ const Adaptor2d_Curve2d* aRCurve = &aToolRst.Value();
+ anU1 = aRCurve->FirstParameter();
+ anU2 = aRCurve->LastParameter();
+ if (aRCurve->GetType() != GeomAbs_Line)
{
- Adaptor2d_Curve2dPtr aRCurve = aToolRst.Value();
- anU1 = aRCurve->FirstParameter();
- anU2 = aRCurve->LastParameter();
- if (aRCurve->GetType() != GeomAbs_Line)
+ aDU = (anU2-anU1)/(aNbPoints-1);
+ aPoint2 = aRCurve->Value(anU1);
+ for (anI = 2; anI <= aNbPoints; ++anI)
{
- aDU = (anU2-anU1)/(aNbPoints-1);
- aPoint2 = aRCurve->Value(anU1);
- for (anI = 2; anI <= aNbPoints; ++anI)
- {
- anU = anU1 + (anI-1)*aDU;
- aPoint1 = aPoint2;
- aPoint2 = aRCurve->Value(anU);
- if(anOrientation == TopAbs_FORWARD )
- anIsoBuild.Trim(aPoint1,aPoint2);
- else
- anIsoBuild.Trim(aPoint2,aPoint1);
- }
- }
- else {
- aPoint1 = aRCurve->Value(anU1);
- aPoint2 = aRCurve->Value(anU2);
+ anU = anU1 + (anI-1)*aDU;
+ aPoint1 = aPoint2;
+ aPoint2 = aRCurve->Value(anU);
if(anOrientation == TopAbs_FORWARD )
anIsoBuild.Trim(aPoint1,aPoint2);
else
anIsoBuild.Trim(aPoint2,aPoint1);
}
}
+ else {
+ aPoint1 = aRCurve->Value(anU1);
+ aPoint2 = aRCurve->Value(anU2);
+ if(anOrientation == TopAbs_FORWARD )
+ anIsoBuild.Trim(aPoint1,aPoint2);
+ else
+ anIsoBuild.Trim(aPoint2,aPoint1);
+ }
}
// Draw the isos
for (aToolRst.Init(); aToolRst.More(); aToolRst.Next())
{
- Adaptor2d_Curve2dPtr aRCurve = aToolRst.Value();
+ const Adaptor2d_Curve2d* aRCurve = &aToolRst.Value();
anU = aRCurve->FirstParameter();
aV = aRCurve->LastParameter();
if (aRCurve->GetType() != GeomAbs_Line)
for (aToolRst.Init(); aToolRst.More(); aToolRst.Next())
{
TopAbs_Orientation Orient = aToolRst.Orientation();
- if (Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED)
- {
- Adaptor2d_Curve2dPtr aRCurve = aToolRst.Value();
- anU1 = aRCurve->FirstParameter();
- anU2 = aRCurve->LastParameter();
- if (aRCurve->GetType() != GeomAbs_Line) {
- aDU = (anU2-anU1)/(aNbPoints-1);
- aPoint2 = aRCurve->Value(anU1);
- for (anI = 2; anI <= aNbPoints; anI++) {
- anU = anU1 + (anI-1)*aDU;
- aPoint1 = aPoint2;
- aPoint2 = aRCurve->Value(anU);
- if(Orient == TopAbs_FORWARD )
- anIsoBuild.Trim(aPoint1,aPoint2);
- else
- anIsoBuild.Trim(aPoint2,aPoint1);
- }
- }
- else {
- aPoint1 = aRCurve->Value(anU1);
- aPoint2 = aRCurve->Value(anU2);
+ const Adaptor2d_Curve2d* aRCurve = &aToolRst.Value();
+ anU1 = aRCurve->FirstParameter();
+ anU2 = aRCurve->LastParameter();
+ if (aRCurve->GetType() != GeomAbs_Line) {
+ aDU = (anU2-anU1)/(aNbPoints-1);
+ aPoint2 = aRCurve->Value(anU1);
+ for (anI = 2; anI <= aNbPoints; anI++) {
+ anU = anU1 + (anI-1)*aDU;
+ aPoint1 = aPoint2;
+ aPoint2 = aRCurve->Value(anU);
if(Orient == TopAbs_FORWARD )
anIsoBuild.Trim(aPoint1,aPoint2);
else
anIsoBuild.Trim(aPoint2,aPoint1);
- }
+ }
+ }
+ else {
+ aPoint1 = aRCurve->Value(anU1);
+ aPoint2 = aRCurve->Value(anU2);
+ if(Orient == TopAbs_FORWARD )
+ anIsoBuild.Trim(aPoint1,aPoint2);
+ else
+ anIsoBuild.Trim(aPoint2,aPoint1);
}
}
BRepAdaptor_Curve cu3d;
for (BRepTools_WireExplorer aWireExplorer (aWire); aWireExplorer.More(); aWireExplorer.Next())
{
- cu3d.Initialize (aWireExplorer.Current());
+ try
+ {
+ OCC_CATCH_SIGNALS
+ cu3d.Initialize (aWireExplorer.Current());
+ }
+ catch (Standard_NullObject)
+ {
+ continue;
+ }
+
Standard_Real wf = 0.0, wl = 0.0;
BRep_Tool::Range (aWireExplorer.Current(), wf, wl);
if (Abs (wf - wl) <= Precision::Confusion())
gp_Pnt dummypnt;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
- if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
+ const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
if (TheRCurve->GetType() != GeomAbs_Line) {
GCPnts_QuasiUniformDeflection UDP(*TheRCurve, Deflection);
if (UDP.IsDone()) {
else
isobuild.Trim(P2,P1);
}
- }
}
// draw the isos
Bnd_Box2d B;
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
- BndLib_Add2dCurve::Add(*TheRCurve, Precision::PConfusion(), B);
+ const Adaptor2d_Curve2d& TheRCurve = ToolRst.Value();
+ BndLib_Add2dCurve::Add(TheRCurve, Precision::PConfusion(), B);
}
B.Get(UMin, VMin, UMax, VMax);
for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
TopAbs_Orientation Orient = ToolRst.Orientation();
- if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
- Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
+ const Adaptor2d_Curve2d* TheRCurve = &ToolRst.Value();
U1 = TheRCurve->FirstParameter();
U2 = TheRCurve->LastParameter();
if (TheRCurve->GetType() != GeomAbs_Line) {
isobuild.Trim(P1,P2);
else
isobuild.Trim(P2,P1);
- }
- }
+ }
}
--- /dev/null
+puts "============="
+puts "0030146: Visualization - e x c e p t i o n during attempt to display Edge without geometry"
+puts "============="
+
+pload MODELING VISUALIZATION
+
+restore [locate_data_file CTO904_cts20176a.rle] a
+incmesh a 0.1
+tclean -geom a
+
+vclear
+vinit View1
+vviewparams -scale 3.69 -proj 0.30 0.94 0.14 -up -0.46 0.013 0.88 -at 103.9 -59.94 -27.08
+vdisplay -dispMode 0 a
+vdump ${imagedir}/${casename}_wireframe.png
+
+vdisplay -dispMode 1 a
+vdump ${imagedir}/${casename}_shaded.png