Salome HOME
PAL16231 (3D Extrusion produced crossing hexahedrons)
authoreap <eap@opencascade.com>
Tue, 19 Jun 2007 16:50:42 +0000 (16:50 +0000)
committereap <eap@opencascade.com>
Tue, 19 Jun 2007 16:50:42 +0000 (16:50 +0000)
     improve copmuting point parameters using parameters hint

src/StdMeshers/StdMeshers_Prism_3D.cxx
src/StdMeshers/StdMeshers_Prism_3D.hxx

index 70a6fc5d43eda9caf942f8b69cbba1238b75e2bc..868ce3ffd7d471a8c5fd8538934baf54c2d78863 100644 (file)
@@ -275,18 +275,16 @@ bool StdMeshers_Prism_3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theSh
     TNodeColumn& column = bot_column->second;
 
     // bottom node parameters and coords
-    gp_XYZ botParams          = tBotNode.GetParams();
     myShapeXYZ[ ID_BOT_FACE ] = tBotNode.GetCoords();
+    gp_XYZ botParams          = tBotNode.GetParams();
 
     // compute top node parameters
-    gp_XYZ topParams;
     myShapeXYZ[ ID_TOP_FACE ] = gpXYZ( column.back() );
-    if ( column.size() < 3 ) { // only top and bottom nodes in columns
-      topParams = botParams;
-    }
-    else {
+    gp_XYZ topParams = botParams;
+    topParams.SetZ( 1 );
+    if ( column.size() > 2 ) {
       gp_Pnt topCoords = myShapeXYZ[ ID_TOP_FACE ];
-      if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE ))
+      if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE, topParams ))
         return error(TCom("Can't compute normalized parameters ")
                      << "for node " << column.back()->GetID()
                      << " on the face #"<< column.back()->GetPosition()->GetShapeId() );
@@ -318,6 +316,10 @@ bool StdMeshers_Prism_3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theSh
       if ( !SMESH_Block::ShellPoint( params, myShapeXYZ, coords ))
         return error("Can't compute coordinates by normalized parameters");
 
+      SHOWYXZ("TOPFacePoint ",myShapeXYZ[ ID_TOP_FACE]);
+      SHOWYXZ("BOT Node "<< tBotNode.myNode->GetID(),gpXYZ(tBotNode.myNode));
+      SHOWYXZ("ShellPoint ",coords);
+
       // create a node
       node = meshDS->AddNode( coords.X(), coords.Y(), coords.Z() );
       meshDS->SetNodeInVolume( node, volumeID );
@@ -511,6 +513,7 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top()
   // Fill myBotToColumnMap
 
   int zSize = myBlock.VerticalSize();
+  TNode prevTNode;
   TNodeNodeMap::iterator bN_tN = n2nMap.begin();
   for ( ; bN_tN != n2nMap.end(); ++bN_tN )
   {
@@ -520,10 +523,16 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top()
       continue; // wall columns are contained in myBlock
     // compute bottom node params
     TNode bN( botNode );
-    if ( zSize > 2 )
-      if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(), ID_BOT_FACE ))
+    if ( zSize > 2 ) {
+      gp_XYZ paramHint(-1,-1,-1);
+//       if ( prevTNode.IsNeighbor( bN ))
+//         paramHint = prevTNode.GetParams();
+      if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(),
+                                       ID_BOT_FACE, paramHint ))
         return error(TCom("Can't compute normalized parameters ")
                      << "for node " << botNode->GetID() << " on the face #"<< botSM->GetId() );
+    }
+    prevTNode = bN;
     // create node column
     TNode2ColumnMap::iterator bN_col = 
       myBotToColumnMap.insert( make_pair ( bN, TNodeColumn() )).first;
@@ -679,6 +688,23 @@ bool StdMeshers_Prism_3D::setFaceAndEdgesXYZ( const int faceID, const gp_XYZ& pa
   return true;
 }
 
+//================================================================================
+/*!
+ * \brief Return true if this node and other one belong to one face
+ */
+//================================================================================
+
+bool TNode::IsNeighbor( const TNode& other ) const
+{
+  if ( !other.myNode || !myNode ) return false;
+
+  SMDS_ElemIteratorPtr fIt = other.myNode->GetInverseElementIterator(SMDSAbs_Face);
+  while ( fIt->more() )
+    if ( fIt->next()->GetNodeIndex( myNode ) >= 0 )
+      return true;
+  return false;
+}
+
 //================================================================================
 /*!
  * \brief Constructor. Initialization is needed
index 20e92a2cbca69e7894f390173404d4b1e8bf7476..81c279e9fe5500d4d9725624d867c40bde38054d 100644 (file)
@@ -78,10 +78,12 @@ struct TNode
   gp_XYZ GetCoords() const { return gp_XYZ( myNode->X(), myNode->Y(), myNode->Z() ); }
   gp_XYZ GetParams() const { return myParams; }
   gp_XYZ& ChangeParams() { return myParams; }
+  bool HasParams() const { return myParams.X() >= 0.0; }
   SMDS_TypeOfPosition GetPositionType() const
   { return myNode ? myNode->GetPosition()->GetTypeOfPosition() : SMDS_TOP_UNSPEC; }
+  bool IsNeighbor( const TNode& other ) const;
 
-  TNode(const SMDS_MeshNode* node = 0): myNode(node), myParams(0,0,0) {}
+  TNode(const SMDS_MeshNode* node = 0): myNode(node), myParams(-1,-1,-1) {}
   bool operator < (const TNode& other) const { return myNode < other.myNode; }
 };