geom/src/GEOMAlgo/GEOMAlgo_VertexSolid.cxx

216 lines
5.4 KiB
C++
Raw Normal View History

2016-03-15 17:26:56 +05:00
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2005-12-05 21:23:52 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2005-12-05 21:23:52 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// 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.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2005-12-05 21:23:52 +05:00
//
2012-08-09 13:58:02 +06:00
// File: GEOMAlgo_VertexSolid.cxx
// Created: Wed Jan 12 16:36:40 2005
// Author: Peter KURNEV
// <pkv@irinox>
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
#include <GEOMAlgo_VertexSolid.hxx>
2005-06-02 15:34:45 +06:00
#include <gp_Pnt.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_State.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
//
#include <BOPCol_ListOfShape.hxx>
2014-06-09 14:56:21 +06:00
#include <IntTools_Context.hxx>
//
#include <BOPDS_DS.hxx>
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
#include <BOPDS_Interf.hxx>
2005-06-02 15:34:45 +06:00
//=======================================================================
//function : GEOMAlgo_VertexSolid
2012-08-09 13:58:02 +06:00
//purpose :
2005-06-02 15:34:45 +06:00
//=======================================================================
GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid()
:
GEOMAlgo_ShapeSolid()
{
}
//=======================================================================
//function : ~
2012-08-09 13:58:02 +06:00
//purpose :
2005-06-02 15:34:45 +06:00
//=======================================================================
GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid()
{
}
//=======================================================================
// function: Perform
2012-08-09 13:58:02 +06:00
// purpose:
2005-06-02 15:34:45 +06:00
//=======================================================================
void GEOMAlgo_VertexSolid::Perform()
{
myErrorStatus=0;
//
try {
if (myDSFiller==NULL) {
myErrorStatus=10;
return;
}
2017-07-10 14:17:26 +05:00
if(myDSFiller->HasErrors()) {
2005-06-02 15:34:45 +06:00
myErrorStatus=11;
return;
}
//
Standard_Integer aNbF, aNbArgs;
2005-06-02 15:34:45 +06:00
TopTools_IndexedMapOfShape aM;
//
const BOPDS_DS& aDS=myDSFiller->DS();
const BOPCol_ListOfShape& aLS=aDS.Arguments();
aNbArgs=aLS.Extent();
if (aNbArgs!=2) {
myErrorStatus=14;
return;
}
const TopoDS_Shape& aObj=aLS.First();
2005-06-02 15:34:45 +06:00
//
TopExp::MapShapes(aObj, TopAbs_FACE, aM);
aNbF=aM.Extent();
myRank=(aNbF) ? 1 : 0;
2005-06-02 15:34:45 +06:00
//
BuildResult();
}
//
catch (Standard_Failure) {
myErrorStatus = 12;
}
2012-08-09 13:58:02 +06:00
}
2005-06-02 15:34:45 +06:00
//=======================================================================
// function: BuildResult
2012-08-09 13:58:02 +06:00
// purpose:
2005-06-02 15:34:45 +06:00
//=======================================================================
void GEOMAlgo_VertexSolid::BuildResult()
2005-06-02 15:34:45 +06:00
{
Standard_Integer i, iBeg, iEnd, aNbVV, aNbVE, aNbVF, j, iFound, aNbRanges;
2005-06-02 15:34:45 +06:00
Standard_Real aTol;
TopAbs_State aSt;
TopAbs_ShapeEnum aType;
gp_Pnt aP3D;
//
myLSIN.Clear();
myLSOUT.Clear();
myLSON.Clear();
//
const BOPDS_DS& aDS=myDSFiller->DS();
BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
2005-06-02 15:34:45 +06:00
//
BOPDS_VectorOfInterfVV& aVVs=pDS->InterfVV();
BOPDS_VectorOfInterfVE& aVEs=pDS->InterfVE();
BOPDS_VectorOfInterfVF& aVFs=pDS->InterfVF();
2005-06-02 15:34:45 +06:00
//
const BOPCol_ListOfShape& aLS=aDS.Arguments();
const TopoDS_Shape& aObj=aLS.First();
2005-06-02 15:34:45 +06:00
//
const TopoDS_Shape& aTool=aLS.Last();
const TopoDS_Solid& aSolid=(myRank==0) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj);
//
2014-06-09 14:56:21 +06:00
Handle(IntTools_Context) aCtx=myDSFiller->Context();
2012-08-09 13:58:02 +06:00
BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
2005-06-02 15:34:45 +06:00
//
aNbRanges=aDS.NbRanges();
const BOPDS_IndexRange& aRange=aDS.Range(myRank);
aRange.Indices(iBeg, iEnd);
2005-06-02 15:34:45 +06:00
//
for (i=iBeg; i<=iEnd; ++i) {
const TopoDS_Shape& aS=aDS.Shape(i);
aType=aS.ShapeType();
2005-06-02 15:34:45 +06:00
if (aType!=TopAbs_VERTEX) {
continue;
2005-06-02 15:34:45 +06:00
}
//
const TopoDS_Vertex& aV=TopoDS::Vertex(aS);
2005-06-02 15:34:45 +06:00
//
iFound=0;
//
// 1
2005-06-02 15:34:45 +06:00
aNbVV=aVVs.Extent();
for (j=0; j<aNbVV; ++j) {
BOPDS_InterfVV& aVV=aVVs(j);
if (aVV.Contains(i)) {
myLSON.Append(aV);
iFound=1;
break;
}
}
if (iFound) {
continue;
}
// 2
aNbVE=aVEs.Extent();
for (j=0; j<aNbVE; ++j) {
BOPDS_InterfVE& aVE=aVEs(j);
if (aVE.Contains(i)) {
myLSON.Append(aV);
iFound=1;
break;
}
}
if (iFound) {
continue;
}
// 3
aNbVF=aVFs.Extent();
for (j=0; j<aNbVF; ++j) {
BOPDS_InterfVF& aVF=aVFs(j);
if (aVF.Contains(i)) {
myLSON.Append(aV);
iFound=1;
break;
2012-08-09 13:58:02 +06:00
}
2005-06-02 15:34:45 +06:00
}
if (iFound) {
continue;
2005-06-02 15:34:45 +06:00
}
2012-08-09 13:58:02 +06:00
//
// 4
2005-06-02 15:34:45 +06:00
aP3D=BRep_Tool::Pnt(aV);
aTol=1.e-7;
2005-06-02 15:34:45 +06:00
aSC.Perform(aP3D, aTol);
aSt=aSC.State();
if (aSt==TopAbs_IN) {
myLSIN.Append(aV);
}
else if (aSt==TopAbs_OUT) {
2005-06-02 15:34:45 +06:00
myLSOUT.Append(aV);
}
}//for (i=iBeg; i<iEnd; ++i) {
2005-06-02 15:34:45 +06:00
}