-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "StdMeshers_QuadToTriaAdaptor.hxx"
#include "SMDS_SetIterator.hxx"
-
+#include "SMESHDS_GroupBase.hxx"
#include "SMESH_Algo.hxx"
-#include "SMESH_MesherHelper.hxx"
#include "SMESH_Group.hxx"
-#include "SMESHDS_GroupBase.hxx"
+#include "SMESH_MeshAlgos.hxx"
+#include "SMESH_MesherHelper.hxx"
#include <IntAna_IntConicQuad.hxx>
#include <IntAna_Quadric.hxx>
#include <TopoDS.hxx>
#include <gp_Lin.hxx>
#include <gp_Pln.hxx>
+
#include "utilities.h"
#include <string>
bool tooClose = ( angle < 15. * M_PI / 180. );
// Check if pyramids collide
- if ( !tooClose && baI * baJ > 0 )
+ if ( !tooClose && ( baI * baJ > 0 ) && ( nI * nJ > 0 ))
{
// find out if nI points outside of PrmI or inside
int dInd = baseNodesIndI[1] - baseNodesIndI[0];
TIDSortedElemSet emptySet, avoidSet;
int i1, i2;
while ( const SMDS_MeshElement* f =
- SMESH_MeshEditor::FindFaceInSet( baseNodes[0], baseNodes[1],
- emptySet, avoidSet, &i1, &i2 ))
+ SMESH_MeshAlgos::FindFaceInSet( baseNodes[0], baseNodes[1],
+ emptySet, avoidSet, &i1, &i2 ))
{
avoidSet.insert( f );
const SMDS_MeshElement* NotCheckedFace)
{
if ( !myElemSearcher )
- myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher();
+ myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *aMesh.GetMeshDS() );
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
//SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
//cout<<" CheckIntersection: meshDS->NbFaces() = "<<meshDS->NbFaces()<<endl;
- bool res = false;
+ bool res = false;
double dist = RealLast(); // find intersection closest to the segment
gp_Pnt Pres;
vector< const SMDS_MeshElement* > suspectElems;
searcher->GetElementsNearLine( line, SMDSAbs_Face, suspectElems);
- for ( int i = 0; i < suspectElems.size(); ++i )
+ for ( size_t iF = 0; iF < suspectElems.size(); ++iF )
{
- const SMDS_MeshElement* face = suspectElems[i];
+ const SMDS_MeshElement* face = suspectElems[iF];
if ( face == NotCheckedFace ) continue;
Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
for ( int i = 0; i < face->NbCornerNodes(); ++i )
if( HasIntersection(P, PC, Pres, aContour) ) {
res = true;
double tmp = PC.Distance(Pres);
- if(tmp<dist) {
+ if ( tmp < dist ) {
Pint = Pres;
dist = tmp;
}
if ( myElemSearcher ) delete myElemSearcher;
if ( aProxyMesh )
- myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher( aProxyMesh->GetFaces(aShape));
+ myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS, aProxyMesh->GetFaces(aShape));
else
- myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher();
+ myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
const SMESHDS_SubMesh * aSubMeshDSFace;
Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
delete myElemSearcher;
myElemSearcher =
- SMESH_MeshEditor(&aMesh).GetElementSearcher( aProxyMesh->GetFaces(aShape));
+ SMESH_MeshAlgos::GetElementSearcher( *meshDS, aProxyMesh->GetFaces(aShape));
}
}
}
helper.IsQuadraticSubMesh(aMesh.GetShapeToMesh());
helper.SetElementsOnShape( true );
- if ( !myElemSearcher )
- myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher();
- SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
-
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_ProxyMesh::SubMesh* prxSubMesh = getProxySubMesh();
+ if ( !myElemSearcher )
+ myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
+ SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
+
SMDS_FaceIteratorPtr fIt = meshDS->facesIterator(/*idInceasingOrder=*/true);
while( fIt->more())
{
vector< const SMDS_MeshElement* > suspectElems;
searcher->GetElementsNearLine( line, SMDSAbs_Face, suspectElems);
- for ( int iF = 0; iF < suspectElems.size(); ++iF ) {
+ for ( size_t iF = 0; iF < suspectElems.size(); ++iF ) {
const SMDS_MeshElement* F = suspectElems[iF];
- if(F==face) continue;
+ if ( F == face ) continue;
Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
for ( int i = 0; i < 4; ++i )
aContour->Append( SMESH_TNodeXYZ( F->GetNode(i) ));
gp_Pnt PPP;
- if( !volumes[0] && HasIntersection(Ptmp1, PC, PPP, aContour) ) {
+ if ( !volumes[0] && HasIntersection( Ptmp1, PC, PPP, aContour )) {
IsOK1 = true;
double tmp = PC.Distance(PPP);
- if(tmp<dist1) {
+ if ( tmp < dist1 ) {
Pres1 = PPP;
dist1 = tmp;
}
}
- if( !volumes[1] && HasIntersection(Ptmp2, PC, PPP, aContour) ) {
+ if ( !volumes[1] && HasIntersection( Ptmp2, PC, PPP, aContour )) {
IsOK2 = true;
double tmp = PC.Distance(PPP);
- if(tmp<dist2) {
+ if ( tmp < dist2 ) {
Pres2 = PPP;
dist2 = tmp;
}
gp_XYZ PCbest(0., 0., 0.); // pyramid peak
int i = 1;
- for(; i<=4; i++) {
+ for ( ; i <= 4; i++ ) {
gp_Pnt Pbest = FindBestPoint(PN->Value(i), PN->Value(i+1), PC, VN->Value(i));
PCbest += Pbest.XYZ();
}
vector< const SMDS_MeshElement* > suspectElems;
searcher->GetElementsNearLine( line, SMDSAbs_Face, suspectElems);
- for ( int iF = 0; iF < suspectElems.size(); ++iF )
+ for ( size_t iF = 0; iF < suspectElems.size(); ++iF )
{
const SMDS_MeshElement* F = suspectElems[iF];
- if(F==face) continue;
+ if ( F == face ) continue;
Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
int nbN = F->NbNodes() / ( F->IsQuadratic() ? 2 : 1 );
for ( i = 0; i < nbN; ++i )
// if the face belong to the group of skinFaces, do not build a pyramid outside
if (groupDS && groupDS->Contains(face))
+ {
intersected[0] = false;
+ }
+ else if ( intersected[0] && intersected[1] ) // check if one of pyramids is in a hole
+ {
+ gp_Pnt P ( PC.XYZ() + tmpDir.XYZ() * 0.5 * PC.Distance( intPnt[0] ));
+ if ( searcher->GetPointState( P ) == TopAbs_OUT )
+ intersected[0] = false;
+ else
+ {
+ P = ( PC.XYZ() - tmpDir.XYZ() * 0.5 * PC.Distance( intPnt[1] ));
+ if ( searcher->GetPointState( P ) == TopAbs_OUT )
+ intersected[1] = false;
+ }
+ }
// Create one or two pyramids
return true;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
- int i, j, k, myShapeID = myPyramids[0]->GetNode(4)->getshapeId();
+ size_t i, j, k;
+ int myShapeID = myPyramids[0]->GetNode(4)->getshapeId();
if ( myElemSearcher ) delete myElemSearcher;
- myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher();
+ myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
set<const SMDS_MeshNode*> nodesToMove;
while ( vIt->more() )
{
const SMDS_MeshElement* PrmJ = vIt->next();
- if ( SMESH_Algo::GetCommonNodes( PrmI, PrmJ ).size() > 1 )
+ if ( SMESH_MeshAlgos::GetCommonNodes( PrmI, PrmJ ).size() > 1 )
checkedPyrams.insert( PrmJ );
}
}
nodesToMove.insert( aNode1 );
nodesToMove.insert( aNode2 );
}
- // fix intersections that could appear after apex movement
+ // fix intersections that can appear after apex movement
MergeAdjacent( PrmI, nodesToMove );
MergeAdjacent( PrmJ, nodesToMove );