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 //=======================================================================
65 // StdMeshers_Penta_3D
67 //=======================================================================
68 //function : StdMeshers_Penta_3D
70 //=======================================================================
71 StdMeshers_Penta_3D::StdMeshers_Penta_3D()
75 myWallNodesMaps.resize( SMESH_Block::NbFaces() );
76 myShapeXYZ.resize( SMESH_Block::NbSubShapes() );
78 //=======================================================================
81 //=======================================================================
82 bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
83 const TopoDS_Shape& aShape)
85 MESSAGE("StdMeshers_Penta_3D::Compute()");
125 //=======================================================================
126 //function : MakeNodes
128 //=======================================================================
129 void StdMeshers_Penta_3D::MakeNodes()
134 int i, j, k, ij, iNbN, aNodeID, aSize, iErr;
136 SMESH_Block::TShapeID aSID, aSIDs[aNbSIDs]={
137 SMESH_Block::ID_V000, SMESH_Block::ID_V100,
138 SMESH_Block::ID_V110, SMESH_Block::ID_V010,
139 SMESH_Block::ID_Ex00, SMESH_Block::ID_E1y0,
140 SMESH_Block::ID_Ex10, SMESH_Block::ID_E0y0,
144 SMESH_Mesh* pMesh=GetMesh();
146 // 1. Define the sizes of mesh
148 // 1.1 Horizontal size
150 for (i=0; i<aNbSIDs; ++i) {
151 const TopoDS_Shape& aS=myBlock.Shape(aSIDs[i]);
152 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
154 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
158 //printf("*** Horizontal: number of nodes summary=%d\n", myJSize);
163 const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_E00z);
164 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
166 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
170 //printf("*** Vertical: number of nodes on edges and vertices=%d\n", myISize);
172 aSize=myISize*myJSize;
173 myTNodes.resize(aSize);
175 StdMeshers_TNode aTNode;
179 // 2. Fill the repers on base face (Z=0)
182 for (k=0; k<aNbSIDs; ++k) {
184 const TopoDS_Shape& aS=myBlock.Shape(aSID);
185 SMDS_NodeIteratorPtr ite =pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
187 const SMDS_MeshNode* aNode = ite->next();
188 aNodeID=aNode->GetID();
190 aTNode.SetNode(aNode);
191 aTNode.SetShapeSupportID(aSID);
192 aTNode.SetBaseNodeID(aNodeID);
194 if ( SMESH_Block::IsEdgeID (aSID))
196 const SMDS_EdgePosition* epos =
197 static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
198 myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords );
204 aP3D.SetCoord(aX, aY, aZ);
205 myBlock.ComputeParameters(aP3D, aS, aCoords);
207 iErr=myBlock.ErrorStatus();
209 MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
210 "SMESHBlock: ComputeParameters operation failed");
211 myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
214 aTNode.SetNormCoord(aCoords);
223 int iShapeSupportID, iBaseNodeID;
225 //printf("\n\n*** Base Face\n");
227 for (j=0; j<myJSize; ++j) {
229 const StdMeshers_TNode& aTNode=myTNodes[ij];
230 iShapeSupportID=aTNode.ShapeSupportID();
231 iBaseNodeID=aTNode.BaseNodeID();
232 const gp_XYZ& aXYZ=aTNode.NormCoord();
233 printf("*** j:%d bID#%d iSS:%d { %lf %lf %lf }\n",
234 j, iBaseNodeID, iShapeSupportID, aXYZ.X(), aXYZ.Y(), aXYZ.Z());
241 // 3. Finding of Z-layers
242 // vector<double> aZL(myISize);
243 // vector<double>::iterator aItZL1, aItZL2 ;
245 // const TopoDS_Shape& aE00z=myBlock.Shape(SMESH_Block::ID_E00z);
246 // SMDS_NodeIteratorPtr aItaE00z =
247 // pMesh->GetSubMeshContaining(aE00z)->GetSubMeshDS()->GetNodes();
251 // while (aItaE00z->more()) {
252 // const SMDS_MeshNode* aNode=aItaE00z->next();
253 // const SMDS_EdgePosition* epos =
254 // static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
255 // myBlock.ComputeParameters( epos->GetUParameter(), aE00z, aCoords );
256 // iErr=myBlock.ErrorStatus();
258 // MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
259 // "SMESHBlock: ComputeParameters operation failed");
260 // myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
263 // aZL[i]=aCoords.Z();
268 // aItZL1=aZL.begin();
271 // // Sorting the layers
272 // sort(aItZL1, aItZL2);
275 printf("** \n\n Layers begin\n");
276 for(i=0, aItZL=aItZL1; aItZL!=aItZL2; ++aItZL, ++i) {
277 printf(" #%d : %lf\n", i, *aItZL);
279 printf("** Layers end\n");
285 // 3.1 Fill maps of wall nodes
286 SMESH_Block::TShapeID wallFaceID[4] = {
287 SMESH_Block::ID_Fx0z, SMESH_Block::ID_Fx1z,
288 SMESH_Block::ID_F0yz, SMESH_Block::ID_F1yz
290 SMESH_Block::TShapeID baseEdgeID[4] = {
291 SMESH_Block::ID_Ex00, SMESH_Block::ID_Ex10,
292 SMESH_Block::ID_E0y0, SMESH_Block::ID_E1y0
294 for ( i = 0; i < 4; ++i ) {
295 int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ i ]);
296 bool ok = LoadIJNodes (myWallNodesMaps[ fIndex ],
297 TopoDS::Face( myBlock.Shape( wallFaceID[ i ] )),
298 TopoDS::Edge( myBlock.Shape( baseEdgeID[ i ] )),
301 myErrorStatus = i + 1;
302 MESSAGE(" Cant LoadIJNodes() from a wall face " << myErrorStatus );
307 // 3.2 find node columns for vertical edges and edge IDs
308 vector<const SMDS_MeshNode*> * verticEdgeNodes[ 4 ];
309 SMESH_Block::TShapeID verticEdgeID [ 4 ];
310 for ( i = 0; i < 4; ++i ) { // 4 first base nodes are nodes on vertices
312 SMESH_Block::TShapeID eID, vID = aSIDs[ i ];
313 ShapeSupportID(false, vID, eID);
314 verticEdgeID[ i ] = eID;
316 StdMeshers_TNode& aTNode = myTNodes[ i ];
317 verticEdgeNodes[ i ] = 0;
318 for ( j = 0; j < 4; ++j ) { // loop on 4 wall faces
319 int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ j ]);
320 StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
321 if ( ijNodes.begin()->second[0] == aTNode.Node() )
322 verticEdgeNodes[ i ] = & ijNodes.begin()->second;
323 else if ( ijNodes.rbegin()->second[0] == aTNode.Node() )
324 verticEdgeNodes[ i ] = & ijNodes.rbegin()->second;
325 if ( verticEdgeNodes[ i ] )
330 // 3.3 set XYZ of vertices, and initialize of the rest
331 SMESHDS_Mesh* aMesh = GetMesh()->GetMeshDS();
332 for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id )
334 if ( SMESH_Block::IsVertexID( id )) {
335 TopoDS_Shape V = myBlock.Shape( id );
336 SMESHDS_SubMesh* sm = aMesh->MeshElements( V );
337 const SMDS_MeshNode* n = sm->GetNodes()->next();
338 myShapeXYZ[ id ].SetCoord( n->X(), n->Y(), n->Z() );
341 myShapeXYZ[ id ].SetCoord( 0., 0., 0. );
345 // 4. Fill the rest repers
348 SMESH_Block::TShapeID aSSID, aBNSSID;
349 StdMeshers_TNode aTN;
351 for (j=0; j<myJSize; ++j)
354 const StdMeshers_TNode& aBN=myTNodes[j];
355 aBNSSID=(SMESH_Block::TShapeID)aBN.ShapeSupportID();
356 iBNID=aBN.BaseNodeID();
357 const gp_XYZ& aBNXYZ=aBN.NormCoord();
358 bool createNode = ( aBNSSID == SMESH_Block::ID_Fxy0 );
360 // set XYZ on horizontal edges and get node columns of faces:
361 // 2 columns for each face, between which a base node is located
362 vector<const SMDS_MeshNode*>* nColumns[8];
363 double ratio[4]; // base node position between columns [0.-1.]
365 for ( k = 0; k < 4; ++k )
366 ratio[ k ] = SetHorizEdgeXYZ (aBNXYZ, wallFaceID[ k ],
367 nColumns[k*2], nColumns[k*2+1]);
369 // XYZ on the bottom and top faces
370 const SMDS_MeshNode* n = aBN.Node();
371 myShapeXYZ[ SMESH_Block::ID_Fxy0 ].SetCoord( n->X(), n->Y(), n->Z() );
372 myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( 0., 0., 0. );
374 // first create or find a top node, then the rest ones in a column
375 for (i=myISize-1; i>0; --i)
378 // set XYZ on vertical edges and faces
379 for ( k = 0; k < 4; ++k ) {
380 const SMDS_MeshNode* n = (*verticEdgeNodes[ k ]) [ i ];
381 myShapeXYZ[ verticEdgeID[ k ] ].SetCoord( n->X(), n->Y(), n->Z() );
383 n = (*nColumns[k*2]) [ i ];
384 gp_XYZ xyz( n->X(), n->Y(), n->Z() );
385 myShapeXYZ[ wallFaceID[ k ]] = ( 1. - ratio[ k ]) * xyz;
386 n = (*nColumns[k*2+1]) [ i ];
387 xyz.SetCoord( n->X(), n->Y(), n->Z() );
388 myShapeXYZ[ wallFaceID[ k ]] += ratio[ k ] * xyz;
391 // fill current node info
394 // -normalized coordinates
398 aZ=(double)i/(double)(myISize-1);
399 aCoords.SetCoord(aX, aY, aZ);
401 // suporting shape ID
402 bIsUpperLayer=(i==(myISize-1));
403 ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID);
405 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
409 aTN.SetShapeSupportID(aSSID);
410 aTN.SetNormCoord(aCoords);
411 aTN.SetBaseNodeID(iBNID);
413 if (aSSID!=SMESH_Block::ID_NONE){
414 // try to find the node
415 const TopoDS_Shape& aS=myBlock.Shape((int)aSSID);
416 FindNodeOnShape(aS, aCoords, i, aTN);
419 // create node and get it id
420 CreateNode (bIsUpperLayer, aCoords, aTN);
422 if ( bIsUpperLayer ) {
423 const SMDS_MeshNode* n = aTN.Node();
424 myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( n->X(), n->Y(), n->Z() );
428 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
438 int iSSID, iBNID, aID;
440 for (i=0; i<myISize; ++i) {
441 printf(" Layer# %d\n", i);
442 for (j=0; j<myJSize; ++j) {
444 const StdMeshers_TNode& aTN=myTNodes[ij];
445 //const StdMeshers_TNode& aTN=aTNodes[ij];
446 const gp_XYZ& aXYZ=aTN.NormCoord();
447 iSSID=aTN.ShapeSupportID();
448 iBNID=aTN.BaseNodeID();
450 const SMDS_MeshNode* aNode=aTN.Node();
455 printf("*** j:%d BNID#%d iSSID:%d ID:%d { %lf %lf %lf }, { %lf %lf %lf }\n",
456 j, iBNID, iSSID, aID, aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aX, aY, aZ);
463 //=======================================================================
464 //function : FindNodeOnShape
466 //=======================================================================
467 void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
468 const gp_XYZ& aParams,
470 StdMeshers_TNode& aTN)
474 double aX, aY, aZ, aD, aTol2, minD;
477 SMESH_Mesh* pMesh=GetMesh();
478 aTol2=myTol3D*myTol3D;
480 SMDS_MeshNode* pNode=NULL;
482 if ( aS.ShapeType() == TopAbs_FACE ||
483 aS.ShapeType() == TopAbs_EDGE )
485 // find a face ID to which aTN belongs to
487 if ( aS.ShapeType() == TopAbs_FACE )
488 faceID = myBlock.ShapeID( aS );
489 else { // edge maybe vertical or top horizontal
490 gp_XYZ aCoord = aParams;
491 if ( aCoord.Z() == 1. )
492 aCoord.SetZ( 0.5 ); // move from top down
494 aCoord.SetX( 0.5 ); // move along X
495 faceID = SMESH_Block::GetShapeIDByParams( aCoord );
497 ASSERT( SMESH_Block::IsFaceID( faceID ));
498 int fIndex = SMESH_Block::ShapeIndex( faceID );
499 StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
500 // look for a base node in ijNodes
501 const SMDS_MeshNode* baseNode = pMesh->GetMeshDS()->FindNode( aTN.BaseNodeID() );
502 StdMeshers_IJNodeMap::const_iterator par_nVec = ijNodes.begin();
503 for ( ; par_nVec != ijNodes.end(); par_nVec++ )
504 if ( par_nVec->second[ 0 ] == baseNode ) {
505 pNode=(SMDS_MeshNode*)par_nVec->second.at( z );
511 myBlock.Point(aParams, aS, aP1);
513 SMDS_NodeIteratorPtr ite=
514 pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
516 const SMDS_MeshNode* aNode = ite->next();
520 aP2.SetCoord(aX, aY, aZ);
521 aD=(double)aP1.SquareDistance(aP2);
522 //printf("** D=%lf ", aD, aTol2);
524 pNode=(SMDS_MeshNode*)aNode;
534 //aTN.SetNode(pNode);
535 //MESSAGE("StdMeshers_Penta_3D::FindNodeOnShape(), can not find the node");
536 //myErrorStatus=11; // can not find the node;
539 //=======================================================================
540 //function : SetHorizEdgeXYZ
542 //=======================================================================
544 double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ& aBaseNodeParams,
546 vector<const SMDS_MeshNode*>*& aCol1,
547 vector<const SMDS_MeshNode*>*& aCol2)
549 // find base and top edges of the face
550 vector< int > edgeVec; // 0-base, 1-top
551 SMESH_Block::GetFaceEdgesIDs( aFaceID, edgeVec );
553 int coord = SMESH_Block::GetCoordIndOnEdge( edgeVec[ 0 ] );
554 double param = aBaseNodeParams.Coord( coord );
555 if ( !myBlock.IsForwadEdge( edgeVec[ 0 ] ))
558 // look for columns around param
559 StdMeshers_IJNodeMap & ijNodes =
560 myWallNodesMaps[ SMESH_Block::ShapeIndex( aFaceID )];
561 StdMeshers_IJNodeMap::iterator par_nVec_1 = ijNodes.begin();
562 while ( par_nVec_1->first < param )
564 StdMeshers_IJNodeMap::iterator par_nVec_2 = par_nVec_1;
567 if ( par_nVec_1 != ijNodes.begin() ) {
569 r = ( param - par_nVec_1->first ) / ( par_nVec_2->first - par_nVec_1->first );
571 aCol1 = & par_nVec_1->second;
572 aCol2 = & par_nVec_2->second;
575 const SMDS_MeshNode* n1 = aCol1->front();
576 const SMDS_MeshNode* n2 = aCol2->front();
577 gp_XYZ xyz1( n1->X(), n1->Y(), n1->Z() ), xyz2( n2->X(), n2->Y(), n2->Z() );
578 myShapeXYZ[ edgeVec[ 0 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
583 xyz1.SetCoord( n1->X(), n1->Y(), n1->Z() );
584 xyz2.SetCoord( n2->X(), n2->Y(), n2->Z() );
585 myShapeXYZ[ edgeVec[ 1 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
590 //=======================================================================
591 //function : MakeVolumeMesh
593 //=======================================================================
594 void StdMeshers_Penta_3D::MakeVolumeMesh()
598 int i, j, ij, ik, i1, i2, aSSID;
601 TopExp_Explorer aExp;
603 SMESH_Mesh* pMesh =GetMesh();
604 SMESHDS_Mesh* meshDS=pMesh->GetMeshDS();
606 aExp.Init(myShape, TopAbs_SHELL);
607 for (; aExp.More(); aExp.Next()){
608 aShell=TopoDS::Shell(aExp.Current());
612 // 1. Set Node In Volume
614 for (i=1; i<ik; ++i){
615 for (j=0; j<myJSize; ++j){
617 const StdMeshers_TNode& aTN=myTNodes[ij];
618 aSSID=aTN.ShapeSupportID();
619 if (aSSID==SMESH_Block::ID_NONE) {
620 SMDS_MeshNode* aNode=(SMDS_MeshNode*)aTN.Node();
621 meshDS->SetNodeInVolume(aNode, aShell);
626 // 2. Make pentahedrons
628 vector<const SMDS_MeshNode*> aN;
630 SMDS_ElemIteratorPtr itf, aItNodes;
632 const TopoDS_Face& aFxy0=
633 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
634 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
635 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
637 itf=aSM0->GetElements();
639 const SMDS_MeshElement* pE0=itf->next();
641 int nbFaceNodes = pE0->NbNodes();
642 if ( aN.size() < nbFaceNodes * 2 )
643 aN.resize( nbFaceNodes * 2 );
646 aItNodes=pE0->nodesIterator();
647 while (aItNodes->more()) {
648 const SMDS_MeshElement* pNode=aItNodes->next();
650 aJ[k]=GetIndexOnLayer(aID0);
652 MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh");
660 for (i=0; i<ik; ++i){
663 for(j=0; j<nbFaceNodes; ++j) {
665 const StdMeshers_TNode& aTN1=myTNodes[ij];
666 const SMDS_MeshNode* aN1=aTN1.Node();
670 const StdMeshers_TNode& aTN2=myTNodes[ij];
671 const SMDS_MeshNode* aN2=aTN2.Node();
672 aN[j+nbFaceNodes]=aN2;
674 // check if volume orientation will be ok
676 SMDS_VolumeTool vTool;
677 switch ( nbFaceNodes ) {
679 SMDS_VolumeOfNodes tmpVol (aN[0], aN[1], aN[2],
680 aN[3], aN[4], aN[5]);
681 vTool.Set( &tmpVol );
685 SMDS_VolumeOfNodes tmpVol(aN[0], aN[1], aN[2], aN[3],
686 aN[4], aN[5], aN[6], aN[7]);
687 vTool.Set( &tmpVol );
693 forward = vTool.IsForward();
696 SMDS_MeshVolume* aV = 0;
697 switch ( nbFaceNodes ) {
700 aV = meshDS->AddVolume(aN[0], aN[1], aN[2],
701 aN[3], aN[4], aN[5]);
703 aV = meshDS->AddVolume(aN[0], aN[2], aN[1],
704 aN[3], aN[5], aN[4]);
708 aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3],
709 aN[4], aN[5], aN[6], aN[7]);
711 aV = meshDS->AddVolume(aN[0], aN[3], aN[2], aN[1],
712 aN[4], aN[7], aN[6], aN[5]);
717 meshDS->SetMeshElementOnShape(aV, aShell);
722 //=======================================================================
723 //function : MakeMeshOnFxy1
725 //=======================================================================
726 void StdMeshers_Penta_3D::MakeMeshOnFxy1()
730 int aID0, aJ, aLevel, ij, aNbNodes, k;
732 SMDS_NodeIteratorPtr itn;
733 SMDS_ElemIteratorPtr itf, aItNodes;
734 SMDSAbs_ElementType aElementType;
736 const TopoDS_Face& aFxy0=
737 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
738 const TopoDS_Face& aFxy1=
739 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
741 SMESH_Mesh* pMesh=GetMesh();
742 SMESHDS_Mesh * meshDS = pMesh->GetMeshDS();
744 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
745 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
747 // set nodes on aFxy1
749 itn=aSM0->GetNodes();
750 aNbNodes=aSM0->NbNodes();
751 //printf("** aNbNodes=%d\n", aNbNodes);
753 const SMDS_MeshNode* aN0=itn->next();
755 aJ=GetIndexOnLayer(aID0);
757 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
761 ij=aLevel*myJSize+aJ;
762 const StdMeshers_TNode& aTN1=myTNodes[ij];
763 SMDS_MeshNode* aN1=(SMDS_MeshNode*)aTN1.Node();
765 meshDS->SetNodeOnFace(aN1, aFxy1);
768 // set elements on aFxy1
769 vector<const SMDS_MeshNode*> aNodes1;
771 itf=aSM0->GetElements();
773 const SMDS_MeshElement * pE0=itf->next();
774 aElementType=pE0->GetType();
775 if (!aElementType==SMDSAbs_Face) {
778 aNbNodes=pE0->NbNodes();
779 // if (aNbNodes!=3) {
782 if ( aNodes1.size() < aNbNodes )
783 aNodes1.resize( aNbNodes );
785 k=aNbNodes-1; // reverse a face
786 aItNodes=pE0->nodesIterator();
787 while (aItNodes->more()) {
788 const SMDS_MeshElement* pNode=aItNodes->next();
790 aJ=GetIndexOnLayer(aID0);
792 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
796 ij=aLevel*myJSize+aJ;
797 const StdMeshers_TNode& aTN1=myTNodes[ij];
798 const SMDS_MeshNode* aN1=aTN1.Node();
802 SMDS_MeshFace * face = 0;
803 switch ( aNbNodes ) {
805 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
808 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
813 meshDS->SetMeshElementOnShape(face, aFxy1);
816 //=======================================================================
817 //function : ClearMeshOnFxy1
819 //=======================================================================
820 void StdMeshers_Penta_3D::ClearMeshOnFxy1()
824 SMESH_subMesh* aSubMesh;
825 SMESH_Mesh* pMesh=GetMesh();
827 const TopoDS_Shape& aFxy1=myBlock.Shape(SMESH_Block::ID_Fxy1);
828 aSubMesh = pMesh->GetSubMeshContaining(aFxy1);
830 aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
833 //=======================================================================
834 //function : GetIndexOnLayer
836 //=======================================================================
837 int StdMeshers_Penta_3D::GetIndexOnLayer(const int aID)
842 StdMeshers_IteratorOfDataMapOfIntegerInteger aMapIt;
844 aMapIt=myConnectingMap.find(aID);
845 if (aMapIt==myConnectingMap.end()) {
852 //=======================================================================
853 //function : MakeConnectingMap
855 //=======================================================================
856 void StdMeshers_Penta_3D::MakeConnectingMap()
860 for (j=0; j<myJSize; ++j) {
861 const StdMeshers_TNode& aBN=myTNodes[j];
862 aBNID=aBN.BaseNodeID();
863 myConnectingMap[aBNID]=j;
866 //=======================================================================
867 //function : CreateNode
869 //=======================================================================
870 void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
871 const gp_XYZ& aParams,
872 StdMeshers_TNode& aTN)
881 SMDS_MeshNode* pNode=NULL;
884 // if (bIsUpperLayer) {
885 // // point on face Fxy1
886 // const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_Fxy1);
887 // myBlock.Point(aParams, aS, aP);
890 // // point inside solid
891 // myBlock.Point(aParams, aP);
895 double u = aParams.X(), v = aParams.Y();
896 double u1 = ( 1. - u ), v1 = ( 1. - v );
897 aP.ChangeCoord() = myShapeXYZ[ SMESH_Block::ID_Ex01 ] * v1;
898 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_Ex11 ] * v;
899 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_E0y1 ] * u1;
900 aP.ChangeCoord() += myShapeXYZ[ SMESH_Block::ID_E1y1 ] * u;
902 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V001 ] * u1 * v1;
903 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V101 ] * u * v1;
904 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V011 ] * u1 * v;
905 aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V111 ] * u * v;
909 SMESH_Block::ShellPoint( aParams, myShapeXYZ, aP.ChangeCoord() );
912 // iErr=myBlock.ErrorStatus();
914 // myErrorStatus=12; // can not find the node point;
918 aX=aP.X(); aY=aP.Y(); aZ=aP.Z();
920 SMESH_Mesh* pMesh=GetMesh();
921 SMESHDS_Mesh* pMeshDS=pMesh->GetMeshDS();
923 pNode = pMeshDS->AddNode(aX, aY, aZ);
926 //=======================================================================
927 //function : ShapeSupportID
929 //=======================================================================
930 void StdMeshers_Penta_3D::ShapeSupportID(const bool bIsUpperLayer,
931 const SMESH_Block::TShapeID aBNSSID,
932 SMESH_Block::TShapeID& aSSID)
937 case SMESH_Block::ID_V000:
938 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z;
940 case SMESH_Block::ID_V100:
941 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V101 : SMESH_Block::ID_E10z;
943 case SMESH_Block::ID_V110:
944 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V111 : SMESH_Block::ID_E11z;
946 case SMESH_Block::ID_V010:
947 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V011 : SMESH_Block::ID_E01z;
949 case SMESH_Block::ID_Ex00:
950 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex01 : SMESH_Block::ID_Fx0z;
952 case SMESH_Block::ID_Ex10:
953 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex11 : SMESH_Block::ID_Fx1z;
955 case SMESH_Block::ID_E0y0:
956 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E0y1 : SMESH_Block::ID_F0yz;
958 case SMESH_Block::ID_E1y0:
959 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E1y1 : SMESH_Block::ID_F1yz;
961 case SMESH_Block::ID_Fxy0:
962 aSSID=SMESH_Block::ID_NONE;//(bIsUpperLayer) ? Shape_ID_Fxy1 : Shape_ID_NONE;
965 aSSID=SMESH_Block::ID_NONE;
966 myErrorStatus=10; // Can not find supporting shape ID
971 //=======================================================================
972 //function : MakeBlock
974 //=======================================================================
975 void StdMeshers_Penta_3D::MakeBlock()
980 int i, j, iNbEV, iNbE, iErr, iCnt, iNbNodes, iNbF;
982 TopoDS_Vertex aV000, aV001;
984 TopTools_IndexedDataMapOfShapeListOfShape aMVES;
985 TopTools_IndexedMapOfShape aME ,aMEV, aM;
986 TopTools_ListIteratorOfListOfShape aIt;
988 TopExp::MapShapes(myShape, TopAbs_FACE, aM);
990 // 0. Find triangulated face aFTr
991 SMDSAbs_ElementType aElementType;
992 SMESH_Mesh* pMesh=GetMesh();
996 for (i=1; i<=iNbF; ++i) {
997 const TopoDS_Shape& aF=aM(i);
998 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF);
1000 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
1001 SMDS_ElemIteratorPtr itf=aSM->GetElements();
1002 while(itf->more()) {
1003 const SMDS_MeshElement * pElement=itf->next();
1004 aElementType=pElement->GetType();
1005 if (aElementType==SMDSAbs_Face) {
1006 iNbNodes=pElement->NbNodes();
1011 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1012 myErrorStatus=5; // more than one face has triangulation
1021 // 1. Vetrices V00, V001;
1023 TopExp::MapShapes(aFTr, TopAbs_EDGE, aME);
1024 TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVES);
1026 // 1.1 Base vertex V000
1029 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1030 myErrorStatus=7; // too few edges are in base face aFTr
1033 const TopoDS_Edge& aE1=TopoDS::Edge(aME(1));
1034 aV000=TopExp::FirstVertex(aE1);
1036 const TopTools_ListOfShape& aLE=aMVES.FindFromKey(aV000);
1037 aIt.Initialize(aLE);
1038 for (; aIt.More(); aIt.Next()) {
1039 const TopoDS_Shape& aEx=aIt.Value();
1042 iNbEV=aMEV.Extent();
1044 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1045 myErrorStatus=7; // too few edges meet in base vertex
1051 for (j=1; j<=iNbEV; ++j) {
1052 const TopoDS_Shape& aEx=aMEV(j);
1053 if (!aME.Contains(aEx)) {
1054 TopoDS_Vertex aV[2];
1056 const TopoDS_Edge& aE=TopoDS::Edge(aEx);
1057 TopExp::Vertices(aE, aV[0], aV[1]);
1058 for (i=0; i<2; ++i) {
1059 if (!aV[i].IsSame(aV000)) {
1069 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1070 myErrorStatus=8; // can not find reper V001
1074 //gp_Pnt aP000, aP001;
1076 //aP000=BRep_Tool::Pnt(TopoDS::Vertex(aV000));
1077 //printf("*** aP000 { %lf, %lf, %lf }\n", aP000.X(), aP000.Y(), aP000.Z());
1078 //aP001=BRep_Tool::Pnt(TopoDS::Vertex(aV001));
1079 //printf("*** aP001 { %lf, %lf, %lf }\n", aP001.X(), aP001.Y(), aP001.Z());
1083 TopExp::MapShapes(myShape, TopAbs_SHELL, aME);
1086 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1087 myErrorStatus=9; // number of shells in source shape !=1
1092 const TopoDS_Shell& aShell=TopoDS::Shell(aME(1));
1093 myBlock.Load(aShell, aV000, aV001);
1094 iErr=myBlock.ErrorStatus();
1096 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
1097 myErrorStatus=100; // SMESHBlock: Load operation failed
1101 //=======================================================================
1102 //function : CheckData
1104 //=======================================================================
1105 void StdMeshers_Penta_3D::CheckData()
1110 int iNbEx[]={8, 12, 6};
1112 TopAbs_ShapeEnum aST;
1113 TopAbs_ShapeEnum aSTEx[]={
1114 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE
1116 TopTools_IndexedMapOfShape aM;
1118 if (myShape.IsNull()){
1119 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1120 myErrorStatus=2; // null shape
1124 aST=myShape.ShapeType();
1125 if (!(aST==TopAbs_SOLID || aST==TopAbs_SHELL)) {
1126 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1127 myErrorStatus=3; // not compatible type of shape
1131 for (i=0; i<3; ++i) {
1133 TopExp::MapShapes(myShape, aSTEx[i], aM);
1136 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
1137 myErrorStatus=4; // number of subshape is not compatible
1143 //=======================================================================
1144 //function : LoadIJNodes
1145 //purpose : Load nodes bound to theFace into column (vectors) and rows
1147 // The value of theIJNodes map is a vector of ordered nodes so
1148 // that the 0-the one lies on theBaseEdge.
1149 // The key of theIJNodes map is a normalized parameter of each
1150 // 0-the node on theBaseEdge.
1151 //=======================================================================
1153 bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
1154 const TopoDS_Face& theFace,
1155 const TopoDS_Edge& theBaseEdge,
1156 SMESHDS_Mesh* theMesh)
1158 // get vertices of theBaseEdge
1159 TopoDS_Vertex vfb, vlb, vft; // first and last, bottom and top vertices
1160 TopoDS_Edge eFrw = TopoDS::Edge( theBaseEdge.Oriented( TopAbs_FORWARD ));
1161 TopExp::Vertices( eFrw, vfb, vlb );
1163 // find the other edges of theFace and orientation of e1
1164 TopoDS_Edge e1, e2, eTop;
1165 bool rev1, CumOri = false;
1166 TopExp_Explorer exp( theFace, TopAbs_EDGE );
1168 for ( ; exp.More(); exp.Next() )
1170 if ( ++nbEdges > 4 )
1171 return false; // more than 4 edges in theFace
1172 TopoDS_Edge e = TopoDS::Edge( exp.Current() );
1173 if ( theBaseEdge.IsSame( e ))
1175 TopoDS_Vertex vCommon;
1176 if ( !TopExp::CommonVertex( theBaseEdge, e, vCommon ))
1178 else if ( vCommon.IsSame( vfb )) {
1180 vft = TopExp::LastVertex( e1, CumOri );
1181 rev1 = vfb.IsSame( vft );
1183 vft = TopExp::FirstVertex( e1, CumOri );
1189 return false; // lass than 4 edges in theFace
1191 // submeshes corresponding to shapes
1192 SMESHDS_SubMesh* smFace = theMesh->MeshElements( theFace );
1193 SMESHDS_SubMesh* smb = theMesh->MeshElements( theBaseEdge );
1194 SMESHDS_SubMesh* smt = theMesh->MeshElements( eTop );
1195 SMESHDS_SubMesh* sm1 = theMesh->MeshElements( e1 );
1196 SMESHDS_SubMesh* sm2 = theMesh->MeshElements( e2 );
1197 SMESHDS_SubMesh* smVfb = theMesh->MeshElements( vfb );
1198 SMESHDS_SubMesh* smVlb = theMesh->MeshElements( vlb );
1199 SMESHDS_SubMesh* smVft = theMesh->MeshElements( vft );
1200 if (!smFace || !smb || !smt || !sm1 || !sm2 || !smVfb || !smVlb || !smVft ) {
1201 MESSAGE( "NULL submesh " <<smFace<<" "<<smb<<" "<<smt<<" "<<
1202 sm1<<" "<<sm2<<" "<<smVfb<<" "<<smVlb<<" "<<smVft);
1205 if ( smb->NbNodes() != smt->NbNodes() || sm1->NbNodes() != sm2->NbNodes() ) {
1206 MESSAGE(" Diff nb of nodes on opposite edges" );
1209 if (smVfb->NbNodes() != 1 || smVlb->NbNodes() != 1 || smVft->NbNodes() != 1) {
1210 MESSAGE("Empty submesh of vertex");
1213 if ( sm1->NbNodes() * smb->NbNodes() != smFace->NbNodes() ) {
1214 MESSAGE( "Wrong nb face nodes: " <<
1215 sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
1219 int vsize = sm1->NbNodes() + 2;
1220 int hsize = smb->NbNodes() + 2;
1222 // load nodes from theBaseEdge
1224 set<const SMDS_MeshNode*> loadedNodes;
1225 const SMDS_MeshNode* nullNode = 0;
1227 vector<const SMDS_MeshNode*> & nVecf = theIJNodes[ 0.];
1228 nVecf.resize( vsize, nullNode );
1229 loadedNodes.insert( nVecf[ 0 ] = smVfb->GetNodes()->next() );
1231 vector<const SMDS_MeshNode*> & nVecl = theIJNodes[ 1.];
1232 nVecl.resize( vsize, nullNode );
1233 loadedNodes.insert( nVecl[ 0 ] = smVlb->GetNodes()->next() );
1236 BRep_Tool::Range( eFrw, f, l );
1237 double range = l - f;
1238 SMDS_NodeIteratorPtr nIt = smb->GetNodes();
1239 const SMDS_MeshNode* node;
1240 while ( nIt->more() )
1243 const SMDS_EdgePosition* pos =
1244 dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
1245 if ( !pos ) return false;
1246 double u = ( pos->GetUParameter() - f ) / range;
1247 vector<const SMDS_MeshNode*> & nVec = theIJNodes[ u ];
1248 nVec.resize( vsize, nullNode );
1249 loadedNodes.insert( nVec[ 0 ] = node );
1251 if ( theIJNodes.size() != hsize ) {
1252 MESSAGE( "Wrong node positions on theBaseEdge" );
1256 // load nodes from e1
1258 map< double, const SMDS_MeshNode*> sortedNodes; // sort by param on edge
1259 nIt = sm1->GetNodes();
1260 while ( nIt->more() )
1263 const SMDS_EdgePosition* pos =
1264 dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
1265 if ( !pos ) return false;
1266 sortedNodes.insert( make_pair( pos->GetUParameter(), node ));
1268 loadedNodes.insert( nVecf[ vsize - 1 ] = smVft->GetNodes()->next() );
1269 map< double, const SMDS_MeshNode*>::iterator u_n = sortedNodes.begin();
1270 int row = rev1 ? vsize - 1 : 0;
1271 for ( ; u_n != sortedNodes.end(); u_n++ )
1275 loadedNodes.insert( nVecf[ row ] = u_n->second );
1278 // try to load the rest nodes
1280 // get all faces from theFace
1281 set<const SMDS_MeshElement*> allFaces, foundFaces;
1282 SMDS_ElemIteratorPtr eIt = smFace->GetElements();
1283 while ( eIt->more() ) {
1284 const SMDS_MeshElement* e = eIt->next();
1285 if ( e->GetType() == SMDSAbs_Face )
1286 allFaces.insert( e );
1288 // Starting from 2 neighbour nodes on theBaseEdge, look for a face
1289 // the nodes belong to, and between the nodes of the found face,
1290 // look for a not loaded node considering this node to be the next
1291 // in a column of the starting second node. Repeat, starting
1292 // from nodes next to the previous starting nodes in their columns,
1293 // and so on while a face can be found. Then go the the next pair
1294 // of nodes on theBaseEdge.
1295 StdMeshers_IJNodeMap::iterator par_nVec_1 = theIJNodes.begin();
1296 StdMeshers_IJNodeMap::iterator par_nVec_2 = par_nVec_1;
1299 for ( par_nVec_2++; par_nVec_2 != theIJNodes.end(); par_nVec_1++, par_nVec_2++ )
1303 const SMDS_MeshNode* n1 = par_nVec_1->second[ row ];
1304 const SMDS_MeshNode* n2 = par_nVec_2->second[ row ];
1305 const SMDS_MeshElement* face = 0;
1307 // look for a face by 2 nodes
1308 face = SMESH_MeshEditor::FindFaceInSet( n1, n2, allFaces, foundFaces );
1311 int nbFaceNodes = face->NbNodes();
1312 if ( nbFaceNodes > 4 ) {
1313 MESSAGE(" Too many nodes in a face: " << nbFaceNodes );
1316 // look for a not loaded node of the <face>
1318 const SMDS_MeshNode* n3 = 0; // a node defferent from n1 and n2
1319 eIt = face->nodesIterator() ;
1320 while ( !found && eIt->more() ) {
1321 node = static_cast<const SMDS_MeshNode*>( eIt->next() );
1322 found = loadedNodes.insert( node ).second;
1323 if ( !found && node != n1 && node != n2 )
1327 if ( ++row > vsize - 1 ) {
1328 MESSAGE( "Too many nodes in column "<< col <<": "<< row+1);
1331 par_nVec_2->second[ row ] = node;
1332 foundFaces.insert( face );
1334 if ( nbFaceNodes == 4 )
1335 n1 = par_nVec_1->second[ row ];
1337 else if (nbFaceNodes == 3 &&
1338 n3 == par_nVec_1->second[ row ] )
1341 MESSAGE( "Not quad mesh, column "<< col );
1345 } while ( face && n1 && n2 );
1347 if ( row < vsize - 1 ) {
1348 MESSAGE( "Too few nodes in column "<< col <<": "<< row+1);
1349 MESSAGE( "Base node 1: "<< par_nVec_1->second[0]);
1350 MESSAGE( "Base node 2: "<< par_nVec_2->second[0]);
1351 MESSAGE( "Current node 1: "<< n1);
1352 MESSAGE( "Current node 2: "<< n2);
1353 MESSAGE( "first base node: "<< theIJNodes.begin()->second[0]);
1354 MESSAGE( "last base node: "<< theIJNodes.rbegin()->second[0]);
1357 } // loop on columns
1362 //////////////////////////////////////////////////////////////////////////
1364 // StdMeshers_SMESHBlock
1366 //////////////////////////////////////////////////////////////////////////
1368 //=======================================================================
1369 //function : StdMeshers_SMESHBlock
1371 //=======================================================================
1372 StdMeshers_SMESHBlock::StdMeshers_SMESHBlock()
1375 myIsEdgeForward.resize( SMESH_Block::NbEdges(), -1 );
1378 //=======================================================================
1379 //function : IsForwadEdge
1381 //=======================================================================
1383 bool StdMeshers_SMESHBlock::IsForwadEdge(const int theEdgeID)
1385 int index = myTBlock.ShapeIndex( theEdgeID );
1386 if ( !myTBlock.IsEdgeID( theEdgeID ))
1389 if ( myIsEdgeForward[ index ] < 0 )
1390 myIsEdgeForward[ index ] =
1391 myTBlock.IsForwardEdge( TopoDS::Edge( Shape( theEdgeID )), myShapeIDMap );
1393 return myIsEdgeForward[ index ];
1396 //=======================================================================
1397 //function : ErrorStatus
1399 //=======================================================================
1400 int StdMeshers_SMESHBlock::ErrorStatus() const
1402 return myErrorStatus;
1404 //=======================================================================
1407 //=======================================================================
1408 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell)
1411 TopoDS_Vertex aV000, aV001;
1413 Load(theShell, aV000, aV001);
1415 //=======================================================================
1418 //=======================================================================
1419 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell,
1420 const TopoDS_Vertex& theV000,
1421 const TopoDS_Vertex& theV001)
1429 myShapeIDMap.Clear();
1430 bOk=myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
1436 //=======================================================================
1437 //function : ComputeParameters
1439 //=======================================================================
1440 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
1443 ComputeParameters(thePnt, myShell, theXYZ);
1445 //=======================================================================
1446 //function : ComputeParameters
1448 //=======================================================================
1449 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
1450 const TopoDS_Shape& theShape,
1458 aID=ShapeID(theShape);
1459 if (myErrorStatus) {
1462 bOk=myTBlock.ComputeParameters(thePnt, theXYZ, aID);
1464 myErrorStatus=4; // problems with computation Parameters
1469 //=======================================================================
1470 //function : ComputeParameters
1472 //=======================================================================
1474 void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
1475 const TopoDS_Shape& theShape,
1483 aID=ShapeID(theShape);
1484 if (myErrorStatus) {
1487 if ( SMESH_Block::IsEdgeID( aID ))
1488 bOk=myTBlock.EdgeParameters( aID, theU, theXYZ );
1490 myErrorStatus=4; // problems with computation Parameters
1495 //=======================================================================
1498 //=======================================================================
1499 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1504 Point(theParams, aS, aP3D);
1506 //=======================================================================
1509 //=======================================================================
1510 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1511 const TopoDS_Shape& theShape,
1518 gp_XYZ aXYZ(99.,99.,99.);
1521 if (theShape.IsNull()) {
1522 bOk=myTBlock.ShellPoint(theParams, aXYZ);
1526 aID=ShapeID(theShape);
1527 if (myErrorStatus) {
1531 if (SMESH_Block::IsVertexID(aID)) {
1532 bOk=myTBlock.VertexPoint(aID, aXYZ);
1534 else if (SMESH_Block::IsEdgeID(aID)) {
1535 bOk=myTBlock.EdgePoint(aID, theParams, aXYZ);
1538 else if (SMESH_Block::IsFaceID(aID)) {
1539 bOk=myTBlock.FacePoint(aID, theParams, aXYZ);
1543 myErrorStatus=4; // problems with point computation
1548 //=======================================================================
1549 //function : ShapeID
1551 //=======================================================================
1552 int StdMeshers_SMESHBlock::ShapeID(const TopoDS_Shape& theShape)
1557 TopoDS_Shape aSF, aSR;
1560 aSF.Orientation(TopAbs_FORWARD);
1562 aSR.Orientation(TopAbs_REVERSED);
1564 if (myShapeIDMap.Contains(aSF)) {
1565 aID=myShapeIDMap.FindIndex(aSF);
1568 if (myShapeIDMap.Contains(aSR)) {
1569 aID=myShapeIDMap.FindIndex(aSR);
1572 myErrorStatus=2; // unknown shape;
1575 //=======================================================================
1578 //=======================================================================
1579 const TopoDS_Shape& StdMeshers_SMESHBlock::Shape(const int theID)
1585 aNb=myShapeIDMap.Extent();
1586 if (theID<1 || theID>aNb) {
1587 myErrorStatus=3; // ID is out of range
1588 return myEmptyShape;
1591 const TopoDS_Shape& aS=myShapeIDMap.FindKey(theID);