+ //================================================================================
+ /*!
+ * \brief Return and angle between two EDGEs
+ * \return double - the angle normalized so that
+ * >~ 0 -> 2.0
+ * PI/2 -> 1.0
+ * PI -> 0.0
+ * -PI/2 -> -1.0
+ * <~ 0 -> -2.0
+ */
+ //================================================================================
+
+ double normAngle(const TopoDS_Edge & E1, const TopoDS_Edge & E2, const TopoDS_Face & F)
+ {
+ return SMESH_MesherHelper::GetAngle( E1, E2, F ) / ( 0.5 * M_PI );
+ }
+
+ //================================================================================
+ /*!
+ * Consider continuous straight EDGES as one side - mark them to unite
+ */
+ //================================================================================
+
+ int countNbSides( const Prism_3D::TPrismTopo & thePrism,
+ vector<int> & nbUnitePerEdge,
+ vector< double > & edgeLength)
+ {
+ int nbEdges = thePrism.myNbEdgesInWires.front(); // nb outer edges
+ int nbSides = nbEdges;
+
+
+ list< TopoDS_Edge >::const_iterator edgeIt = thePrism.myBottomEdges.begin();
+ std::advance( edgeIt, nbEdges-1 );
+ TopoDS_Edge prevE = *edgeIt;
+ // bool isPrevStraight = SMESH_Algo::IsStraight( prevE );
+ int iPrev = nbEdges - 1;
+
+ int iUnite = -1; // the first of united EDGEs
+
+ // analyse angles between EDGEs
+ int nbCorners = 0;
+ vector< bool > isCorner( nbEdges );
+ edgeIt = thePrism.myBottomEdges.begin();
+ for ( int iE = 0; iE < nbEdges; ++iE, ++edgeIt )
+ {
+ const TopoDS_Edge& curE = *edgeIt;
+ edgeLength[ iE ] = SMESH_Algo::EdgeLength( curE );
+
+ // double normAngle = normAngle( prevE, curE, thePrism.myBottom );
+ // isCorner[ iE ] = false;
+ // if ( normAngle < 2.0 )
+ // {
+ // if ( normAngle < 0.001 ) // straight or obtuse angle
+ // {
+ // // unite EDGEs in order not to put a corner of the unit quadrangle at this VERTEX
+ // if ( iUnite < 0 )
+ // iUnite = iPrev;
+ // nbUnitePerEdge[ iUnite ]++;
+ // nbUnitePerEdge[ iE ] = -1;
+ // --nbSides;
+ // }
+ // else
+ // {
+ // isCorner[ iE ] = true;
+ // nbCorners++;
+ // iUnite = -1;
+ // }
+ // }
+ // prevE = curE;
+ }
+
+ if ( nbCorners > 4 )
+ {
+ // define which of corners to put on a side of the unit quadrangle
+ }
+ // edgeIt = thePrism.myBottomEdges.begin();
+ // for ( int iE = 0; iE < nbEdges; ++iE, ++edgeIt )
+ // {
+ // const TopoDS_Edge& curE = *edgeIt;
+ // edgeLength[ iE ] = SMESH_Algo::EdgeLength( curE );
+
+ // const bool isCurStraight = SMESH_Algo::IsStraight( curE );
+ // if ( isPrevStraight && isCurStraight && SMESH_Algo::IsContinuous( prevE, curE ))
+ // {
+ // if ( iUnite < 0 )
+ // iUnite = iPrev;
+ // nbUnitePerEdge[ iUnite ]++;
+ // nbUnitePerEdge[ iE ] = -1;
+ // --nbSides;
+ // }
+ // else
+ // {
+ // iUnite = -1;
+ // }
+ // prevE = curE;
+ // isPrevStraight = isCurStraight;
+ // iPrev = iE;
+ // }
+
+ return nbSides;
+ }
+
+ void pointsToPython(const std::vector<gp_XYZ>& p)
+ {
+#ifdef _DEBUG_
+ for ( int i = SMESH_Block::ID_V000; i < p.size(); ++i )
+ {
+ cout << "mesh.AddNode( " << p[i].X() << ", "<< p[i].Y() << ", "<< p[i].Z() << ") # " << i <<" " ;
+ SMESH_Block::DumpShapeID( i, cout ) << endl;
+ }
+#endif
+ }