mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
PAL13473 (Build repetitive mesh):
New meshers implemented
This commit is contained in:
parent
3324206404
commit
512916b107
@ -51,7 +51,18 @@ EXPORT_HEADERS = \
|
||||
StdMeshers_AutomaticLength.hxx \
|
||||
StdMeshers_Distribution.hxx \
|
||||
StdMeshers_QuadranglePreference.hxx \
|
||||
StdMeshers_QuadraticMesh.hxx
|
||||
StdMeshers_QuadraticMesh.hxx \
|
||||
StdMeshers_NumberOfLayers.hxx \
|
||||
StdMeshers_Prism_3D.hxx \
|
||||
StdMeshers_ProjectionSource1D.hxx \
|
||||
StdMeshers_ProjectionSource2D.hxx \
|
||||
StdMeshers_ProjectionSource3D.hxx \
|
||||
StdMeshers_Projection_1D.hxx \
|
||||
StdMeshers_Projection_2D.hxx \
|
||||
StdMeshers_Projection_3D.hxx \
|
||||
StdMeshers_RadialPrism_3D.hxx \
|
||||
StdMeshers_ProjectionUtils.hxx \
|
||||
StdMeshers_LayerDistribution.hxx
|
||||
|
||||
EXPORT_PYSCRIPTS =
|
||||
|
||||
@ -78,7 +89,18 @@ LIB_SRC = \
|
||||
StdMeshers_AutomaticLength.cxx \
|
||||
StdMeshers_Distribution.cxx \
|
||||
StdMeshers_QuadranglePreference.cxx \
|
||||
StdMeshers_QuadraticMesh.cxx
|
||||
StdMeshers_QuadraticMesh.cxx \
|
||||
StdMeshers_NumberOfLayers.cxx \
|
||||
StdMeshers_Prism_3D.cxx \
|
||||
StdMeshers_ProjectionSource1D.cxx \
|
||||
StdMeshers_ProjectionSource2D.cxx \
|
||||
StdMeshers_ProjectionSource3D.cxx \
|
||||
StdMeshers_Projection_1D.cxx \
|
||||
StdMeshers_Projection_2D.cxx \
|
||||
StdMeshers_Projection_3D.cxx \
|
||||
StdMeshers_RadialPrism_3D.cxx \
|
||||
StdMeshers_ProjectionUtils.cxx \
|
||||
StdMeshers_LayerDistribution.cxx
|
||||
|
||||
LIB_SERVER_IDL =
|
||||
|
||||
|
148
src/StdMeshers/StdMeshers_LayerDistribution.cxx
Normal file
148
src/StdMeshers/StdMeshers_LayerDistribution.cxx
Normal file
@ -0,0 +1,148 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_LayerDistribution.cxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#include "StdMeshers_LayerDistribution.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_LayerDistribution::StdMeshers_LayerDistribution
|
||||
*
|
||||
* Constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_LayerDistribution::StdMeshers_LayerDistribution(int hypId, int studyId,
|
||||
SMESH_Gen * gen)
|
||||
: SMESH_Hypothesis(hypId, studyId, gen)
|
||||
{
|
||||
_name = "LayerDistribution"; // used by RadialPrism_3D
|
||||
_param_algo_dim = 3; // 3D
|
||||
myHyp = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution
|
||||
*
|
||||
* Destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution()
|
||||
{
|
||||
MESSAGE( "StdMeshers_LayerDistribution::~StdMeshers_LayerDistribution" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Sets 1D hypothesis specifying distribution of layers
|
||||
* \param hyp1D - 1D hypothesis
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_LayerDistribution::SetLayerDistribution(SMESH_Hypothesis* hyp1D)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( myHyp != hyp1D ) {
|
||||
if ( myHyp && hyp1D->GetDim() != 1 )
|
||||
throw SALOME_Exception(LOCALIZED("1D hypothesis is expected"));
|
||||
myHyp = hyp1D;
|
||||
}
|
||||
std::ostringstream os;
|
||||
if ( myHyp )
|
||||
myHyp->SaveTo( os );
|
||||
|
||||
if ( mySavedHyp != os.str() )
|
||||
NotifySubMeshesHypothesisModification();
|
||||
|
||||
mySavedHyp = os.str();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Servant saves and loads my hypothesis
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & StdMeshers_LayerDistribution::SaveTo(ostream & save)
|
||||
{
|
||||
return save;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Servant saves and loads my hypothesis
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & StdMeshers_LayerDistribution::LoadFrom(istream & load)
|
||||
{
|
||||
return load;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & operator <<(ostream & save, StdMeshers_LayerDistribution & hyp)
|
||||
{
|
||||
return hyp.SaveTo( save );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & operator >>(istream & load, StdMeshers_LayerDistribution & hyp)
|
||||
{
|
||||
return hyp.LoadFrom( load );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Initialize start and end length by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_LayerDistribution::SetParametersByMesh(const SMESH_Mesh* ,
|
||||
const TopoDS_Shape& )
|
||||
{
|
||||
return false;
|
||||
}
|
91
src/StdMeshers/StdMeshers_LayerDistribution.hxx
Normal file
91
src/StdMeshers/StdMeshers_LayerDistribution.hxx
Normal file
@ -0,0 +1,91 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_LayerDistribution.hxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#ifndef _SMESH_LayerDistribution_HXX_
|
||||
#define _SMESH_LayerDistribution_HXX_
|
||||
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#include <string>
|
||||
|
||||
class SMESH_Gen;
|
||||
|
||||
// =========================================================
|
||||
// =========================================================
|
||||
/*!
|
||||
* This hypothesis is used by "Radial prism" algorithm.
|
||||
* It specifies 1D hypothesis defining distribution of segments between the internal
|
||||
* and the external surfaces.
|
||||
*/
|
||||
// =========================================================
|
||||
// =========================================================
|
||||
|
||||
class StdMeshers_LayerDistribution: public SMESH_Hypothesis
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
StdMeshers_LayerDistribution( int hypId, int studyId, SMESH_Gen * gen );
|
||||
// Destructor
|
||||
virtual ~StdMeshers_LayerDistribution();
|
||||
|
||||
/*!
|
||||
* \brief Sets 1D hypothesis specifying distribution of layers
|
||||
* \param hyp1D - 1D hypothesis
|
||||
*/
|
||||
void SetLayerDistribution(SMESH_Hypothesis* hyp1D)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* \brief Returns 1D hypothesis specifying distribution of layers
|
||||
* \retval SMESH::SMESH_Hypothesis_ptr - 1D hypothesis
|
||||
*/
|
||||
SMESH_Hypothesis* GetLayerDistribution() const { return myHyp; }
|
||||
|
||||
virtual std::ostream & SaveTo(std::ostream & save);
|
||||
virtual std::istream & LoadFrom(std::istream & load);
|
||||
friend std::ostream & operator <<(std::ostream & save, StdMeshers_LayerDistribution & hyp);
|
||||
friend std::istream & operator >>(std::istream & load, StdMeshers_LayerDistribution & hyp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize parameters by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*
|
||||
* Implementation does noting
|
||||
*/
|
||||
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
|
||||
|
||||
protected:
|
||||
SMESH_Hypothesis* myHyp;
|
||||
std::string mySavedHyp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
162
src/StdMeshers/StdMeshers_NumberOfLayers.cxx
Normal file
162
src/StdMeshers/StdMeshers_NumberOfLayers.cxx
Normal file
@ -0,0 +1,162 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_NumberOfLayers.cxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#include "StdMeshers_NumberOfLayers.hxx"
|
||||
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers
|
||||
*
|
||||
* Constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers(int hypId, int studyId,
|
||||
SMESH_Gen * gen)
|
||||
: SMESH_Hypothesis(hypId, studyId, gen)
|
||||
{
|
||||
_name = "NumberOfLayers"; // used by RadialPrism_3D
|
||||
_param_algo_dim = 3; // 3D
|
||||
_nbLayers = 1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers
|
||||
*
|
||||
* Destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers()
|
||||
{
|
||||
MESSAGE( "StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_NumberOfLayers::SetNumberOfLayers
|
||||
*
|
||||
* Sets <number of segments> parameter value
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_NumberOfLayers::SetNumberOfLayers(int numberOfLayers)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( _nbLayers != numberOfLayers ) {
|
||||
if ( numberOfLayers <= 0 )
|
||||
throw SALOME_Exception(LOCALIZED("numberOfLayers must be positive"));
|
||||
_nbLayers = numberOfLayers;
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_NumberOfLayers::GetNumberOfLayers
|
||||
*
|
||||
* Returns <number of layers> parameter value
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
int StdMeshers_NumberOfLayers::GetNumberOfLayers() const
|
||||
{
|
||||
return _nbLayers;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & StdMeshers_NumberOfLayers::SaveTo(ostream & save)
|
||||
{
|
||||
save << _nbLayers;
|
||||
return save;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & StdMeshers_NumberOfLayers::LoadFrom(istream & load)
|
||||
{
|
||||
bool isOK = true;
|
||||
isOK = (load >> _nbLayers);
|
||||
if (!isOK)
|
||||
load.clear(ios::badbit | load.rdstate());
|
||||
return load;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & operator <<(ostream & save, StdMeshers_NumberOfLayers & hyp)
|
||||
{
|
||||
return hyp.SaveTo( save );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & operator >>(istream & load, StdMeshers_NumberOfLayers & hyp)
|
||||
{
|
||||
return hyp.LoadFrom( load );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Initialize start and end length by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh* ,
|
||||
const TopoDS_Shape& )
|
||||
{
|
||||
return false;
|
||||
}
|
81
src/StdMeshers/StdMeshers_NumberOfLayers.hxx
Normal file
81
src/StdMeshers/StdMeshers_NumberOfLayers.hxx
Normal file
@ -0,0 +1,81 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_NumberOfLayers.hxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#ifndef _SMESH_NumberOfLayers_HXX_
|
||||
#define _SMESH_NumberOfLayers_HXX_
|
||||
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
class SMESH_Gen;
|
||||
|
||||
// =========================================================
|
||||
// =========================================================
|
||||
/*!
|
||||
* This hypothesis is used by "Radial prism" algorithm.
|
||||
* It specifies number of segments between the internal
|
||||
* and the external surfaces.
|
||||
*/
|
||||
// =========================================================
|
||||
// =========================================================
|
||||
|
||||
class StdMeshers_NumberOfLayers: public SMESH_Hypothesis
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
StdMeshers_NumberOfLayers( int hypId, int studyId, SMESH_Gen * gen );
|
||||
// Destructor
|
||||
virtual ~StdMeshers_NumberOfLayers();
|
||||
|
||||
// Sets <number of segments> parameter value
|
||||
void SetNumberOfLayers(int numberOfLayers) throw ( SALOME_Exception );
|
||||
|
||||
// Returns <number of layers> parameter value
|
||||
int GetNumberOfLayers() const;
|
||||
|
||||
virtual std::ostream & SaveTo(std::ostream & save);
|
||||
virtual std::istream & LoadFrom(std::istream & load);
|
||||
friend std::ostream & operator <<(std::ostream & save, StdMeshers_NumberOfLayers & hyp);
|
||||
friend std::istream & operator >>(std::istream & load, StdMeshers_NumberOfLayers & hyp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize parameters by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*
|
||||
* Implementation does noting
|
||||
*/
|
||||
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
|
||||
|
||||
protected:
|
||||
int _nbLayers;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1750
src/StdMeshers/StdMeshers_Prism_3D.cxx
Normal file
1750
src/StdMeshers/StdMeshers_Prism_3D.cxx
Normal file
File diff suppressed because it is too large
Load Diff
425
src/StdMeshers/StdMeshers_Prism_3D.hxx
Normal file
425
src/StdMeshers/StdMeshers_Prism_3D.hxx
Normal file
@ -0,0 +1,425 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Prism_3D.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_Prism_3D_HXX_
|
||||
#define _SMESH_Prism_3D_HXX_
|
||||
|
||||
#include "SMESH_3D_Algo.hxx"
|
||||
#include "SMDS_TypeOfPosition.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMESH_Block.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
#include "SMESH_subMesh.hxx"
|
||||
#include "SMESH_MesherHelper.hxx"
|
||||
|
||||
#include <vector.h>
|
||||
#include <map.h>
|
||||
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <Adaptor3d_Surface.hxx>
|
||||
#include <Adaptor2d_Curve2d.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <TopTools_IndexedMapOfOrientedShape.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
|
||||
class SMESHDS_SubMesh;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Faces;
|
||||
struct TNode;
|
||||
|
||||
//typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
|
||||
typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
|
||||
|
||||
// map of bottom nodes to the column of nodes above them
|
||||
// (the column includes the bottom nodes)
|
||||
typedef std::map< TNode, TNodeColumn > TNode2ColumnMap;
|
||||
typedef std::map< double, TNodeColumn > TParam2ColumnMap;
|
||||
typedef std::map< double, TNodeColumn >::const_iterator TParam2ColumnIt;
|
||||
|
||||
typedef TopTools_IndexedMapOfOrientedShape TBlockShapes;
|
||||
|
||||
// ===============================================
|
||||
/*!
|
||||
* \brief Structure containing node relative data
|
||||
*/
|
||||
// ===============================================
|
||||
|
||||
struct TNode
|
||||
{
|
||||
const SMDS_MeshNode* myNode;
|
||||
gp_XYZ myParams;
|
||||
|
||||
gp_XYZ GetCoords() const { return gp_XYZ( myNode->X(), myNode->Y(), myNode->Z() ); }
|
||||
gp_XYZ GetParams() const { return myParams; }
|
||||
gp_XYZ& ChangeParams() { return myParams; }
|
||||
SMDS_TypeOfPosition GetPositionType() const
|
||||
{ return myNode ? myNode->GetPosition()->GetTypeOfPosition() : SMDS_TOP_UNSPEC; }
|
||||
|
||||
TNode(const SMDS_MeshNode* node = 0): myNode(node) {}
|
||||
bool operator < (const TNode& other) const { return myNode < other.myNode; }
|
||||
};
|
||||
|
||||
// ===============================================================
|
||||
/*!
|
||||
* \brief Tool analyzing and giving access to a prism geometry
|
||||
* treating it like a block, i.e. the four side faces are
|
||||
* emulated by division/uniting of missing/excess faces.
|
||||
* It also manage associations between block subshapes and a mesh.
|
||||
*/
|
||||
// ===============================================================
|
||||
|
||||
class StdMeshers_PrismAsBlock: public SMESH_Block
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Constructor. Initialization is needed
|
||||
*/
|
||||
StdMeshers_PrismAsBlock();
|
||||
|
||||
~StdMeshers_PrismAsBlock();
|
||||
|
||||
/*!
|
||||
* \brief Initialization.
|
||||
* \param helper - helper loaded with mesh and 3D shape
|
||||
* \param shape3D - a closed shell or solid
|
||||
* \retval bool - false if a mesh or a shape are KO
|
||||
*
|
||||
* Analyse shape geometry and mesh.
|
||||
* If there are triangles on one of faces, it becomes 'bottom'
|
||||
*/
|
||||
bool Init(SMESH_MesherHelper* helper, const TopoDS_Shape& shape3D);
|
||||
|
||||
/*!
|
||||
* \brief Return number of nodes on every vertical edge
|
||||
* \retval int - number of nodes including end nodes
|
||||
*/
|
||||
int VerticalSize() const { return myParam2ColumnMaps[0].begin()->second.size(); }
|
||||
|
||||
bool HasNotQuadElemOnTop() const { return myNotQuadOnTop; }
|
||||
|
||||
/*!
|
||||
* \brief Return pointer to column of nodes
|
||||
* \param node - bottom node from which the returned column goes up
|
||||
* \retval const TNodeColumn* - the found column
|
||||
*/
|
||||
const TNodeColumn* GetNodeColumn(const SMDS_MeshNode* node) const;
|
||||
|
||||
/*!
|
||||
* \brief Return TParam2ColumnMap for a base edge
|
||||
* \param baseEdgeID - base edge SMESHDS Index
|
||||
* \param isReverse - columns in-block orientation
|
||||
* \retval const TParam2ColumnMap& - map
|
||||
*/
|
||||
const TParam2ColumnMap& GetParam2ColumnMap(const int baseEdgeID,
|
||||
bool & isReverse)
|
||||
{
|
||||
std::pair< TParam2ColumnMap*, bool > & col_frw =
|
||||
myShapeIndex2ColumnMap[ baseEdgeID ];
|
||||
isReverse = !col_frw.second;
|
||||
return * col_frw.first;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return pointer to mesh
|
||||
* \retval SMESH_Mesh - mesh
|
||||
*/
|
||||
SMESH_Mesh* Mesh() const { return myHelper->GetMesh(); }
|
||||
|
||||
/*!
|
||||
* \brief Return pointer to mesh DS
|
||||
* \retval SMESHDS_Mesh - mesh DS
|
||||
*/
|
||||
SMESHDS_Mesh* MeshDS() const { return Mesh()->GetMeshDS(); }
|
||||
|
||||
/*!
|
||||
* \brief Return submesh of a shape
|
||||
* \param shapeID - shape given by in-block index
|
||||
* \retval SMESH_subMesh* - found submesh
|
||||
*/
|
||||
SMESH_subMesh* SubMesh(const int shapeID) const
|
||||
{ return Mesh()->GetSubMesh( Shape( shapeID )); }
|
||||
|
||||
/*!
|
||||
* \brief Return submesh DS of a shape
|
||||
* \param shapeID - shape given by in-block index
|
||||
* \retval SMESHDS_SubMesh* - found submesh DS
|
||||
*/
|
||||
SMESHDS_SubMesh* SubMeshDS(const int shapeID) const
|
||||
{ return SubMesh(shapeID)->GetSubMeshDS(); }
|
||||
|
||||
/*!
|
||||
* \brief Return a in-block shape
|
||||
* \param shapeID - shape given by in-block index
|
||||
* \retval SMESHDS_SubMesh* - found submesh
|
||||
*/
|
||||
const TopoDS_Shape& Shape(const int shapeID) const
|
||||
{ return myShapeIDMap( shapeID ); }
|
||||
|
||||
/*!
|
||||
* \brief Return in-block ID of a shape
|
||||
* \param shape - block subshape
|
||||
* \retval int - ID or zero if the shape has no ID
|
||||
*/
|
||||
int ShapeID(const TopoDS_Shape& shape) const
|
||||
{ return myShapeIDMap.FindIndex( shape ); }
|
||||
|
||||
/*!
|
||||
* \brief Check curve orientation of a bootom edge
|
||||
* \param meshDS - mesh DS
|
||||
* \param columnsMap - node columns map of side face
|
||||
* \param bottomEdge - the bootom edge
|
||||
* \param sideFaceID - side face in-block ID
|
||||
* \retval bool - true if orienation coinside with in-block froward orienation
|
||||
*/
|
||||
static bool IsForwardEdge(SMESHDS_Mesh* meshDS,
|
||||
const TParam2ColumnMap& columnsMap,
|
||||
const TopoDS_Edge & bottomEdge,
|
||||
const int sideFaceID);
|
||||
/*!
|
||||
* \brief Find wall faces by bottom edges
|
||||
* \param mesh - the mesh
|
||||
* \param mainShape - the prism
|
||||
* \param bottomFace - the bottom face
|
||||
* \param bottomEdges - edges bounding the bottom face
|
||||
* \param wallFaces - faces list to fill in
|
||||
*/
|
||||
static bool GetWallFaces( SMESH_Mesh* mesh,
|
||||
const TopoDS_Shape & mainShape,
|
||||
const TopoDS_Shape & bottomFace,
|
||||
const std::list< TopoDS_Edge >& bottomEdges,
|
||||
std::list< TopoDS_Face >& wallFaces);
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Class representing a part of a geom face or
|
||||
* a union of seleral faces. Or just an ordinary geom face
|
||||
*
|
||||
* It's parametrization is within [0,1] range.
|
||||
* It redefines Adaptor3d_Surface::Value(U,V) where U and V are within [0,1]
|
||||
*/
|
||||
// --------------------------------------------------------------------
|
||||
class TSideFace: public Adaptor3d_Surface
|
||||
{
|
||||
int myID; //!< in-block ID
|
||||
// map used to find out real UV by it's normalized UV
|
||||
TParam2ColumnMap* myParamToColumnMap;
|
||||
BRepAdaptor_Surface mySurface;
|
||||
TopoDS_Edge myBaseEdge;
|
||||
// first and last normalized params and orientaion for each component or it-self
|
||||
vector< pair< double, double> > myParams;
|
||||
bool myIsForward;
|
||||
vector< TSideFace* > myComponents;
|
||||
SMESH_MesherHelper * myHelper;
|
||||
public:
|
||||
TSideFace( SMESH_MesherHelper* helper,
|
||||
const int faceID,
|
||||
const TopoDS_Face& face,
|
||||
const TopoDS_Edge& baseEdge,
|
||||
TParam2ColumnMap* columnsMap,
|
||||
const double first = 0.0,
|
||||
const double last = 1.0);
|
||||
TSideFace( const std::vector< TSideFace* >& components,
|
||||
const std::vector< pair< double, double> > & params);
|
||||
TSideFace( const TSideFace& other );
|
||||
~TSideFace();
|
||||
bool IsComplex() const
|
||||
{ return ( NbComponents() > 0 || myParams[0].first != 0. || myParams[0].second != 1. ); }
|
||||
int FaceID() const { return myID; }
|
||||
TParam2ColumnMap* GetColumns() const { return myParamToColumnMap; }
|
||||
gp_XY GetNodeUV(const TopoDS_Face& F, const SMDS_MeshNode* n) const
|
||||
{ return myHelper->GetNodeUV( F, n ); }
|
||||
const TopoDS_Edge & BaseEdge() const { return myBaseEdge; }
|
||||
int ColumnHeight() const {
|
||||
if ( NbComponents() ) return GetComponent(0)->GetColumns()->begin()->second.size();
|
||||
else return GetColumns()->begin()->second.size(); }
|
||||
double GetColumns(const double U, TParam2ColumnIt & col1, TParam2ColumnIt& col2 ) const;
|
||||
int NbComponents() const { return myComponents.size(); }
|
||||
TSideFace* GetComponent(const int i) const { return myComponents.at( i ); }
|
||||
void SetComponent(const int i, TSideFace* c)
|
||||
{ if ( myComponents[i] ) delete myComponents[i]; myComponents[i]=c; }
|
||||
TSideFace* GetComponent(const double U, double& localU) const;
|
||||
bool IsForward() const { return myIsForward; }
|
||||
// boundary geometry for a face
|
||||
Adaptor3d_Surface* Surface() const { return new TSideFace( *this ); }
|
||||
bool GetPCurves(Adaptor2d_Curve2d* pcurv[4]) const;
|
||||
Adaptor2d_Curve2d* HorizPCurve(const bool isTop, const TopoDS_Face& horFace) const;
|
||||
Adaptor3d_Curve* HorizCurve(const bool isTop) const;
|
||||
Adaptor3d_Curve* VertiCurve(const bool isMax) const;
|
||||
TopoDS_Edge GetEdge( const int edge ) const;
|
||||
int InsertSubShapes( TBlockShapes& shapeMap ) const;
|
||||
// redefine Adaptor methods
|
||||
gp_Pnt Value(const Standard_Real U,const Standard_Real V) const;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Class emulating geometry of a vertical edge
|
||||
*/
|
||||
// --------------------------------------------------------------------
|
||||
class TVerticalEdgeAdaptor: public Adaptor3d_Curve
|
||||
{
|
||||
const TNodeColumn* myNodeColumn;
|
||||
public:
|
||||
TVerticalEdgeAdaptor( const TParam2ColumnMap* columnsMap, const double parameter );
|
||||
gp_Pnt Value(const Standard_Real U) const;
|
||||
Standard_Real FirstParameter() const { return 0; }
|
||||
Standard_Real LastParameter() const { return 1; }
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Class emulating geometry of a hirizontal edge
|
||||
*/
|
||||
// --------------------------------------------------------------------
|
||||
class THorizontalEdgeAdaptor: public Adaptor3d_Curve
|
||||
{
|
||||
const TSideFace* mySide;
|
||||
double myV;
|
||||
public:
|
||||
THorizontalEdgeAdaptor( const TSideFace* sideFace, const bool isTop)
|
||||
:mySide(sideFace), myV( isTop ? 1.0 : 0.0 ) {}
|
||||
gp_Pnt Value(const Standard_Real U) const;
|
||||
Standard_Real FirstParameter() const { return 0; }
|
||||
Standard_Real LastParameter() const { return 1; }
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Class emulating pcurve on a hirizontal face
|
||||
*/
|
||||
// --------------------------------------------------------------------
|
||||
class TPCurveOnHorFaceAdaptor: public Adaptor2d_Curve2d
|
||||
{
|
||||
const TSideFace* mySide;
|
||||
int myZ;
|
||||
TopoDS_Face myFace;
|
||||
public:
|
||||
TPCurveOnHorFaceAdaptor( const TSideFace* sideFace,
|
||||
const bool isTop,
|
||||
const TopoDS_Face& horFace)
|
||||
: mySide(sideFace), myFace(horFace), myZ(isTop ? mySide->ColumnHeight() - 1 : 0 ) {}
|
||||
gp_Pnt2d Value(const Standard_Real U) const;
|
||||
Standard_Real FirstParameter() const { return 0; }
|
||||
Standard_Real LastParameter() const { return 1; }
|
||||
};
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
bool myNotQuadOnTop;
|
||||
SMESH_MesherHelper* myHelper;
|
||||
TBlockShapes myShapeIDMap;
|
||||
|
||||
// container of 4 side faces
|
||||
TSideFace* mySide;
|
||||
// node columns for each base edge
|
||||
vector< TParam2ColumnMap > myParam2ColumnMaps;
|
||||
// to find a column for a node by edge SMESHDS Index
|
||||
map< int, pair< TParam2ColumnMap*, bool > > myShapeIndex2ColumnMap;
|
||||
|
||||
|
||||
//vector< SMESH_subMesh* > mySubMeshesVec; // submesh by in-block id
|
||||
};
|
||||
|
||||
// =============================================
|
||||
/*!
|
||||
* \brief Algo building prisms on a prism shape
|
||||
*/
|
||||
// =============================================
|
||||
|
||||
class StdMeshers_Prism_3D: public SMESH_3D_Algo
|
||||
{
|
||||
public:
|
||||
StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~StdMeshers_Prism_3D();
|
||||
|
||||
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus);
|
||||
|
||||
virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
|
||||
|
||||
/*!
|
||||
* \brief Enable removal of quadrangles from the bottom face and
|
||||
* triangles creation there by projection from the top
|
||||
* (sole face meshed with triangles is considered to be a bottom one).
|
||||
* If there are two faces with triangles, triangles must
|
||||
* be of the same topology, else the algo fails.
|
||||
* The method must be called before Compute()
|
||||
*/
|
||||
void ProjectTriangles() { myProjectTriangles = true; }
|
||||
|
||||
/*!
|
||||
* \brief Create prisms
|
||||
* \param nodeColumns - columns of nodes generated from nodes of a mesh face
|
||||
* \param helper - helper initialized by mesh and shape to add prisms to
|
||||
*/
|
||||
static void AddPrisms( vector<const TNodeColumn*> & nodeColumns,
|
||||
SMESH_MesherHelper* helper);
|
||||
|
||||
private:
|
||||
|
||||
/*!
|
||||
* \brief Find correspondence between bottom and top nodes.
|
||||
* If elements on the bottom and top faces are topologically different,
|
||||
* and projection is possible and allowed, perform the projection
|
||||
* \retval bool - is a success or not
|
||||
*/
|
||||
bool assocOrProjBottom2Top();
|
||||
|
||||
/*!
|
||||
* \brief Remove quadrangles from the top face and
|
||||
* create triangles there by projection from the bottom
|
||||
* \retval bool - a success or not
|
||||
*/
|
||||
bool projectBottomToTop();
|
||||
|
||||
/*!
|
||||
* \brief Set projection coordinates of a node to a face and it's subshapes
|
||||
* \param faceID - the face given by in-block ID
|
||||
* \param params - node normalized parameters
|
||||
* \retval bool - is a success
|
||||
*/
|
||||
bool setFaceAndEdgesXYZ( const int faceID, const gp_XYZ& params, int z );
|
||||
|
||||
private:
|
||||
|
||||
bool myProjectTriangles;
|
||||
|
||||
StdMeshers_PrismAsBlock myBlock;
|
||||
SMESH_MesherHelper* myHelper;
|
||||
|
||||
vector<gp_XYZ> myShapeXYZ; // point on each sub-shape
|
||||
|
||||
// map of bottom nodes to the column of nodes above them
|
||||
// (the column includes the bottom node)
|
||||
typedef std::map< TNode, TNodeColumn > TNode2ColumnMap;
|
||||
TNode2ColumnMap myBotToColumnMap;
|
||||
};
|
||||
|
||||
#endif
|
219
src/StdMeshers/StdMeshers_ProjectionSource1D.cxx
Normal file
219
src/StdMeshers/StdMeshers_ProjectionSource1D.cxx
Normal file
@ -0,0 +1,219 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource1D.cxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#include "StdMeshers_ProjectionSource1D.hxx"
|
||||
|
||||
#include "SMESH_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D
|
||||
*
|
||||
* Constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource1D::StdMeshers_ProjectionSource1D(int hypId, int studyId,
|
||||
SMESH_Gen * gen)
|
||||
: SMESH_Hypothesis(hypId, studyId, gen)
|
||||
{
|
||||
_name = "ProjectionSource1D"; // used by Projection_1D
|
||||
_param_algo_dim = 1; // 1D
|
||||
_sourceMesh = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D
|
||||
*
|
||||
* Destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D()
|
||||
{
|
||||
MESSAGE( "StdMeshers_ProjectionSource1D::~StdMeshers_ProjectionSource1D" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets source <edge> to take a mesh pattern from
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource1D::SetSourceEdge(const TopoDS_Shape& edge)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( edge.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Null edge is not allowed"));
|
||||
|
||||
if ( edge.ShapeType() != TopAbs_EDGE )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
|
||||
if ( !_sourceEdge.IsSame( edge ) )
|
||||
{
|
||||
_sourceEdge = TopoDS::Edge( edge );
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets vertex association between the source edge and the target one.
|
||||
* This parameter is optional
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource1D::SetVertexAssociation(const TopoDS_Shape& sourceVertex,
|
||||
const TopoDS_Shape& targetVertex)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( sourceVertex.IsNull() != targetVertex.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Two or none vertices must be provided"));
|
||||
|
||||
if ( !sourceVertex.IsNull() ) {
|
||||
if ( sourceVertex.ShapeType() != TopAbs_VERTEX ||
|
||||
targetVertex.ShapeType() != TopAbs_VERTEX )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
}
|
||||
|
||||
if ( !_sourceVertex.IsSame( sourceVertex ) ||
|
||||
!_targetVertex.IsSame( targetVertex ) )
|
||||
{
|
||||
_sourceVertex = TopoDS::Vertex( sourceVertex );
|
||||
_targetVertex = TopoDS::Vertex( targetVertex );
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & StdMeshers_ProjectionSource1D::SaveTo(ostream & save)
|
||||
{
|
||||
// we store it in order to be able to detect that hypo is really modified
|
||||
save << " " << _sourceEdge.TShape().operator->() ;
|
||||
save << " " << _sourceVertex.TShape().operator->();
|
||||
save << " " << _targetVertex.TShape().operator->();
|
||||
save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
|
||||
return save;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & StdMeshers_ProjectionSource1D::LoadFrom(istream & load)
|
||||
{
|
||||
// impossible to restore w/o any context
|
||||
return load;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & operator <<(ostream & save, StdMeshers_ProjectionSource1D & hyp)
|
||||
{
|
||||
return hyp.SaveTo( save );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & operator >>(istream & load, StdMeshers_ProjectionSource1D & hyp)
|
||||
{
|
||||
return hyp.LoadFrom( load );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Initialize start and end length by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_ProjectionSource1D::SetParametersByMesh(const SMESH_Mesh* ,
|
||||
const TopoDS_Shape& )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource1D::GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3) const
|
||||
{
|
||||
s1 = _sourceEdge;
|
||||
s2 = _sourceVertex;
|
||||
s3 = _targetVertex;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource1D::RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
SMESH_Mesh* mesh)
|
||||
{
|
||||
_sourceEdge = TopoDS::Edge( s1 );
|
||||
_sourceVertex = TopoDS::Vertex( s2 );
|
||||
_targetVertex = TopoDS::Vertex( s3 );
|
||||
_sourceMesh = mesh;
|
||||
}
|
||||
|
142
src/StdMeshers/StdMeshers_ProjectionSource1D.hxx
Normal file
142
src/StdMeshers/StdMeshers_ProjectionSource1D.hxx
Normal file
@ -0,0 +1,142 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource1D.hxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#ifndef _SMESH_ProjectionSource1D_HXX_
|
||||
#define _SMESH_ProjectionSource1D_HXX_
|
||||
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
class SMESH_Gen;
|
||||
|
||||
// =========================================================
|
||||
/*!
|
||||
* This hypothesis specifies a meshed edge to take a mesh pattern from
|
||||
* and optionally association of vertices between the source edge and a
|
||||
* target one (where a hipothesis is assigned to)
|
||||
*/
|
||||
// =========================================================
|
||||
|
||||
class StdMeshers_ProjectionSource1D: public SMESH_Hypothesis
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
StdMeshers_ProjectionSource1D( int hypId, int studyId, SMESH_Gen * gen );
|
||||
// Destructor
|
||||
virtual ~StdMeshers_ProjectionSource1D();
|
||||
|
||||
/*!
|
||||
* Sets source <edge> to take a mesh pattern from
|
||||
*/
|
||||
void SetSourceEdge(const TopoDS_Shape& edge)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the source edge
|
||||
*/
|
||||
TopoDS_Edge GetSourceEdge() const { return _sourceEdge; }
|
||||
|
||||
/*!
|
||||
* Sets source <mesh> to take a mesh pattern from
|
||||
*/
|
||||
void SetSourceMesh(SMESH_Mesh* mesh) { _sourceMesh = mesh; }
|
||||
|
||||
/*!
|
||||
* Return source mesh
|
||||
*/
|
||||
SMESH_Mesh* GetSourceMesh() const { return _sourceMesh; }
|
||||
|
||||
/*!
|
||||
* Sets vertex association between the source edge and the target one.
|
||||
* This parameter is optional
|
||||
*/
|
||||
void SetVertexAssociation(const TopoDS_Shape& sourceVertex,
|
||||
const TopoDS_Shape& targetVertex)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the vertex associated with the target vertex.
|
||||
* Result may be nil if association not set
|
||||
*/
|
||||
TopoDS_Vertex GetSourceVertex() const { return _sourceVertex; }
|
||||
|
||||
/*!
|
||||
* Returns the vertex associated with the source vertex.
|
||||
* Result may be nil if association not set
|
||||
*/
|
||||
TopoDS_Vertex GetTargetVertex() const { return _targetVertex; }
|
||||
|
||||
/*!
|
||||
* \brief Test if vertex association defined
|
||||
* \retval bool - test result
|
||||
*/
|
||||
bool HasVertexAssociation() const
|
||||
{ return ( !_sourceVertex.IsNull() && !_targetVertex.IsNull() ); }
|
||||
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
void GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3) const;
|
||||
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
void RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
SMESH_Mesh* mesh);
|
||||
|
||||
virtual std::ostream & SaveTo(std::ostream & save);
|
||||
virtual std::istream & LoadFrom(std::istream & load);
|
||||
friend std::ostream & operator <<(std::ostream & save, StdMeshers_ProjectionSource1D & hyp);
|
||||
friend std::istream & operator >>(std::istream & load, StdMeshers_ProjectionSource1D & hyp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize parameters by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*
|
||||
* Implementation does noting
|
||||
*/
|
||||
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Edge _sourceEdge;
|
||||
SMESH_Mesh* _sourceMesh;
|
||||
TopoDS_Vertex _sourceVertex;
|
||||
TopoDS_Vertex _targetVertex;
|
||||
};
|
||||
|
||||
#endif
|
287
src/StdMeshers/StdMeshers_ProjectionSource2D.cxx
Normal file
287
src/StdMeshers/StdMeshers_ProjectionSource2D.cxx
Normal file
@ -0,0 +1,287 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource2D.cxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
|
||||
#include "StdMeshers_ProjectionSource2D.hxx"
|
||||
|
||||
#include "SMESH_Mesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource2D::StdMeshers_ProjectionSource2D
|
||||
*
|
||||
* Constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource2D::StdMeshers_ProjectionSource2D(int hypId, int studyId,
|
||||
SMESH_Gen * gen)
|
||||
: SMESH_Hypothesis(hypId, studyId, gen)
|
||||
{
|
||||
_name = "ProjectionSource2D"; // used by Projection_2D
|
||||
_param_algo_dim = 2; // 2D
|
||||
_sourceMesh = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource2D::~StdMeshers_ProjectionSource2D
|
||||
*
|
||||
* Destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource2D::~StdMeshers_ProjectionSource2D()
|
||||
{
|
||||
MESSAGE( "StdMeshers_ProjectionSource2D::~StdMeshers_ProjectionSource2D" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets a source <face> to take a mesh pattern from
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource2D::SetSourceFace(const TopoDS_Shape& Face)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( Face.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Null Face is not allowed"));
|
||||
|
||||
if ( Face.ShapeType() != TopAbs_FACE )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
|
||||
if ( !_sourceFace.IsSame( Face ) )
|
||||
{
|
||||
_sourceFace = TopoDS::Face( Face );
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets vertex association between the source face and the target one.
|
||||
* This parameter is optional.
|
||||
* Two vertices must belong to one edge of a face
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource2D::SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
|
||||
const TopoDS_Shape& sourceVertex2,
|
||||
const TopoDS_Shape& targetVertex1,
|
||||
const TopoDS_Shape& targetVertex2)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( sourceVertex1.IsNull() != targetVertex1.IsNull() ||
|
||||
sourceVertex2.IsNull() != targetVertex2.IsNull() ||
|
||||
sourceVertex1.IsNull() != targetVertex2.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Two or none pairs of vertices must be provided"));
|
||||
|
||||
if ( !sourceVertex1.IsNull() ) {
|
||||
if ( sourceVertex1.ShapeType() != TopAbs_VERTEX ||
|
||||
sourceVertex2.ShapeType() != TopAbs_VERTEX ||
|
||||
targetVertex1.ShapeType() != TopAbs_VERTEX ||
|
||||
targetVertex2.ShapeType() != TopAbs_VERTEX )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
}
|
||||
|
||||
if ( !_sourceVertex1.IsSame( sourceVertex1 ) ||
|
||||
!_sourceVertex2.IsSame( sourceVertex2 ) ||
|
||||
!_targetVertex1.IsSame( targetVertex1 ) ||
|
||||
!_targetVertex2.IsSame( targetVertex2 ) )
|
||||
{
|
||||
_sourceVertex1 = TopoDS::Vertex( sourceVertex1 );
|
||||
_sourceVertex2 = TopoDS::Vertex( sourceVertex2 );
|
||||
_targetVertex1 = TopoDS::Vertex( targetVertex1 );
|
||||
_targetVertex2 = TopoDS::Vertex( targetVertex2 );
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the source face
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Face StdMeshers_ProjectionSource2D::GetSourceFace() const
|
||||
{
|
||||
return _sourceFace;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the vertex associated with the target vertex.
|
||||
* Result may be nil if association not set
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Vertex StdMeshers_ProjectionSource2D::GetSourceVertex(int i) const
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( i == 1 )
|
||||
return _sourceVertex1;
|
||||
else if ( i == 2 )
|
||||
return _sourceVertex2;
|
||||
else
|
||||
throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the <i>-th target vertex associated with the <i>-th source vertex.
|
||||
* Result may be nil if association not set.
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Vertex StdMeshers_ProjectionSource2D::GetTargetVertex(int i) const
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( i == 1 )
|
||||
return _targetVertex1;
|
||||
else if ( i == 2 )
|
||||
return _targetVertex2;
|
||||
else
|
||||
throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & StdMeshers_ProjectionSource2D::SaveTo(ostream & save)
|
||||
{
|
||||
// we store it in order to be able to detect that hypo is really modified
|
||||
save << " " << _sourceFace.TShape().operator->() ;
|
||||
save << " " << _sourceVertex1.TShape().operator->();
|
||||
save << " " << _targetVertex1.TShape().operator->();
|
||||
save << " " << _sourceVertex2.TShape().operator->();
|
||||
save << " " << _targetVertex2.TShape().operator->();
|
||||
save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
|
||||
return save;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & StdMeshers_ProjectionSource2D::LoadFrom(istream & load)
|
||||
{
|
||||
// impossible to restore w/o any context
|
||||
// It is done by servant
|
||||
return load;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & operator <<(ostream & save, StdMeshers_ProjectionSource2D & hyp)
|
||||
{
|
||||
return hyp.SaveTo( save );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & operator >>(istream & load, StdMeshers_ProjectionSource2D & hyp)
|
||||
{
|
||||
return hyp.LoadFrom( load );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Initialize start and end length by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_ProjectionSource2D::SetParametersByMesh(const SMESH_Mesh* ,
|
||||
const TopoDS_Shape& )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource2D::GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3,
|
||||
TopoDS_Shape& s4,
|
||||
TopoDS_Shape& s5) const
|
||||
{
|
||||
s1 = _sourceFace;
|
||||
s2 = _sourceVertex1;
|
||||
s3 = _sourceVertex2;
|
||||
s4 = _targetVertex1;
|
||||
s5 = _targetVertex2;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource2D::RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
const TopoDS_Shape& s4,
|
||||
const TopoDS_Shape& s5,
|
||||
SMESH_Mesh* mesh)
|
||||
{
|
||||
_sourceFace = TopoDS::Face( s1 );
|
||||
_sourceVertex1 = TopoDS::Vertex( s2 );
|
||||
_sourceVertex2 = TopoDS::Vertex( s3 );
|
||||
_targetVertex1 = TopoDS::Vertex( s4 );
|
||||
_targetVertex2 = TopoDS::Vertex( s5 );
|
||||
_sourceMesh = mesh;
|
||||
}
|
155
src/StdMeshers/StdMeshers_ProjectionSource2D.hxx
Normal file
155
src/StdMeshers/StdMeshers_ProjectionSource2D.hxx
Normal file
@ -0,0 +1,155 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource2D.hxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#ifndef _SMESH_ProjectionSource2D_HXX_
|
||||
#define _SMESH_ProjectionSource2D_HXX_
|
||||
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
class SMESH_Gen;
|
||||
|
||||
// =========================================================
|
||||
/*!
|
||||
* This hypothesis specifies a meshed face to take a mesh pattern from
|
||||
* and optionally association of vertices between the source face and a
|
||||
* target one (where a hipothesis is assigned to)
|
||||
*/
|
||||
// =========================================================
|
||||
|
||||
class StdMeshers_ProjectionSource2D: public SMESH_Hypothesis
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
StdMeshers_ProjectionSource2D( int hypId, int studyId, SMESH_Gen * gen );
|
||||
// Destructor
|
||||
virtual ~StdMeshers_ProjectionSource2D();
|
||||
|
||||
/*!
|
||||
* Sets a source <face> to take a mesh pattern from
|
||||
*/
|
||||
void SetSourceFace(const TopoDS_Shape& face)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the source face
|
||||
*/
|
||||
TopoDS_Face GetSourceFace() const;
|
||||
|
||||
/*!
|
||||
* Sets source <mesh> to take a mesh pattern from
|
||||
*/
|
||||
void SetSourceMesh(SMESH_Mesh* mesh) { _sourceMesh = mesh; }
|
||||
|
||||
/*!
|
||||
* Return source mesh
|
||||
*/
|
||||
SMESH_Mesh* GetSourceMesh() const { return _sourceMesh; }
|
||||
|
||||
/*!
|
||||
* Sets vertex association between the source face and the target one.
|
||||
* This parameter is optional.
|
||||
* Two vertices must belong to one edge of a face
|
||||
*/
|
||||
void SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
|
||||
const TopoDS_Shape& sourceVertex2,
|
||||
const TopoDS_Shape& targetVertex1,
|
||||
const TopoDS_Shape& targetVertex2)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the <i>-th source vertex associated with the <i>-th target vertex.
|
||||
* Result may be nil if association not set.
|
||||
* Valid indices are 1 and 2
|
||||
*/
|
||||
TopoDS_Vertex GetSourceVertex(int i) const throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the <i>-th target vertex associated with the <i>-th source vertex.
|
||||
* Result may be nil if association not set.
|
||||
* Valid indices are 1 and 2
|
||||
*/
|
||||
TopoDS_Vertex GetTargetVertex(int i) const throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* \brief Test if vertex association defined
|
||||
* \retval bool - test result
|
||||
*/
|
||||
bool HasVertexAssociation() const
|
||||
{ return ( !_sourceVertex1.IsNull() && !_targetVertex1.IsNull() &&
|
||||
!_sourceVertex2.IsNull() && !_targetVertex2.IsNull()); }
|
||||
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
void GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3,
|
||||
TopoDS_Shape& s4,
|
||||
TopoDS_Shape& s5) const;
|
||||
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
void RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
const TopoDS_Shape& s4,
|
||||
const TopoDS_Shape& s5,
|
||||
SMESH_Mesh* mesh);
|
||||
|
||||
virtual std::ostream & SaveTo(std::ostream & save);
|
||||
virtual std::istream & LoadFrom(std::istream & load);
|
||||
friend std::ostream & operator <<(std::ostream & save, StdMeshers_ProjectionSource2D & hyp);
|
||||
friend std::istream & operator >>(std::istream & load, StdMeshers_ProjectionSource2D & hyp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize parameters by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*
|
||||
* Implementation does noting
|
||||
*/
|
||||
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Face _sourceFace;
|
||||
SMESH_Mesh* _sourceMesh;
|
||||
TopoDS_Vertex _sourceVertex1;
|
||||
TopoDS_Vertex _sourceVertex2;
|
||||
TopoDS_Vertex _targetVertex1;
|
||||
TopoDS_Vertex _targetVertex2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
286
src/StdMeshers/StdMeshers_ProjectionSource3D.cxx
Normal file
286
src/StdMeshers/StdMeshers_ProjectionSource3D.cxx
Normal file
@ -0,0 +1,286 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource3D.cxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#include "StdMeshers_ProjectionSource3D.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
#include "SMESH_Gen.hxx"
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource3D::StdMeshers_ProjectionSource3D
|
||||
*
|
||||
* Constructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource3D::StdMeshers_ProjectionSource3D(int hypId, int studyId,
|
||||
SMESH_Gen * gen)
|
||||
: SMESH_Hypothesis(hypId, studyId, gen)
|
||||
{
|
||||
_name = "ProjectionSource3D"; // used by Projection_3D
|
||||
_param_algo_dim = 3; // 3D
|
||||
_sourceMesh = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* StdMeshers_ProjectionSource3D::~StdMeshers_ProjectionSource3D
|
||||
*
|
||||
* Destructor
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
StdMeshers_ProjectionSource3D::~StdMeshers_ProjectionSource3D()
|
||||
{
|
||||
MESSAGE( "StdMeshers_ProjectionSource3D::~StdMeshers_ProjectionSource3D" );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets a source <face> to take a mesh pattern from
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource3D::SetSource3DShape(const TopoDS_Shape& Shape)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( Shape.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Null Shape is not allowed"));
|
||||
|
||||
if ( SMESH_Gen::GetShapeDim( Shape ) != 3 )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
|
||||
if ( !_sourceShape.IsSame( Shape ) )
|
||||
{
|
||||
_sourceShape = Shape;
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Sets vertex association between the source shape and the target one.
|
||||
* This parameter is optional.
|
||||
* Two vertices must belong to one edge of a shape
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource3D::SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
|
||||
const TopoDS_Shape& sourceVertex2,
|
||||
const TopoDS_Shape& targetVertex1,
|
||||
const TopoDS_Shape& targetVertex2)
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( sourceVertex1.IsNull() != targetVertex1.IsNull() ||
|
||||
sourceVertex2.IsNull() != targetVertex2.IsNull() ||
|
||||
sourceVertex1.IsNull() != targetVertex2.IsNull() )
|
||||
throw SALOME_Exception(LOCALIZED("Two or none pairs of vertices must be provided"));
|
||||
|
||||
if ( !sourceVertex1.IsNull() ) {
|
||||
if ( sourceVertex1.ShapeType() != TopAbs_VERTEX ||
|
||||
sourceVertex2.ShapeType() != TopAbs_VERTEX ||
|
||||
targetVertex1.ShapeType() != TopAbs_VERTEX ||
|
||||
targetVertex2.ShapeType() != TopAbs_VERTEX )
|
||||
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
|
||||
}
|
||||
|
||||
if ( !_sourceVertex1.IsSame( sourceVertex1 ) ||
|
||||
!_sourceVertex2.IsSame( sourceVertex2 ) ||
|
||||
!_targetVertex1.IsSame( targetVertex1 ) ||
|
||||
!_targetVertex2.IsSame( targetVertex2 ) )
|
||||
{
|
||||
_sourceVertex1 = TopoDS::Vertex( sourceVertex1 );
|
||||
_sourceVertex2 = TopoDS::Vertex( sourceVertex2 );
|
||||
_targetVertex1 = TopoDS::Vertex( targetVertex1 );
|
||||
_targetVertex2 = TopoDS::Vertex( targetVertex2 );
|
||||
|
||||
NotifySubMeshesHypothesisModification();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the source face
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Shape StdMeshers_ProjectionSource3D::GetSource3DShape() const
|
||||
{
|
||||
return _sourceShape;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the vertex associated with the target vertex.
|
||||
* Result may be nil if association not set
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Vertex StdMeshers_ProjectionSource3D::GetSourceVertex(int i) const
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( i == 1 )
|
||||
return _sourceVertex1;
|
||||
else if ( i == 2 )
|
||||
return _sourceVertex2;
|
||||
else
|
||||
throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Returns the <i>-th target vertex associated with the <i>-th source vertex.
|
||||
* Result may be nil if association not set.
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
TopoDS_Vertex StdMeshers_ProjectionSource3D::GetTargetVertex(int i) const
|
||||
throw ( SALOME_Exception )
|
||||
{
|
||||
if ( i == 1 )
|
||||
return _targetVertex1;
|
||||
else if ( i == 2 )
|
||||
return _targetVertex2;
|
||||
else
|
||||
throw SALOME_Exception(LOCALIZED("Wrong vertex index"));
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & StdMeshers_ProjectionSource3D::SaveTo(ostream & save)
|
||||
{
|
||||
// we store it in order to be able to detect that hypo is really modified
|
||||
save << " " << _sourceShape.TShape().operator->() ;
|
||||
save << " " << _sourceVertex1.TShape().operator->();
|
||||
save << " " << _targetVertex1.TShape().operator->();
|
||||
save << " " << _sourceVertex2.TShape().operator->();
|
||||
save << " " << _targetVertex2.TShape().operator->();
|
||||
save << " " << ( _sourceMesh ? _sourceMesh->GetId() : -1 );
|
||||
return save;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & StdMeshers_ProjectionSource3D::LoadFrom(istream & load)
|
||||
{
|
||||
// impossible to restore w/o any context
|
||||
// It is done by servant
|
||||
return load;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
ostream & operator <<(ostream & save, StdMeshers_ProjectionSource3D & hyp)
|
||||
{
|
||||
return hyp.SaveTo( save );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
istream & operator >>(istream & load, StdMeshers_ProjectionSource3D & hyp)
|
||||
{
|
||||
return hyp.LoadFrom( load );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Initialize start and end length by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_ProjectionSource3D::SetParametersByMesh(const SMESH_Mesh* ,
|
||||
const TopoDS_Shape& )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource3D::GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3,
|
||||
TopoDS_Shape& s4,
|
||||
TopoDS_Shape& s5) const
|
||||
{
|
||||
s1 = _sourceShape;
|
||||
s2 = _sourceVertex1;
|
||||
s3 = _sourceVertex2;
|
||||
s4 = _targetVertex1;
|
||||
s5 = _targetVertex2;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void StdMeshers_ProjectionSource3D::RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
const TopoDS_Shape& s4,
|
||||
const TopoDS_Shape& s5,
|
||||
SMESH_Mesh* mesh)
|
||||
{
|
||||
_sourceShape = s1;
|
||||
_sourceVertex1 = TopoDS::Vertex( s2 );
|
||||
_sourceVertex2 = TopoDS::Vertex( s3 );
|
||||
_targetVertex1 = TopoDS::Vertex( s4 );
|
||||
_targetVertex2 = TopoDS::Vertex( s5 );
|
||||
_sourceMesh = mesh;
|
||||
}
|
153
src/StdMeshers/StdMeshers_ProjectionSource3D.hxx
Normal file
153
src/StdMeshers/StdMeshers_ProjectionSource3D.hxx
Normal file
@ -0,0 +1,153 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionSource3D.hxx
|
||||
// Author : Edward AGAPOV
|
||||
// Module : SMESH
|
||||
// $Header$
|
||||
|
||||
#ifndef _SMESH_ProjectionSource3D_HXX_
|
||||
#define _SMESH_ProjectionSource3D_HXX_
|
||||
|
||||
#include "SMESH_Hypothesis.hxx"
|
||||
#include "Utils_SALOME_Exception.hxx"
|
||||
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
class SMESH_Gen;
|
||||
|
||||
// =========================================================
|
||||
/*!
|
||||
* This hypothesis specifies a meshed shell or solid to take a mesh pattern from
|
||||
* and optionally association of vertices between the source shape and a
|
||||
* target one (where a hipothesis is assigned to)
|
||||
*/
|
||||
// =========================================================
|
||||
|
||||
class StdMeshers_ProjectionSource3D: public SMESH_Hypothesis
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
StdMeshers_ProjectionSource3D( int hypId, int studyId, SMESH_Gen * gen );
|
||||
// Destructor
|
||||
virtual ~StdMeshers_ProjectionSource3D();
|
||||
|
||||
/*!
|
||||
* Sets a source <shape> to take a mesh pattern from
|
||||
*/
|
||||
void SetSource3DShape(const TopoDS_Shape& shape)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the source shape
|
||||
*/
|
||||
TopoDS_Shape GetSource3DShape() const;
|
||||
|
||||
/*!
|
||||
* Sets source <mesh> to take a mesh pattern from
|
||||
*/
|
||||
void SetSourceMesh(SMESH_Mesh* mesh) { _sourceMesh = mesh; }
|
||||
|
||||
/*!
|
||||
* Return source mesh
|
||||
*/
|
||||
SMESH_Mesh* GetSourceMesh() const { return _sourceMesh; }
|
||||
|
||||
/*!
|
||||
* Sets vertex association between the source shape and the target one.
|
||||
* This parameter is optional.
|
||||
* Two vertices must belong to one edge of a shape
|
||||
*/
|
||||
void SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
|
||||
const TopoDS_Shape& sourceVertex2,
|
||||
const TopoDS_Shape& targetVertex1,
|
||||
const TopoDS_Shape& targetVertex2)
|
||||
throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the <i>-th source vertex associated with the <i>-th target vertex.
|
||||
* Result may be nil if association not set.
|
||||
*/
|
||||
TopoDS_Vertex GetSourceVertex(int i) const throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* Returns the <i>-th target vertex associated with the <i>-th source vertex.
|
||||
* Result may be nil if association not set.
|
||||
*/
|
||||
TopoDS_Vertex GetTargetVertex(int i) const throw ( SALOME_Exception );
|
||||
|
||||
/*!
|
||||
* \brief Test if vertex association defined
|
||||
* \retval bool - test result
|
||||
*/
|
||||
bool HasVertexAssociation() const
|
||||
{ return ( !_sourceVertex1.IsNull() && !_targetVertex1.IsNull() &&
|
||||
!_sourceVertex2.IsNull() && !_targetVertex2.IsNull()); }
|
||||
|
||||
/*!
|
||||
* \brief Return all parameters
|
||||
*/
|
||||
void GetStoreParams(TopoDS_Shape& s1,
|
||||
TopoDS_Shape& s2,
|
||||
TopoDS_Shape& s3,
|
||||
TopoDS_Shape& s4,
|
||||
TopoDS_Shape& s5) const;
|
||||
|
||||
/*!
|
||||
* \brief Set all parameters without notifying on modification
|
||||
*/
|
||||
void RestoreParams(const TopoDS_Shape& s1,
|
||||
const TopoDS_Shape& s2,
|
||||
const TopoDS_Shape& s3,
|
||||
const TopoDS_Shape& s4,
|
||||
const TopoDS_Shape& s5,
|
||||
SMESH_Mesh* mesh);
|
||||
|
||||
virtual std::ostream & SaveTo(std::ostream & save);
|
||||
virtual std::istream & LoadFrom(std::istream & load);
|
||||
friend std::ostream & operator <<(std::ostream & save, StdMeshers_ProjectionSource3D & hyp);
|
||||
friend std::istream & operator >>(std::istream & load, StdMeshers_ProjectionSource3D & hyp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize parameters by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
* \param theShape - the geometry of interest
|
||||
* \retval bool - true if parameter values have been successfully defined
|
||||
*
|
||||
* Implementation does noting
|
||||
*/
|
||||
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Shape _sourceShape;
|
||||
SMESH_Mesh* _sourceMesh;
|
||||
TopoDS_Vertex _sourceVertex1;
|
||||
TopoDS_Vertex _sourceVertex2;
|
||||
TopoDS_Vertex _targetVertex1;
|
||||
TopoDS_Vertex _targetVertex2;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1241
src/StdMeshers/StdMeshers_ProjectionUtils.cxx
Normal file
1241
src/StdMeshers/StdMeshers_ProjectionUtils.cxx
Normal file
File diff suppressed because it is too large
Load Diff
198
src/StdMeshers/StdMeshers_ProjectionUtils.hxx
Normal file
198
src/StdMeshers/StdMeshers_ProjectionUtils.hxx
Normal file
@ -0,0 +1,198 @@
|
||||
// SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_ProjectionUtils.hxx
|
||||
// Created : Thu Oct 26 15:37:24 2006
|
||||
// Author : Edward AGAPOV (eap)
|
||||
|
||||
|
||||
#ifndef StdMeshers_ProjectionUtils_HeaderFile
|
||||
#define StdMeshers_ProjectionUtils_HeaderFile
|
||||
|
||||
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class SMDS_MeshNode;
|
||||
class SMESH_Mesh;
|
||||
class SMESH_Hypothesis;
|
||||
class SMESH_subMesh;
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating methods common to Projection algorithms
|
||||
*/
|
||||
class StdMeshers_ProjectionUtils
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TopTools_DataMapOfShapeShape TShapeShapeMap;
|
||||
typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
|
||||
|
||||
/*!
|
||||
* \brief Looks for association of all subshapes of two shapes
|
||||
* \param theShape1 - shape 1
|
||||
* \param theMesh1 - mesh built on shape 1
|
||||
* \param theShape2 - shape 2
|
||||
* \param theMesh2 - mesh built on shape 2
|
||||
* \param theAssociation - association map to be filled that may
|
||||
* contain association of one or two pairs of vertices
|
||||
* \retval bool - true if association found
|
||||
*/
|
||||
static bool FindSubShapeAssociation(const TopoDS_Shape& theShape1,
|
||||
SMESH_Mesh* theMesh1,
|
||||
const TopoDS_Shape& theShape2,
|
||||
SMESH_Mesh* theMesh2,
|
||||
TShapeShapeMap & theAssociationMap);
|
||||
|
||||
/*!
|
||||
* \brief Find association of edges of faces
|
||||
* \param face1 - face 1
|
||||
* \param VV1 - vertices of face 1
|
||||
* \param face2 - face 2
|
||||
* \param VV2 - vertices of face 2 associated with oned of face 1
|
||||
* \param edges1 - out list of edges of face 1
|
||||
* \param edges2 - out list of edges of face 2
|
||||
* \retval int - nb of edges in an outer wire in a success case, else zero
|
||||
*/
|
||||
static int FindFaceAssociation(const TopoDS_Face& face1,
|
||||
TopoDS_Vertex VV1[2],
|
||||
const TopoDS_Face& face2,
|
||||
TopoDS_Vertex VV2[2],
|
||||
list< TopoDS_Edge > & edges1,
|
||||
list< TopoDS_Edge > & edges2);
|
||||
|
||||
/*!
|
||||
* \brief Insert vertex association defined by a hypothesis into a map
|
||||
* \param theHyp - hypothesis
|
||||
* \param theAssociationMap - association map
|
||||
*/
|
||||
static void InitVertexAssociation( const SMESH_Hypothesis* theHyp,
|
||||
TShapeShapeMap & theAssociationMap);
|
||||
|
||||
/*!
|
||||
* \brief Inserts association theShape1 <-> theShape2 to TShapeShapeMap
|
||||
* \param theShape1 - shape 1
|
||||
* \param theShape2 - shape 2
|
||||
* \param theAssociationMap - association map
|
||||
* \param theBidirectional - if false, inserts theShape1 -> theShape2 association
|
||||
* \retval bool - true if there was no association for these shapes before
|
||||
*/
|
||||
static bool InsertAssociation( const TopoDS_Shape& theShape1,
|
||||
const TopoDS_Shape& theShape2,
|
||||
TShapeShapeMap & theAssociationMap,
|
||||
const bool theBidirectional=true);
|
||||
|
||||
static bool IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMesh );
|
||||
|
||||
static bool IsSubShape( const TopoDS_Shape& shape, const TopoDS_Shape& mainShape );
|
||||
|
||||
/*!
|
||||
* \brief Finds an edge by its vertices in a main shape of the mesh
|
||||
* \param aMesh - the mesh
|
||||
* \param V1 - vertex 1
|
||||
* \param V2 - vertex 2
|
||||
* \retval TopoDS_Edge - found edge
|
||||
*/
|
||||
static TopoDS_Edge GetEdgeByVertices( SMESH_Mesh* aMesh,
|
||||
const TopoDS_Vertex& V1,
|
||||
const TopoDS_Vertex& V2);
|
||||
|
||||
/*!
|
||||
* \brief Return another face sharing an edge
|
||||
* \param aMesh - mesh
|
||||
* \param edge - edge
|
||||
* \param face - face
|
||||
* \retval TopoDS_Face - found face
|
||||
*/
|
||||
static TopoDS_Face GetNextFace( SMESH_Mesh* aMesh,
|
||||
const TopoDS_Edge& edge,
|
||||
const TopoDS_Face& face);
|
||||
|
||||
/*!
|
||||
* \brief Return an oriented propagation edge
|
||||
* \param aMesh - mesh
|
||||
* \param fromEdge - start edge for propagation
|
||||
* \retval TopoDS_Edge - found edge
|
||||
*/
|
||||
static TopoDS_Edge GetPropagationEdge( SMESH_Mesh* aMesh,
|
||||
const TopoDS_Edge& anEdge,
|
||||
const TopoDS_Edge& fromEdge);
|
||||
|
||||
/*!
|
||||
* \brief Find corresponding nodes on two faces
|
||||
* \param face1 - the first face
|
||||
* \param mesh1 - mesh containing elements on the first face
|
||||
* \param face2 - the second face
|
||||
* \param mesh2 - mesh containing elements on the second face
|
||||
* \param assocMap - map associating subshapes of the faces
|
||||
* \param nodeIn2OutMap - map containing found matching nodes
|
||||
* \retval bool - is a success
|
||||
*/
|
||||
static bool FindMatchingNodesOnFaces( const TopoDS_Face& face1,
|
||||
SMESH_Mesh* mesh1,
|
||||
const TopoDS_Face& face2,
|
||||
SMESH_Mesh* mesh2,
|
||||
const TShapeShapeMap & assocMap,
|
||||
TNodeNodeMap & nodeIn2OutMap);
|
||||
/*!
|
||||
* \brief Check if the first and last vertices of an edge are the same
|
||||
* \param anEdge - the edge to check
|
||||
* \retval bool - true if same
|
||||
*/
|
||||
static bool IsClosedEdge( const TopoDS_Edge& anEdge );
|
||||
|
||||
/*!
|
||||
* \brief Return any subshape of a face belonging to the outer wire
|
||||
* \param face - the face
|
||||
* \param type - type of subshape to return
|
||||
* \retval TopoDS_Shape - the found subshape
|
||||
*/
|
||||
static TopoDS_Shape OuterShape( const TopoDS_Face& face,
|
||||
TopAbs_ShapeEnum type);
|
||||
|
||||
/*!
|
||||
* \brief Check that submeshis is computed and try to compute it if is not
|
||||
* \param sm - submesh to compute
|
||||
* \param iterationNb - int used to stop infinite recursive call
|
||||
* \retval bool - true if computed
|
||||
*/
|
||||
static bool MakeComputed(SMESH_subMesh * sm, const int iterationNb = 0);
|
||||
|
||||
/*!
|
||||
* \brief Count nb of subshapes
|
||||
* \param shape - the shape
|
||||
* \param type - the type of subshapes to count
|
||||
* \param ignoreSame - if true, use map not to count same shapes, esle use explorer
|
||||
* \retval int - the calculated number
|
||||
*/
|
||||
static int Count(const TopoDS_Shape& shape,
|
||||
const TopAbs_ShapeEnum type,
|
||||
const bool ignoreSame);
|
||||
};
|
||||
|
||||
#endif
|
362
src/StdMeshers/StdMeshers_Projection_1D.cxx
Normal file
362
src/StdMeshers/StdMeshers_Projection_1D.cxx
Normal file
@ -0,0 +1,362 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_1D.cxx
|
||||
// Module : SMESH
|
||||
// Created : Fri Oct 20 11:37:07 2006
|
||||
// Author : Edward AGAPOV (eap)
|
||||
|
||||
|
||||
#include "StdMeshers_Projection_1D.hxx"
|
||||
|
||||
#include "StdMeshers_ProjectionSource1D.hxx"
|
||||
#include "StdMeshers_ProjectionUtils.hxx"
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshElement.hxx"
|
||||
#include "SMESHDS_Mesh.hxx"
|
||||
#include "SMESHDS_SubMesh.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESH_MesherHelper.hxx"
|
||||
#include "SMESH_subMesh.hxx"
|
||||
#include "SMESH_subMeshEventListener.hxx"
|
||||
#include "SMESH_Gen.hxx"
|
||||
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; }
|
||||
|
||||
typedef StdMeshers_ProjectionUtils TAssocTool;
|
||||
|
||||
//=======================================================================
|
||||
//function : StdMeshers_Projection_1D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
StdMeshers_Projection_1D::StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen)
|
||||
:SMESH_1D_Algo(hypId, studyId, gen)
|
||||
{
|
||||
_name = "Projection_1D";
|
||||
_shapeType = (1 << TopAbs_EDGE); // 1 bit per shape type
|
||||
|
||||
_compatibleHypothesis.push_back("ProjectionSource1D");
|
||||
_sourceHypo = 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
StdMeshers_Projection_1D::~StdMeshers_Projection_1D()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckHypothesis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_1D::CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus)
|
||||
{
|
||||
_sourceHypo = 0;
|
||||
list <const SMESHDS_Hypothesis * >::const_iterator itl;
|
||||
|
||||
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
|
||||
if ( hyps.size() == 0 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_MISSING;
|
||||
return false; // can't work with no hypothesis
|
||||
}
|
||||
|
||||
if ( hyps.size() > 1 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
|
||||
return false;
|
||||
}
|
||||
|
||||
const SMESHDS_Hypothesis *theHyp = hyps.front();
|
||||
|
||||
string hypName = theHyp->GetName();
|
||||
|
||||
aStatus = SMESH_Hypothesis::HYP_OK;
|
||||
|
||||
if (hypName == "ProjectionSource1D")
|
||||
{
|
||||
_sourceHypo = static_cast<const StdMeshers_ProjectionSource1D *>(theHyp);
|
||||
|
||||
// Check hypo parameters
|
||||
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh* tgtMesh = & aMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
// check vertices
|
||||
if ( _sourceHypo->HasVertexAssociation() )
|
||||
{
|
||||
// source and target vertices
|
||||
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(), srcMesh ) ||
|
||||
!TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), tgtMesh ) ||
|
||||
!TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), aShape ) ||
|
||||
!TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(),
|
||||
_sourceHypo->GetSourceEdge() ))
|
||||
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
|
||||
}
|
||||
// check source edge
|
||||
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceEdge(), srcMesh ))
|
||||
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
}
|
||||
return ( aStatus == HYP_OK );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_1D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape)
|
||||
{
|
||||
if ( !_sourceHypo )
|
||||
return false;
|
||||
|
||||
TopoDS_Edge tgtEdge = TopoDS::Edge( theShape.Oriented(TopAbs_FORWARD));
|
||||
TopoDS_Edge srcEdge = TopoDS::Edge( _sourceHypo->GetSourceEdge().Oriented(TopAbs_FORWARD));
|
||||
|
||||
TopoDS_Vertex tgtV[2], srcV[2];
|
||||
TopExp::Vertices( tgtEdge, tgtV[0], tgtV[1] );
|
||||
TopExp::Vertices( srcEdge, srcV[0], srcV[1] );
|
||||
|
||||
SMESH_Mesh * srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh * tgtMesh = & theMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
|
||||
|
||||
// ---------------------------
|
||||
// Make subshapes association
|
||||
// ---------------------------
|
||||
|
||||
TAssocTool::TShapeShapeMap shape2ShapeMap;
|
||||
TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
|
||||
if ( !TAssocTool::FindSubShapeAssociation( tgtEdge, tgtMesh, srcEdge, srcMesh,
|
||||
shape2ShapeMap) )
|
||||
RETURN_BAD_RESULT("FindSubShapeAssociation failed");
|
||||
|
||||
// ----------------------------------------------
|
||||
// Assure that mesh on a source edge is computed
|
||||
// ----------------------------------------------
|
||||
|
||||
SMESH_subMesh* srcSubMesh = srcMesh->GetSubMesh( srcEdge );
|
||||
//SMESH_subMesh* tgtSubMesh = tgtMesh->GetSubMesh( tgtEdge );
|
||||
|
||||
if ( tgtMesh == srcMesh ) {
|
||||
if ( !TAssocTool::MakeComputed( srcSubMesh ))
|
||||
RETURN_BAD_RESULT("Impossible to compute the source mesh");
|
||||
}
|
||||
else {
|
||||
if ( !srcSubMesh->IsMeshComputed() )
|
||||
RETURN_BAD_RESULT("Source mesh is not computed");
|
||||
}
|
||||
// -----------------------------------------------
|
||||
// Find out nodes distribution on the source edge
|
||||
// -----------------------------------------------
|
||||
|
||||
double srcLength = EdgeLength( srcEdge );
|
||||
double tgtLength = EdgeLength( tgtEdge );
|
||||
|
||||
vector< double > params; // sorted parameters of nodes on the source edge
|
||||
if ( !SMESH_Algo::GetNodeParamOnEdge( srcMesh->GetMeshDS(), srcEdge, params ))
|
||||
RETURN_BAD_RESULT("Bad node params on the source edge");
|
||||
|
||||
int i, nbNodes = params.size();
|
||||
|
||||
vector< double > lengths( nbNodes - 1 ); // lengths of segments of the source edge
|
||||
if ( srcLength > 0 )
|
||||
{
|
||||
BRepAdaptor_Curve curveAdaptor( srcEdge );
|
||||
for ( i = 1; i < nbNodes; ++i )
|
||||
lengths[ i-1 ] = GCPnts_AbscissaPoint::Length( curveAdaptor, params[i-1], params[i]);
|
||||
}
|
||||
else // degenerated source edge
|
||||
{
|
||||
for ( i = 1; i < nbNodes; ++i )
|
||||
lengths[ i-1 ] = params[i] - params[i-1];
|
||||
srcLength = params.back() - params[0];
|
||||
}
|
||||
|
||||
bool reverse = ( srcV[0].IsSame( shape2ShapeMap( tgtV[1] )));
|
||||
if ( shape2ShapeMap.IsBound( tgtEdge )) // case of closed edge
|
||||
reverse = ( shape2ShapeMap( tgtEdge ).Orientation() == TopAbs_REVERSED );
|
||||
if ( reverse ) // reverse lengths of segments
|
||||
std::reverse( lengths.begin(), lengths.end() );
|
||||
|
||||
// ----------
|
||||
// Make mesh
|
||||
// ----------
|
||||
|
||||
// vector of target nodes
|
||||
vector< const SMDS_MeshNode* > nodes ( nbNodes );
|
||||
|
||||
// Get the first and last nodes
|
||||
// -----------------------------
|
||||
|
||||
SMESHDS_SubMesh* smV0 = meshDS->MeshElements( tgtV[0] );
|
||||
SMESHDS_SubMesh* smV1 = meshDS->MeshElements( tgtV[1] );
|
||||
if ( !smV0 || !smV1 )
|
||||
RETURN_BAD_RESULT("No submeshes on vertices");
|
||||
|
||||
SMDS_NodeIteratorPtr nItV0 = smV0->GetNodes();
|
||||
SMDS_NodeIteratorPtr nItV1 = smV1->GetNodes();
|
||||
if ( !nItV0->more() || !nItV1->more() )
|
||||
RETURN_BAD_RESULT("No nodes on vertices");
|
||||
|
||||
nodes.front() = nItV0->next();
|
||||
nodes.back() = nItV1->next();
|
||||
|
||||
// Compute parameters on the target edge and make internal nodes
|
||||
// --------------------------------------------------------------
|
||||
|
||||
vector< double > tgtParams( nbNodes );
|
||||
|
||||
BRep_Tool::Range( tgtEdge, tgtParams.front(), tgtParams.back() );
|
||||
if ( tgtLength <= 0 )
|
||||
tgtLength = tgtParams.back() - tgtParams.front();
|
||||
double dl = tgtLength / srcLength;
|
||||
|
||||
if ( tgtLength > 0 )
|
||||
{
|
||||
BRepAdaptor_Curve curveAdaptor( tgtEdge );
|
||||
|
||||
// compute params on internal nodes
|
||||
for ( i = 1; i < nbNodes - 1; ++i )
|
||||
{
|
||||
// computes a point on a <curveAdaptor> at the given distance
|
||||
// from the point at given parameter.
|
||||
GCPnts_AbscissaPoint Discret( curveAdaptor, dl * lengths[ i-1 ], tgtParams[ i-1 ] );
|
||||
if ( !Discret.IsDone() )
|
||||
RETURN_BAD_RESULT(" GCPnts_AbscissaPoint failed");
|
||||
tgtParams[ i ] = Discret.Parameter();
|
||||
}
|
||||
// make internal nodes
|
||||
for ( i = 1; i < nbNodes - 1; ++i )
|
||||
{
|
||||
gp_Pnt P = curveAdaptor.Value( tgtParams[ i ]);
|
||||
SMDS_MeshNode* node = meshDS->AddNode(P.X(), P.Y(), P.Z());
|
||||
meshDS->SetNodeOnEdge( node, tgtEdge, tgtParams[ i ]);
|
||||
nodes[ i ] = node;
|
||||
}
|
||||
}
|
||||
else // degenerated target edge
|
||||
{
|
||||
// compute params and make internal nodes
|
||||
gp_Pnt P = BRep_Tool::Pnt( tgtV[0] );
|
||||
|
||||
for ( i = 1; i < nbNodes - 1; ++i )
|
||||
{
|
||||
SMDS_MeshNode* node = meshDS->AddNode(P.X(), P.Y(), P.Z());
|
||||
tgtParams[ i ] = tgtParams[ i-1 ] + dl * lengths[ i-1 ];
|
||||
meshDS->SetNodeOnEdge( node, tgtEdge, tgtParams[ i ]);
|
||||
nodes[ i ] = node;
|
||||
}
|
||||
}
|
||||
|
||||
// Quadratic mesh?
|
||||
// ----------------
|
||||
|
||||
bool quadratic = false;
|
||||
SMDS_ElemIteratorPtr elemIt = srcSubMesh->GetSubMeshDS()->GetElements();
|
||||
if ( elemIt->more() )
|
||||
quadratic = elemIt->next()->IsQuadratic();
|
||||
else {
|
||||
SMDS_NodeIteratorPtr nodeIt = srcSubMesh->GetSubMeshDS()->GetNodes();
|
||||
while ( nodeIt->more() && !quadratic )
|
||||
quadratic = SMESH_MesherHelper::IsMedium( nodeIt->next() );
|
||||
}
|
||||
// enough nodes to make all edges quadratic?
|
||||
if ( quadratic && ( nbNodes < 3 || ( nbNodes % 2 != 1 )))
|
||||
RETURN_BAD_RESULT("Wrong nb nodes to make quadratic mesh");
|
||||
|
||||
// Create edges
|
||||
// -------------
|
||||
|
||||
SMDS_MeshElement* edge = 0;
|
||||
int di = quadratic ? 2 : 1;
|
||||
for ( i = di; i < nbNodes; i += di)
|
||||
{
|
||||
if ( quadratic )
|
||||
edge = meshDS->AddEdge( nodes[i-2], nodes[i], nodes[i-1] );
|
||||
else
|
||||
edge = meshDS->AddEdge( nodes[i-1], nodes[i] );
|
||||
meshDS->SetMeshElementOnShape(edge, tgtEdge );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source edge
|
||||
* \param subMesh - submesh where algo is set
|
||||
*
|
||||
* This method is called when a submesh gets HYP_OK algo_state.
|
||||
* After being set, event listener is notified on each event of a submesh.
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the submesh
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_Projection_1D::SetEventListener(SMESH_subMesh* subMesh)
|
||||
{
|
||||
if ( _sourceHypo && ! _sourceHypo->GetSourceEdge().IsNull() )
|
||||
{
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
if ( !srcMesh )
|
||||
srcMesh = subMesh->GetFather();
|
||||
|
||||
SMESH_subMesh* srcEdgeSM =
|
||||
srcMesh->GetSubMesh( _sourceHypo->GetSourceEdge() );
|
||||
|
||||
if ( srcEdgeSM != subMesh )
|
||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(),
|
||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
||||
srcEdgeSM );
|
||||
}
|
||||
}
|
||||
|
64
src/StdMeshers/StdMeshers_Projection_1D.hxx
Normal file
64
src/StdMeshers/StdMeshers_Projection_1D.hxx
Normal file
@ -0,0 +1,64 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_1D.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_Projection_1D_HXX_
|
||||
#define _SMESH_Projection_1D_HXX_
|
||||
|
||||
#include "SMESH_1D_Algo.hxx"
|
||||
|
||||
|
||||
class StdMeshers_ProjectionSource1D;
|
||||
|
||||
class StdMeshers_Projection_1D: public SMESH_1D_Algo
|
||||
{
|
||||
public:
|
||||
StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~StdMeshers_Projection_1D();
|
||||
|
||||
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus);
|
||||
|
||||
virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
|
||||
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source edge
|
||||
* \param whenSetToSubMesh - submesh where algo is set
|
||||
*
|
||||
* After being set, event listener is notified on each event of a submesh.
|
||||
* This method is called when a submesh gets HYP_OK algo_state.
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the whenSetToSubMesh submesh.
|
||||
*/
|
||||
virtual void SetEventListener(SMESH_subMesh* whenSetToSubMesh);
|
||||
|
||||
protected:
|
||||
|
||||
const StdMeshers_ProjectionSource1D* _sourceHypo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
638
src/StdMeshers/StdMeshers_Projection_2D.cxx
Normal file
638
src/StdMeshers/StdMeshers_Projection_2D.cxx
Normal file
@ -0,0 +1,638 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_2D.cxx
|
||||
// Module : SMESH
|
||||
// Created : Fri Oct 20 11:37:07 2006
|
||||
// Author : Edward AGAPOV (eap)
|
||||
|
||||
|
||||
#include "StdMeshers_Projection_2D.hxx"
|
||||
|
||||
#include "StdMeshers_ProjectionSource2D.hxx"
|
||||
#include "StdMeshers_ProjectionUtils.hxx"
|
||||
|
||||
#include "SMESHDS_Hypothesis.hxx"
|
||||
#include "SMESHDS_SubMesh.hxx"
|
||||
#include "SMESH_Block.hxx"
|
||||
#include "SMESH_Gen.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESH_MeshEditor.hxx"
|
||||
#include "SMESH_Pattern.hxx"
|
||||
#include "SMESH_subMesh.hxx"
|
||||
#include "SMESH_subMeshEventListener.hxx"
|
||||
#include "SMDS_EdgePosition.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; }
|
||||
|
||||
typedef StdMeshers_ProjectionUtils TAssocTool;
|
||||
|
||||
//=======================================================================
|
||||
//function : StdMeshers_Projection_2D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
StdMeshers_Projection_2D::StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen)
|
||||
:SMESH_2D_Algo(hypId, studyId, gen)
|
||||
{
|
||||
_name = "Projection_2D";
|
||||
_shapeType = (1 << TopAbs_FACE); // 1 bit per shape type
|
||||
|
||||
_compatibleHypothesis.push_back("ProjectionSource2D");
|
||||
_sourceHypo = 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
StdMeshers_Projection_2D::~StdMeshers_Projection_2D()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckHypothesis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_2D::CheckHypothesis(SMESH_Mesh& theMesh,
|
||||
const TopoDS_Shape& theShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& theStatus)
|
||||
{
|
||||
list <const SMESHDS_Hypothesis * >::const_iterator itl;
|
||||
|
||||
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(theMesh, theShape);
|
||||
if ( hyps.size() == 0 )
|
||||
{
|
||||
theStatus = HYP_MISSING;
|
||||
return false; // can't work with no hypothesis
|
||||
}
|
||||
|
||||
if ( hyps.size() > 1 )
|
||||
{
|
||||
theStatus = HYP_ALREADY_EXIST;
|
||||
return false;
|
||||
}
|
||||
|
||||
const SMESHDS_Hypothesis *theHyp = hyps.front();
|
||||
|
||||
string hypName = theHyp->GetName();
|
||||
|
||||
theStatus = HYP_OK;
|
||||
|
||||
if (hypName == "ProjectionSource2D")
|
||||
{
|
||||
_sourceHypo = static_cast<const StdMeshers_ProjectionSource2D *>(theHyp);
|
||||
|
||||
// Check hypo parameters
|
||||
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh* tgtMesh = & theMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
// check vertices
|
||||
if ( _sourceHypo->HasVertexAssociation() )
|
||||
{
|
||||
// source vertices
|
||||
TopoDS_Shape edge = TAssocTool::GetEdgeByVertices
|
||||
( srcMesh, _sourceHypo->GetSourceVertex(1), _sourceHypo->GetSourceVertex(2) );
|
||||
if ( edge.IsNull() ||
|
||||
!TAssocTool::IsSubShape( edge, srcMesh ) ||
|
||||
!TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() ))
|
||||
{
|
||||
SCRUTE((edge.IsNull()));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() )));
|
||||
theStatus = HYP_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
// target vertices
|
||||
edge = TAssocTool::GetEdgeByVertices
|
||||
( tgtMesh, _sourceHypo->GetTargetVertex(1), _sourceHypo->GetTargetVertex(2) );
|
||||
if ( edge.IsNull() ||
|
||||
!TAssocTool::IsSubShape( edge, tgtMesh ) ||
|
||||
!TAssocTool::IsSubShape( edge, theShape ))
|
||||
{
|
||||
SCRUTE((edge.IsNull()));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, theShape )));
|
||||
theStatus = HYP_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check a source face
|
||||
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh )) {
|
||||
MESSAGE("Bad source face");
|
||||
theStatus = HYP_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = HYP_INCOMPATIBLE;
|
||||
}
|
||||
return ( theStatus == HYP_OK );
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief define if a node is new or old
|
||||
* \param node - node to check
|
||||
* \retval bool - true if the node existed before Compute() is called
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool isOldNode( const SMDS_MeshNode* node )
|
||||
{
|
||||
// old nodes are shared by edges and new ones are shared
|
||||
// only by faces created by mapper
|
||||
bool isOld = false;
|
||||
SMDS_ElemIteratorPtr invElem = node->GetInverseElementIterator();
|
||||
while ( !isOld && invElem->more() )
|
||||
isOld = ( invElem->next()->GetType() == SMDSAbs_Edge );
|
||||
return isOld;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Class to remove mesh built by pattern mapper on edges
|
||||
* and vertices in the case of failure of projection algo.
|
||||
* It does it's job at destruction
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
class MeshCleaner {
|
||||
SMESH_subMesh* sm;
|
||||
public:
|
||||
MeshCleaner( SMESH_subMesh* faceSubMesh ): sm(faceSubMesh) {}
|
||||
~MeshCleaner() { Clean(sm); }
|
||||
void Release() { sm = 0; } // mesh will not be removed
|
||||
static void Clean( SMESH_subMesh* sm )
|
||||
{
|
||||
if ( !sm ) return;
|
||||
switch ( sm->GetSubShape().ShapeType() ) {
|
||||
case TopAbs_VERTEX:
|
||||
case TopAbs_EDGE: {
|
||||
SMDS_NodeIteratorPtr nIt = sm->GetSubMeshDS()->GetNodes();
|
||||
SMESHDS_Mesh* mesh = sm->GetFather()->GetMeshDS();
|
||||
while ( nIt->more() ) {
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
if ( !isOldNode( node ) )
|
||||
mesh->RemoveNode( node );
|
||||
}
|
||||
// do not break but iterate over DependsOn()
|
||||
}
|
||||
default:
|
||||
const map< int, SMESH_subMesh * >& subSM = sm->DependsOn();
|
||||
map< int, SMESH_subMesh * >::const_iterator i_sm = subSM.begin();
|
||||
for ( ; i_sm != subSM.end(); ++i_sm )
|
||||
Clean( i_sm->second );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief find new nodes belonging to one free border of mesh on face
|
||||
* \param sm - submesh on edge or vertex containg nodes to choose from
|
||||
* \param face - the face bound the submesh
|
||||
* \param u2nodes - map to fill with nodes
|
||||
* \param seamNodes - set of found nodes
|
||||
* \retval bool - is a success
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool getBoundaryNodes ( SMESH_subMesh* sm,
|
||||
const TopoDS_Face& face,
|
||||
map< double, const SMDS_MeshNode* > & u2nodes,
|
||||
set< const SMDS_MeshNode* > & seamNodes)
|
||||
{
|
||||
u2nodes.clear();
|
||||
seamNodes.clear();
|
||||
if ( !sm || !sm->GetSubMeshDS() )
|
||||
RETURN_BAD_RESULT("Null submesh");
|
||||
|
||||
SMDS_NodeIteratorPtr nIt = sm->GetSubMeshDS()->GetNodes();
|
||||
switch ( sm->GetSubShape().ShapeType() ) {
|
||||
|
||||
case TopAbs_VERTEX: {
|
||||
while ( nIt->more() ) {
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
if ( isOldNode( node ) ) continue;
|
||||
u2nodes.insert( make_pair( 0., node ));
|
||||
seamNodes.insert( node );
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TopAbs_EDGE: {
|
||||
|
||||
// Get submeshes of sub-vertices
|
||||
const map< int, SMESH_subMesh * >& subSM = sm->DependsOn();
|
||||
if ( subSM.size() != 2 )
|
||||
RETURN_BAD_RESULT("there must be 2 submeshes of sub-vertices"
|
||||
" but we have " << subSM.size());
|
||||
SMESH_subMesh* smV1 = subSM.begin()->second;
|
||||
SMESH_subMesh* smV2 = subSM.rbegin()->second;
|
||||
if ( !smV1->IsMeshComputed() || !smV2->IsMeshComputed() )
|
||||
RETURN_BAD_RESULT("Empty vertex submeshes");
|
||||
|
||||
// Look for a new node on V1
|
||||
nIt = smV1->GetSubMeshDS()->GetNodes();
|
||||
const SMDS_MeshNode* nV1 = 0;
|
||||
while ( nIt->more() && !nV1 ) {
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
if ( !isOldNode( node ) ) nV1 = node;
|
||||
}
|
||||
if ( !nV1 )
|
||||
RETURN_BAD_RESULT("No new node found on V1");
|
||||
|
||||
// Find a new node connected to nV1 and belonging to edge submesh;
|
||||
const SMDS_MeshNode* nE = 0;
|
||||
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
|
||||
SMDS_ElemIteratorPtr vElems = nV1->GetInverseElementIterator();
|
||||
while ( vElems->more() && !nE ) {
|
||||
const SMDS_MeshElement* elem = vElems->next();
|
||||
if ( elem->GetType() != SMDSAbs_Face )
|
||||
continue; // new nodes are shared by faces
|
||||
int nbNodes = elem->NbNodes();
|
||||
if ( elem->IsQuadratic() )
|
||||
nbNodes /= 2;
|
||||
int iV1 = elem->GetNodeIndex( nV1 );
|
||||
// try next aftre nV1
|
||||
int iE = SMESH_MesherHelper::WrapIndex( iV1 + 1, nbNodes );
|
||||
if ( smDS->Contains( elem->GetNode( iE ) ))
|
||||
nE = elem->GetNode( iE );
|
||||
if ( !nE ) {
|
||||
// try node before nV1
|
||||
iE = SMESH_MesherHelper::WrapIndex( iV1 - 1, nbNodes );
|
||||
if ( smDS->Contains( elem->GetNode( iE )))
|
||||
nE = elem->GetNode( iE );
|
||||
}
|
||||
if ( nE && elem->IsQuadratic() ) { // find medium node between nV1 and nE
|
||||
if ( Abs( iV1 - iE ) == 1 )
|
||||
nE = elem->GetNode( Min ( iV1, iE ) + nbNodes );
|
||||
else
|
||||
nE = elem->GetNode( elem->NbNodes() - 1 );
|
||||
}
|
||||
}
|
||||
if ( !nE )
|
||||
RETURN_BAD_RESULT("new node on edge not found");
|
||||
|
||||
// Get the whole free border of a face
|
||||
list< const SMDS_MeshNode* > bordNodes;
|
||||
list< const SMDS_MeshElement* > bordFaces;
|
||||
if ( !SMESH_MeshEditor::FindFreeBorder (nV1, nE, nV1, bordNodes, bordFaces ))
|
||||
RETURN_BAD_RESULT("free border of a face not found by nodes " <<
|
||||
nV1->GetID() << " " << nE->GetID() );
|
||||
|
||||
// Insert nodes of the free border to the map until node on V2 encountered
|
||||
SMESHDS_SubMesh* v2smDS = smV2->GetSubMeshDS();
|
||||
list< const SMDS_MeshNode* >::iterator bordIt = bordNodes.begin();
|
||||
bordIt++; // skip nV1
|
||||
for ( ; bordIt != bordNodes.end(); ++bordIt ) {
|
||||
const SMDS_MeshNode* node = *bordIt;
|
||||
if ( v2smDS->Contains( node ))
|
||||
break;
|
||||
if ( node->GetPosition()->GetTypeOfPosition() != SMDS_TOP_EDGE )
|
||||
RETURN_BAD_RESULT("Bad node position type: node " << node->GetID() <<
|
||||
" pos type " << node->GetPosition()->GetTypeOfPosition());
|
||||
const SMDS_EdgePosition* pos =
|
||||
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
|
||||
u2nodes.insert( make_pair( pos->GetUParameter(), node ));
|
||||
seamNodes.insert( node );
|
||||
}
|
||||
if ( u2nodes.size() != seamNodes.size() )
|
||||
RETURN_BAD_RESULT("Bad node params on edge " << sm->GetId() <<
|
||||
", " << u2nodes.size() << " != " << seamNodes.size() );
|
||||
return true;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
RETURN_BAD_RESULT ("Unexpected submesh type");
|
||||
|
||||
} // bool getBoundaryNodes()
|
||||
|
||||
} // namespace
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape)
|
||||
{
|
||||
if ( !_sourceHypo )
|
||||
return false;
|
||||
|
||||
TopoDS_Face tgtFace = TopoDS::Face( theShape.Oriented(TopAbs_FORWARD));
|
||||
TopoDS_Face srcFace = TopoDS::Face( _sourceHypo->GetSourceFace().Oriented(TopAbs_FORWARD));
|
||||
|
||||
SMESH_Mesh * srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh * tgtMesh = & theMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
SMESHDS_Mesh * meshDS = theMesh.GetMeshDS();
|
||||
|
||||
SMESH_MesherHelper helper( theMesh );
|
||||
helper.SetSubShape( tgtFace );
|
||||
|
||||
// ---------------------------
|
||||
// Make subshapes association
|
||||
// ---------------------------
|
||||
|
||||
TAssocTool::TShapeShapeMap shape2ShapeMap;
|
||||
TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
|
||||
if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcFace, srcMesh,
|
||||
shape2ShapeMap) )
|
||||
RETURN_BAD_RESULT("FindSubShapeAssociation failed");
|
||||
|
||||
// ----------------------------------------------
|
||||
// Assure that mesh on a source Face is computed
|
||||
// ----------------------------------------------
|
||||
|
||||
SMESH_subMesh* srcSubMesh = srcMesh->GetSubMesh( srcFace );
|
||||
SMESH_subMesh* tgtSubMesh = tgtMesh->GetSubMesh( tgtFace );
|
||||
|
||||
if ( tgtMesh == srcMesh ) {
|
||||
if ( !TAssocTool::MakeComputed( srcSubMesh ))
|
||||
RETURN_BAD_RESULT("Impossible to compute the source mesh");
|
||||
}
|
||||
else {
|
||||
if ( !srcSubMesh->IsMeshComputed() )
|
||||
RETURN_BAD_RESULT("Source mesh is not computed");
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Prepare to mapping
|
||||
// --------------------
|
||||
|
||||
// Load pattern from the source face
|
||||
SMESH_Pattern mapper;
|
||||
mapper.Load( srcMesh, srcFace );
|
||||
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
|
||||
RETURN_BAD_RESULT("SMESH_Pattern::Load() failed");
|
||||
|
||||
// Find the first target vertex corresponding to first vertex of the <mapper>
|
||||
// and <theReverse> flag needed to call mapper.Apply()
|
||||
|
||||
TopoDS_Vertex srcV1 = TopoDS::Vertex( mapper.GetSubShape( 1 ));
|
||||
if ( srcV1.IsNull() )
|
||||
RETURN_BAD_RESULT("Mesh is not bound to the face");
|
||||
if ( !shape2ShapeMap.IsBound( srcV1 ))
|
||||
RETURN_BAD_RESULT("Not associated vertices, srcV1 " << srcV1.TShape().operator->() );
|
||||
TopoDS_Vertex tgtV1 = TopoDS::Vertex( shape2ShapeMap( srcV1 ));
|
||||
|
||||
if ( !TAssocTool::IsSubShape( srcV1, srcFace ))
|
||||
RETURN_BAD_RESULT("Wrong srcV1 " << srcV1.TShape().operator->());
|
||||
if ( !TAssocTool::IsSubShape( tgtV1, tgtFace ))
|
||||
RETURN_BAD_RESULT("Wrong tgtV1 " << tgtV1.TShape().operator->());
|
||||
|
||||
// try to find out orientation by order of edges
|
||||
bool reverse = false;
|
||||
list< TopoDS_Edge > tgtEdges, srcEdges;
|
||||
list< int > nbEdgesInWires;
|
||||
SMESH_Block::GetOrderedEdges( tgtFace, tgtV1, tgtEdges, nbEdgesInWires);
|
||||
SMESH_Block::GetOrderedEdges( srcFace, srcV1, srcEdges, nbEdgesInWires);
|
||||
if ( nbEdgesInWires.front() > 1 ) // possible to find out
|
||||
{
|
||||
TopoDS_Edge srcE1 = srcEdges.front(), tgtE1 = tgtEdges.front();
|
||||
reverse = ( ! srcE1.IsSame( shape2ShapeMap( tgtE1 )));
|
||||
if ( BRep_Tool::IsClosed( tgtE1, tgtFace )) {
|
||||
reverse = ( srcE1.Orientation() == tgtE1.Orientation() );
|
||||
if ( _sourceHypo->GetSourceFace().Orientation() != theShape.Orientation() )
|
||||
reverse = !reverse;
|
||||
}
|
||||
}
|
||||
else if ( nbEdgesInWires.front() == 1 )
|
||||
{
|
||||
// TODO::Compare orientation of curves in a sole edge
|
||||
//RETURN_BAD_RESULT("Not implemented case");
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_BAD_RESULT("Bad result from SMESH_Block::GetOrderedEdges()");
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Perform 2D mapping
|
||||
// --------------------
|
||||
|
||||
// Compute mesh on a target face
|
||||
|
||||
mapper.Apply( tgtFace, tgtV1, reverse );
|
||||
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
|
||||
RETURN_BAD_RESULT("SMESH_Pattern::Apply() failed");
|
||||
|
||||
// Create the mesh
|
||||
|
||||
const bool toCreatePolygons = false, toCreatePolyedrs = false;
|
||||
mapper.MakeMesh( tgtMesh, toCreatePolygons, toCreatePolyedrs );
|
||||
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
|
||||
RETURN_BAD_RESULT("SMESH_Pattern::MakeMesh() failed");
|
||||
|
||||
// it will remove mesh built by pattern mapper on edges and vertices
|
||||
// in failure case
|
||||
MeshCleaner cleaner( tgtSubMesh );
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// mapper doesn't take care of nodes already existing on edges and vertices,
|
||||
// so we must merge nodes created by it with existing ones
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
SMESH_MeshEditor editor( tgtMesh );
|
||||
SMESH_MeshEditor::TListOfListOfNodes groupsOfNodes;
|
||||
|
||||
// Make groups of nodes to merge
|
||||
|
||||
// loop on edge and vertex submeshes of a target face
|
||||
const map< int, SMESH_subMesh * >& subSM = tgtSubMesh->DependsOn();
|
||||
map< int, SMESH_subMesh * >::const_iterator i_subSM = subSM.begin();
|
||||
for ( ; i_subSM != subSM.end(); ++i_subSM )
|
||||
{
|
||||
SMESH_subMesh* sm = i_subSM->second;
|
||||
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
|
||||
|
||||
// Sort new and old nodes of a submesh separately
|
||||
|
||||
bool isSeam = helper.IsSeamShape( sm->GetId() );
|
||||
|
||||
enum { NEW_NODES, OLD_NODES };
|
||||
map< double, const SMDS_MeshNode* > u2nodesMaps[2], u2nodesOnSeam;
|
||||
map< double, const SMDS_MeshNode* >::iterator u_oldNode, u_newNode, u_newOnSeam, newEnd;
|
||||
set< const SMDS_MeshNode* > seamNodes;
|
||||
|
||||
// mapper puts on a seam edge nodes from 2 edges
|
||||
if ( isSeam && ! getBoundaryNodes ( sm, tgtFace, u2nodesOnSeam, seamNodes ))
|
||||
RETURN_BAD_RESULT("getBoundaryNodes() failed");
|
||||
|
||||
SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
|
||||
while ( nIt->more() )
|
||||
{
|
||||
const SMDS_MeshNode* node = nIt->next();
|
||||
bool isOld = isOldNode( node );
|
||||
|
||||
if ( !isOld && isSeam ) { // new node on a seam edge
|
||||
if ( seamNodes.find( node ) != seamNodes.end())
|
||||
continue; // node is already in the map
|
||||
}
|
||||
|
||||
// sort nodes on edges by its position
|
||||
map< double, const SMDS_MeshNode* > & pos2nodes = u2nodesMaps[ isOld ];
|
||||
switch ( node->GetPosition()->GetTypeOfPosition() )
|
||||
{
|
||||
case SMDS_TOP_VERTEX: {
|
||||
pos2nodes.insert( make_pair( 0, node ));
|
||||
break;
|
||||
}
|
||||
case SMDS_TOP_EDGE: {
|
||||
const SMDS_EdgePosition* pos =
|
||||
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
|
||||
pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
RETURN_BAD_RESULT("Wrong node position type: "<<
|
||||
node->GetPosition()->GetTypeOfPosition());
|
||||
}
|
||||
}
|
||||
if ( u2nodesMaps[ OLD_NODES ].size() != u2nodesMaps[ NEW_NODES ].size() )
|
||||
RETURN_BAD_RESULT("Different nb of old and new nodes " <<
|
||||
u2nodesMaps[ OLD_NODES ].size() << " != " <<
|
||||
u2nodesMaps[ NEW_NODES ].size());
|
||||
if ( isSeam && u2nodesMaps[ OLD_NODES ].size() != u2nodesOnSeam.size() )
|
||||
RETURN_BAD_RESULT("Different nb of old and seam nodes " <<
|
||||
u2nodesMaps[ OLD_NODES ].size() << " != " << u2nodesOnSeam.size());
|
||||
|
||||
// Make groups of nodes to merge
|
||||
u_oldNode = u2nodesMaps[ OLD_NODES ].begin();
|
||||
u_newNode = u2nodesMaps[ NEW_NODES ].begin();
|
||||
newEnd = u2nodesMaps[ NEW_NODES ].end();
|
||||
u_newOnSeam = u2nodesOnSeam.begin();
|
||||
for ( ; u_newNode != newEnd; ++u_newNode, ++u_oldNode ) {
|
||||
groupsOfNodes.push_back( list< const SMDS_MeshNode* >() );
|
||||
groupsOfNodes.back().push_back( u_oldNode->second );
|
||||
groupsOfNodes.back().push_back( u_newNode->second );
|
||||
if ( isSeam )
|
||||
groupsOfNodes.back().push_back( (u_newOnSeam++)->second );
|
||||
}
|
||||
}
|
||||
|
||||
// Merge
|
||||
|
||||
editor.MergeNodes( groupsOfNodes );
|
||||
|
||||
// ---------------------------
|
||||
// Check elements orientation
|
||||
// ---------------------------
|
||||
|
||||
TopoDS_Face face = tgtFace;
|
||||
if ( !theMesh.IsMainShape( tgtFace ))
|
||||
{
|
||||
// find the main shape
|
||||
TopoDS_Shape mainShape = meshDS->ShapeToMesh();
|
||||
switch ( mainShape.ShapeType() ) {
|
||||
case TopAbs_SHELL:
|
||||
case TopAbs_SOLID: break;
|
||||
default:
|
||||
TopTools_ListIteratorOfListOfShape ancestIt = theMesh.GetAncestors( face );
|
||||
for ( ; ancestIt.More(); ancestIt.Next() ) {
|
||||
TopAbs_ShapeEnum type = ancestIt.Value().ShapeType();
|
||||
if ( type == TopAbs_SOLID ) {
|
||||
mainShape = ancestIt.Value();
|
||||
break;
|
||||
} else if ( type == TopAbs_SHELL ) {
|
||||
mainShape = ancestIt.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
// find tgtFace in the main solid or shell to know it's true orientation.
|
||||
TopExp_Explorer exp( mainShape, TopAbs_FACE );
|
||||
for ( ; exp.More(); exp.Next() ) {
|
||||
if ( tgtFace.IsSame( exp.Current() )) {
|
||||
face = TopoDS::Face( exp.Current() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix orientation
|
||||
if ( SMESH_Algo::IsReversedSubMesh( face, meshDS ))
|
||||
{
|
||||
SMDS_ElemIteratorPtr eIt = meshDS->MeshElements( face )->GetElements();
|
||||
while ( eIt->more() ) {
|
||||
const SMDS_MeshElement* e = eIt->next();
|
||||
if ( e->GetType() == SMDSAbs_Face && !editor.Reorient( e ))
|
||||
RETURN_BAD_RESULT("Pb of SMESH_MeshEditor::Reorient()");
|
||||
}
|
||||
}
|
||||
|
||||
cleaner.Release(); // do not remove mesh
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source face
|
||||
* \param subMesh - submesh where algo is set
|
||||
*
|
||||
* This method is called when a submesh gets HYP_OK algo_state.
|
||||
* After being set, event listener is notified on each event of a submesh.
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the submesh
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh)
|
||||
{
|
||||
if ( _sourceHypo && ! _sourceHypo->GetSourceFace().IsNull() )
|
||||
{
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
if ( !srcMesh )
|
||||
srcMesh = subMesh->GetFather();
|
||||
|
||||
SMESH_subMesh* srcFaceSM =
|
||||
srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() );
|
||||
|
||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(),
|
||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
||||
srcFaceSM );
|
||||
}
|
||||
}
|
63
src/StdMeshers/StdMeshers_Projection_2D.hxx
Normal file
63
src/StdMeshers/StdMeshers_Projection_2D.hxx
Normal file
@ -0,0 +1,63 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_2D.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_Projection_2D_HXX_
|
||||
#define _SMESH_Projection_2D_HXX_
|
||||
|
||||
#include "SMESH_2D_Algo.hxx"
|
||||
|
||||
class StdMeshers_ProjectionSource2D;
|
||||
|
||||
class StdMeshers_Projection_2D: public SMESH_2D_Algo
|
||||
{
|
||||
public:
|
||||
StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~StdMeshers_Projection_2D();
|
||||
|
||||
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus);
|
||||
|
||||
virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
|
||||
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source face
|
||||
* \param whenSetToSubMesh - submesh where algo is set
|
||||
*
|
||||
* After being set, event listener is notified on each event of a submesh.
|
||||
* This method is called when a submesh gets HYP_OK algo_state.
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the whenSetToSubMesh submesh.
|
||||
*/
|
||||
virtual void SetEventListener(SMESH_subMesh* whenSetToSubMesh);
|
||||
|
||||
protected:
|
||||
|
||||
const StdMeshers_ProjectionSource2D* _sourceHypo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
438
src/StdMeshers/StdMeshers_Projection_3D.cxx
Normal file
438
src/StdMeshers/StdMeshers_Projection_3D.cxx
Normal file
@ -0,0 +1,438 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_3D.cxx
|
||||
// Module : SMESH
|
||||
// Created : Fri Oct 20 11:37:07 2006
|
||||
// Author : Edward AGAPOV (eap)
|
||||
|
||||
|
||||
#include "StdMeshers_Projection_3D.hxx"
|
||||
#include "StdMeshers_ProjectionSource3D.hxx"
|
||||
|
||||
#include "StdMeshers_ProjectionUtils.hxx"
|
||||
|
||||
#include "SMESHDS_Hypothesis.hxx"
|
||||
#include "SMESHDS_SubMesh.hxx"
|
||||
#include "SMESH_Block.hxx"
|
||||
#include "SMESH_Gen.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESH_MeshEditor.hxx"
|
||||
#include "SMESH_Pattern.hxx"
|
||||
#include "SMESH_subMesh.hxx"
|
||||
#include "SMESH_subMeshEventListener.hxx"
|
||||
#include "SMESH_MesherHelper.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; }
|
||||
#define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z())
|
||||
#define SHOWYXZ(msg, xyz) // {\
|
||||
// gp_Pnt p (xyz); \
|
||||
// cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl;\
|
||||
// }
|
||||
|
||||
typedef StdMeshers_ProjectionUtils TAssocTool;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : StdMeshers_Projection_3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
StdMeshers_Projection_3D::StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen)
|
||||
:SMESH_3D_Algo(hypId, studyId, gen)
|
||||
{
|
||||
_name = "Projection_3D";
|
||||
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit per shape type
|
||||
|
||||
_compatibleHypothesis.push_back("ProjectionSource3D");
|
||||
_sourceHypo = 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
StdMeshers_Projection_3D::~StdMeshers_Projection_3D()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckHypothesis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_3D::CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus)
|
||||
{
|
||||
// check aShape that must be a 6 faces block
|
||||
if ( TAssocTool::Count( aShape, TopAbs_SHELL, 1 ) != 1 ||
|
||||
TAssocTool::Count( aShape, TopAbs_FACE , 1 ) != 6 ||
|
||||
TAssocTool::Count( aShape, TopAbs_EDGE , 1 ) != 12 ||
|
||||
TAssocTool::Count( aShape, TopAbs_WIRE , 1 ) != 6 )
|
||||
{
|
||||
aStatus = HYP_BAD_GEOMETRY;
|
||||
return false;
|
||||
}
|
||||
|
||||
list <const SMESHDS_Hypothesis * >::const_iterator itl;
|
||||
|
||||
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
|
||||
if ( hyps.size() == 0 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_MISSING;
|
||||
return false; // can't work with no hypothesis
|
||||
}
|
||||
|
||||
if ( hyps.size() > 1 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
|
||||
return false;
|
||||
}
|
||||
|
||||
const SMESHDS_Hypothesis *theHyp = hyps.front();
|
||||
|
||||
string hypName = theHyp->GetName();
|
||||
|
||||
aStatus = SMESH_Hypothesis::HYP_OK;
|
||||
|
||||
if (hypName == "ProjectionSource3D")
|
||||
{
|
||||
_sourceHypo = static_cast<const StdMeshers_ProjectionSource3D *>(theHyp);
|
||||
// Check hypo parameters
|
||||
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh* tgtMesh = & aMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
// check vertices
|
||||
if ( _sourceHypo->HasVertexAssociation() )
|
||||
{
|
||||
// source vertices
|
||||
TopoDS_Shape edge = TAssocTool::GetEdgeByVertices
|
||||
( srcMesh, _sourceHypo->GetSourceVertex(1), _sourceHypo->GetSourceVertex(2) );
|
||||
if ( edge.IsNull() ||
|
||||
!TAssocTool::IsSubShape( edge, srcMesh ) ||
|
||||
!TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() ))
|
||||
{
|
||||
SCRUTE((edge.IsNull()));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() )));
|
||||
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
// target vertices
|
||||
edge = TAssocTool::GetEdgeByVertices
|
||||
( tgtMesh, _sourceHypo->GetTargetVertex(1), _sourceHypo->GetTargetVertex(2) );
|
||||
if ( edge.IsNull() ||
|
||||
!TAssocTool::IsSubShape( edge, tgtMesh ) ||
|
||||
!TAssocTool::IsSubShape( edge, aShape ))
|
||||
{
|
||||
SCRUTE((edge.IsNull()));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
|
||||
SCRUTE((TAssocTool::IsSubShape( edge, aShape )));
|
||||
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check a source shape
|
||||
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh ) ||
|
||||
( srcMesh == tgtMesh && aShape == _sourceHypo->GetSource3DShape()))
|
||||
{
|
||||
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh)));
|
||||
SCRUTE((srcMesh == tgtMesh));
|
||||
SCRUTE((aShape == _sourceHypo->GetSource3DShape()));
|
||||
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
}
|
||||
return ( aStatus == HYP_OK );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
|
||||
{
|
||||
if ( !_sourceHypo )
|
||||
return false;
|
||||
|
||||
SMESH_Mesh * srcMesh = _sourceHypo->GetSourceMesh();
|
||||
SMESH_Mesh * tgtMesh = & aMesh;
|
||||
if ( !srcMesh )
|
||||
srcMesh = tgtMesh;
|
||||
|
||||
SMESHDS_Mesh * srcMeshDS = srcMesh->GetMeshDS();
|
||||
SMESHDS_Mesh * tgtMeshDS = tgtMesh->GetMeshDS();
|
||||
|
||||
// get shell from shape3D
|
||||
TopoDS_Shell srcShell, tgtShell;
|
||||
TopExp_Explorer exp( _sourceHypo->GetSource3DShape(), TopAbs_SHELL );
|
||||
int nbShell;
|
||||
for ( nbShell = 0; exp.More(); exp.Next(), ++nbShell )
|
||||
srcShell = TopoDS::Shell( exp.Current() );
|
||||
if ( nbShell != 1 )
|
||||
RETURN_BAD_RESULT("There must be 1 shell in the source shape");
|
||||
|
||||
exp.Init( aShape, TopAbs_SHELL );
|
||||
for ( nbShell = 0; exp.More(); exp.Next(), ++nbShell )
|
||||
tgtShell = TopoDS::Shell( exp.Current() );
|
||||
if ( nbShell != 1 )
|
||||
RETURN_BAD_RESULT("There must be 1 shell in the target shape");
|
||||
|
||||
// Assure that mesh on a source shape is computed
|
||||
|
||||
SMESH_subMesh* srcSubMesh = srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
|
||||
//SMESH_subMesh* tgtSubMesh = tgtMesh->GetSubMesh( aShape );
|
||||
|
||||
if ( tgtMesh == srcMesh && !aShape.IsSame( _sourceHypo->GetSource3DShape() )) {
|
||||
if ( !TAssocTool::MakeComputed( srcSubMesh ))
|
||||
RETURN_BAD_RESULT("Impossible to compute the source mesh");
|
||||
}
|
||||
else {
|
||||
if ( !srcSubMesh->IsMeshComputed() )
|
||||
RETURN_BAD_RESULT("Source mesh is not computed");
|
||||
}
|
||||
|
||||
// Find 2 pairs of corresponding vertices
|
||||
|
||||
TopoDS_Vertex tgtV000, tgtV100, srcV000, srcV100;
|
||||
TAssocTool::TShapeShapeMap shape2ShapeMap;
|
||||
|
||||
if ( _sourceHypo->HasVertexAssociation() )
|
||||
{
|
||||
tgtV000 = _sourceHypo->GetTargetVertex(1);
|
||||
tgtV100 = _sourceHypo->GetTargetVertex(2);
|
||||
srcV000 = _sourceHypo->GetSourceVertex(1);
|
||||
srcV100 = _sourceHypo->GetSourceVertex(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !TAssocTool::FindSubShapeAssociation( tgtShell, tgtMesh, srcShell, srcMesh,
|
||||
shape2ShapeMap) )
|
||||
RETURN_BAD_RESULT("FindSubShapeAssociation() failed");
|
||||
|
||||
exp.Init( tgtShell, TopAbs_EDGE );
|
||||
TopExp::Vertices( TopoDS::Edge( exp.Current() ), tgtV000, tgtV100 );
|
||||
|
||||
if ( !shape2ShapeMap.IsBound( tgtV000 ) || !shape2ShapeMap.IsBound( tgtV100 ))
|
||||
RETURN_BAD_RESULT("Shape associating not done");
|
||||
srcV000 = TopoDS::Vertex( shape2ShapeMap( tgtV000 ));
|
||||
srcV100 = TopoDS::Vertex( shape2ShapeMap( tgtV100 ));
|
||||
if ( !TAssocTool::IsSubShape( srcV000, srcShell ) ||
|
||||
!TAssocTool::IsSubShape( srcV100, srcShell ))
|
||||
RETURN_BAD_RESULT("Wrong target vertices");
|
||||
}
|
||||
|
||||
// Load 2 SMESH_Block's with src and tgt shells
|
||||
|
||||
SMESH_Block srcBlock, tgtBlock;
|
||||
TopTools_IndexedMapOfOrientedShape scrShapes, tgtShapes;
|
||||
if ( !tgtBlock.LoadBlockShapes( tgtShell, tgtV000, tgtV100, tgtShapes ))
|
||||
RETURN_BAD_RESULT("SMESH_Block::LoadBlockShapes(tgtShell) failed");
|
||||
|
||||
if ( !srcBlock.LoadBlockShapes( srcShell, srcV000, srcV100, scrShapes ))
|
||||
RETURN_BAD_RESULT("SMESH_Block::LoadBlockShapes(srcShell) failed");
|
||||
|
||||
// Find matching nodes of src and tgt shells
|
||||
|
||||
TNodeNodeMap src2tgtNodeMap;
|
||||
for ( int fId = SMESH_Block::ID_FirstF; fId < SMESH_Block::ID_Shell; ++fId )
|
||||
{
|
||||
// Corresponding subshapes
|
||||
TopoDS_Face srcFace = TopoDS::Face( scrShapes( fId ));
|
||||
TopoDS_Face tgtFace = TopoDS::Face( tgtShapes( fId ));
|
||||
if ( _sourceHypo->HasVertexAssociation() ) { // associate face subshapes
|
||||
shape2ShapeMap.Clear();
|
||||
vector< int > edgeIdVec;
|
||||
SMESH_Block::GetFaceEdgesIDs( fId, edgeIdVec );
|
||||
for ( int i = 0; i < edgeIdVec.size(); ++i ) {
|
||||
int eID = edgeIdVec[ i ];
|
||||
shape2ShapeMap.Bind( tgtShapes( eID ), scrShapes( eID ));
|
||||
if ( i < 2 ) {
|
||||
vector< int > vertexIdVec;
|
||||
SMESH_Block::GetEdgeVertexIDs( eID, vertexIdVec );
|
||||
shape2ShapeMap.Bind( tgtShapes( vertexIdVec[0] ), scrShapes( vertexIdVec[0] ));
|
||||
shape2ShapeMap.Bind( tgtShapes( vertexIdVec[1] ), scrShapes( vertexIdVec[1] ));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Find matching nodes of tgt and src faces
|
||||
TNodeNodeMap faceMatchingNodes;
|
||||
if ( ! TAssocTool::FindMatchingNodesOnFaces( srcFace, srcMesh, tgtFace, tgtMesh,
|
||||
shape2ShapeMap, faceMatchingNodes ))
|
||||
RETURN_BAD_RESULT("Different mesh on corresponding src and tgt faces: "
|
||||
<< srcMeshDS->ShapeToIndex( srcFace ) << " and "
|
||||
<< tgtMeshDS->ShapeToIndex( tgtFace ));
|
||||
|
||||
// put found matching nodes of 2 faces to the global map
|
||||
src2tgtNodeMap.insert( faceMatchingNodes.begin(), faceMatchingNodes.end() );
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// Make mesh
|
||||
// ------------------
|
||||
|
||||
SMDS_VolumeTool volTool;
|
||||
SMESH_MesherHelper helper( *tgtMesh );
|
||||
helper.IsQuadraticSubMesh( aShape );
|
||||
|
||||
SMESHDS_SubMesh* srcSMDS = srcSubMesh->GetSubMeshDS();
|
||||
SMDS_ElemIteratorPtr volIt = srcSMDS->GetElements();
|
||||
while ( volIt->more() ) // loop on source volumes
|
||||
{
|
||||
const SMDS_MeshElement* srcVol = volIt->next();
|
||||
if ( !srcVol || srcVol->GetType() != SMDSAbs_Volume )
|
||||
continue;
|
||||
int nbNodes = srcVol->NbNodes();
|
||||
SMDS_VolumeTool::VolumeType volType = volTool.GetType( nbNodes );
|
||||
if ( srcVol->IsQuadratic() )
|
||||
nbNodes = volTool.NbCornerNodes( volType );
|
||||
|
||||
// Find or create a new tgt node for each node of a src volume
|
||||
|
||||
vector< const SMDS_MeshNode* > nodes( nbNodes );
|
||||
for ( int i = 0; i < nbNodes; ++i )
|
||||
{
|
||||
const SMDS_MeshNode* srcNode = srcVol->GetNode( i );
|
||||
const SMDS_MeshNode* tgtNode = 0;
|
||||
TNodeNodeMap::iterator sN_tN = src2tgtNodeMap.find( srcNode );
|
||||
if ( sN_tN != src2tgtNodeMap.end() ) // found
|
||||
{
|
||||
tgtNode = sN_tN->second;
|
||||
}
|
||||
else // Create a new tgt node
|
||||
{
|
||||
// compute normalized parameters of source node in srcBlock
|
||||
gp_Pnt srcCoord = gpXYZ( srcNode );
|
||||
gp_XYZ srcParam;
|
||||
if ( !srcBlock.ComputeParameters( srcCoord, srcParam ))
|
||||
RETURN_BAD_RESULT("srcBlock.ComputeParameters() failed");
|
||||
// compute coordinates of target node by srcParam
|
||||
gp_XYZ tgtXYZ;
|
||||
if ( !tgtBlock.ShellPoint( srcParam, tgtXYZ ))
|
||||
RETURN_BAD_RESULT("tgtBlock.ShellPoint() failed");
|
||||
// add node
|
||||
SMDS_MeshNode* newNode = tgtMeshDS->AddNode( tgtXYZ.X(), tgtXYZ.Y(), tgtXYZ.Z() );
|
||||
tgtMeshDS->SetNodeInVolume( newNode, helper.GetSubShapeID() );
|
||||
tgtNode = newNode;
|
||||
src2tgtNodeMap.insert( make_pair( srcNode, tgtNode ));
|
||||
}
|
||||
nodes[ i ] = tgtNode;
|
||||
}
|
||||
|
||||
// Create a new volume
|
||||
|
||||
SMDS_MeshVolume * tgtVol = 0;
|
||||
switch ( volType ) {
|
||||
case SMDS_VolumeTool::TETRA :
|
||||
case SMDS_VolumeTool::QUAD_TETRA:
|
||||
tgtVol = helper.AddVolume( nodes[0],
|
||||
nodes[1],
|
||||
nodes[2],
|
||||
nodes[3]); break;
|
||||
case SMDS_VolumeTool::PYRAM :
|
||||
case SMDS_VolumeTool::QUAD_PYRAM:
|
||||
tgtVol = helper.AddVolume( nodes[0],
|
||||
nodes[1],
|
||||
nodes[2],
|
||||
nodes[3],
|
||||
nodes[4]); break;
|
||||
case SMDS_VolumeTool::PENTA :
|
||||
case SMDS_VolumeTool::QUAD_PENTA:
|
||||
tgtVol = helper.AddVolume( nodes[0],
|
||||
nodes[1],
|
||||
nodes[2],
|
||||
nodes[3],
|
||||
nodes[4],
|
||||
nodes[5]); break;
|
||||
case SMDS_VolumeTool::HEXA :
|
||||
case SMDS_VolumeTool::QUAD_HEXA :
|
||||
tgtVol = helper.AddVolume( nodes[0],
|
||||
nodes[1],
|
||||
nodes[2],
|
||||
nodes[3],
|
||||
nodes[4],
|
||||
nodes[5],
|
||||
nodes[6],
|
||||
nodes[7]); break;
|
||||
default: // polyhedron
|
||||
const SMDS_PolyhedralVolumeOfNodes * poly =
|
||||
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( srcVol );
|
||||
if ( !poly )
|
||||
RETURN_BAD_RESULT("Unexpected volume type");
|
||||
vector<int> quantities( poly->NbFaces(), 0 );
|
||||
for ( int i = 0; i < quantities.size(); ++i )
|
||||
quantities[ i ] = poly->NbFaceNodes( i + 1 );
|
||||
tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, quantities );
|
||||
}
|
||||
if ( tgtVol ) {
|
||||
tgtMeshDS->SetMeshElementOnShape( tgtVol, helper.GetSubShapeID() );
|
||||
}
|
||||
} // loop on volumes of src shell
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source shape
|
||||
* \param subMesh - submesh where algo is set
|
||||
*
|
||||
* This method is called when a submesh gets HYP_OK algo_state.
|
||||
* After being set, event listener is notified on each event of a submesh.
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the submesh
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh)
|
||||
{
|
||||
if ( _sourceHypo && ! _sourceHypo->GetSource3DShape().IsNull() )
|
||||
{
|
||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
||||
if ( !srcMesh )
|
||||
srcMesh = subMesh->GetFather();
|
||||
|
||||
SMESH_subMesh* srcShapeSM =
|
||||
srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
|
||||
|
||||
if ( srcShapeSM != subMesh )
|
||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(),
|
||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
||||
srcShapeSM );
|
||||
}
|
||||
}
|
||||
|
61
src/StdMeshers/StdMeshers_Projection_3D.hxx
Normal file
61
src/StdMeshers/StdMeshers_Projection_3D.hxx
Normal file
@ -0,0 +1,61 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_Projection_3D.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_Projection_3D_HXX_
|
||||
#define _SMESH_Projection_3D_HXX_
|
||||
|
||||
#include "SMESH_3D_Algo.hxx"
|
||||
|
||||
class StdMeshers_ProjectionSource3D;
|
||||
|
||||
class StdMeshers_Projection_3D: public SMESH_3D_Algo
|
||||
{
|
||||
public:
|
||||
StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~StdMeshers_Projection_3D();
|
||||
|
||||
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus);
|
||||
|
||||
virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
|
||||
|
||||
/*!
|
||||
* \brief Sets a default event listener to submesh of the source shape
|
||||
* \param whenSetToSubMesh - submesh where algo is set
|
||||
*
|
||||
* Arranges that CLEAN event is translated from source submesh to
|
||||
* the whenSetToSubMesh submesh.
|
||||
*/
|
||||
virtual void SetEventListener(SMESH_subMesh* whenSetToSubMesh);
|
||||
|
||||
protected:
|
||||
|
||||
const StdMeshers_ProjectionSource3D* _sourceHypo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
372
src/StdMeshers/StdMeshers_RadialPrism_3D.cxx
Normal file
372
src/StdMeshers/StdMeshers_RadialPrism_3D.cxx
Normal file
@ -0,0 +1,372 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_RadialPrism_3D.cxx
|
||||
// Module : SMESH
|
||||
// Created : Fri Oct 20 11:37:07 2006
|
||||
// Author : Edward AGAPOV (eap)
|
||||
|
||||
|
||||
#include "StdMeshers_RadialPrism_3D.hxx"
|
||||
|
||||
#include "StdMeshers_ProjectionUtils.hxx"
|
||||
#include "StdMeshers_NumberOfLayers.hxx"
|
||||
#include "StdMeshers_LayerDistribution.hxx"
|
||||
#include "StdMeshers_Prism_3D.hxx"
|
||||
#include "StdMeshers_Regular_1D.hxx"
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMESHDS_SubMesh.hxx"
|
||||
#include "SMESH_Gen.hxx"
|
||||
#include "SMESH_Mesh.hxx"
|
||||
#include "SMESH_MeshEditor.hxx"
|
||||
#include "SMESH_MesherHelper.hxx"
|
||||
#include "SMESH_subMesh.hxx"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <TopoDS_Shell.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; }
|
||||
#define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z())
|
||||
|
||||
typedef StdMeshers_ProjectionUtils TAssocTool;
|
||||
|
||||
//=======================================================================
|
||||
//function : StdMeshers_RadialPrism_3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen)
|
||||
:SMESH_3D_Algo(hypId, studyId, gen)
|
||||
{
|
||||
_name = "RadialPrism_3D";
|
||||
_shapeType = (1 << TopAbs_SOLID); // 1 bit per shape type
|
||||
|
||||
_compatibleHypothesis.push_back("LayerDistribution");
|
||||
_compatibleHypothesis.push_back("NumberOfLayers");
|
||||
myNbLayerHypo = 0;
|
||||
myDistributionHypo = 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Destructor
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
StdMeshers_RadialPrism_3D::~StdMeshers_RadialPrism_3D()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckHypothesis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_RadialPrism_3D::CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus)
|
||||
{
|
||||
// check aShape that must have 2 shells
|
||||
if ( TAssocTool::Count( aShape, TopAbs_SOLID, 0 ) != 1 ||
|
||||
TAssocTool::Count( aShape, TopAbs_SHELL, 0 ) != 2 )
|
||||
{
|
||||
aStatus = HYP_BAD_GEOMETRY;
|
||||
return false;
|
||||
}
|
||||
|
||||
myNbLayerHypo = 0;
|
||||
myDistributionHypo = 0;
|
||||
|
||||
list <const SMESHDS_Hypothesis * >::const_iterator itl;
|
||||
|
||||
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
|
||||
if ( hyps.size() == 0 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_MISSING;
|
||||
return false; // can't work with no hypothesis
|
||||
}
|
||||
|
||||
if ( hyps.size() > 1 )
|
||||
{
|
||||
aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
|
||||
return false;
|
||||
}
|
||||
|
||||
const SMESHDS_Hypothesis *theHyp = hyps.front();
|
||||
|
||||
string hypName = theHyp->GetName();
|
||||
|
||||
if (hypName == "NumberOfLayers")
|
||||
{
|
||||
myNbLayerHypo = static_cast<const StdMeshers_NumberOfLayers *>(theHyp);
|
||||
aStatus = SMESH_Hypothesis::HYP_OK;
|
||||
return true;
|
||||
}
|
||||
if (hypName == "LayerDistribution")
|
||||
{
|
||||
myDistributionHypo = static_cast<const StdMeshers_LayerDistribution *>(theHyp);
|
||||
aStatus = SMESH_Hypothesis::HYP_OK;
|
||||
return true;
|
||||
}
|
||||
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
|
||||
{
|
||||
TopExp_Explorer exp;
|
||||
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
|
||||
|
||||
myHelper = new SMESH_MesherHelper( aMesh );
|
||||
myHelper->IsQuadraticSubMesh( aShape );
|
||||
// to delete helper at exit from Compute()
|
||||
std::auto_ptr<SMESH_MesherHelper> helperDeleter( myHelper );
|
||||
|
||||
// get 2 shells
|
||||
TopoDS_Solid solid = TopoDS::Solid( aShape );
|
||||
TopoDS_Shell outerShell = BRepTools::OuterShell( solid );
|
||||
TopoDS_Shape innerShell;
|
||||
int nbShells = 0;
|
||||
for ( TopoDS_Iterator It (solid); It.More(); It.Next(), ++nbShells )
|
||||
if ( !outerShell.IsSame( It.Value() ))
|
||||
innerShell = It.Value();
|
||||
if ( nbShells != 2 )
|
||||
RETURN_BAD_RESULT("Must be 2 shells");
|
||||
|
||||
// ----------------------------------
|
||||
// Associate subshapes of the shells
|
||||
// ----------------------------------
|
||||
|
||||
TAssocTool::TShapeShapeMap shape2ShapeMap;
|
||||
if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
|
||||
innerShell, &aMesh,
|
||||
shape2ShapeMap) )
|
||||
RETURN_BAD_RESULT("FindSubShapeAssociation failed");
|
||||
|
||||
// ------------------
|
||||
// Make mesh
|
||||
// ------------------
|
||||
|
||||
TNode2ColumnMap node2columnMap;
|
||||
myLayerPositions.clear();
|
||||
|
||||
for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
|
||||
{
|
||||
// Corresponding subshapes
|
||||
TopoDS_Face outFace = TopoDS::Face( exp.Current() );
|
||||
TopoDS_Face inFace;
|
||||
if ( !shape2ShapeMap.IsBound( outFace )) {
|
||||
RETURN_BAD_RESULT("Association not found for face " << meshDS->ShapeToIndex( outFace ));
|
||||
} else {
|
||||
inFace = TopoDS::Face( shape2ShapeMap( outFace ));
|
||||
}
|
||||
|
||||
// Find matching nodes of in and out faces
|
||||
TNodeNodeMap nodeIn2OutMap;
|
||||
if ( ! TAssocTool::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
|
||||
shape2ShapeMap, nodeIn2OutMap ))
|
||||
RETURN_BAD_RESULT("Different mesh on corresponding out and in faces: "
|
||||
<< meshDS->ShapeToIndex( outFace ) << " and "
|
||||
<< meshDS->ShapeToIndex( inFace ));
|
||||
// Create volumes
|
||||
|
||||
SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements();
|
||||
while ( faceIt->more() ) // loop on faces on inFace
|
||||
{
|
||||
const SMDS_MeshElement* face = faceIt->next();
|
||||
if ( !face || face->GetType() != SMDSAbs_Face )
|
||||
continue;
|
||||
int nbNodes = face->NbNodes();
|
||||
if ( face->IsQuadratic() )
|
||||
nbNodes /= 2;
|
||||
|
||||
// find node columns for each node
|
||||
vector< const TNodeColumn* > columns( nbNodes );
|
||||
for ( int i = 0; i < nbNodes; ++i )
|
||||
{
|
||||
const SMDS_MeshNode* n = face->GetNode( i );
|
||||
TNode2ColumnMap::iterator n_col = node2columnMap.find( n );
|
||||
if ( n_col != node2columnMap.end() )
|
||||
columns[ i ] = & n_col->second;
|
||||
else
|
||||
columns[ i ] = makeNodeColumn( node2columnMap, n, nodeIn2OutMap[ n ] );
|
||||
}
|
||||
|
||||
StdMeshers_Prism_3D::AddPrisms( columns, myHelper );
|
||||
}
|
||||
} // loop on faces of out shell
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Create a column of nodes from outNode to inNode
|
||||
* \param n2ColMap - map of node columns to add a created column
|
||||
* \param outNode - botton node of a column
|
||||
* \param inNode - top node of a column
|
||||
* \retval const TNodeColumn* - a new column pointer
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
TNodeColumn* StdMeshers_RadialPrism_3D::makeNodeColumn( TNode2ColumnMap& n2ColMap,
|
||||
const SMDS_MeshNode* outNode,
|
||||
const SMDS_MeshNode* inNode)
|
||||
{
|
||||
SMESHDS_Mesh * meshDS = myHelper->GetMeshDS();
|
||||
int shapeID = myHelper->GetSubShapeID();
|
||||
|
||||
if ( myLayerPositions.empty() )
|
||||
computeLayerPositions( gpXYZ( inNode ), gpXYZ( outNode ));
|
||||
|
||||
int nbSegments = myLayerPositions.size() + 1;
|
||||
|
||||
TNode2ColumnMap::iterator n_col =
|
||||
n2ColMap.insert( make_pair( outNode, TNodeColumn() )).first;
|
||||
TNodeColumn & column = n_col->second;
|
||||
column.resize( nbSegments + 1 );
|
||||
column.front() = outNode;
|
||||
column.back() = inNode;
|
||||
|
||||
gp_XYZ p1 = gpXYZ( outNode );
|
||||
gp_XYZ p2 = gpXYZ( inNode );
|
||||
for ( int z = 1; z < nbSegments; ++z )
|
||||
{
|
||||
double r = myLayerPositions[ z - 1 ];
|
||||
gp_XYZ p = ( 1 - r ) * p1 + r * p2;
|
||||
SMDS_MeshNode* n = meshDS->AddNode( p.X(), p.Y(), p.Z() );
|
||||
meshDS->SetNodeInVolume( n, shapeID );
|
||||
column[ z ] = n;
|
||||
}
|
||||
|
||||
return & column;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Class computing layers distribution using data of
|
||||
* StdMeshers_LayerDistribution hypothesis
|
||||
*/
|
||||
//================================================================================
|
||||
//================================================================================
|
||||
|
||||
class TNodeDistributor: private StdMeshers_Regular_1D
|
||||
{
|
||||
list <const SMESHDS_Hypothesis *> myUsedHyps;
|
||||
public:
|
||||
// -----------------------------------------------------------------------------
|
||||
static TNodeDistributor* GetDistributor(SMESH_Mesh& aMesh)
|
||||
{
|
||||
const int myID = -1000;
|
||||
map < int, SMESH_1D_Algo * > & algoMap = aMesh.GetGen()->_map1D_Algo;
|
||||
map < int, SMESH_1D_Algo * >::iterator id_algo = algoMap.find( myID );
|
||||
if ( id_algo == algoMap.end() )
|
||||
return new TNodeDistributor( myID, 0, aMesh.GetGen() );
|
||||
return static_cast< TNodeDistributor* >( id_algo->second );
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
bool Compute( vector< double > & positions,
|
||||
gp_Pnt pIn,
|
||||
gp_Pnt pOut,
|
||||
SMESH_Mesh& aMesh,
|
||||
const StdMeshers_LayerDistribution* hyp)
|
||||
{
|
||||
double len = pIn.Distance( pOut );
|
||||
if ( len <= DBL_MIN ) RETURN_BAD_RESULT("Bad points");
|
||||
|
||||
if ( !hyp || !hyp->GetLayerDistribution() )
|
||||
RETURN_BAD_RESULT("Bad StdMeshers_LayerDistribution hypothesis");
|
||||
myUsedHyps.clear();
|
||||
myUsedHyps.push_back( hyp->GetLayerDistribution() );
|
||||
|
||||
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge( pIn, pOut );
|
||||
|
||||
SMESH_Hypothesis::Hypothesis_Status aStatus;
|
||||
if ( !StdMeshers_Regular_1D::CheckHypothesis( aMesh, edge, aStatus ))
|
||||
RETURN_BAD_RESULT("StdMeshers_Regular_1D::CheckHypothesis() failed with status "<<aStatus);
|
||||
|
||||
list< double > params;
|
||||
if ( !StdMeshers_Regular_1D::computeInternalParameters( edge, params, false ))
|
||||
RETURN_BAD_RESULT("StdMeshers_Regular_1D::computeInternalParameters() failed");
|
||||
|
||||
positions.clear();
|
||||
positions.reserve( params.size() );
|
||||
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++)
|
||||
positions.push_back( *itU / len );
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
// -----------------------------------------------------------------------------
|
||||
TNodeDistributor( int hypId, int studyId, SMESH_Gen* gen)
|
||||
: StdMeshers_Regular_1D( hypId, studyId, gen)
|
||||
{
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
virtual const list <const SMESHDS_Hypothesis *> &
|
||||
GetUsedHypothesis(SMESH_Mesh &, const TopoDS_Shape &, const bool)
|
||||
{
|
||||
return myUsedHyps;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
};
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Compute positions of nodes between the internal and the external surfaces
|
||||
* \retval bool - is a success
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool StdMeshers_RadialPrism_3D::computeLayerPositions(gp_Pnt pIn, gp_Pnt pOut)
|
||||
{
|
||||
if ( myNbLayerHypo )
|
||||
{
|
||||
int nbSegments = myNbLayerHypo->GetNumberOfLayers();
|
||||
myLayerPositions.resize( nbSegments - 1 );
|
||||
for ( int z = 1; z < nbSegments; ++z )
|
||||
myLayerPositions[ z - 1 ] = double( z )/ double( nbSegments );
|
||||
return true;
|
||||
}
|
||||
if ( myDistributionHypo ) {
|
||||
SMESH_Mesh * mesh = myHelper->GetMesh();
|
||||
return TNodeDistributor::GetDistributor(*mesh)->Compute( myLayerPositions, pIn, pOut,
|
||||
*mesh, myDistributionHypo );
|
||||
}
|
||||
RETURN_BAD_RESULT("Bad hypothesis");
|
||||
}
|
70
src/StdMeshers/StdMeshers_RadialPrism_3D.hxx
Normal file
70
src/StdMeshers/StdMeshers_RadialPrism_3D.hxx
Normal file
@ -0,0 +1,70 @@
|
||||
// SMESH SMESH : implementaion of SMESH idl descriptions
|
||||
//
|
||||
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
// File : StdMeshers_RadialPrism_3D.hxx
|
||||
// Module : SMESH
|
||||
|
||||
#ifndef _SMESH_RadialPrism_3D_HXX_
|
||||
#define _SMESH_RadialPrism_3D_HXX_
|
||||
|
||||
#include "SMESH_3D_Algo.hxx"
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class StdMeshers_NumberOfLayers;
|
||||
class StdMeshers_LayerDistribution;
|
||||
class SMESH_MesherHelper;
|
||||
|
||||
class StdMeshers_RadialPrism_3D: public SMESH_3D_Algo
|
||||
{
|
||||
public:
|
||||
StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~StdMeshers_RadialPrism_3D();
|
||||
|
||||
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
|
||||
const TopoDS_Shape& aShape,
|
||||
SMESH_Hypothesis::Hypothesis_Status& aStatus);
|
||||
|
||||
virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
|
||||
|
||||
protected:
|
||||
|
||||
typedef vector<const SMDS_MeshNode* > TNodeColumn;
|
||||
typedef map< const SMDS_MeshNode*, TNodeColumn > TNode2ColumnMap;
|
||||
|
||||
TNodeColumn* makeNodeColumn( TNode2ColumnMap& n2ColMap,
|
||||
const SMDS_MeshNode* outNode,
|
||||
const SMDS_MeshNode* inNode);
|
||||
|
||||
bool computeLayerPositions(gp_Pnt pIn, gp_Pnt pOut);
|
||||
|
||||
|
||||
const StdMeshers_NumberOfLayers* myNbLayerHypo;
|
||||
const StdMeshers_LayerDistribution* myDistributionHypo;
|
||||
SMESH_MesherHelper* myHelper;
|
||||
vector< double > myLayerPositions;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user