TShapeShapeMap & theMap)
{
// Structure of this long function is following
- // 1) Group->group projection: theShape1 is a group member,
- // theShape2 is a group. We find a group theShape1 is in and recall self.
+ // 1) Group -> Group projection: theShape1 is a group member,
+ // theShape2 is another group. We find a group theShape1 is in and recall self.
// 2) Accosiate same shapes with different location (partners).
// 3) If vertex association is given, perform accosiation according to shape type:
// switch ( ShapeType ) {
TopTools_ListIteratorOfListOfShape ancestIt1( edgeToFace1.FindFromKey( edge1 ));
for ( ; F1.IsNull() && ancestIt1.More(); ancestIt1.Next() )
if ( ancestIt1.Value().ShapeType() == TopAbs_FACE )
- F1 = ancestIt1.Value().Oriented( TopAbs_FORWARD );
+ F1 = ancestIt1.Value().Oriented //( TopAbs_FORWARD );
+ ( SMESH_MesherHelper::GetSubShapeOri( theShape1, ancestIt1.Value() ));
if ( F1.IsNull() )
RETURN_BAD_RESULT(" Face1 not found");
TopTools_ListIteratorOfListOfShape ancestIt2( edgeToFace2.FindFromKey( edge2 ));
for ( int i = 0; FF2[1].IsNull() && ancestIt2.More(); ancestIt2.Next() )
if ( ancestIt2.Value().ShapeType() == TopAbs_FACE )
- FF2[ i++ ] = ancestIt2.Value().Oriented( TopAbs_FORWARD );
+ FF2[ i++ ] = ancestIt2.Value().Oriented // ( TopAbs_FORWARD );
+ ( SMESH_MesherHelper::GetSubShapeOri( theShape2, ancestIt2.Value() ));
// get oriented edge1 and edge2 from F1 and FF2[0]
for ( exp.Init( F1, TopAbs_EDGE ); exp.More(); exp.Next() )
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
-#if OCC_VERSION_LARGE > 0x06050400
-#include <BRepClass3d.hxx>
-#else
-#include <BRepTools.hxx>
-#endif
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
-#include <TopTools_MapOfShape.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
+#if OCC_VERSION_LARGE > 0x06050400
+#include <BRepClass3d.hxx>
+#else
+#include <BRepTools.hxx>
+#endif
using namespace std;
#define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; }
#define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z())
-namespace TAssocTool = StdMeshers_ProjectionUtils;
+namespace ProjectionUtils = StdMeshers_ProjectionUtils;
//=======================================================================
//function : StdMeshers_RadialPrism_3D
{
// check aShape that must have 2 shells
/* PAL16229
- if ( TAssocTool::Count( aShape, TopAbs_SOLID, 0 ) != 1 ||
- TAssocTool::Count( aShape, TopAbs_SHELL, 0 ) != 2 )
+ if ( ProjectionUtils::Count( aShape, TopAbs_SOLID, 0 ) != 1 ||
+ ProjectionUtils::Count( aShape, TopAbs_SHELL, 0 ) != 2 )
{
aStatus = HYP_BAD_GEOMETRY;
return false;
// Associate sub-shapes of the shells
// ----------------------------------
- TAssocTool::TShapeShapeMap shape2ShapeMap;
- if ( !TAssocTool::FindSubShapeAssociation( innerShell, &aMesh,
- outerShell, &aMesh,
- shape2ShapeMap) )
+ ProjectionUtils::TShapeShapeMap shape2ShapeMaps[2];
+ if ( !ProjectionUtils::FindSubShapeAssociation( innerShell, &aMesh,
+ outerShell, &aMesh,
+ shape2ShapeMaps[0])
+ &&
+ !ProjectionUtils::FindSubShapeAssociation( innerShell.Reversed(), &aMesh,
+ outerShell, &aMesh,
+ shape2ShapeMaps[1]))
return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
+ int iMap;
+ if ( shape2ShapeMaps[0].Extent() == shape2ShapeMaps[1].Extent() )
+ {
+ // choose an assiciation by shortest distance between VERTEXes
+ double dist1 = 0, dist2 = 0;
+ TopTools_DataMapIteratorOfDataMapOfShapeShape ssIt( shape2ShapeMaps[0]._map1to2 );
+ for (; ssIt.More(); ssIt.Next() )
+ {
+ if ( ssIt.Key().ShapeType() != TopAbs_VERTEX ) continue;
+ gp_Pnt pIn = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Key() ));
+ gp_Pnt pOut1 = BRep_Tool::Pnt( TopoDS::Vertex( ssIt.Value() ));
+ gp_Pnt pOut2 = BRep_Tool::Pnt( TopoDS::Vertex( shape2ShapeMaps[1]( ssIt.Key() )));
+ dist1 += pIn.SquareDistance( pOut1 );
+ dist2 += pIn.SquareDistance( pOut2 );
+ }
+ iMap = ( dist1 < dist2 ) ? 0 : 1;
+ }
+ else
+ {
+ iMap = ( shape2ShapeMaps[0].Extent() > shape2ShapeMaps[1].Extent() ) ? 0 : 1;
+ }
+ ProjectionUtils::TShapeShapeMap& shape2ShapeMap = shape2ShapeMaps[iMap];
+
// ------------------
// Make mesh
// ------------------
// Find matching nodes of in and out faces
TNodeNodeMap nodeIn2OutMap;
- if ( ! TAssocTool::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
- shape2ShapeMap, nodeIn2OutMap ))
+ if ( ! ProjectionUtils::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh,
+ shape2ShapeMap, nodeIn2OutMap ))
return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #")
<< meshDS->ShapeToIndex( outFace ) << " and "
<< meshDS->ShapeToIndex( inFace ) << " seems different" );
}
// Associate sub-shapes of the shells
- TAssocTool::TShapeShapeMap shape2ShapeMap;
- if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
- innerShell, &aMesh,
- shape2ShapeMap) ) {
+ ProjectionUtils::TShapeShapeMap shape2ShapeMap;
+ if ( !ProjectionUtils::FindSubShapeAssociation( outerShell, &aMesh,
+ innerShell, &aMesh,
+ shape2ShapeMap) ) {
std::vector<int> aResVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);