Fix of searching for shapes on surface (NGO letter from 20.02.2015)

This commit is contained in:
skv 2015-02-27 10:22:05 +03:00
parent 58803ba33e
commit eaee8de41c
9 changed files with 446 additions and 156 deletions

View File

@ -36,8 +36,9 @@
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx" #include "GEOM_PythonDump.hxx"
#include "GEOMUtils.hxx" #include "GEOMUtils.hxx"
#include "GEOMAlgo_ClsfSurf.hxx"
#include "GEOMAlgo_FinderShapeOn2.hxx"
#include "GEOMAlgo_Splitter.hxx" #include "GEOMAlgo_Splitter.hxx"
#include "GEOMAlgo_FinderShapeOn1.hxx"
#include "GEOMImpl_Gen.hxx" #include "GEOMImpl_Gen.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
@ -815,11 +816,13 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf
const Standard_Real theTolerance, const Standard_Real theTolerance,
TopTools_ListOfShape &theFaces) TopTools_ListOfShape &theFaces)
{ {
GEOMAlgo_FinderShapeOn1 aFinder; GEOMAlgo_FinderShapeOn2 aFinder;
Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf;
aClsfSurf->SetSurface(theSurface);
aFinder.SetShape(theShape); aFinder.SetShape(theShape);
aFinder.SetTolerance(theTolerance); aFinder.SetTolerance(theTolerance);
aFinder.SetSurface(theSurface); aFinder.SetClsf(aClsfSurf);
aFinder.SetShapeType(TopAbs_FACE); aFinder.SetShapeType(TopAbs_FACE);
aFinder.SetState(GEOMAlgo_ST_ON); aFinder.SetState(GEOMAlgo_ST_ON);
@ -836,7 +839,7 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
MESSAGE(" iErr : " << iErr); MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
@ -845,7 +848,7 @@ bool AdvancedEngine_IOperations::GetFacesOnSurf
return false; return false;
} }
Standard_Integer iWrn = aFinder.WarningStatus(); Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iWrn) { if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn); MESSAGE(" *** iWrn : " << iWrn);
} }

View File

@ -26,9 +26,9 @@
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_IOperations.hxx" #include "GEOM_IOperations.hxx"
#include "GEOMUtils.hxx" #include "GEOMUtils.hxx"
#include "GEOMAlgo_FinderShapeOn1.hxx"
#include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx"
#include "GEOMAlgo_ClsfBox.hxx" #include "GEOMAlgo_ClsfBox.hxx"
#include "GEOMAlgo_ClsfSurf.hxx"
#include "GEOMAlgo_Splitter.hxx" #include "GEOMAlgo_Splitter.hxx"
#include "Geom_CylindricalSurface.hxx" #include "Geom_CylindricalSurface.hxx"
@ -127,7 +127,7 @@ AdvancedEngine_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox,
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
aMsg += TCollection_AsciiString(iErr); aMsg += TCollection_AsciiString(iErr);
@ -185,12 +185,14 @@ Handle(TColStd_HSequenceOfInteger)
} }
// Call algo // Call algo
GEOMAlgo_FinderShapeOn1 aFinder; GEOMAlgo_FinderShapeOn2 aFinder;
Standard_Real aTol = 1e-6; Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf;
Standard_Real aTol = 1e-6;
aClsfSurf->SetSurface(theSurface);
aFinder.SetShape(theShape); aFinder.SetShape(theShape);
aFinder.SetTolerance(aTol); aFinder.SetTolerance(aTol);
aFinder.SetSurface(theSurface); aFinder.SetClsf(aClsfSurf);
aFinder.SetShapeType(theShapeType); aFinder.SetShapeType(theShapeType);
aFinder.SetState(theState); aFinder.SetState(theState);
@ -208,7 +210,7 @@ Handle(TColStd_HSequenceOfInteger)
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
// MESSAGE(" iErr : " << iErr); // MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
@ -217,7 +219,7 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
// Standard_Integer iWrn = aFinder.WarningStatus(); // Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
// if (iWrn) { // if (iWrn) {
// MESSAGE(" *** iWrn : " << iWrn); // MESSAGE(" *** iWrn : " << iWrn);
// } // }

