2014-02-20 18:25:37 +06:00
|
|
|
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
2014-02-20 18:25:37 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SMESH SMDS : implementaion of Salome mesh data structure
|
2004-12-01 15:48:31 +05:00
|
|
|
// File : SMDS_VolumeTool.hxx
|
|
|
|
// Module : SMESH
|
|
|
|
// Created : Tue Jul 13 11:27:17 2004
|
|
|
|
// Author : Edward AGAPOV (eap)
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2004-12-01 15:48:31 +05:00
|
|
|
#ifndef SMDS_VolumeTool_HeaderFile
|
|
|
|
#define SMDS_VolumeTool_HeaderFile
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
#include "SMESH_SMDS.hxx"
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
class SMDS_MeshElement;
|
|
|
|
class SMDS_MeshNode;
|
2012-08-09 16:03:55 +06:00
|
|
|
class SMDS_VtkVolume;
|
2008-03-07 12:47:05 +05:00
|
|
|
class SMDS_MeshVolume;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
//
|
|
|
|
// Class providing topological and other information about SMDS_MeshVolume:
|
|
|
|
// allows iteration on faces or, to be precise, on nodes of volume sides;
|
|
|
|
// provides info on nodes connection etc.
|
|
|
|
//
|
|
|
|
// =========================================================================
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
class SMDS_EXPORT SMDS_VolumeTool
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA,
|
|
|
|
HEX_PRISM, QUAD_TETRA, QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA,
|
|
|
|
POLYHEDA, NB_VOLUME_TYPES }; // to keep synchronised with GetSize()!
|
2005-10-10 20:37:11 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SMDS_VolumeTool ();
|
|
|
|
~SMDS_VolumeTool ();
|
2012-08-09 16:03:55 +06:00
|
|
|
SMDS_VolumeTool (const SMDS_MeshElement* theVolume,
|
|
|
|
const bool ignoreCentralNodes=true);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool Set (const SMDS_MeshElement* theVolume,
|
|
|
|
const bool ignoreCentralNodes=true);
|
2004-12-01 15:48:31 +05:00
|
|
|
// Set volume.
|
2012-08-09 16:03:55 +06:00
|
|
|
// Return false if theVolume is not of type SMDSAbs_Volume.
|
|
|
|
// ignoreCentralNodes makes skip nodes at face centers when returning
|
|
|
|
// nodes of faces of SMDSEntity_TriQuad_Hexa
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
const SMDS_MeshVolume* Element() const;
|
2008-03-07 12:47:05 +05:00
|
|
|
// return element
|
|
|
|
|
|
|
|
int ID() const;
|
|
|
|
// return element ID
|
|
|
|
|
2013-05-16 22:14:01 +06:00
|
|
|
bool IsPoly() const { return myPolyedre; }
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// -----------------------
|
|
|
|
// general info
|
|
|
|
// -----------------------
|
|
|
|
|
2005-10-10 20:37:11 +06:00
|
|
|
VolumeType GetVolumeType() const;
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
bool IsForward() const { return myVolForward; }
|
|
|
|
// Check volume orientation. can be changed by Inverse().
|
2005-01-20 11:25:54 +05:00
|
|
|
// See node order of forward volumes at the file bottom
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
void Inverse();
|
|
|
|
// Change nodes order as if the volume changes its orientation:
|
|
|
|
// top and bottom faces are reversed.
|
|
|
|
// Result of IsForward() and methods returning nodes change
|
|
|
|
|
|
|
|
const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
|
|
|
|
// Return array of volume nodes
|
|
|
|
|
|
|
|
int NbNodes() { return myVolumeNbNodes; }
|
|
|
|
// Return array of volume nodes
|
|
|
|
|
|
|
|
double GetSize() const;
|
|
|
|
// Return element volume
|
|
|
|
|
|
|
|
bool GetBaryCenter (double & X, double & Y, double & Z) const;
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool IsOut(double X, double Y, double Z, double tol) const;
|
|
|
|
// Classify a point
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// info on node connection
|
|
|
|
// -----------------------
|
|
|
|
|
|
|
|
bool IsLinked (const SMDS_MeshNode* theNode1,
|
2012-08-09 16:03:55 +06:00
|
|
|
const SMDS_MeshNode* theNode2,
|
|
|
|
const bool theIgnoreMediumNodes=false) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return true if theNode1 is linked with theNode2.
|
2012-08-09 16:03:55 +06:00
|
|
|
// If theIgnoreMediumNodes then corner nodes of quadratic cell are considered linked as well
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
bool IsLinked (const int theNode1Index,
|
2012-08-09 16:03:55 +06:00
|
|
|
const int theNode2Index,
|
|
|
|
bool theIgnoreMediumNodes=false) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return true if the node with theNode1Index is linked
|
|
|
|
// with the node with theNode2Index
|
2012-08-09 16:03:55 +06:00
|
|
|
// If theIgnoreMediumNodes then corner nodes of quadratic cell are considered linked as well
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
int GetNodeIndex(const SMDS_MeshNode* theNode) const;
|
|
|
|
// Return an index of theNode
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const;
|
|
|
|
// Fill vector with boundary edges existing in the mesh
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
double MinLinearSize2() const;
|
|
|
|
// Return minimal square distance between connected corner nodes
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
double MaxLinearSize2() const;
|
|
|
|
// Return maximal square distance between connected corner nodes
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// -------------
|
|
|
|
// info on faces
|
|
|
|
// -------------
|
2012-08-09 16:03:55 +06:00
|
|
|
// For all elements, 0-th face is bottom based on the first nodes.
|
|
|
|
// For prismatic elements (tetra,hexa,prisms), 1-th face is a top one.
|
|
|
|
// For all elements, side faces follow order of bottom nodes
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
void SetExternalNormal ();
|
|
|
|
// Node order in faces will be so that faces normals are external.
|
|
|
|
|
|
|
|
int NbFaces() const { return myNbFaces; }
|
|
|
|
// Return number of faces of the volume. In the following
|
|
|
|
// methods 0 <= faceIndex < NbFaces()
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
int NbFaceNodes( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return number of nodes in the array of face nodes
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
const int* GetFaceNodesIndices( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return the array of face nodes indices
|
|
|
|
// To comfort link iteration, the array
|
|
|
|
// length == NbFaceNodes( faceIndex ) + 1 and
|
2012-08-09 16:03:55 +06:00
|
|
|
// the last node index == the first one, except for
|
|
|
|
// SMDSEntity_TriQuad_Hexa at ignoreCentralNodes==false.
|
|
|
|
// NOTE: for the quadratic volume, node indices are in the order the nodes encounter
|
|
|
|
// in face boundary and not the order they are in the mesh face
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
const SMDS_MeshNode** GetFaceNodes( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return the array of face nodes.
|
|
|
|
// To comfort link iteration, the array
|
|
|
|
// length == NbFaceNodes( faceIndex ) + 1 and
|
2012-08-09 16:03:55 +06:00
|
|
|
// the last node == the first one, except for
|
|
|
|
// SMDSEntity_TriQuad_Hexa at ignoreCentralNodes==false.
|
|
|
|
// NOTE: for the quadratic volume, nodes are in the order they encounter in face boundary
|
|
|
|
// and not the order they are in the mesh face
|
2004-12-01 15:48:31 +05:00
|
|
|
// WARNING: do not modify the array, some methods
|
|
|
|
// work basing on its contents
|
|
|
|
|
|
|
|
bool GetFaceNodes (int faceIndex,
|
2012-08-09 16:03:55 +06:00
|
|
|
std::set<const SMDS_MeshNode*>& theFaceNodes ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return a set of face nodes.
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool IsFaceExternal( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Check normal orientation of a face.
|
2005-01-20 11:25:54 +05:00
|
|
|
// SetExternalNormal() is taken into account.
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool IsFreeFace( int faceIndex, const SMDS_MeshElement** otherVol=0 ) const;
|
2013-05-16 22:14:01 +06:00
|
|
|
// Fast check that only one volume is built on nodes of a given face
|
|
|
|
// otherVol returns another volume sharing the given facet
|
|
|
|
|
|
|
|
bool IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** otherVol=0 ) const;
|
|
|
|
// Thorough check that all volumes built on the face nodes lays on one side
|
2012-08-09 16:03:55 +06:00
|
|
|
// otherVol returns another volume sharing the given facet
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return a normal to a face
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool GetFaceBaryCenter (int faceIndex, double & X, double & Y, double & Z) const;
|
|
|
|
// Return barycenter of a face
|
|
|
|
|
|
|
|
double GetFaceArea( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return face area
|
|
|
|
|
|
|
|
int GetOppFaceIndex( int faceIndex ) const;
|
|
|
|
// Return index of the opposite face if it exists, else -1.
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
int GetCenterNodeIndex( int faceIndex ) const;
|
|
|
|
// Return index of the node located at face center of a quadratic element like HEX27
|
|
|
|
|
2014-01-20 16:32:49 +06:00
|
|
|
int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes,
|
|
|
|
const int theFaceIndexHint=-1) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return index of a face formed by theFaceNodes.
|
|
|
|
// Return -1 if a face not found
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
|
2004-12-01 15:48:31 +05:00
|
|
|
// Return index of a face formed by theFaceNodesIndices
|
|
|
|
// Return -1 if a face not found
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces) const;
|
2008-03-07 12:47:05 +05:00
|
|
|
// Fill vector with boundary faces existing in the mesh
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// ------------------------
|
|
|
|
// static methods for faces
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
static VolumeType GetType(int nbNodes);
|
|
|
|
// return VolumeType by nb of nodes in a volume
|
|
|
|
|
|
|
|
static int NbFaces( VolumeType type );
|
|
|
|
// return nb of faces by volume type
|
|
|
|
|
|
|
|
static const int* GetFaceNodesIndices(VolumeType type,
|
|
|
|
int faceIndex,
|
|
|
|
bool external);
|
|
|
|
// Return the array of face nodes indices
|
|
|
|
// To comfort link iteration, the array
|
|
|
|
// length == NbFaceNodes( faceIndex ) + 1 and
|
|
|
|
// the last node index == the first one.
|
2012-08-09 16:03:55 +06:00
|
|
|
// Nodes at face centers of SMDSEntity_TriQuad_Hexa are ignored
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
static int NbFaceNodes(VolumeType type, int faceIndex );
|
2005-06-07 19:22:20 +06:00
|
|
|
// Return number of nodes in the array of face nodes
|
2012-08-09 16:03:55 +06:00
|
|
|
// Nodes at face centers of SMDSEntity_TriQuad_Hexa are ignored
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
static int NbCornerNodes(VolumeType type);
|
|
|
|
// Useful to know nb of corner nodes of a quadratic volume
|
|
|
|
|
2014-01-20 16:32:49 +06:00
|
|
|
static int GetOppFaceIndexOfHex( int faceIndex );
|
|
|
|
// Return index of the opposite face of the hexahedron
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
private:
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
bool setFace( int faceIndex ) const;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
const SMDS_MeshElement* myVolume;
|
2012-08-09 16:03:55 +06:00
|
|
|
const SMDS_VtkVolume* myPolyedre;
|
|
|
|
bool myIgnoreCentralNodes;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
bool myVolForward;
|
|
|
|
int myNbFaces;
|
|
|
|
int myVolumeNbNodes;
|
2005-06-07 19:22:20 +06:00
|
|
|
const SMDS_MeshNode** myVolumeNodes;
|
2012-08-09 16:03:55 +06:00
|
|
|
std::vector< int > myPolyIndices;
|
|
|
|
|
|
|
|
mutable bool myExternalFaces;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
mutable const int* myAllFacesNodeIndices_F;
|
|
|
|
mutable const int* myAllFacesNodeIndices_RE;
|
|
|
|
mutable const int* myAllFacesNbNodes;
|
|
|
|
mutable int myMaxFaceNbNodes;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
mutable int myCurFace;
|
|
|
|
mutable int myFaceNbNodes;
|
|
|
|
mutable int* myFaceNodeIndices;
|
|
|
|
mutable const SMDS_MeshNode** myFaceNodes;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ORDER OF NODES OF FORWARD ELEMENT
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
/*
|
|
|
|
// N3
|
|
|
|
// +
|
|
|
|
// /|\
|
|
|
|
// / | \
|
|
|
|
// / | \
|
2005-01-20 11:25:54 +05:00
|
|
|
// N0 +---|---+ N1 TETRAHEDRON
|
2004-12-01 15:48:31 +05:00
|
|
|
// \ | /
|
|
|
|
// \ | /
|
|
|
|
// \ | /
|
|
|
|
// \|/
|
|
|
|
// +
|
2005-01-20 11:25:54 +05:00
|
|
|
// N2
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// + N4
|
|
|
|
// /|\
|
|
|
|
// / | \
|
|
|
|
// / | \
|
|
|
|
// / | \
|
|
|
|
// N3 +---------+ N5
|
|
|
|
// | | |
|
|
|
|
// | + N1 |
|
|
|
|
// | / \ | PENTAHEDRON
|
|
|
|
// | / \ |
|
|
|
|
// | / \ |
|
|
|
|
// |/ \|
|
|
|
|
// N0 +---------+ N2
|
|
|
|
|
2005-01-20 11:25:54 +05:00
|
|
|
// N5+----------+N6
|
2004-12-01 15:48:31 +05:00
|
|
|
// /| /|
|
|
|
|
// / | / |
|
|
|
|
// / | / |
|
2005-01-20 11:25:54 +05:00
|
|
|
// N4+----------+N7 |
|
2004-12-01 15:48:31 +05:00
|
|
|
// | | | | HEXAHEDRON
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
2005-01-20 11:25:54 +05:00
|
|
|
// | N1+------|---+N2
|
2004-12-01 15:48:31 +05:00
|
|
|
// | / | /
|
|
|
|
// | / | /
|
|
|
|
// |/ |/
|
2005-01-20 11:25:54 +05:00
|
|
|
// N0+----------+N3
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
*/
|