1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMESH : implementation of SMESH idl descriptions
21 // File : StdMeshers_CompositeHexa_3D.cxx
23 // Created : Tue Nov 25 11:04:59 2008
24 // Author : Edward AGAPOV (eap)
26 #include "StdMeshers_CompositeHexa_3D.hxx"
28 #include "SMDS_Mesh.hxx"
29 #include "SMDS_MeshNode.hxx"
30 #include "SMDS_SetIterator.hxx"
31 #include "SMESHDS_Mesh.hxx"
32 #include "SMESHDS_SubMesh.hxx"
33 #include "SMESH_Block.hxx"
34 #include "SMESH_Comment.hxx"
35 #include "SMESH_ComputeError.hxx"
36 #include "SMESH_HypoFilter.hxx"
37 #include "SMESH_Mesh.hxx"
38 #include "SMESH_MeshAlgos.hxx"
39 #include "SMESH_MesherHelper.hxx"
40 #include "SMESH_subMesh.hxx"
41 #include "StdMeshers_ViscousLayers.hxx"
43 #include <BRepAdaptor_Surface.hxx>
44 #include <BRep_Tool.hxx>
45 #include <Standard_ErrorHandler.hxx>
46 #include <Standard_Failure.hxx>
47 #include <TopExp_Explorer.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <TopTools_MapIteratorOfMapOfShape.hxx>
50 #include <TopTools_MapOfShape.hxx>
51 #include <TopTools_SequenceOfShape.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Face.hxx>
55 #include <TopoDS_Vertex.hxx>
57 #include <gp_Pnt2d.hxx>
70 // #define DUMP_VERT(msg,V) { TopoDS_Vertex v = V; gp_Pnt p = BRep_Tool::Pnt(v); cout << msg << "( "<< p.X()<<", "<<p.Y()<<", "<<p.Z()<<" )"<<endl; }
74 #define DUMP_VERT(msg,v)
77 //================================================================================
78 // text for message about an internal error
79 #define ERR_LI(txt) SMESH_Comment(txt) << ":" << __LINE__
81 // order corresponds to right order of edges in CASCADE face
82 enum EQuadSides{ Q_BOTTOM=0, Q_RIGHT, Q_TOP, Q_LEFT, Q_CHILD, Q_PARENT };
84 enum EBoxSides{ B_BOTTOM=0, B_RIGHT, B_TOP, B_LEFT, B_FRONT, B_BACK, B_UNDEFINED };
86 enum EAxes{ COO_X=1, COO_Y, COO_Z };
88 //================================================================================
90 * \brief Converter of a pair of integers to a sole index
95 _Indexer( int xSize, int ySize ): _xSize(xSize), _ySize(ySize) {}
96 int size() const { return _xSize * _ySize; }
97 int operator()(const int x, const int y) const { return y * _xSize + x; }
100 //================================================================================
102 * \brief Wrapper of a composite or an ordinary edge.
107 _FaceSide(const _FaceSide& other);
108 _FaceSide(const TopoDS_Edge& edge=TopoDS_Edge());
109 _FaceSide(const list<TopoDS_Edge>& edges);
110 _FaceSide* GetSide(const int i);
111 const _FaceSide* GetSide(const int i) const;
112 int size() const { return myChildren.size(); }
113 int NbVertices() const;
114 int NbCommonVertices( const TopTools_MapOfShape& VV ) const;
115 TopoDS_Vertex FirstVertex() const;
116 TopoDS_Vertex LastVertex() const;
117 TopoDS_Vertex Vertex(int i) const;
118 TopoDS_Edge Edge(int i) const;
119 bool Contain( const _FaceSide& side, int* which=0 ) const;
120 bool Contain( const TopoDS_Vertex& vertex ) const;
121 void AppendSide( const _FaceSide& side );
122 void SetBottomSide( int i );
123 int GetNbSegments(SMESH_ProxyMesh& mesh, const SMESHDS_SubMesh* smToCheckEdges=0) const;
124 bool StoreNodes(SMESH_ProxyMesh& mesh, vector<const SMDS_MeshNode*>& myGrid,
125 bool reverse, bool isProxy, const SMESHDS_SubMesh* smToCheckEdges=0 );
126 void SetID(EQuadSides id) { myID = id; }
127 static inline const TopoDS_TShape* ptr(const TopoDS_Shape& theShape)
128 { return theShape.TShape().operator->(); }
135 list< _FaceSide > myChildren;
138 TopTools_MapOfShape myVertices;
140 EQuadSides myID; // debug
142 //================================================================================
144 * \brief Class corresponding to a meshed composite face of a box.
145 * Provides simplified access to it's sub-mesh data.
149 typedef list< _QuadFaceGrid > TChildren;
153 public: //** Methods to find and orient faces of 6 sides of the box **//
156 bool Init(const TopoDS_Face& f, SMESH_ProxyMesh& mesh );
158 //!< try to unite self with other face
159 bool AddContinuousFace( const _QuadFaceGrid& f, const TopTools_MapOfShape& internalEdges );
161 //!< Try to set the side as bottom hirizontal side
162 bool SetBottomSide(const _FaceSide& side, int* sideIndex=0);
164 //!< Return face adjacent to zero-based i-th side of this face
165 _QuadFaceGrid* FindAdjacentForSide(int i, list<_QuadFaceGrid>& faces, EBoxSides id) const;
167 //!< Reverse edges in order to have the bottom edge going along axes of the unit box
170 bool IsComplex() const { return !myChildren.empty(); }
172 int NbChildren() const { return myChildren.size(); }
174 typedef SMDS_SetIterator< const _QuadFaceGrid&,
175 TChildren::const_iterator,
176 SMDS::SimpleAccessor<const _QuadFaceGrid&,TChildren::const_iterator>,
177 SMDS::PassAllValueFilter<_QuadFaceGrid> >
180 TChildIterator GetChildren() const
181 { return TChildIterator( myChildren.begin(), myChildren.end()); }
183 public: //** Loading and access to mesh **//
185 //!< Load nodes of a mesh
186 bool LoadGrid( SMESH_ProxyMesh& mesh );
188 //!< Computes normalized parameters of nodes of myGrid
189 void ComputeIJK( int i1, int i2, double v3 );
191 //!< Return number of segments on the hirizontal sides
192 int GetNbHoriSegments(SMESH_ProxyMesh& mesh, bool withBrothers=false) const;
194 //!< Return number of segments on the vertical sides
195 int GetNbVertSegments(SMESH_ProxyMesh& mesh, bool withBrothers=false) const;
197 //!< Return edge on the hirizontal bottom sides
198 int GetHoriEdges(vector<TopoDS_Edge> & edges) const;
200 //!< Return a node by its position
201 const SMDS_MeshNode* GetNode(int iHori, int iVert) const;
203 //!< Return node coordinates by its position
204 gp_XYZ GetXYZ(int iHori, int iVert) const;
206 //!< Return normalized parameters of nodes within the unitary cube
207 gp_XYZ& GetIJK(int iCol, int iRow) { return myIJK[ myIndexer( iCol, iRow )]; }
209 public: //** Access to member fields **//
211 //!< Return i-th face side (0<i<4)
212 const _FaceSide& GetSide(int i) const;
214 //!< Return it's face, NULL if it is composite
215 TopoDS_Face GetFace() const { return myFace; }
217 //!< Return normal to the face at vertex v
218 bool GetNormal( const TopoDS_Vertex& v, gp_Vec& n ) const;
220 SMESH_ComputeErrorPtr GetError() const { return myError; }
222 void SetID(EBoxSides id) { myID = id; }
224 void DumpGrid() const;
226 void DumpVertices() const;
230 bool error(const std::string& text, int code = COMPERR_ALGO_FAILED)
231 { myError = SMESH_ComputeError::New( code, text ); return false; }
233 bool error(const SMESH_ComputeErrorPtr& err)
234 { myError = err; return ( !myError || myError->IsOK() ); }
236 bool loadCompositeGrid(SMESH_ProxyMesh& mesh);
238 bool fillGrid(SMESH_ProxyMesh& theMesh,
239 vector<const SMDS_MeshNode*> & theGrid,
240 const _Indexer& theIndexer,
244 bool locateChildren();
246 void setBrothers( set< _QuadFaceGrid* >& notLocatedBrothers );
252 TChildren myChildren;
254 _QuadFaceGrid* myLeftBottomChild;
255 _QuadFaceGrid* myRightBrother;
256 _QuadFaceGrid* myUpBrother;
259 vector<const SMDS_MeshNode*> myGrid;
260 vector<gp_XYZ> myIJK; // normalized parameters of nodes
262 SMESH_ComputeErrorPtr myError;
264 EBoxSides myID; // debug
267 //================================================================================
271 //================================================================================
273 StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, SMESH_Gen* gen)
274 :SMESH_3D_Algo(hypId, gen)
276 _name = "CompositeHexa_3D";
277 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
280 //================================================================================
282 * \brief always return true
284 //================================================================================
286 bool StdMeshers_CompositeHexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
287 const TopoDS_Shape& aShape,
288 Hypothesis_Status& aStatus)
297 //================================================================================
299 * \brief Checks structure of a quadrangular mesh at the common VERTEX of two EDGEs.
300 * Returns true if there are two quadrangles near the VERTEX.
302 //================================================================================
304 bool isContinuousMesh(TopoDS_Edge E1,
306 const TopoDS_Face& F,
307 const SMESH_ProxyMesh& mesh)
309 if (E1.Orientation() > TopAbs_REVERSED) // INTERNAL
310 E1.Orientation( TopAbs_FORWARD );
311 if (E2.Orientation() > TopAbs_REVERSED) // INTERNAL
312 E2.Orientation( TopAbs_FORWARD );
315 if ( !TopExp::CommonVertex( E1, E2, V )) return false;
317 const SMDS_MeshNode* n = SMESH_Algo::VertexNode( V, mesh.GetMeshDS() );
318 if ( !n ) return SMESH_Algo::IsContinuous( E1, E2 ); // meshed by "composite segment"
320 n = mesh.GetProxyNode( n );
322 const SMESHDS_SubMesh* sm = mesh.GetSubMesh( F );
323 if ( !sm ) return false;
326 SMDS_ElemIteratorPtr fIt = mesh.GetInverseElementIterator( n, SMDSAbs_Face );
328 return SMESH_Algo::IsContinuous( E1, E2 ); // meshed by "composite segment"
329 while ( fIt->more() )
331 const SMDS_MeshElement* f = fIt->next();
332 if ( !sm->Contains( f )) continue;
334 if ( f->NbCornerNodes() == 4 )
342 //================================================================================
344 * \brief Return true if a vertex holds a node and this node is used by some quadrangle
346 //================================================================================
348 // bool isMeshedVertex( TopoDS_Vertex& V,
349 // const SMESH_Mesh& mesh )
351 // const SMDS_MeshNode* n = SMESH_Algo::VertexNode( V, mesh.GetMeshDS() );
352 // if ( !n ) return false;
354 // SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator(SMDSAbs_Face);
355 // while ( fIt->more() )
357 // const SMDS_MeshElement* f = fIt->next();
358 // if ( f->NbCornerNodes() == 4 )
364 //================================================================================
366 * \brief Finds VERTEXes located at block corners
368 //================================================================================
370 void getBlockCorners( SMESH_ProxyMesh& mesh,
371 const TopoDS_Shape& shape,
372 TopTools_MapOfShape& cornerVV)
374 std::set<int> faceIDs; // ids of FACEs in the shape
376 for ( exp.Init( shape, TopAbs_FACE ); exp.More(); exp.Next() )
377 faceIDs.insert( mesh.GetMeshDS()->ShapeToIndex( exp.Current() ));
379 TopTools_MapOfShape checkedVV;
380 for ( exp.Init( shape, TopAbs_VERTEX ); exp.More(); exp.Next() )
382 TopoDS_Vertex V = TopoDS::Vertex( exp.Current() );
383 if ( !checkedVV.Add( V )) continue;
385 const SMDS_MeshNode* n = SMESH_Algo::VertexNode( V, mesh.GetMeshDS() );
388 const SMDS_MeshNode* nProxy = mesh.GetProxyNode( n );
389 bool isProxy = ( nProxy != n );
393 SMDS_ElemIteratorPtr fIt = mesh.GetInverseElementIterator( n, SMDSAbs_Face );
394 while ( fIt->more() )
396 const SMDS_MeshElement* f = fIt->next();
397 if ( !faceIDs.count( f->getshapeId() )) continue;
399 if ( isProxy && !mesh.GetSubMesh( f->getshapeId() )->Contains( f ))
402 if ( f->NbCornerNodes() == 4 )
412 //================================================================================
414 * \brief Return EDGEs dividing one box side
416 //================================================================================
418 bool getInternalEdges( SMESH_Mesh& mesh,
419 const TopoDS_Shape& shape,
420 const TopTools_MapOfShape& cornerVV,
421 TopTools_MapOfShape& internEE)
423 TopTools_IndexedMapOfShape subEE, subFF;
424 TopExp::MapShapes( shape, TopAbs_EDGE, subEE );
425 TopExp::MapShapes( shape, TopAbs_FACE, subFF );
428 TopTools_MapOfShape subChecked, ridgeEE;
429 TopTools_MapIteratorOfMapOfShape vIt( cornerVV );
430 for ( ; vIt.More(); vIt.Next() )
432 TopoDS_Shape V0 = vIt.Key();
433 // walk from one corner VERTEX to another along ridge EDGEs
434 PShapeIteratorPtr riIt = SMESH_MesherHelper::GetAncestors( V0, mesh, TopAbs_EDGE );
435 while ( const TopoDS_Shape* riE = riIt->next() )
437 if ( !subEE.Contains( *riE ) || !subChecked.Add( *riE ))
439 TopoDS_Edge ridgeE = TopoDS::Edge( *riE );
440 while ( !ridgeE.IsNull() )
442 if ( !ridgeEE.Add( ridgeE ))
444 TopExp::Vertices( ridgeE, VV[0], VV[1] );
445 TopoDS_Shape V1 = VV[ V0.IsSame( VV[0] )];
446 if ( cornerVV.Contains( V1 ) )
447 break; // ridgeE reached a corner VERTEX
449 // detect internal EDGEs among those sharing V1. There can be 2, 3 or 4 EDGEs and
450 // number of internal EDGEs is N-2
451 TopoDS_Shape nextRidgeE;
452 PShapeIteratorPtr eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
453 while ( const TopoDS_Shape* E = eIt->next() )
455 if ( E->IsSame( ridgeE ) || !subEE.Contains( *E ) || !subChecked.Add( *E ))
457 // look for FACEs sharing both E and ridgeE
458 PShapeIteratorPtr fIt = SMESH_MesherHelper::GetAncestors( *E, mesh, TopAbs_FACE );
459 while ( const TopoDS_Shape* F = fIt->next() )
461 if ( !SMESH_MesherHelper::IsSubShape( ridgeE, *F ))
463 if ( !subFF.Contains( *F ))
465 if ( isContinuousMesh( ridgeE, TopoDS::Edge( *E ), TopoDS::Face( *F ), mesh ))
476 // look for the next ridge EDGE ending at V1
477 if ( nextRidgeE.IsNull() )
479 eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
480 while ( const TopoDS_Shape* E = eIt->next() )
481 if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) && subEE.Contains( *E ))
487 ridgeE = TopoDS::Edge( nextRidgeE );
490 if ( ridgeE.IsNull() )
492 } // check EDGEs around the last VERTEX of ridgeE
493 } // loop on ridge EDGEs around a corner VERTEX
494 } // loop on on corner VERTEXes
496 if ( subEE.Extent() > ridgeEE.Extent() + internEE.Extent() ) // PAL23269
497 for ( int i = 1; i < subEE.Extent(); ++i )
498 if ( !ridgeEE.Contains( subEE(i) ))
499 internEE.Add( subEE(i) );
502 } // getInternalEdges()
504 //================================================================================
506 * \brief Find a face including two given nodes
508 //================================================================================
510 const SMDS_MeshElement* FindFaceByNodes( const SMDS_MeshNode* n1,
511 const SMDS_MeshNode* n2,
512 TIDSortedElemSet avoidSet,
513 SMESH_ProxyMesh& mesh)
515 SMDS_ElemIteratorPtr faceIt = mesh.GetInverseElementIterator( n1, SMDSAbs_Face );
516 while ( faceIt->more() )
518 const SMDS_MeshElement* f = faceIt->next();
519 if ( !avoidSet.count( f ) && f->GetNodeIndex( n2 ) >= 0 )
525 //================================================================================
527 * \brief Check that a segment bounds a face belonging to smOfFaces
529 //================================================================================
531 bool IsSegmentOnSubMeshBoundary( const SMDS_MeshNode* n1,
532 const SMDS_MeshNode* n2,
533 const SMESHDS_SubMesh* smOfFaces,
534 SMESH_ProxyMesh& mesh)
536 TIDSortedElemSet avoidSet;
537 bool faceFound = false;
539 while ( const SMDS_MeshElement* f = FindFaceByNodes( n1, n2, avoidSet, mesh ))
541 if (( faceFound = smOfFaces->Contains( f )))
543 avoidSet.insert( f );
550 //================================================================================
552 * \brief Tries to find 6 sides of a box
554 //================================================================================
556 bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
557 list< _QuadFaceGrid >& boxFaces,
559 SMESH_ProxyMesh& proxyMesh,
560 _QuadFaceGrid * & fBottom,
561 _QuadFaceGrid * & fTop,
562 _QuadFaceGrid * & fFront,
563 _QuadFaceGrid * & fBack,
564 _QuadFaceGrid * & fLeft,
565 _QuadFaceGrid * & fRight)
567 TopTools_MapOfShape cornerVertices;
568 getBlockCorners( proxyMesh, shape, cornerVertices );
569 if ( cornerVertices.Extent() != 8 )
570 return error( COMPERR_BAD_INPUT_MESH, "Can't find 8 corners of a block by 2D mesh" );
571 TopTools_MapOfShape internalEdges;
572 if ( !getInternalEdges( mesh, shape, cornerVertices, internalEdges ))
573 return error( COMPERR_BAD_INPUT_MESH, "2D mesh is not suitable for i,j,k hexa meshing" );
575 list< _QuadFaceGrid >::iterator boxFace;
578 for ( exp.Init( shape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFaces )
581 if ( !f.Init( TopoDS::Face( exp.Current() ), proxyMesh ))
582 return error (COMPERR_BAD_SHAPE);
584 _QuadFaceGrid* prevContinuous = 0;
585 for ( boxFace = boxFaces.begin(); boxFace != boxFaces.end(); ++boxFace )
587 if ( prevContinuous )
589 if ( prevContinuous->AddContinuousFace( *boxFace, internalEdges ))
590 boxFace = --boxFaces.erase( boxFace );
592 else if ( boxFace->AddContinuousFace( f, internalEdges ))
594 prevContinuous = & (*boxFace);
597 if ( !prevContinuous )
598 boxFaces.push_back( f );
600 // Check what we have
601 if ( boxFaces.size() != 6 && nbFaces != 6)
604 SMESH_Comment("Can't find 6 sides of a box. Number of found sides - ")<<boxFaces.size());
606 if ( boxFaces.size() != 6 && nbFaces == 6 ) { // strange ordinary box with continuous faces
607 boxFaces.resize( 6 );
608 boxFace = boxFaces.begin();
609 for ( exp.Init( shape, TopAbs_FACE); exp.More(); exp.Next(), ++boxFace )
610 boxFace->Init( TopoDS::Face( exp.Current() ), proxyMesh );
612 // ----------------------------------------
613 // Find out position of faces within a box
614 // ----------------------------------------
615 // start from a bottom face
616 fBottom = &boxFaces.front();
617 fBottom->SetID( B_BOTTOM );
618 // find vertical faces
619 fFront = fBottom->FindAdjacentForSide( Q_BOTTOM, boxFaces, B_FRONT );
620 fLeft = fBottom->FindAdjacentForSide( Q_RIGHT, boxFaces, B_LEFT );
621 fBack = fBottom->FindAdjacentForSide( Q_TOP, boxFaces, B_BACK );
622 fRight = fBottom->FindAdjacentForSide( Q_LEFT, boxFaces, B_RIGHT );
624 if ( !fFront || !fBack || !fLeft || !fRight )
625 return error(COMPERR_BAD_SHAPE);
628 for ( boxFace = ++boxFaces.begin(); boxFace != boxFaces.end() && !fTop; ++boxFace )
631 fTop->SetID( B_TOP );
632 if ( fTop==fFront || fTop==fLeft || fTop==fBack || fTop==fRight )
635 // set bottom of the top side
636 if ( !fTop->SetBottomSide( fFront->GetSide( Q_TOP ) )) {
637 if ( !fFront->IsComplex() )
638 return error( ERR_LI("Error in StdMeshers_CompositeHexa_3D::Compute()"));
640 _QuadFaceGrid::TChildIterator chIt = fFront->GetChildren();
641 while ( chIt.more() ) {
642 const _QuadFaceGrid& frontChild = chIt.next();
643 if ( fTop->SetBottomSide( frontChild.GetSide( Q_TOP )))
649 return error(COMPERR_BAD_SHAPE);
651 // orient bottom edge of faces along axes of the unit box
652 fBottom->ReverseEdges();
653 fBack ->ReverseEdges();
654 fLeft ->ReverseEdges();
659 //================================================================================
661 * \brief Computes hexahedral mesh on a box with composite sides
662 * \param aMesh - mesh to compute
663 * \param aShape - shape to mesh
664 * \retval bool - success sign
666 //================================================================================
668 bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
669 const TopoDS_Shape& theShape)
671 SMESH_MesherHelper helper( theMesh );
672 _quadraticMesh = helper.IsQuadraticSubMesh( theShape );
673 helper.SetElementsOnShape( true );
676 SMESH_ProxyMesh::Ptr proxyMesh;
677 SMESH_HypoFilter vlFilter( SMESH_HypoFilter::HasName( StdMeshers_ViscousLayers::GetHypType() ));
678 const SMESH_Hypothesis * hyp = theMesh.GetHypothesis( theShape, vlFilter, true );
679 const StdMeshers_ViscousLayers* vlHyp = static_cast< const StdMeshers_ViscousLayers* >( hyp );
681 proxyMesh = vlHyp->Compute( theMesh, theShape, /*toMakeN2NMap=*/true );
683 proxyMesh.reset( new SMESH_ProxyMesh( theMesh ));
685 // -------------------------
686 // Try to find 6 side faces
687 // -------------------------
688 list< _QuadFaceGrid > boxFaceContainer;
689 _QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
690 if ( ! findBoxFaces( theShape, boxFaceContainer, theMesh, *proxyMesh,
691 fBottom, fTop, fFront, fBack, fLeft, fRight))
694 // ------------------------------------------
695 // Fill columns of nodes with existing nodes
696 // ------------------------------------------
698 // let faces load their grids
699 if ( !fBottom->LoadGrid( *proxyMesh )) return error( fBottom->GetError() );
700 if ( !fBack ->LoadGrid( *proxyMesh )) return error( fBack ->GetError() );
701 if ( !fLeft ->LoadGrid( *proxyMesh )) return error( fLeft ->GetError() );
702 if ( !fFront ->LoadGrid( *proxyMesh )) return error( fFront ->GetError() );
703 if ( !fRight ->LoadGrid( *proxyMesh )) return error( fRight ->GetError() );
704 if ( !fTop ->LoadGrid( *proxyMesh )) return error( fTop ->GetError() );
706 // compute normalized parameters of nodes on sides (PAL23189)
707 fBottom->ComputeIJK( COO_X, COO_Y, /*z=*/0. );
708 fBack ->ComputeIJK( COO_X, COO_Z, /*y=*/1. );
709 fLeft ->ComputeIJK( COO_Y, COO_Z, /*x=*/0. );
710 fFront ->ComputeIJK( COO_X, COO_Z, /*y=*/0. );
711 fRight ->ComputeIJK( COO_Y, COO_Z, /*x=*/1. );
712 fTop ->ComputeIJK( COO_X, COO_Y, /*z=*/1. );
714 int x, xSize = fBottom->GetNbHoriSegments(*proxyMesh) + 1, X = xSize - 1;
715 int y, ySize = fBottom->GetNbVertSegments(*proxyMesh) + 1, Y = ySize - 1;
716 int z, zSize = fFront ->GetNbVertSegments(*proxyMesh) + 1, Z = zSize - 1;
717 _Indexer colIndex( xSize, ySize );
718 vector< vector< const SMDS_MeshNode* > > columns( colIndex.size() );
720 // fill node columns by front and back box sides
721 for ( x = 0; x < xSize; ++x ) {
722 vector< const SMDS_MeshNode* >& column0 = columns[ colIndex( x, 0 )];
723 vector< const SMDS_MeshNode* >& column1 = columns[ colIndex( x, Y )];
724 column0.resize( zSize );
725 column1.resize( zSize );
726 for ( z = 0; z < zSize; ++z ) {
727 column0[ z ] = fFront->GetNode( x, z );
728 column1[ z ] = fBack ->GetNode( x, z );
731 // fill node columns by left and right box sides
732 for ( y = 1; y < ySize-1; ++y ) {
733 vector< const SMDS_MeshNode* >& column0 = columns[ colIndex( 0, y )];
734 vector< const SMDS_MeshNode* >& column1 = columns[ colIndex( X, y )];
735 column0.resize( zSize );
736 column1.resize( zSize );
737 for ( z = 0; z < zSize; ++z ) {
738 column0[ z ] = fLeft ->GetNode( y, z );
739 column1[ z ] = fRight->GetNode( y, z );
742 // get nodes from top and bottom box sides
743 for ( x = 1; x < xSize-1; ++x ) {
744 for ( y = 1; y < ySize-1; ++y ) {
745 vector< const SMDS_MeshNode* >& column = columns[ colIndex( x, y )];
746 column.resize( zSize );
747 column.front() = fBottom->GetNode( x, y );
748 column.back() = fTop ->GetNode( x, y );
752 // ----------------------------
753 // Add internal nodes of a box
754 // ----------------------------
755 // projection points of internal nodes on box sub-shapes by which
756 // coordinates of internal nodes are computed
757 vector<gp_XYZ> pointsOnShapes( SMESH_Block::ID_Shell );
759 // projections on vertices are constant
760 pointsOnShapes[ SMESH_Block::ID_V000 ] = fBottom->GetXYZ( 0, 0 );
761 pointsOnShapes[ SMESH_Block::ID_V100 ] = fBottom->GetXYZ( X, 0 );
762 pointsOnShapes[ SMESH_Block::ID_V010 ] = fBottom->GetXYZ( 0, Y );
763 pointsOnShapes[ SMESH_Block::ID_V110 ] = fBottom->GetXYZ( X, Y );
764 pointsOnShapes[ SMESH_Block::ID_V001 ] = fTop->GetXYZ( 0, 0 );
765 pointsOnShapes[ SMESH_Block::ID_V101 ] = fTop->GetXYZ( X, 0 );
766 pointsOnShapes[ SMESH_Block::ID_V011 ] = fTop->GetXYZ( 0, Y );
767 pointsOnShapes[ SMESH_Block::ID_V111 ] = fTop->GetXYZ( X, Y );
769 gp_XYZ params; // normalized parameters of an internal node within the unit box
771 for ( x = 1; x < xSize-1; ++x )
773 const double rX = x / double(X);
774 for ( y = 1; y < ySize-1; ++y )
776 const double rY = y / double(Y);
777 // column to fill during z loop
778 vector< const SMDS_MeshNode* >& column = columns[ colIndex( x, y )];
779 // points projections on horizontal edges
780 pointsOnShapes[ SMESH_Block::ID_Ex00 ] = fBottom->GetXYZ( x, 0 );
781 pointsOnShapes[ SMESH_Block::ID_Ex10 ] = fBottom->GetXYZ( x, Y );
782 pointsOnShapes[ SMESH_Block::ID_E0y0 ] = fBottom->GetXYZ( 0, y );
783 pointsOnShapes[ SMESH_Block::ID_E1y0 ] = fBottom->GetXYZ( X, y );
784 pointsOnShapes[ SMESH_Block::ID_Ex01 ] = fTop->GetXYZ( x, 0 );
785 pointsOnShapes[ SMESH_Block::ID_Ex11 ] = fTop->GetXYZ( x, Y );
786 pointsOnShapes[ SMESH_Block::ID_E0y1 ] = fTop->GetXYZ( 0, y );
787 pointsOnShapes[ SMESH_Block::ID_E1y1 ] = fTop->GetXYZ( X, y );
788 // points projections on horizontal faces
789 pointsOnShapes[ SMESH_Block::ID_Fxy0 ] = fBottom->GetXYZ( x, y );
790 pointsOnShapes[ SMESH_Block::ID_Fxy1 ] = fTop ->GetXYZ( x, y );
791 for ( z = 1; z < zSize-1; ++z ) // z loop
793 // compute normalized parameters of an internal node within the unit box
794 const double rZ = z / double(Z);
795 const gp_XYZ& pBo = fBottom->GetIJK( x, y );
796 const gp_XYZ& pTo = fTop ->GetIJK( x, y );
797 const gp_XYZ& pFr = fFront ->GetIJK( x, z );
798 const gp_XYZ& pBa = fBack ->GetIJK( x, z );
799 const gp_XYZ& pLe = fLeft ->GetIJK( y, z );
800 const gp_XYZ& pRi = fRight ->GetIJK( y, z );
801 params.SetCoord( 1, 0.5 * ( pBo.X() * ( 1. - rZ ) + pTo.X() * rZ +
802 pFr.X() * ( 1. - rY ) + pBa.X() * rY ));
803 params.SetCoord( 2, 0.5 * ( pBo.Y() * ( 1. - rZ ) + pTo.Y() * rZ +
804 pLe.Y() * ( 1. - rX ) + pRi.Y() * rX ));
805 params.SetCoord( 3, 0.5 * ( pFr.Z() * ( 1. - rY ) + pBa.Z() * rY +
806 pLe.Z() * ( 1. - rX ) + pRi.Z() * rX ));
808 // point projections on vertical edges
809 pointsOnShapes[ SMESH_Block::ID_E00z ] = fFront->GetXYZ( 0, z );
810 pointsOnShapes[ SMESH_Block::ID_E10z ] = fFront->GetXYZ( X, z );
811 pointsOnShapes[ SMESH_Block::ID_E01z ] = fBack->GetXYZ( 0, z );
812 pointsOnShapes[ SMESH_Block::ID_E11z ] = fBack->GetXYZ( X, z );
813 // point projections on vertical faces
814 pointsOnShapes[ SMESH_Block::ID_Fx0z ] = fFront->GetXYZ( x, z );
815 pointsOnShapes[ SMESH_Block::ID_Fx1z ] = fBack ->GetXYZ( x, z );
816 pointsOnShapes[ SMESH_Block::ID_F0yz ] = fLeft ->GetXYZ( y, z );
817 pointsOnShapes[ SMESH_Block::ID_F1yz ] = fRight->GetXYZ( y, z );
819 // compute internal node coordinates
821 SMESH_Block::ShellPoint( params, pointsOnShapes, coords );
822 column[ z ] = helper.AddNode( coords.X(), coords.Y(), coords.Z() );
826 //cout << "----------------------------------------------------------------------"<<endl;
827 //for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id)
829 // gp_XYZ p = pointsOnShapes[ id ];
830 // SMESH_Block::DumpShapeID( id,cout)<<" ( "<<p.X()<<", "<<p.Y()<<", "<<p.Z()<<" )"<<endl;
832 //cout << "Params: ( "<< params.X()<<", "<<params.Y()<<", "<<params.Z()<<" )"<<endl;
833 //cout << "coords: ( "<< coords.X()<<", "<<coords.Y()<<", "<<coords.Z()<<" )"<<endl;
838 // faces no more needed, free memory
839 boxFaceContainer.clear();
844 for ( x = 0; x < xSize-1; ++x ) {
845 for ( y = 0; y < ySize-1; ++y ) {
846 vector< const SMDS_MeshNode* >& col00 = columns[ colIndex( x, y )];
847 vector< const SMDS_MeshNode* >& col10 = columns[ colIndex( x+1, y )];
848 vector< const SMDS_MeshNode* >& col01 = columns[ colIndex( x, y+1 )];
849 vector< const SMDS_MeshNode* >& col11 = columns[ colIndex( x+1, y+1 )];
850 for ( z = 0; z < zSize-1; ++z )
852 // bottom face normal of a hexa mush point outside the volume
853 helper.AddVolume(col00[z], col01[z], col11[z], col10[z],
854 col00[z+1], col01[z+1], col11[z+1], col10[z+1]);
861 //================================================================================
865 //================================================================================
867 bool StdMeshers_CompositeHexa_3D::Evaluate(SMESH_Mesh& theMesh,
868 const TopoDS_Shape& theShape,
869 MapShapeNbElems& aResMap)
871 SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
873 // -------------------------
874 // Try to find 6 side faces
875 // -------------------------
876 list< _QuadFaceGrid > boxFaceContainer;
877 _QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
878 if ( ! findBoxFaces( theShape, boxFaceContainer, theMesh, *proxyMesh,
879 fBottom, fTop, fFront, fBack, fLeft, fRight))
882 // Find a less complex side
883 _QuadFaceGrid * lessComplexSide = & boxFaceContainer.front();
884 list< _QuadFaceGrid >::iterator face = boxFaceContainer.begin();
885 for ( ++face; face != boxFaceContainer.end() && lessComplexSide->IsComplex(); ++face )
886 if ( face->NbChildren() < lessComplexSide->NbChildren() )
887 lessComplexSide = & *face;
889 // Get an 1D size of lessComplexSide
891 vector<TopoDS_Edge> edges;
892 if ( !lessComplexSide->GetHoriEdges(edges) )
894 for ( size_t i = 0; i < edges.size(); ++i )
896 const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( edges[i] )];
897 if ( !nbElems.empty() )
898 nbSeg1 += Max( nbElems[ SMDSEntity_Edge ], nbElems[ SMDSEntity_Quad_Edge ]);
901 // Get an 1D size of a box side orthogonal to lessComplexSide
903 _QuadFaceGrid* ortoSide =
904 lessComplexSide->FindAdjacentForSide( Q_LEFT, boxFaceContainer, B_UNDEFINED );
906 if ( !ortoSide || !ortoSide->GetHoriEdges(edges) ) return false;
907 for ( size_t i = 0; i < edges.size(); ++i )
909 const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( edges[i] )];
910 if ( !nbElems.empty() )
911 nbSeg2 += Max( nbElems[ SMDSEntity_Edge ], nbElems[ SMDSEntity_Quad_Edge ]);
914 // Get an 2D size of a box side orthogonal to lessComplexSide
915 int nbFaces = 0, nbQuadFace = 0;
916 list< TopoDS_Face > sideFaces;
917 if ( ortoSide->IsComplex() )
918 for ( _QuadFaceGrid::TChildIterator child = ortoSide->GetChildren(); child.more(); )
919 sideFaces.push_back( child.next().GetFace() );
921 sideFaces.push_back( ortoSide->GetFace() );
923 list< TopoDS_Face >::iterator f = sideFaces.begin();
924 for ( ; f != sideFaces.end(); ++f )
926 const vector<int>& nbElems = aResMap[ theMesh.GetSubMesh( *f )];
927 if ( !nbElems.empty() )
929 nbFaces = nbElems[ SMDSEntity_Quadrangle ];
930 nbQuadFace = nbElems[ SMDSEntity_Quad_Quadrangle ];
934 // Fill nb of elements
935 vector<int> aResVec(SMDSEntity_Last,0);
936 int nbSeg3 = ( nbFaces + nbQuadFace ) / nbSeg2;
937 aResVec[SMDSEntity_Node] = (nbSeg1-1) * (nbSeg2-1) * (nbSeg3-1);
938 aResVec[SMDSEntity_Hexa] = nbSeg1 * nbFaces;
939 aResVec[SMDSEntity_Quad_Hexa] = nbSeg1 * nbQuadFace;
941 aResMap.insert( make_pair( theMesh.GetSubMesh(theShape), aResVec ));
947 //================================================================================
949 * \brief constructor of non-initialized _QuadFaceGrid
951 //================================================================================
953 _QuadFaceGrid::_QuadFaceGrid():
954 myReverse(false), myRightBrother(0), myUpBrother(0), myIndexer(0,0), myID(B_UNDEFINED)
958 //================================================================================
960 * \brief Initialization
962 //================================================================================
964 bool _QuadFaceGrid::Init(const TopoDS_Face& f, SMESH_ProxyMesh& mesh)
967 mySides = _FaceSide();
969 myLeftBottomChild = myRightBrother = myUpBrother = 0;
972 //if ( myFace.Orientation() != TopAbs_FORWARD )
975 list< TopoDS_Edge > edges;
976 list< int > nbEdgesInWire;
977 int nbWire = SMESH_Block::GetOrderedEdges (myFace, edges, nbEdgesInWire);
981 list< TopoDS_Edge >::iterator edgeIt = edges.begin();
982 if ( nbEdgesInWire.front() == 4 ) // exactly 4 edges
984 for ( ; edgeIt != edges.end(); ++edgeIt )
985 mySides.AppendSide( _FaceSide( *edgeIt ));
987 else if ( nbEdgesInWire.front() > 4 ) { // more than 4 edges - try to unite some
988 list< TopoDS_Edge > sideEdges;
989 while ( !edges.empty()) {
991 sideEdges.splice( sideEdges.end(), edges, edges.begin());// edges.front()->sideEdges.back()
992 if ( SMESH_Algo::isDegenerated( sideEdges.back() ))
994 while ( !edges.empty() ) {
995 if ( isContinuousMesh( sideEdges.back(), edges.front(), f, mesh )) {
996 sideEdges.splice( sideEdges.end(), edges, edges.begin());
998 else if ( isContinuousMesh( sideEdges.front(), edges.back(), f, mesh )) {
999 sideEdges.splice( sideEdges.begin(), edges, --edges.end());
1005 mySides.AppendSide( _FaceSide( sideEdges ));
1008 if (mySides.size() != 4)
1012 mySides.GetSide( Q_BOTTOM )->SetID( Q_BOTTOM );
1013 mySides.GetSide( Q_RIGHT )->SetID( Q_RIGHT );
1014 mySides.GetSide( Q_TOP )->SetID( Q_TOP );
1015 mySides.GetSide( Q_LEFT )->SetID( Q_LEFT );
1021 //================================================================================
1023 * \brief Try to unite self with other ordinary face
1025 //================================================================================
1027 bool _QuadFaceGrid::AddContinuousFace( const _QuadFaceGrid& other,
1028 const TopTools_MapOfShape& internalEdges)
1030 for ( int i = 0; i < 4; ++i )
1032 const _FaceSide& otherSide = other.GetSide( i );
1034 if ( mySides.Contain( otherSide, &iMyCommon ))
1036 if ( internalEdges.Contains( otherSide.Edge( 0 )))
1038 DUMP_VERT("Cont 1", mySides.GetSide(iMyCommon)->FirstVertex());
1039 DUMP_VERT("Cont 2", mySides.GetSide(iMyCommon)->LastVertex());
1040 DUMP_VERT("Cont 3", otherSide.FirstVertex());
1041 DUMP_VERT("Cont 4", otherSide.LastVertex());
1043 if ( myChildren.empty() )
1045 myChildren.push_back( *this );
1048 else // find iMyCommon in myChildren
1050 for ( TChildIterator children = GetChildren(); children.more(); ) {
1051 const _QuadFaceGrid& child = children.next();
1052 if ( child.mySides.Contain( otherSide, &iMyCommon ))
1057 // orient new children equally
1058 int otherBottomIndex = SMESH_MesherHelper::WrapIndex( i - iMyCommon + 2, 4 );
1059 if ( other.IsComplex() )
1060 for ( TChildIterator children = other.GetChildren(); children.more(); ) {
1061 myChildren.push_back( children.next() );
1062 myChildren.back().SetBottomSide( myChildren.back().GetSide( otherBottomIndex ));
1065 myChildren.push_back( other );
1066 myChildren.back().SetBottomSide( myChildren.back().GetSide( otherBottomIndex ));
1069 myLeftBottomChild = 0;
1071 // collect vertices in mySides
1072 if ( other.IsComplex() )
1073 for ( TChildIterator children = other.GetChildren(); children.more(); )
1075 const _QuadFaceGrid& child = children.next();
1076 for ( int i = 0; i < 4; ++i )
1077 mySides.AppendSide( child.GetSide(i) );
1080 for ( int i = 0; i < 4; ++i )
1081 mySides.AppendSide( other.GetSide(i) );
1090 //================================================================================
1092 * \brief Try to set the side as bottom hirizontal side
1094 //================================================================================
1096 bool _QuadFaceGrid::SetBottomSide(const _FaceSide& bottom, int* sideIndex)
1098 myLeftBottomChild = myRightBrother = myUpBrother = 0;
1101 if ( myChildren.empty() )
1103 if ( mySides.Contain( bottom, &myBottomIndex )) {
1104 mySides.SetBottomSide( myBottomIndex );
1106 *sideIndex = myBottomIndex;
1112 TChildren::iterator childFace = myChildren.begin(), childEnd = myChildren.end();
1113 for ( ; childFace != childEnd; ++childFace )
1115 if ( childFace->SetBottomSide( bottom, &myBottomIndex ))
1117 TChildren::iterator orientedChild = childFace;
1118 for ( childFace = myChildren.begin(); childFace != childEnd; ++childFace ) {
1119 if ( childFace != orientedChild )
1120 childFace->SetBottomSide( childFace->GetSide( myBottomIndex ));
1123 *sideIndex = myBottomIndex;
1131 //================================================================================
1133 * \brief Return face adjacent to i-th side of this face, (0<i<4)
1135 //================================================================================
1137 _QuadFaceGrid* _QuadFaceGrid::FindAdjacentForSide(int i,
1138 list<_QuadFaceGrid>& faces,
1141 const _FaceSide & iSide = GetSide( i );
1142 list< _QuadFaceGrid >::iterator boxFace = faces.begin();
1143 for ( ; boxFace != faces.end(); ++boxFace )
1145 _QuadFaceGrid* f = & (*boxFace);
1146 if ( f != this && f->SetBottomSide( iSide ))
1147 return f->SetID( id ), f;
1149 return (_QuadFaceGrid*) 0;
1152 //================================================================================
1154 * \brief Return i-th side
1156 //================================================================================
1158 const _FaceSide& _QuadFaceGrid::GetSide(int i) const
1160 if ( myChildren.empty() )
1161 return *mySides.GetSide(i);
1163 _QuadFaceGrid* me = const_cast<_QuadFaceGrid*>(this);
1164 if ( !me->locateChildren() || !myLeftBottomChild )
1165 return *mySides.GetSide(i);
1167 const _QuadFaceGrid* child = myLeftBottomChild;
1173 while ( child->myRightBrother )
1174 child = child->myRightBrother;
1177 while ( child->myUpBrother )
1178 child = child->myUpBrother;
1182 return child->GetSide( i );
1185 //================================================================================
1187 * \brief Reverse edges in order to have them oriented along axes of the unit box
1189 //================================================================================
1191 void _QuadFaceGrid::ReverseEdges()
1193 myReverse = !myReverse;
1196 // if ( !myFace.IsNull() )
1197 // TopAbs::Print(myFace.Orientation(), cout);
1200 if ( myChildren.empty() )
1207 TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
1208 for ( ; child != childEnd; ++child )
1209 child->ReverseEdges();
1213 //================================================================================
1215 * \brief Load nodes of a mesh
1217 //================================================================================
1219 bool _QuadFaceGrid::LoadGrid( SMESH_ProxyMesh& mesh )
1221 if ( !myChildren.empty() )
1223 // Let child faces load their grids
1224 TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
1225 for ( ; child != childEnd; ++child ) {
1226 child->SetID( myID );
1227 if ( !child->LoadGrid( mesh ) )
1228 return error( child->GetError() );
1230 // Fill myGrid with nodes of patches
1231 return loadCompositeGrid( mesh );
1234 // ---------------------------------------
1235 // Fill myGrid with nodes bound to myFace
1236 // ---------------------------------------
1238 if ( !myGrid.empty() )
1241 const SMESHDS_SubMesh* faceSubMesh = mesh.GetSubMesh( myFace );
1243 // check that all faces are quadrangular
1244 SMDS_ElemIteratorPtr fIt = faceSubMesh->GetElements();
1245 while ( fIt->more() )
1246 if ( fIt->next()->NbNodes() % 4 > 0 )
1247 return error("Non-quadrangular mesh faces are not allowed on sides of a composite block");
1249 bool isProxy, isTmpElem;
1250 if ( faceSubMesh && faceSubMesh->NbElements() > 0 )
1252 isProxy = dynamic_cast< const SMESH_ProxyMesh::SubMesh* >( faceSubMesh );
1253 isTmpElem = mesh.IsTemporary( faceSubMesh->GetElements()->next() );
1255 const SMESHDS_SubMesh* smToCheckEdges = ( isProxy && !isTmpElem ) ? faceSubMesh : 0;
1257 myIndexer._xSize = 1 + mySides.GetSide( Q_BOTTOM )->GetNbSegments( mesh, smToCheckEdges );
1258 myIndexer._ySize = 1 + mySides.GetSide( Q_LEFT )->GetNbSegments( mesh, smToCheckEdges );
1260 myGrid.resize( myIndexer.size() );
1262 // store nodes bound to the bottom edge
1263 mySides.GetSide( Q_BOTTOM )->StoreNodes( mesh, myGrid, myReverse, isProxy, smToCheckEdges );
1265 // store the rest nodes row by row
1267 TIDSortedElemSet avoidSet;
1268 const SMDS_MeshElement* firstQuad = 0; // most left face above the last row of found nodes
1270 size_t nbFoundNodes = myIndexer._xSize;
1271 while ( nbFoundNodes != myGrid.size() )
1273 // first and last nodes of the last filled row of nodes
1274 const SMDS_MeshNode* n1down = myGrid[ nbFoundNodes - myIndexer._xSize ];
1275 const SMDS_MeshNode* n2down = myGrid[ nbFoundNodes - myIndexer._xSize + 1];
1276 const SMDS_MeshNode* n1downLast = myGrid[ nbFoundNodes-1 ];
1278 // find the first face above the row by the first two left nodes
1286 firstQuad = FindFaceByNodes( n1down, n2down, avoidSet, mesh );
1287 while ( firstQuad && !faceSubMesh->Contains( firstQuad )) {
1288 avoidSet.insert( firstQuad );
1289 firstQuad = FindFaceByNodes( n1down, n2down, avoidSet, mesh);
1291 if ( !firstQuad || !faceSubMesh->Contains( firstQuad ))
1292 return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));
1294 // find the node of quad bound to the left geom edge
1295 int i2down = firstQuad->GetNodeIndex( n2down );
1296 const SMDS_MeshNode* n1up = firstQuad->GetNode(( i2down+2 ) % 4 );
1297 myGrid[ nbFoundNodes++ ] = n1up;
1298 // the 4-the node of the first quad
1299 int i1down = firstQuad->GetNodeIndex( n1down );
1300 const SMDS_MeshNode* n2up = firstQuad->GetNode(( i1down+2 ) % 4 );
1301 myGrid[ nbFoundNodes++ ] = n2up;
1305 const SMDS_MeshElement* quad = firstQuad;
1307 // find the rest nodes by remaining faces above the row
1315 while ( n1down != n1downLast )
1318 avoidSet.clear(); avoidSet.insert( quad );
1319 quad = FindFaceByNodes( n1down, n1up, avoidSet, mesh );
1320 if ( !quad || quad->NbNodes() % 4 > 0)
1321 return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));
1324 if ( quad->GetNode( i1down ) != n1down ) // check already found index
1325 i1down = quad->GetNodeIndex( n1down );
1326 n2up = quad->GetNode(( i1down+2 ) % 4 );
1327 myGrid[ nbFoundNodes++ ] = n2up;
1329 n1down = myGrid[ nbFoundNodes - myIndexer._xSize - 1 ];
1332 avoidSet.clear(); avoidSet.insert( firstQuad );
1334 DumpGrid(); // debug
1339 //================================================================================
1341 * \brief Fill myIJK with normalized parameters of nodes in myGrid
1342 * \param [in] i1 - coordinate index along rows of myGrid
1343 * \param [in] i2 - coordinate index along columns of myGrid
1344 * \param [in] v3 - value of the constant parameter
1346 //================================================================================
1348 void _QuadFaceGrid::ComputeIJK( int i1, int i2, double v3 )
1350 gp_XYZ ijk( v3, v3, v3 );
1351 myIJK.resize( myIndexer.size(), ijk );
1353 const size_t nbCol = myIndexer._xSize;
1354 const size_t nbRow = myIndexer._ySize;
1356 vector< double > len( nbRow );
1358 for ( size_t i = 0; i < nbCol; ++i )
1360 gp_Pnt pPrev = GetXYZ( i, 0 );
1361 for ( size_t j = 1; j < nbRow; ++j )
1363 gp_Pnt p = GetXYZ( i, j );
1364 len[ j ] = len[ j-1 ] + p.Distance( pPrev );
1367 for ( size_t j = 0; j < nbRow; ++j )
1368 GetIJK( i, j ).SetCoord( i2, len[ j ]/len.back() );
1371 len.resize( nbCol );
1372 for ( size_t j = 0; j < nbRow; ++j )
1374 gp_Pnt pPrev = GetXYZ( 0, j );
1375 for ( size_t i = 1; i < nbCol; ++i )
1377 gp_Pnt p = GetXYZ( i, j );
1378 len[ i ] = len[ i-1 ] + p.Distance( pPrev );
1381 for ( size_t i = 0; i < nbCol; ++i )
1382 GetIJK( i, j ).SetCoord( i1, len[ i ]/len.back() );
1386 //================================================================================
1388 * \brief Find out mutual location of children: find their right and up brothers
1390 //================================================================================
1392 bool _QuadFaceGrid::locateChildren()
1394 if ( myLeftBottomChild )
1397 TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
1399 // find a child sharing it's first bottom vertex with no other brother
1400 myLeftBottomChild = 0;
1401 for ( ; !myLeftBottomChild && child != childEnd; ++child )
1403 TopoDS_Vertex leftVertex = child->GetSide( Q_BOTTOM ).FirstVertex();
1404 bool sharedVertex = false;
1405 TChildren::iterator otherChild = myChildren.begin();
1406 for ( ; otherChild != childEnd && !sharedVertex; ++otherChild )
1407 if ( otherChild != child )
1408 sharedVertex = otherChild->mySides.Contain( leftVertex );
1409 if ( !sharedVertex ) {
1410 myLeftBottomChild = & (*child);
1411 DUMP_VERT("0 left bottom Vertex: ",leftVertex );
1414 if (!myLeftBottomChild)
1415 return error(ERR_LI("Error in locateChildren()"));
1417 set< _QuadFaceGrid* > notLocatedChilren;
1418 for (child = myChildren.begin() ; child != childEnd; ++child )
1419 notLocatedChilren.insert( & (*child));
1421 // connect myLeftBottomChild to it's right and upper brothers
1422 notLocatedChilren.erase( myLeftBottomChild );
1423 myLeftBottomChild->setBrothers( notLocatedChilren );
1424 if ( !notLocatedChilren.empty() )
1425 return error(ERR_LI("Error in locateChildren()"));
1430 //================================================================================
1432 * \brief Fill myGrid with nodes of patches
1434 //================================================================================
1436 bool _QuadFaceGrid::loadCompositeGrid(SMESH_ProxyMesh& mesh)
1438 // Find out mutual location of children: find their right and up brothers
1439 if ( !locateChildren() )
1442 // Load nodes according to mutual location of children
1445 myIndexer._xSize = 1 + myLeftBottomChild->GetNbHoriSegments( mesh, /*withBrothers=*/true );
1446 myIndexer._ySize = 1 + myLeftBottomChild->GetNbVertSegments( mesh, /*withBrothers=*/true );
1448 myGrid.resize( myIndexer.size() );
1450 int fromX = myReverse ? myIndexer._xSize : 0;
1451 if ( !myLeftBottomChild->fillGrid( mesh, myGrid, myIndexer, fromX, 0 ))
1452 return error( myLeftBottomChild->GetError() );
1459 //================================================================================
1461 * \brief Find right an upper brothers among notLocatedBrothers
1463 //================================================================================
1465 void _QuadFaceGrid::setBrothers( set< _QuadFaceGrid* >& notLocatedBrothers )
1467 if ( !notLocatedBrothers.empty() )
1469 // find right brother
1470 TopoDS_Vertex rightVertex = GetSide( Q_BOTTOM ).LastVertex();
1471 DUMP_VERT("1 right bottom Vertex: ",rightVertex );
1472 set< _QuadFaceGrid* >::iterator brIt, brEnd = notLocatedBrothers.end();
1473 for ( brIt = notLocatedBrothers.begin(); brIt != brEnd; ++brIt )
1475 _QuadFaceGrid* brother = *brIt;
1476 TopoDS_Vertex brotherLeftVertex = brother->GetSide( Q_BOTTOM ).FirstVertex();
1477 DUMP_VERT( "brother left bottom: ", brotherLeftVertex );
1478 if ( rightVertex.IsSame( brotherLeftVertex )) {
1479 myRightBrother = brother;
1480 notLocatedBrothers.erase( brIt );
1484 // find upper brother
1485 TopoDS_Vertex upVertex = GetSide( Q_LEFT ).FirstVertex();
1486 DUMP_VERT("1 left up Vertex: ",upVertex);
1487 brIt = notLocatedBrothers.begin(), brEnd = notLocatedBrothers.end();
1488 for ( ; brIt != brEnd; ++brIt )
1490 _QuadFaceGrid* brother = *brIt;
1491 TopoDS_Vertex brotherLeftVertex = brother->GetSide( Q_BOTTOM ).FirstVertex();
1492 DUMP_VERT("brother left bottom: ", brotherLeftVertex);
1493 if ( upVertex.IsSame( brotherLeftVertex )) {
1494 myUpBrother = brother;
1495 notLocatedBrothers.erase( myUpBrother );
1500 if ( myRightBrother )
1501 myRightBrother->setBrothers( notLocatedBrothers );
1503 myUpBrother->setBrothers( notLocatedBrothers );
1507 //================================================================================
1509 * \brief Store nodes of a simple face into grid starting from (x,y) position
1511 //================================================================================
1513 bool _QuadFaceGrid::fillGrid(SMESH_ProxyMesh& theMesh,
1514 vector<const SMDS_MeshNode*> & theGrid,
1515 const _Indexer& theIndexer,
1519 if ( myGrid.empty() && !LoadGrid( theMesh ))
1522 // store my own grid in the global grid
1524 int fromX = myReverse ? theX - myIndexer._xSize: theX;
1526 for ( int i = 0, x = fromX; i < myIndexer._xSize; ++i, ++x )
1527 for ( int j = 0, y = theY; j < myIndexer._ySize; ++j, ++y )
1528 theGrid[ theIndexer( x, y )] = myGrid[ myIndexer( i, j )];
1530 // store grids of my right and upper brothers
1532 if ( myRightBrother )
1537 fromX += myIndexer._xSize - 1;
1538 if ( !myRightBrother->fillGrid( theMesh, theGrid, theIndexer, fromX, theY ))
1539 return error( myRightBrother->GetError() );
1543 if ( !myUpBrother->fillGrid( theMesh, theGrid, theIndexer,
1544 theX, theY + myIndexer._ySize - 1))
1545 return error( myUpBrother->GetError() );
1550 //================================================================================
1552 * \brief Return number of segments on the hirizontal sides
1554 //================================================================================
1556 int _QuadFaceGrid::GetNbHoriSegments(SMESH_ProxyMesh& mesh, bool withBrothers) const
1559 if ( myLeftBottomChild )
1561 nbSegs += myLeftBottomChild->GetNbHoriSegments( mesh, true );
1565 nbSegs = mySides.GetSide( Q_BOTTOM )->GetNbSegments( mesh );
1566 if ( withBrothers && myRightBrother )
1567 nbSegs += myRightBrother->GetNbHoriSegments( mesh, withBrothers );
1572 //================================================================================
1574 * \brief Return number of segments on the vertical sides
1576 //================================================================================
1578 int _QuadFaceGrid::GetNbVertSegments(SMESH_ProxyMesh& mesh, bool withBrothers) const
1581 if ( myLeftBottomChild )
1583 nbSegs += myLeftBottomChild->GetNbVertSegments( mesh, true );
1587 nbSegs = mySides.GetSide( Q_LEFT )->GetNbSegments(mesh,0);
1588 if ( withBrothers && myUpBrother )
1589 nbSegs += myUpBrother->GetNbVertSegments( mesh, withBrothers );
1594 //================================================================================
1596 * \brief Return edge on the hirizontal bottom sides
1598 //================================================================================
1600 int _QuadFaceGrid::GetHoriEdges(vector<TopoDS_Edge> & edges) const
1602 if ( myLeftBottomChild )
1604 return myLeftBottomChild->GetHoriEdges( edges );
1608 const _FaceSide* bottom = mySides.GetSide( Q_BOTTOM );
1611 TopoDS_Edge e = bottom->Edge( i++ );
1615 edges.push_back( e );
1617 if ( myRightBrother )
1618 myRightBrother->GetHoriEdges( edges );
1620 return edges.size();
1623 //================================================================================
1625 * \brief Return a node by its position
1627 //================================================================================
1629 const SMDS_MeshNode* _QuadFaceGrid::GetNode(int iHori, int iVert) const
1631 return myGrid[ myIndexer( iHori, iVert )];
1634 //================================================================================
1636 * \brief Return node coordinates by its position
1638 //================================================================================
1640 gp_XYZ _QuadFaceGrid::GetXYZ(int iHori, int iVert) const
1642 SMESH_TNodeXYZ xyz = myGrid[ myIndexer( iHori, iVert )];
1646 //================================================================================
1648 * \brief Return normal to the face at vertex v
1650 //================================================================================
1652 bool _QuadFaceGrid::GetNormal( const TopoDS_Vertex& v, gp_Vec& n ) const
1654 if ( myChildren.empty() )
1656 if ( mySides.Contain( v )) {
1658 gp_Pnt2d uv = BRep_Tool::Parameters( v, myFace );
1659 BRepAdaptor_Surface surface( myFace );
1660 gp_Pnt p; gp_Vec d1u, d1v;
1661 surface.D1( uv.X(), uv.Y(), p, d1u, d1v );
1662 n = d1u.Crossed( d1v );
1665 catch (Standard_Failure) {
1672 TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
1673 for ( ; child != childEnd; ++child )
1674 if ( child->GetNormal( v, n ))
1680 //================================================================================
1682 * \brief Dumps coordinates of grid nodes
1684 //================================================================================
1686 void _QuadFaceGrid::DumpGrid() const
1689 const char* names[] = { "B_BOTTOM", "B_RIGHT", "B_TOP", "B_LEFT", "B_FRONT", "B_BACK" };
1690 cout << "****** Face " << names[ myID ] << endl;
1692 if ( myChildren.empty() || !myGrid.empty() )
1694 cout << "x size: " << myIndexer._xSize << "; y size: " << myIndexer._ySize << endl;
1695 for ( int y = 0; y < myIndexer._ySize; ++y ) {
1696 cout << "-- row " << y << endl;
1697 for ( int x = 0; x < myIndexer._xSize; ++x ) {
1698 const SMDS_MeshNode* n = myGrid[ myIndexer( x, y ) ];
1699 cout << x << " ( " << n->X() << ", " << n->Y() << ", " << n->Z() << " )" << endl;
1705 cout << "Nb children: " << myChildren.size() << endl;
1706 TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
1707 for ( int i=0; child != childEnd; ++child, ++i ) {
1708 cout << " *** SUBFACE " << i+1 << endl;
1709 ((_QuadFaceGrid&)(*child)).SetID( myID );
1716 //================================================================================
1718 * \brief Dump vertices
1720 //================================================================================
1722 void _QuadFaceGrid::DumpVertices() const
1725 cout << "****** Face ";
1726 const char* names[] = { "B_BOTTOM", "B_RIGHT", "B_TOP", "B_LEFT", "B_FRONT", "B_BACK" };
1727 if ( myID >= B_BOTTOM && myID < B_BACK )
1728 cout << names[ myID ] << endl;
1730 cout << "UNDEFINED" << endl;
1732 if ( myChildren.empty() )
1734 for ( int i = 0; i < 4; ++i )
1736 cout << " Side "; mySides.GetSide( i )->Dump();
1741 cout << "-- Nb children: " << myChildren.size() << endl;
1742 TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
1743 for ( int i=0; child != childEnd; ++child, ++i ) {
1744 cout << " *** SUBFACE " << i+1 << endl;
1745 ((_QuadFaceGrid&)(*child)).SetID( myID );
1746 child->DumpVertices();
1752 //=======================================================================
1753 //function : _FaceSide
1754 //purpose : copy constructor
1755 //=======================================================================
1757 _FaceSide::_FaceSide(const _FaceSide& other)
1759 myEdge = other.myEdge;
1760 myChildren = other.myChildren;
1761 myNbChildren = other.myNbChildren;
1762 myVertices.Assign( other.myVertices );
1766 //================================================================================
1768 * \brief Construct a face side of one edge
1770 //================================================================================
1772 _FaceSide::_FaceSide(const TopoDS_Edge& edge):
1773 myEdge( edge ), myNbChildren(0)
1775 if ( !edge.IsNull() )
1776 for ( TopExp_Explorer exp( edge, TopAbs_VERTEX ); exp.More(); exp.Next() )
1777 //myVertices.insert( ptr ( exp.Current() ));
1778 myVertices.Add( exp.Current() );
1781 //================================================================================
1783 * \brief Construct a face side of several edges
1785 //================================================================================
1787 _FaceSide::_FaceSide(const list<TopoDS_Edge>& edges):
1790 list<TopoDS_Edge>::const_iterator edge = edges.begin(), eEnd = edges.end();
1791 for ( ; edge != eEnd; ++edge ) {
1792 myChildren.push_back( _FaceSide( *edge ));
1794 myVertices.Add( myChildren.back().FirstVertex() );
1795 myVertices.Add( myChildren.back().LastVertex() );
1796 myChildren.back().SetID( Q_CHILD ); // not to splice them
1800 //=======================================================================
1801 //function : GetSide
1803 //=======================================================================
1805 _FaceSide* _FaceSide::GetSide(const int i)
1807 if ( i >= myNbChildren )
1810 list< _FaceSide >::iterator side = myChildren.begin();
1812 std::advance( side, i );
1816 //=======================================================================
1817 //function : GetSide
1819 //=======================================================================
1821 const _FaceSide* _FaceSide::GetSide(const int i) const
1823 return const_cast< _FaceSide* >(this)->GetSide(i);
1826 //=======================================================================
1827 //function : NbVertices
1828 //purpose : return nb of vertices in the side
1829 //=======================================================================
1831 int _FaceSide::NbVertices() const
1833 if ( myChildren.empty() )
1834 return myVertices.Extent();
1836 return myNbChildren + 1;
1839 //=======================================================================
1840 //function : NbCommonVertices
1841 //purpose : Returns number of my vertices common with the given ones
1842 //=======================================================================
1844 int _FaceSide::NbCommonVertices( const TopTools_MapOfShape& VV ) const
1847 TopTools_MapIteratorOfMapOfShape vIt ( myVertices );
1848 for ( ; vIt.More(); vIt.Next() )
1849 nbCommon += ( VV.Contains( vIt.Key() ));
1854 //=======================================================================
1855 //function : FirstVertex
1857 //=======================================================================
1859 TopoDS_Vertex _FaceSide::FirstVertex() const
1861 if ( myChildren.empty() )
1862 return TopExp::FirstVertex( myEdge, Standard_True );
1864 return myChildren.front().FirstVertex();
1867 //=======================================================================
1868 //function : LastVertex
1870 //=======================================================================
1872 TopoDS_Vertex _FaceSide::LastVertex() const
1874 if ( myChildren.empty() )
1875 return TopExp::LastVertex( myEdge, Standard_True );
1877 return myChildren.back().LastVertex();
1880 //=======================================================================
1883 //=======================================================================
1885 TopoDS_Vertex _FaceSide::Vertex(int i) const
1887 if ( myChildren.empty() )
1888 return i ? LastVertex() : FirstVertex();
1890 if ( i >= myNbChildren )
1891 return myChildren.back().LastVertex();
1893 return GetSide(i)->FirstVertex();
1896 //================================================================================
1898 * \brief Return i-the zero-based edge of the side
1900 //================================================================================
1902 TopoDS_Edge _FaceSide::Edge(int i) const
1904 if ( i == 0 && !myEdge.IsNull() )
1907 if ( const _FaceSide* iSide = GetSide( i ))
1908 return iSide->myEdge;
1910 return TopoDS_Edge();
1913 //=======================================================================
1914 //function : Contain
1916 //=======================================================================
1918 bool _FaceSide::Contain( const _FaceSide& side, int* which ) const
1920 if ( !which || myChildren.empty() )
1925 TopTools_MapIteratorOfMapOfShape vIt ( side.myVertices );
1926 for ( ; vIt.More(); vIt.Next() )
1927 nbCommon += ( myVertices.Contains( vIt.Key() ));
1928 return (nbCommon > 1);
1930 list< _FaceSide >::const_iterator mySide = myChildren.begin(), sideEnd = myChildren.end();
1931 for ( int i = 0; mySide != sideEnd; ++mySide, ++i ) {
1932 if ( mySide->Contain( side )) {
1940 //=======================================================================
1941 //function : Contain
1943 //=======================================================================
1945 bool _FaceSide::Contain( const TopoDS_Vertex& vertex ) const
1947 return myVertices.Contains( vertex );
1950 //=======================================================================
1951 //function : AppendSide
1953 //=======================================================================
1955 void _FaceSide::AppendSide( const _FaceSide& side )
1957 if ( !myEdge.IsNull() )
1959 myChildren.push_back( *this );
1963 myChildren.push_back( side );
1965 TopTools_MapIteratorOfMapOfShape vIt ( side.myVertices );
1966 for ( ; vIt.More(); vIt.Next() )
1967 myVertices.Add( vIt.Key() );
1970 myChildren.back().SetID( EQuadSides( myNbChildren-1 ));
1973 //=======================================================================
1974 //function : SetBottomSide
1976 //=======================================================================
1978 void _FaceSide::SetBottomSide( int i )
1980 if ( i > 0 && myID == Q_PARENT ) {
1981 list< _FaceSide >::iterator sideEnd, side = myChildren.begin();
1982 std::advance( side, i );
1983 myChildren.splice( myChildren.begin(), myChildren, side, myChildren.end() );
1985 side = myChildren.begin(), sideEnd = myChildren.end();
1986 for ( int i = 0; side != sideEnd; ++side, ++i ) {
1987 side->SetID( EQuadSides(i) );
1988 side->SetBottomSide(i);
1993 //=======================================================================
1994 //function : GetNbSegments
1996 //=======================================================================
1998 int _FaceSide::GetNbSegments(SMESH_ProxyMesh& mesh, const SMESHDS_SubMesh* smToCheckEdges) const
2001 if ( myChildren.empty() )
2003 nb = mesh.GetSubMesh(myEdge)->NbElements();
2005 if ( smToCheckEdges )
2007 // check that segments bound faces belonging to smToCheckEdges
2008 SMDS_ElemIteratorPtr segIt = mesh.GetSubMesh(myEdge)->GetElements();
2009 while ( segIt->more() )
2011 const SMDS_MeshElement* seg = segIt->next();
2012 if ( !IsSegmentOnSubMeshBoundary( mesh.GetProxyNode( seg->GetNode(0) ),
2013 mesh.GetProxyNode( seg->GetNode(1) ),
2014 smToCheckEdges, mesh ))
2021 list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
2022 for ( ; side != sideEnd; ++side )
2023 nb += side->GetNbSegments( mesh, smToCheckEdges );
2028 //=======================================================================
2029 //function : StoreNodes
2031 //=======================================================================
2033 bool _FaceSide::StoreNodes(SMESH_ProxyMesh& mesh,
2034 vector<const SMDS_MeshNode*>& myGrid,
2037 const SMESHDS_SubMesh* smToCheckEdges)
2039 list< TopoDS_Edge > edges;
2040 if ( myChildren.empty() )
2042 edges.push_back( myEdge );
2046 list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
2047 for ( ; side != sideEnd; ++side )
2049 edges.push_front( side->myEdge );
2051 edges.push_back ( side->myEdge );
2054 list< TopoDS_Edge >::iterator edge = edges.begin(), eEnd = edges.end();
2055 for ( ; edge != eEnd; ++edge )
2057 typedef map< double, const SMDS_MeshNode* > TParamNodeMap;
2058 TParamNodeMap nodes;
2059 bool ok = SMESH_Algo::GetSortedNodesOnEdge( mesh.GetMeshDS(),
2061 /*ignoreMediumNodes=*/true,
2063 if ( !ok ) return false;
2065 // skip nodes on VERTEXes not included in faces
2066 if ( !nodes.begin()->second->GetInverseElementIterator(SMDSAbs_Face)->more() )
2067 nodes.erase( nodes.begin() );
2068 if ( !nodes.empty() &&
2069 !nodes.rbegin()->second->GetInverseElementIterator(SMDSAbs_Face)->more() )
2070 nodes.erase( --nodes.end() );
2074 TParamNodeMap::iterator u_node, nEnd = nodes.end();
2075 for ( u_node = nodes.begin(); u_node != nEnd; ++u_node )
2076 u_node->second = mesh.GetProxyNode( u_node->second );
2079 if ( smToCheckEdges ) // erase nodes of segments not bounding faces of smToCheckEdges
2082 TParamNodeMap::iterator u_node1, u_node2 = nodes.begin(), nEnd = nodes.end();
2083 for ( u_node1 = u_node2++; u_node2 != nEnd; u_node1 = u_node2++ )
2084 if ( IsSegmentOnSubMeshBoundary( u_node1->second, u_node2->second,
2085 smToCheckEdges, mesh ))
2088 nodes.erase( u_node1 );
2091 TParamNodeMap::reverse_iterator u_node1, u_node2 = nodes.rbegin(), nEnd = nodes.rend();
2092 for ( u_node1 = u_node2++; u_node2 != nEnd; u_node1 = u_node2++ )
2093 if ( IsSegmentOnSubMeshBoundary( u_node1->second, u_node2->second,
2094 smToCheckEdges, mesh ))
2097 nodes.erase( --( u_node1.base() ));
2101 bool forward = ( edge->Orientation() == TopAbs_FORWARD );
2102 if ( reverse ) forward = !forward;
2105 TParamNodeMap::iterator u_node, nEnd = nodes.end();
2106 for ( u_node = nodes.begin(); u_node != nEnd; ++u_node )
2107 myGrid[ nbNodes++ ] = u_node->second;
2111 TParamNodeMap::reverse_iterator u_node, nEnd = nodes.rend();
2112 for ( u_node = nodes.rbegin(); u_node != nEnd; ++u_node )
2113 myGrid[ nbNodes++ ] = u_node->second;
2115 nbNodes--; // node on vertex present in two adjacent edges
2120 //=======================================================================
2122 //purpose : dump end vertices
2123 //=======================================================================
2125 void _FaceSide::Dump() const
2127 if ( myChildren.empty() )
2129 const char* sideNames[] = { "Q_BOTTOM", "Q_RIGHT", "Q_TOP", "Q_LEFT", "Q_CHILD", "Q_PARENT" };
2130 if ( myID >= Q_BOTTOM && myID < Q_PARENT )
2131 cout << sideNames[ myID ] << endl;
2133 cout << "<UNDEFINED ID>" << endl;
2134 TopoDS_Vertex f = FirstVertex();
2135 TopoDS_Vertex l = LastVertex();
2136 gp_Pnt pf = BRep_Tool::Pnt(f);
2137 gp_Pnt pl = BRep_Tool::Pnt(l);
2138 cout << "\t ( "<< ptr( f ) << " - " << ptr( l )<< " )"
2139 << "\t ( "<< pf.X()<<", "<<pf.Y()<<", "<<pf.Z()<<" ) - "
2140 << " ( "<< pl.X()<<", "<<pl.Y()<<", "<<pl.Z()<<" )"<<endl;
2144 list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
2145 for ( ; side != sideEnd; ++side ) {