View File

@ -51,6 +51,7 @@ SET(GEOMAlgo_HEADERS
GEOMAlgo_BuilderShape.hxx GEOMAlgo_BuilderShape.hxx
GEOMAlgo_Clsf.hxx GEOMAlgo_Clsf.hxx
GEOMAlgo_ClsfBox.hxx GEOMAlgo_ClsfBox.hxx
GEOMAlgo_ClsfQuad.hxx
GEOMAlgo_ClsfSolid.hxx GEOMAlgo_ClsfSolid.hxx
GEOMAlgo_ClsfSurf.hxx GEOMAlgo_ClsfSurf.hxx
GEOMAlgo_CoupleOfShapes.hxx GEOMAlgo_CoupleOfShapes.hxx
@ -58,10 +59,7 @@ SET(GEOMAlgo_HEADERS
GEOMAlgo_DataMapOfPassKeyInteger.hxx GEOMAlgo_DataMapOfPassKeyInteger.hxx
GEOMAlgo_DataMapOfShapeMapOfShape.hxx GEOMAlgo_DataMapOfShapeMapOfShape.hxx
GEOMAlgo_DataMapOfShapePnt.hxx GEOMAlgo_DataMapOfShapePnt.hxx
GEOMAlgo_FinderShapeOn.hxx
GEOMAlgo_FinderShapeOn1.hxx
GEOMAlgo_FinderShapeOn2.hxx GEOMAlgo_FinderShapeOn2.hxx
GEOMAlgo_FinderShapeOnQuad.hxx
GEOMAlgo_GetInPlace.hxx GEOMAlgo_GetInPlace.hxx
GEOMAlgo_GetInPlaceAPI.hxx GEOMAlgo_GetInPlaceAPI.hxx
GEOMAlgo_GlueAnalyser.hxx GEOMAlgo_GlueAnalyser.hxx
@ -116,13 +114,11 @@ SET(GEOMAlgo_SOURCES
GEOMAlgo_BuilderShape.cxx GEOMAlgo_BuilderShape.cxx
GEOMAlgo_Clsf.cxx GEOMAlgo_Clsf.cxx
GEOMAlgo_ClsfBox.cxx GEOMAlgo_ClsfBox.cxx
GEOMAlgo_ClsfQuad.cxx
GEOMAlgo_ClsfSolid.cxx GEOMAlgo_ClsfSolid.cxx
GEOMAlgo_ClsfSurf.cxx GEOMAlgo_ClsfSurf.cxx
GEOMAlgo_CoupleOfShapes.cxx GEOMAlgo_CoupleOfShapes.cxx
GEOMAlgo_FinderShapeOn.cxx
GEOMAlgo_FinderShapeOn1.cxx
GEOMAlgo_FinderShapeOn2.cxx GEOMAlgo_FinderShapeOn2.cxx
GEOMAlgo_FinderShapeOnQuad.cxx
GEOMAlgo_GetInPlace.cxx GEOMAlgo_GetInPlace.cxx
GEOMAlgo_GetInPlace_1.cxx GEOMAlgo_GetInPlace_1.cxx
GEOMAlgo_GetInPlace_2.cxx GEOMAlgo_GetInPlace_2.cxx

View File

@ -16,24 +16,20 @@ GEOMAlgo_SolidSolid.hxx
GEOMAlgo_SolidSolid.cxx GEOMAlgo_SolidSolid.cxx
GEOMAlgo_ShapeAlgo.hxx GEOMAlgo_ShapeAlgo.hxx
GEOMAlgo_ShapeAlgo.cxx GEOMAlgo_ShapeAlgo.cxx
GEOMAlgo_FinderShapeOn.hxx
GEOMAlgo_FinderShapeOn.cxx
GEOMAlgo_FinderShapeOn1.hxx
GEOMAlgo_FinderShapeOn1.cxx
GEOMAlgo_HAlgo.hxx GEOMAlgo_HAlgo.hxx
GEOMAlgo_HAlgo.cxx GEOMAlgo_HAlgo.cxx
GEOMAlgo_Clsf.hxx GEOMAlgo_Clsf.hxx
GEOMAlgo_Clsf.cxx GEOMAlgo_Clsf.cxx
GEOMAlgo_ClsfBox.hxx GEOMAlgo_ClsfBox.hxx
GEOMAlgo_ClsfBox.cxx GEOMAlgo_ClsfBox.cxx
GEOMAlgo_ClsfQuad.hxx
GEOMAlgo_ClsfQuad.cxx
GEOMAlgo_ClsfSolid.hxx GEOMAlgo_ClsfSolid.hxx
GEOMAlgo_ClsfSolid.cxx GEOMAlgo_ClsfSolid.cxx
GEOMAlgo_ClsfSurf.hxx GEOMAlgo_ClsfSurf.hxx
GEOMAlgo_ClsfSurf.cxx GEOMAlgo_ClsfSurf.cxx
GEOMAlgo_FinderShapeOn2.hxx GEOMAlgo_FinderShapeOn2.hxx
GEOMAlgo_FinderShapeOn2.cxx GEOMAlgo_FinderShapeOn2.cxx
GEOMAlgo_FinderShapeOnQuad.hxx
GEOMAlgo_FinderShapeOnQuad.cxx
GEOMAlgo_Gluer.hxx GEOMAlgo_Gluer.hxx
GEOMAlgo_Gluer.cxx GEOMAlgo_Gluer.cxx
GEOMAlgo_GlueAnalyser.hxx GEOMAlgo_GlueAnalyser.hxx

View File

@ -0,0 +1,219 @@
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_ClsfQuad.cxx
// Created: Fri Feb 13 16:03:19 2015
// Author: Sergey KHROMOV
//
#include <GEOMAlgo_ClsfQuad.hxx>
#include <GEOMAlgo_SurfaceTools.hxx>
#include <Geom_Plane.hxx>
IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf);
IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf);
//=======================================================================
//function :
//purpose :
//=======================================================================
GEOMAlgo_ClsfQuad::GEOMAlgo_ClsfQuad()
: GEOMAlgo_Clsf(),
myQuadNormal(0., 0., 0.)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
GEOMAlgo_ClsfQuad::~GEOMAlgo_ClsfQuad()
{
}
//=======================================================================
//function : SetCorners
//purpose :
//=======================================================================
void GEOMAlgo_ClsfQuad::SetCorners(const gp_Pnt &theTopLeftPoint,
const gp_Pnt &theTopRigthPoint,
const gp_Pnt &theBottomLeftPoint,
const gp_Pnt &theBottomRigthPoint)
{
myPoints.resize(6);
myPoints[0] = theTopLeftPoint;
myPoints[1] = theTopRigthPoint;
myPoints[2] = theBottomRigthPoint;
myPoints[3] = theBottomLeftPoint;
myPoints[4] = myPoints[0];
myPoints[5] = myPoints[1];
// Find plane normal defined by corner points, it will be used to define
// a plane for each quadrangle side.
myQuadNormal.SetCoord (0., 0., 0.);
for ( int i = 1; i <= 4; ++i ) {
myQuadNormal +=
gp_Vec(myPoints[i], myPoints[i+1]) ^ gp_Vec(myPoints[i], myPoints[i-1]);
}
if (myQuadNormal.SquareMagnitude() <= DBL_MIN) {
return;
}
// detect concave quadrangle sides
myConcaveQuad = false;
myConcaveSide.resize (4, false);
for ( int i = 1; i <= 4; ++i ) {
gp_Vec localQN =
gp_Vec(myPoints[i], myPoints[i+1]) ^ gp_Vec(myPoints[i], myPoints[i-1]);
if (myQuadNormal * localQN < 0) {
myConcaveSide[i-1] = myConcaveSide[i] = myConcaveQuad = true;
}
}
// loop on quadrangle sides
myPlanes.reserve( 4 );
for ( int i = 0; i < 4; ++i ) {
// point1 -> point2 vector
gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]);
// plane normal
gp_Vec aSideNorm = aSideVec ^ myQuadNormal;
if (aSideNorm.SquareMagnitude() <= DBL_MIN) {
continue;
}
// make plane
Handle(Geom_Plane) aPlane = new Geom_Plane(myPoints[i], aSideNorm);
myPlanes.push_back(GeomAdaptor_Surface());
myPlanes.back().Load( aPlane );
}
}
//=======================================================================
//function : GetCorners
//purpose :
//=======================================================================
void GEOMAlgo_ClsfQuad::GetCorners(gp_Pnt &theTopLeftPoint,
gp_Pnt &theTopRigthPoint,
gp_Pnt &theBottomLeftPoint,
gp_Pnt &theBottomRigthPoint) const
{
if (myPoints.size() == 6) {
theTopLeftPoint = myPoints[0];
theTopRigthPoint = myPoints[1];
theBottomLeftPoint = myPoints[3];
theBottomRigthPoint = myPoints[2];
}
}
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================
void GEOMAlgo_ClsfQuad::CheckData()
{
if (myQuadNormal.SquareMagnitude() <= DBL_MIN) {
myErrorStatus = 10; // undefined quadrangle normal.
return;
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void GEOMAlgo_ClsfQuad::Perform()
{
myErrorStatus=0;
//
// Return IN if aP has TopAbs_IN with all sides.
// In the case of concave quadrangle, return IN if
// aP is OUT of only one concave side
double nbIn = 0.;
for (size_t i = 0; i < myPlanes.size(); ++i) {
TopAbs_State aSt;
GEOMAlgo_SurfaceTools::GetState(myPnt, myPlanes[i], myTolerance, aSt);
if (aSt == TopAbs_IN) {
nbIn += myConcaveSide[i] ? 0.5 : 1.0;
} else if (aSt == TopAbs_ON) {
// check that aP is between quadrangle corners
Handle(Geom_Plane) aSidePlane =
Handle(Geom_Plane)::DownCast(myPlanes[i].Surface());
gp_Vec aSideNorm = aSidePlane->Axis().Direction();
gp_Vec aSideVec = myQuadNormal ^ aSideNorm;
gp_Vec c1p (myPoints[i], myPnt);
gp_Vec pc2 (myPnt, myPoints[i+1]);
if (aSideVec * c1p >= 0. && aSideVec * pc2 >= 0.) {
myState = TopAbs_ON;
return;
}
// consider to be IN (???????????)
//nbIn += myConcaveSide[i] ? 0.5 : 1.0;
}
}
Standard_Real inThreshold = myPlanes.size(); // usually 4.0
if (myConcaveQuad) {
inThreshold = 2.5; // 1.0 + 1.0 + 0.5
}
if (nbIn >= inThreshold) {
myState = TopAbs_IN;
} else {
myState = TopAbs_OUT;
}
}
//=======================================================================
//function : CanBeON
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_ClsfQuad::CanBeON(const Handle(Geom_Curve)& aC) const
{
return GEOMAlgo_Clsf::CanBeON(aC);
}
//=======================================================================
//function : CanBeON
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_ClsfQuad::CanBeON(const Handle(Geom_Surface)& aS1) const
{
GeomAdaptor_Surface aGAS1;
aGAS1.Load(aS1);
GeomAbs_SurfaceType aST1 = aGAS1.GetType();
Standard_Boolean bRet = (aST1 == GeomAbs_Plane);
return bRet;
}

View File

@ -0,0 +1,92 @@
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_ClsfQuad.hxx
// Created: Fri Feb 13 16:03:19 2015
// Author: Sergey KHROMOV
//
//
#ifndef _GEOMAlgo_ClsfQuad_HeaderFile
#define _GEOMAlgo_ClsfQuad_HeaderFile
#include <GEOMAlgo_Clsf.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Standard_DefineHandle.hxx>
#include <vector>
DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfQuad, GEOMAlgo_Clsf)
//=======================================================================
// class : GEOMAlgo_ClsfQuad
//purpose :
//=======================================================================
class GEOMAlgo_ClsfQuad : public GEOMAlgo_Clsf
{
public:
Standard_EXPORT
GEOMAlgo_ClsfQuad();
Standard_EXPORT
virtual ~GEOMAlgo_ClsfQuad();
Standard_EXPORT
void SetCorners(const gp_Pnt &theTopLeftPoint,
const gp_Pnt &theTopRigthPoint,
const gp_Pnt &theBottomLeftPoint,
const gp_Pnt &theBottomRigthPoint);
Standard_EXPORT
void GetCorners(gp_Pnt &theTopLeftPoint,
gp_Pnt &theTopRigthPoint,
gp_Pnt &theBottomLeftPoint,
gp_Pnt &theBottomRigthPoint) const;
Standard_EXPORT
virtual void Perform();
Standard_EXPORT
virtual void CheckData();
Standard_EXPORT
virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const;
Standard_EXPORT
virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;
DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfQuad);
protected:
bool myConcaveQuad;
std::vector<bool> myConcaveSide;
std::vector<gp_Pnt> myPoints;
std::vector<GeomAdaptor_Surface> myPlanes;
gp_Vec myQuadNormal;
};
#endif

