1 // SMESH StdMeshers_Penta_3D implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : StdMeshers_Penta_3D.cxx
27 #include "StdMeshers_Penta_3D.hxx"
29 #include "utilities.h"
30 #include "Utils_ExceptHandlers.hxx"
32 #include "SMDS_EdgePosition.hxx"
33 #include "SMDS_MeshElement.hxx"
34 #include "SMDS_VolumeOfNodes.hxx"
35 #include "SMDS_VolumeTool.hxx"
36 #include "SMESHDS_SubMesh.hxx"
37 #include "SMESH_Mesh.hxx"
38 #include "SMESH_subMesh.hxx"
39 #include "SMESH_MeshEditor.hxx"
41 #include <BRep_Tool.hxx>
42 #include <TopAbs_ShapeEnum.hxx>
44 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
46 #include <TopTools_IndexedMapOfShape.hxx>
47 #include <TopTools_ListIteratorOfListOfShape.hxx>
48 #include <TopTools_ListOfShape.hxx>
50 #include <TopoDS_Edge.hxx>
51 #include <TopoDS_Shell.hxx>
52 #include <TopoDS_Vertex.hxx>
60 typedef map < int, int, less<int> >::iterator \
61 StdMeshers_IteratorOfDataMapOfIntegerInteger;
63 //=======================================================================
64 //function : StdMeshers_Penta_3D
66 //=======================================================================
67 StdMeshers_Penta_3D::StdMeshers_Penta_3D()
71 myWallNodesMaps.resize( SMESH_Block::NbFaces() );
72 myShapeXYZ.resize( SMESH_Block::NbSubShapes() );
74 //=======================================================================
77 //=======================================================================
78 bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
79 const TopoDS_Shape& aShape)
81 MESSAGE("StdMeshers_Penta_3D::Compute()");
121 //=======================================================================
122 //function : MakeNodes
124 //=======================================================================
125 void StdMeshers_Penta_3D::MakeNodes()
130 int i, j, k, ij, iNbN, aNodeID, aSize, iErr;
132 SMESH_Block::TShapeID aSID, aSIDs[aNbSIDs]={
133 SMESH_Block::ID_V000, SMESH_Block::ID_V100,
134 SMESH_Block::ID_V110, SMESH_Block::ID_V010,
135 SMESH_Block::ID_Ex00, SMESH_Block::ID_E1y0,
136 SMESH_Block::ID_Ex10, SMESH_Block::ID_E0y0,
140 SMESH_Mesh* pMesh=GetMesh();
142 // 1. Define the sizes of mesh
144 // 1.1 Horizontal size
146 for (i=0; i<aNbSIDs; ++i) {
147 const TopoDS_Shape& aS=myBlock.Shape(aSIDs[i]);
148 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
150 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
154 //printf("*** Horizontal: number of nodes summary=%d\n", myJSize);
159 const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_E00z);
160 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
162 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
166 //printf("*** Vertical: number of nodes on edges and vertices=%d\n", myISize);
168 aSize=myISize*myJSize;
169 myTNodes.resize(aSize);
171 StdMeshers_TNode aTNode;
175 // 2. Fill the repers on base face (Z=0)
178 for (k=0; k<aNbSIDs; ++k) {
180 const TopoDS_Shape& aS=myBlock.Shape(aSID);
181 SMDS_NodeIteratorPtr ite =pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
183 const SMDS_MeshNode* aNode = ite->next();
184 aNodeID=aNode->GetID();
186 aTNode.SetNode(aNode);
187 aTNode.SetShapeSupportID(aSID);
188 aTNode.SetBaseNodeID(aNodeID);
190 if ( SMESH_Block::IsEdgeID (aSID))
192 const SMDS_EdgePosition* epos =
193 static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
194 myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords );
200 aP3D.SetCoord(aX, aY, aZ);
201 myBlock.ComputeParameters(aP3D, aS, aCoords);
203 iErr=myBlock.ErrorStatus();
205 MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
206 "SMESHBlock: ComputeParameters operation failed");
207 myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
210 aTNode.SetNormCoord(aCoords);
219 int iShapeSupportID, iBaseNodeID;
221 //printf("\n\n*** Base Face\n");
223 for (j=0; j<myJSize; ++j) {
225 const StdMeshers_TNode& aTNode=myTNodes[ij];
226 iShapeSupportID=aTNode.ShapeSupportID();
227 iBaseNodeID=aTNode.BaseNodeID();
228 const gp_XYZ& aXYZ=aTNode.NormCoord();
229 printf("*** j:%d bID#%d iSS:%d { %lf %lf %lf }\n",
230 j, iBaseNodeID, iShapeSupportID, aXYZ.X(), aXYZ.Y(), aXYZ.Z());
237 // 3. Finding of Z-layers
238 // vector<double> aZL(myISize);
239 // vector<double>::iterator aItZL1, aItZL2 ;
241 // const TopoDS_Shape& aE00z=myBlock.Shape(SMESH_Block::ID_E00z);
242 // SMDS_NodeIteratorPtr aItaE00z =
243 // pMesh->GetSubMeshContaining(aE00z)->GetSubMeshDS()->GetNodes();
247 // while (aItaE00z->more()) {
248 // const SMDS_MeshNode* aNode=aItaE00z->next();
249 // const SMDS_EdgePosition* epos =
250 // static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
251 // myBlock.ComputeParameters( epos->GetUParameter(), aE00z, aCoords );
252 // iErr=myBlock.ErrorStatus();
254 // MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
255 // "SMESHBlock: ComputeParameters operation failed");
256 // myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
259 // aZL[i]=aCoords.Z();
264 // aItZL1=aZL.begin();
267 // // Sorting the layers
268 // sort(aItZL1, aItZL2);
271 printf("** \n\n Layers begin\n");
272 for(i=0, aItZL=aItZL1; aItZL!=aItZL2; ++aItZL, ++i) {
273 printf(" #%d : %lf\n", i, *aItZL);
275 printf("** Layers end\n");
281 // 3.1 Fill maps of wall nodes
282 SMESH_Block::TShapeID wallFaceID[4] = {
283 SMESH_Block::ID_Fx0z, SMESH_Block::ID_Fx1z,
284 SMESH_Block::ID_F0yz, SMESH_Block::ID_F1yz
286 SMESH_Block::TShapeID baseEdgeID[4] = {
287 SMESH_Block::ID_Ex00, SMESH_Block::ID_Ex10,
288 SMESH_Block::ID_E0y0, SMESH_Block::ID_E1y0
290 for ( i = 0; i < 4; ++i ) {
291 int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ i ]);
292 bool ok = LoadIJNodes (myWallNodesMaps[ fIndex ],
293 TopoDS::Face( myBlock.Shape( wallFaceID[ i ] )),
294 TopoDS::Edge( myBlock.Shape( baseEdgeID[ i ] )),
297 myErrorStatus = i + 1;
298 MESSAGE(" Cant LoadIJNodes() from a wall face " << myErrorStatus );
303 // 3.2 find node columns for vertical edges and edge IDs
304 vector<const SMDS_MeshNode*> * verticEdgeNodes[ 4 ];
305 SMESH_Block::TShapeID verticEdgeID [ 4 ];
306 for ( i = 0; i < 4; ++i ) { // 4 first base nodes are nodes on vertices
308 SMESH_Block::TShapeID eID, vID = aSIDs[ i ];
309 ShapeSupportID(false, vID, eID);
310 verticEdgeID[ i ] = eID;
312 StdMeshers_TNode& aTNode = myTNodes[ i ];
313 verticEdgeNodes[ i ] = 0;
314 for ( j = 0; j < 4; ++j ) { // loop on 4 wall faces
315 int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ j ]);
316 StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
317 if ( ijNodes.begin()->second[0] == aTNode.Node() )
318 verticEdgeNodes[ i ] = & ijNodes.begin()->second;
319 else if ( ijNodes.rbegin()->second[0] == aTNode.Node() )
320 verticEdgeNodes[ i ] = & ijNodes.rbegin()->second;
321 if ( verticEdgeNodes[ i ] )
326 // 3.3 set XYZ of vertices, and initialize of the rest
327 SMESHDS_Mesh* aMesh = GetMesh()->GetMeshDS();
328 for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id )
330 if ( SMESH_Block::IsVertexID( id )) {
331 TopoDS_Shape V = myBlock.Shape( id );
332 SMESHDS_SubMesh* sm = aMesh->MeshElements( V );
333 const SMDS_MeshNode* n = sm->GetNodes()->next();
334 myShapeXYZ[ id ].SetCoord( n->X(), n->Y(), n->Z() );
337 myShapeXYZ[ id ].SetCoord( 0., 0., 0. );
341 // 4. Fill the rest repers
344 SMESH_Block::TShapeID aSSID, aBNSSID;
345 StdMeshers_TNode aTN;
347 for (j=0; j<myJSize; ++j)
350 const StdMeshers_TNode& aBN=myTNodes[j];
351 aBNSSID=(SMESH_Block::TShapeID)aBN.ShapeSupportID();
352 iBNID=aBN.BaseNodeID();
353 const gp_XYZ& aBNXYZ=aBN.NormCoord();
354 bool createNode = ( aBNSSID == SMESH_Block::ID_Fxy0 );
356 // set XYZ on horizontal edges and get node columns of faces:
357 // 2 columns for each face, between which a base node is located
358 vector<const SMDS_MeshNode*>* nColumns[8];
359 double ratio[4]; // base node position between columns [0.-1.]
361 for ( k = 0; k < 4; ++k )
362 ratio[ k ] = SetHorizEdgeXYZ (aBNXYZ, wallFaceID[ k ],
363 nColumns[k*2], nColumns[k*2+1]);
365 // XYZ on the bottom and top faces
366 const SMDS_MeshNode* n = aBN.Node();
367 myShapeXYZ[ SMESH_Block::ID_Fxy0 ].SetCoord( n->X(), n->Y(), n->Z() );
368 myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( 0., 0., 0. );
370 // first create or find a top node, then the rest ones in a column
371 for (i=myISize-1; i>0; --i)
374 // set XYZ on vertical edges and faces
375 for ( k = 0; k < 4; ++k ) {
376 const SMDS_MeshNode* n = (*verticEdgeNodes[ k ]) [ i ];
377 myShapeXYZ[ verticEdgeID[ k ] ].SetCoord( n->X(), n->Y(), n->Z() );
379 n = (*nColumns[k*2]) [ i ];
380 gp_XYZ xyz( n->X(), n->Y(), n->Z() );
381 myShapeXYZ[ wallFaceID[ k ]] = ( 1. - ratio[ k ]) * xyz;
382 n = (*nColumns[k*2+1]) [ i ];
383 xyz.SetCoord( n->X(), n->Y(), n->Z() );
384 myShapeXYZ[ wallFaceID[ k ]] += ratio[ k ] * xyz;
387 // fill current node info
390 // -normalized coordinates
394 aZ=(double)i/(double)(myISize-1);
395 aCoords.SetCoord(aX, aY, aZ);
397 // suporting shape ID
398 bIsUpperLayer=(i==(myISize-1));
399 ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID);
401 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
405 aTN.SetShapeSupportID(aSSID);
406 aTN.SetNormCoord(aCoords);
407 aTN.SetBaseNodeID(iBNID);
409 if (aSSID!=SMESH_Block::ID_NONE){
410 // try to find the node
411 const TopoDS_Shape& aS=myBlock.Shape((int)aSSID);
412 FindNodeOnShape(aS, aCoords, i, aTN);
415 // create node and get it id
416 CreateNode (bIsUpperLayer, aCoords, aTN);
418 if ( bIsUpperLayer ) {
419 const SMDS_MeshNode* n = aTN.Node();
420 myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( n->X(), n->Y(), n->Z() );
424 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
434 int iSSID, iBNID, aID;
436 for (i=0; i<myISize; ++i) {
437 printf(" Layer# %d\n", i);
438 for (j=0; j<myJSize; ++j) {
440 const StdMeshers_TNode& aTN=myTNodes[ij];
441 //const StdMeshers_TNode& aTN=aTNodes[ij];
442 const gp_XYZ& aXYZ=aTN.NormCoord();
443 iSSID=aTN.ShapeSupportID();
444 iBNID=aTN.BaseNodeID();
446 const SMDS_MeshNode* aNode=aTN.Node();
451 printf("*** j:%d BNID#%d iSSID:%d ID:%d { %lf %lf %lf }, { %lf %lf %lf }\n",
452 j, iBNID, iSSID, aID, aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aX, aY, aZ);
459 //=======================================================================
460 //function : FindNodeOnShape
462 //=======================================================================
463 void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
464 const gp_XYZ& aParams,
466 StdMeshers_TNode& aTN)
470 double aX, aY, aZ, aD, aTol2, minD;
473 SMESH_Mesh* pMesh=GetMesh();
474 aTol2=myTol3D*myTol3D;
476 SMDS_MeshNode* pNode=NULL;
478 if ( aS.ShapeType() == TopAbs_FACE ||
479 aS.ShapeType() == TopAbs_EDGE )
481 // find a face ID to which aTN belongs to
483 if ( aS.ShapeType() == TopAbs_FACE )
484 faceID = myBlock.ShapeID( aS );
485 else { // edge maybe vertical or top horizontal
486 gp_XYZ aCoord = aParams;
487 if ( aCoord.Z() == 1. )
488 aCoord.SetZ( 0.5 ); // move from top down
490 aCoord.SetX( 0.5 ); // move along X
491 faceID = SMESH_Block::GetShapeIDByParams( aCoord );
493 ASSERT( SMESH_Block::IsFaceID( faceID ));
494 int fIndex = SMESH_Block::ShapeIndex( faceID );
495 StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
496 // look for a base node in ijNodes
497 const SMDS_MeshNode* baseNode = pMesh->GetMeshDS()->FindNode( aTN.BaseNodeID() );
498 StdMeshers_IJNodeMap::const_iterator par_nVec = ijNodes.begin();
499 for ( ; par_nVec != ijNodes.end(); par_nVec++ )
500 if ( par_nVec->second[ 0 ] == baseNode ) {
501 pNode=(SMDS_MeshNode*)par_nVec->second.at( z );
507 myBlock.Point(aParams, aS, aP1);
509 SMDS_NodeIteratorPtr ite=
510 pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
512 const SMDS_MeshNode* aNode = ite->next();
516 aP2.SetCoord(aX, aY, aZ);
517 aD=(double)aP1.SquareDistance(aP2);
518 //printf("** D=%lf ", aD, aTol2);
520 pNode=(SMDS_MeshNode*)aNode;
530 //aTN.SetNode(pNode);
531 //MESSAGE("StdMeshers_Penta_3D::FindNodeOnShape(), can not find the node");
532 //myErrorStatus=11; // can not find the node;
535 //=======================================================================
536 //function : SetHorizEdgeXYZ
538 //=======================================================================
540 double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ& aBaseNodeParams,
542 vector<const SMDS_MeshNode*>*& aCol1,
543 vector<const SMDS_MeshNode*>*& aCol2)
545 // find base and top edges of the face
546 vector< int > edgeVec; // 0-base, 1-top
547 SMESH_Block::GetFaceEdgesIDs( aFaceID, edgeVec );
549 int coord = SMESH_Block::GetCoordIndOnEdge( edgeVec[ 0 ] );
550 double param = aBaseNodeParams.Coord( coord );
551 if ( !myBlock.IsForwadEdge( edgeVec[ 0 ] ))
554 // look for columns around param
555 StdMeshers_IJNodeMap & ijNodes =
556 myWallNodesMaps[ SMESH_Block::ShapeIndex( aFaceID )];
557 StdMeshers_IJNodeMap::iterator par_nVec_1 = ijNodes.begin();
558 while ( par_nVec_1->first < param )
560 StdMeshers_IJNodeMap::iterator par_nVec_2 = par_nVec_1;
563 if ( par_nVec_1 != ijNodes.begin() ) {
565 r = ( param - par_nVec_1->first ) / ( par_nVec_2->first - par_nVec_1->first );
567 aCol1 = & par_nVec_1->second;
568 aCol2 = & par_nVec_2->second;
571 const SMDS_MeshNode* n1 = aCol1->front();
572 const SMDS_MeshNode* n2 = aCol2->front();
573 gp_XYZ xyz1( n1->X(), n1->Y(), n1->Z() ), xyz2( n2->X(), n2->Y(), n2->Z() );
574 myShapeXYZ[ edgeVec[ 0 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
579 xyz1.SetCoord( n1->X(), n1->Y(), n1->Z() );
580 xyz2.SetCoord( n2->X(), n2->Y(), n2->Z() );
581 myShapeXYZ[ edgeVec[ 1 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
586 //=======================================================================
587 //function : MakeVolumeMesh
589 //=======================================================================
590 void StdMeshers_Penta_3D::MakeVolumeMesh()
594 int i, j, ij, ik, i1, i2, aSSID;
596 SMESH_Mesh* pMesh =GetMesh();
597 SMESHDS_Mesh* meshDS=pMesh->GetMeshDS();
599 int shapeID = meshDS->ShapeToIndex( myShape );
601 // 1. Set Node In Volume
603 for (i=1; i<ik; ++i){
604 for (j=0; j<myJSize; ++j){
606 const StdMeshers_TNode& aTN=myTNodes[ij];
607 aSSID=aTN.ShapeSupportID();
608 if (aSSID==SMESH_Block::ID_NONE) {
609 SMDS_MeshNode* aNode=(SMDS_MeshNode*)aTN.Node();
610 meshDS->SetNodeInVolume(aNode, shapeID);
615 // 2. Make pentahedrons
617 vector<const SMDS_MeshNode*> aN;
619 SMDS_ElemIteratorPtr itf, aItNodes;
621 const TopoDS_Face& aFxy0=
622 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
623 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
624 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
626 itf=aSM0->GetElements();
628 const SMDS_MeshElement* pE0=itf->next();
630 int nbFaceNodes = pE0->NbNodes();
631 if ( aN.size() < nbFaceNodes * 2 )
632 aN.resize( nbFaceNodes * 2 );
635 aItNodes=pE0->nodesIterator();
636 while (aItNodes->more()) {
637 const SMDS_MeshElement* pNode=aItNodes->next();
639 aJ[k]=GetIndexOnLayer(aID0);
641 MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh");
649 for (i=0; i<ik; ++i){
652 for(j=0; j<nbFaceNodes; ++j) {
654 const StdMeshers_TNode& aTN1=myTNodes[ij];
655 const SMDS_MeshNode* aN1=aTN1.Node();
659 const StdMeshers_TNode& aTN2=myTNodes[ij];
660 const SMDS_MeshNode* aN2=aTN2.Node();
661 aN[j+nbFaceNodes]=aN2;
663 // check if volume orientation will be ok
665 SMDS_VolumeTool vTool;
666 switch ( nbFaceNodes ) {
668 SMDS_VolumeOfNodes tmpVol (aN[0], aN[1], aN[2],
669 aN[3], aN[4], aN[5]);
670 vTool.Set( &tmpVol );
674 SMDS_VolumeOfNodes tmpVol(aN[0], aN[1], aN[2], aN[3],
675 aN[4], aN[5], aN[6], aN[7]);
676 vTool.Set( &tmpVol );
682 forward = vTool.IsForward();
685 SMDS_MeshVolume* aV = 0;
686 switch ( nbFaceNodes ) {
689 aV = meshDS->AddVolume(aN[0], aN[1], aN[2],
690 aN[3], aN[4], aN[5]);
692 aV = meshDS->AddVolume(aN[0], aN[2], aN[1],
693 aN[3], aN[5], aN[4]);
697 aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3],
698 aN[4], aN[5], aN[6], aN[7]);
700 aV = meshDS->AddVolume(aN[0], aN[3], aN[2], aN[1],
701 aN[4], aN[7], aN[6], aN[5]);
706 meshDS->SetMeshElementOnShape(aV, shapeID);
711 //=======================================================================
712 //function : MakeMeshOnFxy1
714 //=======================================================================
715 void StdMeshers_Penta_3D::MakeMeshOnFxy1()
719 int aID0, aJ, aLevel, ij, aNbNodes, k;
721 SMDS_NodeIteratorPtr itn;
722 SMDS_ElemIteratorPtr itf, aItNodes;
723 SMDSAbs_ElementType aElementType;
725 const TopoDS_Face& aFxy0=
726 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
727 const TopoDS_Face& aFxy1=
728 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
730 SMESH_Mesh* pMesh=GetMesh();
731 SMESHDS_Mesh * meshDS = pMesh->GetMeshDS();
733 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
734 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
736 // set nodes on aFxy1
738 itn=aSM0->GetNodes();
739 aNbNodes=aSM0->NbNodes();
740 //printf("** aNbNodes=%d\n", aNbNodes);
742 const SMDS_MeshNode* aN0=itn->next();
744 aJ=GetIndexOnLayer(aID0);
746 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
750 ij=aLevel*myJSize+aJ;
751 const StdMeshers_TNode& aTN1=myTNodes[ij];
752 SMDS_MeshNode* aN1=(SMDS_MeshNode*)aTN1.Node();
754 meshDS->SetNodeOnFace(aN1, aFxy1);
757 // set elements on aFxy1
758 vector<const SMDS_MeshNode*> aNodes1;
760 itf=aSM0->GetElements();
762 const SMDS_MeshElement * pE0=itf->next();
763 aElementType=pE0->GetType();
764 if (!aElementType==SMDSAbs_Face) {
767 aNbNodes=pE0->NbNodes();
768 // if (aNbNodes!=3) {
771 if ( aNodes1.size() < aNbNodes )
772 aNodes1.resize( aNbNodes );
774 k=aNbNodes-1; // reverse a face
775 aItNodes=pE0->nodesIterator();
776 while (aItNodes->more()) {
777 const SMDS_MeshElement* pNode=aItNodes->next();
779 aJ=GetIndexOnLayer(aID0);
781 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
785 ij=aLevel*myJSize+aJ;
786 const StdMeshers_TNode& aTN1=myTNodes[ij];
787 const SMDS_MeshNode* aN1=aTN1.Node();
791 SMDS_MeshFace * face = 0;
792 switch ( aNbNodes ) {
794 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
797 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
802 meshDS->SetMeshElementOnShape(face, aFxy1);
805 //=======================================================================
806 //function : ClearMeshOnFxy1
808 //=======================================================================
809 void StdMeshers_Penta_3D::ClearMeshOnFxy1()
813 SMESH_subMesh* aSubMesh;
814 SMESH_Mesh* pMesh=GetMesh();
816 const TopoDS_Shape& aFxy1=myBlock.Shape(SMESH_Block::ID_Fxy1);
817 aSubMesh = pMesh->GetSubMeshContaining(aFxy1);
819 aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
822 //=======================================================================
823 //function : GetIndexOnLayer
825 //=======================================================================
826 int StdMeshers_Penta_3D::GetIndexOnLayer(const int aID)
831 StdMeshers_IteratorOfDataMapOfIntegerInteger aMapIt;
833 aMapIt=myConnectingMap.find(aID);
834 if (aMapIt==myConnectingMap.end()) {
841 //=======================================================================
842 //function : MakeConnectingMap
844 //=======================================================================
845 void StdMeshers_Penta_3D::MakeConnectingMap()
849 for (j=0; j<myJSize; ++j) {
850 const StdMeshers_TNode& aBN=myTNodes[j];
851 aBNID=aBN.BaseNodeID();
852 myConnectingMap[aBNID]=j;
855 //=======================================================================
856 //function : CreateNode
858 //=======================================================================
859 void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
860 const gp_XYZ& aParams,
861 StdMeshers_TNode& aTN)
870 SMDS_MeshNode* pNode=NULL;
873 // if (bIsUpperLayer) {
874 // // point on face Fxy1
875 // const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_Fxy1);
876 // myBlock.Point(aParams, aS, aP);
879 // // point inside solid
880 // myBlock.Point(aParams, aP);
884 double u = aParams.X(), v = aParams.Y();
885 double u1 = ( 1. - u ), v1 = ( 1. - v );
886 aP.ChangeCoord() = myShapeXYZ[ SMESH_Block::ID_Ex01 ] * v1;
887 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_Ex11 ] * v;
888 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_E0y1 ] * u1;
889 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_E1y1 ] * u;
891 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V001 ] * u1 * v1;
892 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V101 ] * u * v1;
893 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V011 ] * u1 * v;
894 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V111 ] * u * v;
898 SMESH_Block::ShellPoint( aParams, myShapeXYZ, aP.ChangeCoord() );
901 // iErr=myBlock.ErrorStatus();
903 // myErrorStatus=12; // can not find the node point;
907 aX=aP.X(); aY=aP.Y(); aZ=aP.Z();
909 SMESH_Mesh* pMesh=GetMesh();
910 SMESHDS_Mesh* pMeshDS=pMesh->GetMeshDS();
912 pNode = pMeshDS->AddNode(aX, aY, aZ);
915 //=======================================================================
916 //function : ShapeSupportID
918 //=======================================================================
919 void StdMeshers_Penta_3D::ShapeSupportID(const bool bIsUpperLayer,
920 const SMESH_Block::TShapeID aBNSSID,
921 SMESH_Block::TShapeID& aSSID)
926 case SMESH_Block::ID_V000:
927 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z;
929 case SMESH_Block::ID_V100:
930 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V101 : SMESH_Block::ID_E10z;
932 case SMESH_Block::ID_V110:
933 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V111 : SMESH_Block::ID_E11z;
935 case SMESH_Block::ID_V010:
936 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V011 : SMESH_Block::ID_E01z;
938 case SMESH_Block::ID_Ex00:
939 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex01 : SMESH_Block::ID_Fx0z;
941 case SMESH_Block::ID_Ex10:
942 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex11 : SMESH_Block::ID_Fx1z;
944 case SMESH_Block::ID_E0y0:
945 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E0y1 : SMESH_Block::ID_F0yz;
947 case SMESH_Block::ID_E1y0:
948 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E1y1 : SMESH_Block::ID_F1yz;
950 case SMESH_Block::ID_Fxy0:
951 aSSID=SMESH_Block::ID_NONE;//(bIsUpperLayer) ? Shape_ID_Fxy1 : Shape_ID_NONE;
954 aSSID=SMESH_Block::ID_NONE;
955 myErrorStatus=10; // Can not find supporting shape ID
960 //=======================================================================
961 //function : MakeBlock
963 //=======================================================================
964 void StdMeshers_Penta_3D::MakeBlock()
969 int i, j, iNbEV, iNbE, iErr, iCnt, iNbNodes, iNbF;
971 TopoDS_Vertex aV000, aV001;
973 TopTools_IndexedDataMapOfShapeListOfShape aMVES;
974 TopTools_IndexedMapOfShape aME ,aMEV, aM;
975 TopTools_ListIteratorOfListOfShape aIt;
977 TopExp::MapShapes(myShape, TopAbs_FACE, aM);
979 // 0. Find triangulated face aFTr
980 SMDSAbs_ElementType aElementType;
981 SMESH_Mesh* pMesh=GetMesh();
985 for (i=1; i<=iNbF; ++i) {
986 const TopoDS_Shape& aF=aM(i);
987 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF);
989 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
990 SMDS_ElemIteratorPtr itf=aSM->GetElements();
992 const SMDS_MeshElement * pElement=itf->next();
993 aElementType=pElement->GetType();
994 if (aElementType==SMDSAbs_Face) {
995 iNbNodes=pElement->NbNodes();
1000 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1001 myErrorStatus=5; // more than one face has triangulation
1010 // 1. Vetrices V00, V001;
1012 TopExp::MapShapes(aFTr, TopAbs_EDGE, aME);
1013 TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVES);
1015 // 1.1 Base vertex V000
1018 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1019 myErrorStatus=7; // too few edges are in base face aFTr
1022 const TopoDS_Edge& aE1=TopoDS::Edge(aME(1));
1023 aV000=TopExp::FirstVertex(aE1);
1025 const TopTools_ListOfShape& aLE=aMVES.FindFromKey(aV000);
1026 aIt.Initialize(aLE);
1027 for (; aIt.More(); aIt.Next()) {
1028 const TopoDS_Shape& aEx=aIt.Value();
1031 iNbEV=aMEV.Extent();
1033 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1034 myErrorStatus=7; // too few edges meet in base vertex
1040 for (j=1; j<=iNbEV; ++j) {
1041 const TopoDS_Shape& aEx=aMEV(j);
1042 if (!aME.Contains(aEx)) {
1043 TopoDS_Vertex aV[2];
1045 const TopoDS_Edge& aE=TopoDS::Edge(aEx);
1046 TopExp::Vertices(aE, aV[0], aV[1]);
1047 for (i=0; i<2; ++i) {
1048 if (!aV[i].IsSame(aV000)) {
1058 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1059 myErrorStatus=8; // can not find reper V001
1063 //gp_Pnt aP000, aP001;
1065 //aP000=BRep_Tool::Pnt(TopoDS::Vertex(aV000));
1066 //printf("*** aP000 { %lf, %lf, %lf }\n", aP000.X(), aP000.Y(), aP000.Z());
1067 //aP001=BRep_Tool::Pnt(TopoDS::Vertex(aV001));
1068 //printf("*** aP001 { %lf, %lf, %lf }\n", aP001.X(), aP001.Y(), aP001.Z());
1072 TopExp::MapShapes(myShape, TopAbs_SHELL, aME);
1075 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1076 myErrorStatus=9; // number of shells in source shape !=1
1081 const TopoDS_Shell& aShell=TopoDS::Shell(aME(1));
1082 myBlock.Load(aShell, aV000, aV001);
1083 iErr=myBlock.ErrorStatus();
1085 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1086 myErrorStatus=100; // SMESHBlock: Load operation failed
1090 //=======================================================================
1091 //function : CheckData
1093 //=======================================================================
1094 void StdMeshers_Penta_3D::CheckData()
1099 int iNbEx[]={8, 12, 6};
1101 TopAbs_ShapeEnum aST;
1102 TopAbs_ShapeEnum aSTEx[]={
1103 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE
1105 TopTools_IndexedMapOfShape aM;
1107 if (myShape.IsNull()){
1108 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1109 myErrorStatus=2; // null shape
1113 aST=myShape.ShapeType();
1114 if (!(aST==TopAbs_SOLID || aST==TopAbs_SHELL)) {
1115 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1116 myErrorStatus=3; // not compatible type of shape
1120 for (i=0; i<3; ++i) {
1122 TopExp::MapShapes(myShape, aSTEx[i], aM);
1125 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1126 myErrorStatus=4; // number of subshape is not compatible
1132 //=======================================================================
1133 //function : LoadIJNodes
1134 //purpose : Load nodes bound to theFace into column (vectors) and rows
1136 // The value of theIJNodes map is a vector of ordered nodes so
1137 // that the 0-the one lies on theBaseEdge.
1138 // The key of theIJNodes map is a normalized parameter of each
1139 // 0-the node on theBaseEdge.
1140 //=======================================================================
1142 bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
1143 const TopoDS_Face& theFace,
1144 const TopoDS_Edge& theBaseEdge,
1145 SMESHDS_Mesh* theMesh)
1147 // get vertices of theBaseEdge
1148 TopoDS_Vertex vfb, vlb, vft; // first and last, bottom and top vertices
1149 TopoDS_Edge eFrw = TopoDS::Edge( theBaseEdge.Oriented( TopAbs_FORWARD ));
1150 TopExp::Vertices( eFrw, vfb, vlb );
1152 // find the other edges of theFace and orientation of e1
1153 TopoDS_Edge e1, e2, eTop;
1154 bool rev1, CumOri = false;
1155 TopExp_Explorer exp( theFace, TopAbs_EDGE );
1157 for ( ; exp.More(); exp.Next() )
1159 if ( ++nbEdges > 4 )
1160 return false; // more than 4 edges in theFace
1161 TopoDS_Edge e = TopoDS::Edge( exp.Current() );
1162 if ( theBaseEdge.IsSame( e ))
1164 TopoDS_Vertex vCommon;
1165 if ( !TopExp::CommonVertex( theBaseEdge, e, vCommon ))
1167 else if ( vCommon.IsSame( vfb )) {
1169 vft = TopExp::LastVertex( e1, CumOri );
1170 rev1 = vfb.IsSame( vft );
1172 vft = TopExp::FirstVertex( e1, CumOri );
1178 return false; // lass than 4 edges in theFace
1180 // submeshes corresponding to shapes
1181 SMESHDS_SubMesh* smFace = theMesh->MeshElements( theFace );
1182 SMESHDS_SubMesh* smb = theMesh->MeshElements( theBaseEdge );
1183 SMESHDS_SubMesh* smt = theMesh->MeshElements( eTop );
1184 SMESHDS_SubMesh* sm1 = theMesh->MeshElements( e1 );
1185 SMESHDS_SubMesh* sm2 = theMesh->MeshElements( e2 );
1186 SMESHDS_SubMesh* smVfb = theMesh->MeshElements( vfb );
1187 SMESHDS_SubMesh* smVlb = theMesh->MeshElements( vlb );
1188 SMESHDS_SubMesh* smVft = theMesh->MeshElements( vft );
1189 if (!smFace || !smb || !smt || !sm1 || !sm2 || !smVfb || !smVlb || !smVft ) {
1190 MESSAGE( "NULL submesh " <<smFace<<" "<<smb<<" "<<smt<<" "<<
1191 sm1<<" "<<sm2<<" "<<smVfb<<" "<<smVlb<<" "<<smVft);
1194 if ( smb->NbNodes() != smt->NbNodes() || sm1->NbNodes() != sm2->NbNodes() ) {
1195 MESSAGE(" Diff nb of nodes on opposite edges" );
1198 if (smVfb->NbNodes() != 1 || smVlb->NbNodes() != 1 || smVft->NbNodes() != 1) {
1199 MESSAGE("Empty submesh of vertex");
1202 if ( sm1->NbNodes() * smb->NbNodes() != smFace->NbNodes() ) {
1203 MESSAGE( "Wrong nb face nodes: " <<
1204 sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
1208 int vsize = sm1->NbNodes() + 2;
1209 int hsize = smb->NbNodes() + 2;
1211 // load nodes from theBaseEdge
1213 set<const SMDS_MeshNode*> loadedNodes;
1214 const SMDS_MeshNode* nullNode = 0;
1216 vector<const SMDS_MeshNode*> & nVecf = theIJNodes[ 0.];
1217 nVecf.resize( vsize, nullNode );
1218 loadedNodes.insert( nVecf[ 0 ] = smVfb->GetNodes()->next() );
1220 vector<const SMDS_MeshNode*> & nVecl = theIJNodes[ 1.];
1221 nVecl.resize( vsize, nullNode );
1222 loadedNodes.insert( nVecl[ 0 ] = smVlb->GetNodes()->next() );
1225 BRep_Tool::Range( eFrw, f, l );
1226 double range = l - f;
1227 SMDS_NodeIteratorPtr nIt = smb->GetNodes();
1228 const SMDS_MeshNode* node;
1229 while ( nIt->more() )
1232 const SMDS_EdgePosition* pos =
1233 dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
1234 if ( !pos ) return false;
1235 double u = ( pos->GetUParameter() - f ) / range;
1236 vector<const SMDS_MeshNode*> & nVec = theIJNodes[ u ];
1237 nVec.resize( vsize, nullNode );
1238 loadedNodes.insert( nVec[ 0 ] = node );
1240 if ( theIJNodes.size() != hsize ) {
1241 MESSAGE( "Wrong node positions on theBaseEdge" );
1245 // load nodes from e1
1247 map< double, const SMDS_MeshNode*> sortedNodes; // sort by param on edge
1248 nIt = sm1->GetNodes();
1249 while ( nIt->more() )
1252 const SMDS_EdgePosition* pos =
1253 dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
1254 if ( !pos ) return false;
1255 sortedNodes.insert( make_pair( pos->GetUParameter(), node ));
1257 loadedNodes.insert( nVecf[ vsize - 1 ] = smVft->GetNodes()->next() );
1258 map< double, const SMDS_MeshNode*>::iterator u_n = sortedNodes.begin();
1259 int row = rev1 ? vsize - 1 : 0;
1260 for ( ; u_n != sortedNodes.end(); u_n++ )
1264 loadedNodes.insert( nVecf[ row ] = u_n->second );
1267 // try to load the rest nodes
1269 // get all faces from theFace
1270 set<const SMDS_MeshElement*> allFaces, foundFaces;
1271 SMDS_ElemIteratorPtr eIt = smFace->GetElements();
1272 while ( eIt->more() ) {
1273 const SMDS_MeshElement* e = eIt->next();
1274 if ( e->GetType() == SMDSAbs_Face )
1275 allFaces.insert( e );
1277 // Starting from 2 neighbour nodes on theBaseEdge, look for a face
1278 // the nodes belong to, and between the nodes of the found face,
1279 // look for a not loaded node considering this node to be the next
1280 // in a column of the starting second node. Repeat, starting
1281 // from nodes next to the previous starting nodes in their columns,
1282 // and so on while a face can be found. Then go the the next pair
1283 // of nodes on theBaseEdge.
1284 StdMeshers_IJNodeMap::iterator par_nVec_1 = theIJNodes.begin();
1285 StdMeshers_IJNodeMap::iterator par_nVec_2 = par_nVec_1;
1288 for ( par_nVec_2++; par_nVec_2 != theIJNodes.end(); par_nVec_1++, par_nVec_2++ )
1292 const SMDS_MeshNode* n1 = par_nVec_1->second[ row ];
1293 const SMDS_MeshNode* n2 = par_nVec_2->second[ row ];
1294 const SMDS_MeshElement* face = 0;
1296 // look for a face by 2 nodes
1297 face = SMESH_MeshEditor::FindFaceInSet( n1, n2, allFaces, foundFaces );
1300 int nbFaceNodes = face->NbNodes();
1301 if ( nbFaceNodes > 4 ) {
1302 MESSAGE(" Too many nodes in a face: " << nbFaceNodes );
1305 // look for a not loaded node of the <face>
1307 const SMDS_MeshNode* n3 = 0; // a node defferent from n1 and n2
1308 eIt = face->nodesIterator() ;
1309 while ( !found && eIt->more() ) {
1310 node = static_cast<const SMDS_MeshNode*>( eIt->next() );
1311 found = loadedNodes.insert( node ).second;
1312 if ( !found && node != n1 && node != n2 )
1316 if ( ++row > vsize - 1 ) {
1317 MESSAGE( "Too many nodes in column "<< col <<": "<< row+1);
1320 par_nVec_2->second[ row ] = node;
1321 foundFaces.insert( face );
1323 if ( nbFaceNodes == 4 )
1324 n1 = par_nVec_1->second[ row ];
1326 else if (nbFaceNodes == 3 &&
1327 n3 == par_nVec_1->second[ row ] )
1330 MESSAGE( "Not quad mesh, column "<< col );
1334 } while ( face && n1 && n2 );
1336 if ( row < vsize - 1 ) {
1337 MESSAGE( "Too few nodes in column "<< col <<": "<< row+1);
1338 MESSAGE( "Base node 1: "<< par_nVec_1->second[0]);
1339 MESSAGE( "Base node 2: "<< par_nVec_2->second[0]);
1340 MESSAGE( "Current node 1: "<< n1);
1341 MESSAGE( "Current node 2: "<< n2);
1342 MESSAGE( "first base node: "<< theIJNodes.begin()->second[0]);
1343 MESSAGE( "last base node: "<< theIJNodes.rbegin()->second[0]);
1346 } // loop on columns
1351 //////////////////////////////////////////////////////////////////////////
1353 // StdMeshers_SMESHBlock
1355 //////////////////////////////////////////////////////////////////////////
1357 //=======================================================================
1358 //function : StdMeshers_SMESHBlock
1360 //=======================================================================
1361 StdMeshers_SMESHBlock::StdMeshers_SMESHBlock()
1364 myIsEdgeForward.resize( SMESH_Block::NbEdges(), -1 );
1367 //=======================================================================
1368 //function : IsForwadEdge
1370 //=======================================================================
1372 bool StdMeshers_SMESHBlock::IsForwadEdge(const int theEdgeID)
1374 int index = myTBlock.ShapeIndex( theEdgeID );
1375 if ( !myTBlock.IsEdgeID( theEdgeID ))
1378 if ( myIsEdgeForward[ index ] < 0 )
1379 myIsEdgeForward[ index ] =
1380 myTBlock.IsForwardEdge( TopoDS::Edge( Shape( theEdgeID )), myShapeIDMap );
1382 return myIsEdgeForward[ index ];
1385 //=======================================================================
1386 //function : ErrorStatus
1388 //=======================================================================
1389 int StdMeshers_SMESHBlock::ErrorStatus() const
1391 return myErrorStatus;
1393 //=======================================================================
1396 //=======================================================================
1397 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell)
1400 TopoDS_Vertex aV000, aV001;
1402 Load(theShell, aV000, aV001);
1404 //=======================================================================
1407 //=======================================================================
1408 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell,
1409 const TopoDS_Vertex& theV000,
1410 const TopoDS_Vertex& theV001)
1418 myShapeIDMap.Clear();
1419 bOk=myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
1425 //=======================================================================
1426 //function : ComputeParameters
1428 //=======================================================================
1429 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
1432 ComputeParameters(thePnt, myShell, theXYZ);
1434 //=======================================================================
1435 //function : ComputeParameters
1437 //=======================================================================
1438 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
1439 const TopoDS_Shape& theShape,
1447 aID=ShapeID(theShape);
1448 if (myErrorStatus) {
1451 bOk=myTBlock.ComputeParameters(thePnt, theXYZ, aID);
1453 myErrorStatus=4; // problems with computation Parameters
1458 //=======================================================================
1459 //function : ComputeParameters
1461 //=======================================================================
1463 void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
1464 const TopoDS_Shape& theShape,
1472 aID=ShapeID(theShape);
1473 if (myErrorStatus) {
1476 if ( SMESH_Block::IsEdgeID( aID ))
1477 bOk=myTBlock.EdgeParameters( aID, theU, theXYZ );
1479 myErrorStatus=4; // problems with computation Parameters
1484 //=======================================================================
1487 //=======================================================================
1488 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1493 Point(theParams, aS, aP3D);
1495 //=======================================================================
1498 //=======================================================================
1499 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1500 const TopoDS_Shape& theShape,
1507 gp_XYZ aXYZ(99.,99.,99.);
1510 if (theShape.IsNull()) {
1511 bOk=myTBlock.ShellPoint(theParams, aXYZ);
1515 aID=ShapeID(theShape);
1516 if (myErrorStatus) {
1520 if (SMESH_Block::IsVertexID(aID)) {
1521 bOk=myTBlock.VertexPoint(aID, aXYZ);
1523 else if (SMESH_Block::IsEdgeID(aID)) {
1524 bOk=myTBlock.EdgePoint(aID, theParams, aXYZ);
1527 else if (SMESH_Block::IsFaceID(aID)) {
1528 bOk=myTBlock.FacePoint(aID, theParams, aXYZ);
1532 myErrorStatus=4; // problems with point computation
1537 //=======================================================================
1538 //function : ShapeID
1540 //=======================================================================
1541 int StdMeshers_SMESHBlock::ShapeID(const TopoDS_Shape& theShape)
1546 TopoDS_Shape aSF, aSR;
1549 aSF.Orientation(TopAbs_FORWARD);
1551 aSR.Orientation(TopAbs_REVERSED);
1553 if (myShapeIDMap.Contains(aSF)) {
1554 aID=myShapeIDMap.FindIndex(aSF);
1557 if (myShapeIDMap.Contains(aSR)) {
1558 aID=myShapeIDMap.FindIndex(aSR);
1561 myErrorStatus=2; // unknown shape;
1564 //=======================================================================
1567 //=======================================================================
1568 const TopoDS_Shape& StdMeshers_SMESHBlock::Shape(const int theID)
1574 aNb=myShapeIDMap.Extent();
1575 if (theID<1 || theID>aNb) {
1576 myErrorStatus=3; // ID is out of range
1577 return myEmptyShape;
1580 const TopoDS_Shape& aS=myShapeIDMap.FindKey(theID);