From 70a26bb8227b4cf1b0c08a54e318f76cf240ccb0 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 1 Nov 2005 13:27:09 +0000 Subject: [PATCH] PAL10015. Add GEOMAlgo_FinderShapeOnQuad --- src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx | 143 ++++++++++++++++++++ src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx | 59 ++++++++ src/GEOMAlgo/Makefile.in | 2 + 3 files changed, 204 insertions(+) create mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx new file mode 100644 index 000000000..9b1b67fda --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.cxx @@ -0,0 +1,143 @@ +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMAlgo_FinderShapeOnQuad.cxx +// Created : Mon Oct 17 17:31:45 2005 +// Author : Edward AGAPOV (eap) + +#include "GEOMAlgo_FinderShapeOnQuad.hxx" +#include "GEOMAlgo_SurfaceTools.hxx" + +#include +#include +#include + + +GEOMAlgo_FinderShapeOnQuad::GEOMAlgo_FinderShapeOnQuad(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] ); + //std::cout< point2 vector + gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]); + //std::cout<<" Y Vec : "<Axis().Direction(); + gp_Vec aSideVec = myQuadNormal ^ aSideNorm; + gp_Vec c1p ( myPoints[i], aP ); + gp_Vec pc2 ( aP, myPoints[i+1] ); + if ( aSideVec * c1p >= 0. && aSideVec * pc2 >= 0. ) + return TopAbs_ON; + // 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 ) + return TopAbs_IN; + + return TopAbs_OUT; +} + diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx new file mode 100644 index 000000000..6f00989de --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOnQuad.hxx @@ -0,0 +1,59 @@ +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMAlgo_FinderShapeOnQuad.hxx +// Created : Mon Oct 17 17:15:59 2005 +// Author : Edward AGAPOV (eap) + +#ifndef GEOMAlgo_FinderShapeOnQuad_HeaderFile +#define GEOMAlgo_FinderShapeOnQuad_HeaderFile + +#include "GEOMAlgo_FinderShapeOn1.hxx" + +#include + +#include + + +class GEOMAlgo_FinderShapeOnQuad: public GEOMAlgo_FinderShapeOn1 +{ +public: + + GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint, + const gp_Pnt & theTopRigthPoint, + const gp_Pnt & theBottomLeftPoint, + const gp_Pnt & theBottomRigthPoint); + +protected: + + virtual void CheckData() ; + + virtual TopAbs_State GetPointState(const gp_Pnt& aP) ; + +private: + + bool myConcaveQuad; + vector myConcaveSide; + vector myPoints; + vector myPlanes; + gp_Vec myQuadNormal; +}; +#endif diff --git a/src/GEOMAlgo/Makefile.in b/src/GEOMAlgo/Makefile.in index 934d12095..d250da21c 100644 --- a/src/GEOMAlgo/Makefile.in +++ b/src/GEOMAlgo/Makefile.in @@ -49,6 +49,7 @@ LIB_SRC = \ GEOMAlgo_DataMapNodeOfDataMapOfPassKeyInteger_0.cxx \ GEOMAlgo_DataMapOfPassKeyInteger_0.cxx \ GEOMAlgo_FinderShapeOn1.cxx \ + GEOMAlgo_FinderShapeOnQuad.cxx \ GEOMAlgo_GlueAnalyser.cxx \ GEOMAlgo_Gluer.cxx \ GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfIntegerShape_0.cxx \ @@ -87,6 +88,7 @@ EXPORT_HEADERS = \ GEOMAlgo_GlueAnalyser.hxx \ GEOMAlgo_Gluer.hxx \ GEOMAlgo_FinderShapeOn1.hxx \ + GEOMAlgo_FinderShapeOnQuad.hxx \ GEOMAlgo_IndexedDataMapOfShapeState.hxx \ GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx \ GEOMAlgo_ListOfCoupleOfShapes.hxx \ -- 2.39.2