View File

@ -26,75 +26,54 @@
// <pkv@irinox> // <pkv@irinox>
// //
#include <GEOMAlgo_FinderShapeOn2.hxx> #include <GEOMAlgo_FinderShapeOn2.hxx>
#include <math.h> #include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
#include <Basics_OCCTVersion.hxx> #include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
#include <GEOMAlgo_PassKey.hxx>
#include <Precision.hxx> #include <GEOMAlgo_StateCollector.hxx>
#include <TColStd_Array1OfInteger.hxx> #include <GEOMAlgo_SurfaceTools.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <gp_Trsf.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Triangle.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Bnd_Box.hxx>
#include <BRep_Tool.hxx>
#include <BRepBndLib.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepTools.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <TopAbs_State.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRep_Tool.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
#include <GEOMAlgo_SurfaceTools.hxx>
#include <GEOMAlgo_StateCollector.hxx>
#include <GEOMAlgo_FinderShapeOn.hxx>
#include <GEOMAlgo_PassKey.hxx>
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
//
#include <gp_Dir2d.hxx>
#include <gp_Pnt2d.hxx>
#include <Geom2d_Line.hxx> #include <Geom2d_Line.hxx>
#include <Geom2dAdaptor_Curve.hxx> #include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Hatcher.hxx> #include <Geom2dHatch_Hatcher.hxx>
#include <TColStd_ListOfInteger.hxx> #include <gp_Dir2d.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx> #include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <HatchGen_Domain.hxx> #include <HatchGen_Domain.hxx>
#include <Geom2dHatch_Hatcher.hxx> #include <IntTools_Tools.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangle.hxx>
#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TopAbs_State.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#if OCC_VERSION_LARGE > 0x06070100 #if OCC_VERSION_LARGE > 0x06070100
#include <IntTools_Context.hxx> #include <IntTools_Context.hxx>
#else #else
#include <BOPInt_Context.hxx> #include <BOPInt_Context.hxx>
#endif #endif
#include <BRepTools.hxx>
#include <IntTools_Tools.hxx>
//======================================================================= //=======================================================================
//function : //function :
@ -626,7 +605,7 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF,
// //
aTRF=BRep_Tool::Triangulation(aF, aLoc); aTRF=BRep_Tool::Triangulation(aF, aLoc);
if (aTRF.IsNull()) { if (aTRF.IsNull()) {
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) { if (!BuildTriangulation(aF)) {
myWarningStatus=20; // no triangulation found myWarningStatus=20; // no triangulation found
return; return;
} }
@ -770,7 +749,7 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
if (aTRE.IsNull() || aPTE.IsNull()) { if (aTRE.IsNull() || aPTE.IsNull()) {
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc); Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
if (aPE.IsNull()) { if (aPE.IsNull()) {
if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) { if (!BuildTriangulation(aE)) {
myErrorStatus=20; // no triangulation found myErrorStatus=20; // no triangulation found
return; return;
} }
@ -841,6 +820,59 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
} }
} }
//=======================================================================
//function : BuildTriangulation
//purpose :
//=======================================================================
Standard_Boolean
GEOMAlgo_FinderShapeOn2::BuildTriangulation (const TopoDS_Shape& theShape)
{
// calculate deflection
Standard_Real aDeviationCoefficient = 0.001;
Bnd_Box B;
BRepBndLib::Add(theShape, B);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
Standard_Real aHLRAngle = 0.349066;
// build triangulation
BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle);
// check triangulation
bool isTriangulation = true;
TopExp_Explorer exp (theShape, TopAbs_FACE);
if (exp.More())
{
TopLoc_Location aTopLoc;
Handle(Poly_Triangulation) aTRF;
aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
if (aTRF.IsNull()) {
isTriangulation = false;
}
}
else // no faces, try edges
{
TopExp_Explorer expe (theShape, TopAbs_EDGE);
if (!expe.More()) {
isTriangulation = false;
}
else {
TopLoc_Location aLoc;
Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
if (aPE.IsNull()) {
isTriangulation = false;
}
}
}
return isTriangulation;
}
// //
// myErrorStatus : // myErrorStatus :
// //
@ -854,60 +886,3 @@ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
// 40- point can not be classified // 40- point can not be classified
// 41- invalid data for classifier // 41- invalid data for classifier
// 42- can not compute hatching // 42- can not compute hatching
/*
// A
if (!aNb && myNbPntsMin) {
// try to fill it yourself
Standard_Boolean bIsDone;
Standard_Integer aN1, aN2;
Handle(Geom_Surface) aS;
GeomAdaptor_Surface aGAS;
GeomAbs_SurfaceType aType;
//
aS=BRep_Tool::Surface(aF);
aGAS.Load(aS);
aType=aGAS.GetType();
if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
// inner links
aNbLinks=aMPKI.Extent();
aIt.Initialize(aMPKI);
for (; aIt.More(); aIt.Next()) {
iCnt=aIt.Value();
if (iCnt>1) {
// take the first having occured inner link
// and discretize it
const GEOMAlgo_PassKey& aPK=aIt.Key();
//
aN1=(Standard_Integer)aPK.Id(1);
aN2=(Standard_Integer)aPK.Id(2);
//
aP1=aNodes(aN1).Transformed(aTrsf);
aP2=aNodes(aN2).Transformed(aTrsf);
//
if (aType==GeomAbs_Cylinder) {
gp_Cylinder aCyl;
//
aCyl=aGAS.Cylinder();
if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) {
continue;
}
}
//
BRepLib_MakeEdge aBME(aP1, aP2);
bIsDone=aBME.IsDone();
if (!bIsDone) {
myErrorStatus=30; //can not obtain the line fron the link
return;
}
//
const TopoDS_Shape& aSx=aBME.Shape();
const TopoDS_Edge& aE=TopoDS::Edge(aSx);
//
InnerPoints(aE, myNbPntsMin, aLP);
break;
}// if (iCnt>1)
}// for (; aIt.More(); aIt.Next())
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
}// if (!aNb && myNbPntsMin) {
*/

View File

@ -126,6 +126,9 @@ protected:
const Standard_Integer aNbPnts, const Standard_Integer aNbPnts,
GEOMAlgo_ListOfPnt& aLP) ; GEOMAlgo_ListOfPnt& aLP) ;
Standard_EXPORT
Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
TopAbs_ShapeEnum myShapeType; TopAbs_ShapeEnum myShapeType;
GEOMAlgo_State myState; GEOMAlgo_State myState;

View File

@ -54,9 +54,9 @@
#include "GEOMUtils.hxx" #include "GEOMUtils.hxx"
#include "GEOMAlgo_ClsfBox.hxx" #include "GEOMAlgo_ClsfBox.hxx"
#include "GEOMAlgo_ClsfQuad.hxx"
#include "GEOMAlgo_ClsfSolid.hxx" #include "GEOMAlgo_ClsfSolid.hxx"
#include "GEOMAlgo_FinderShapeOn1.hxx" #include "GEOMAlgo_ClsfSurf.hxx"
#include "GEOMAlgo_FinderShapeOnQuad.hxx"
#include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx"
#include "GEOMAlgo_GetInPlace.hxx" #include "GEOMAlgo_GetInPlace.hxx"
#include "GEOMAlgo_GetInPlaceAPI.hxx" #include "GEOMAlgo_GetInPlaceAPI.hxx"
@ -2636,7 +2636,7 @@ Handle(TColStd_HSequenceOfInteger)
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
MESSAGE(" iErr : " << iErr); MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
@ -2645,7 +2645,7 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
Standard_Integer iWrn = aFinder.WarningStatus(); Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iWrn) { if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn); MESSAGE(" *** iWrn : " << iWrn);
} }
@ -2803,7 +2803,7 @@ Handle(TColStd_HSequenceOfInteger)
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
if (iErr == 41) { if (iErr == 41) {
SetErrorCode("theCheckShape must be a solid"); SetErrorCode("theCheckShape must be a solid");
@ -2817,7 +2817,7 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
Standard_Integer iWrn = aFinder.WarningStatus(); Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iWrn) { if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn); MESSAGE(" *** iWrn : " << iWrn);
} }
@ -3074,13 +3074,14 @@ Handle(TColStd_HSequenceOfInteger)
// END: Mantis issue 0020961 // END: Mantis issue 0020961
// Call algo // Call algo
GEOMAlgo_FinderShapeOn1 aFinder; GEOMAlgo_FinderShapeOn2 aFinder;
//Standard_Real aTol = 0.0001; // default value Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf;
Standard_Real aTol = VertMax; // Mantis issue 0020961 Standard_Real aTol = VertMax; // Mantis issue 0020961
aClsfSurf->SetSurface(theSurface);
aFinder.SetShape(theShape); aFinder.SetShape(theShape);
aFinder.SetTolerance(aTol); aFinder.SetTolerance(aTol);
aFinder.SetSurface(theSurface); aFinder.SetClsf(aClsfSurf);
aFinder.SetShapeType(theShapeType); aFinder.SetShapeType(theShapeType);
aFinder.SetState(theState); aFinder.SetState(theState);
@ -3098,7 +3099,7 @@ Handle(TColStd_HSequenceOfInteger)
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
MESSAGE(" iErr : " << iErr); MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
@ -3107,7 +3108,7 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
Standard_Integer iWrn = aFinder.WarningStatus(); Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iWrn) { if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn); MESSAGE(" *** iWrn : " << iWrn);
} }
@ -3985,12 +3986,15 @@ Handle(TColStd_HSequenceOfInteger)
gp_Pnt aPntBL = BRep_Tool::Pnt(TopoDS::Vertex(aBL)); gp_Pnt aPntBL = BRep_Tool::Pnt(TopoDS::Vertex(aBL));
gp_Pnt aPntBR = BRep_Tool::Pnt(TopoDS::Vertex(aBR)); gp_Pnt aPntBR = BRep_Tool::Pnt(TopoDS::Vertex(aBR));
GEOMAlgo_FinderShapeOnQuad aFinder( aPntTL, aPntTR, aPntBL, aPntBR ); GEOMAlgo_FinderShapeOn2 aFinder;
Handle(GEOMAlgo_ClsfQuad) aClsfQuad = new GEOMAlgo_ClsfQuad;
Standard_Real aTol = 0.0001; // default value Standard_Real aTol = 0.0001; // default value
aClsfQuad->SetCorners(aPntTL, aPntTR, aPntBL, aPntBR);
aFinder.SetShape(aShape); aFinder.SetShape(aShape);
aFinder.SetTolerance(aTol); aFinder.SetTolerance(aTol);
//aFinder.SetSurface(theSurface); aFinder.SetClsf(aClsfQuad);
aFinder.SetShapeType(aShapeType); aFinder.SetShapeType(aShapeType);
aFinder.SetState(theState); aFinder.SetState(theState);
@ -4008,7 +4012,7 @@ Handle(TColStd_HSequenceOfInteger)
// Interprete results // Interprete results
Standard_Integer iErr = aFinder.ErrorStatus(); Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iErr) { if (iErr) {
MESSAGE(" iErr : " << iErr); MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : "); TCollection_AsciiString aMsg (" iErr : ");
@ -4017,7 +4021,7 @@ Handle(TColStd_HSequenceOfInteger)
return aSeqOfIDs; return aSeqOfIDs;
} }
Standard_Integer iWrn = aFinder.WarningStatus(); Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
if (iWrn) { if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn); MESSAGE(" *** iWrn : " << iWrn);
} }