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
29 #include <StdMeshers_Penta_3D.hxx>
35 #include "utilities.h"
36 #include "Utils_ExceptHandlers.hxx"
38 #include <TopAbs_ShapeEnum.hxx>
39 #include <TopTools_IndexedMapOfShape.hxx>
41 #include <SMESH_Mesh.hxx>
42 #include <SMESH_subMesh.hxx>
43 #include <SMESHDS_SubMesh.hxx>
45 #include <SMDS_MeshElement.hxx>
46 #include <TopTools_IndexedMapOfShape.hxx>
47 #include <TopTools_ListOfShape.hxx>
48 #include <TopoDS_Vertex.hxx>
49 #include <TopoDS_Edge.hxx>
51 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
52 #include <TopTools_ListIteratorOfListOfShape.hxx>
54 #include <BRep_Tool.hxx>
55 #include <TopoDS_Shell.hxx>
57 typedef map < int, int, less<int> >::iterator \
58 StdMeshers_IteratorOfDataMapOfIntegerInteger;
60 //=======================================================================
62 // StdMeshers_Penta_3D
64 //=======================================================================
65 //function : StdMeshers_Penta_3D
67 //=======================================================================
68 StdMeshers_Penta_3D::StdMeshers_Penta_3D()
73 //=======================================================================
76 //=======================================================================
77 bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
78 const TopoDS_Shape& aShape)
118 //=======================================================================
119 //function : MakeNodes
121 //=======================================================================
122 void StdMeshers_Penta_3D::MakeNodes()
127 int i, j, k, ij, iNbN, aNodeID, aSize, iErr;
129 SMESH_Block::TShapeID aSID, aSIDs[aNbSIDs]={
130 SMESH_Block::ID_V000, SMESH_Block::ID_V100,
131 SMESH_Block::ID_V110, SMESH_Block::ID_V010,
132 SMESH_Block::ID_Ex00, SMESH_Block::ID_E1y0,
133 SMESH_Block::ID_Ex10, SMESH_Block::ID_E0y0,
137 SMESH_Mesh* pMesh=GetMesh();
139 // 1. Define the sizes of mesh
141 // 1.1 Horizontal size
143 for (i=0; i<aNbSIDs; ++i) {
144 const TopoDS_Shape& aS=myBlock.Shape(aSIDs[i]);
145 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
147 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
151 //printf("*** Horizontal: number of nodes summary=%d\n", myJSize);
156 const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_E00z);
157 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
159 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
163 //printf("*** Vertical: number of nodes on edges and vertices=%d\n", myISize);
165 aSize=myISize*myJSize;
166 myTNodes.resize(aSize);
168 StdMeshers_TNode aTNode;
172 // 2. Fill the repers on base face (Z=0)
175 for (k=0; k<aNbSIDs; ++k) {
177 const TopoDS_Shape& aS=myBlock.Shape(aSID);
178 SMDS_NodeIteratorPtr ite =pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
180 const SMDS_MeshNode* aNode = ite->next();
181 aNodeID=aNode->GetID();
183 aTNode.SetNode(aNode);
184 aTNode.SetShapeSupportID(aSID);
185 aTNode.SetBaseNodeID(aNodeID);
188 case SMESH_Block::ID_V000:
189 aCoords.SetCoord(0., 0., 0.);
191 case SMESH_Block::ID_V100:
192 aCoords.SetCoord(1., 0., 0.);
194 case SMESH_Block::ID_V110:
195 aCoords.SetCoord(1., 1., 0.);
197 case SMESH_Block::ID_V010:
198 aCoords.SetCoord(0., 1., 0.);
200 case SMESH_Block::ID_Ex00:
201 case SMESH_Block::ID_E1y0:
202 case SMESH_Block::ID_Ex10:
203 case SMESH_Block::ID_E0y0:
204 case SMESH_Block::ID_Fxy0:{
208 aP3D.SetCoord(aX, aY, aZ);
209 myBlock.ComputeParameters(aP3D, aS, aCoords);
210 iErr=myBlock.ErrorStatus();
212 MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
213 "SMESHBlock: ComputeParameters operation failed");
214 myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
222 aTNode.SetNormCoord(aCoords);
231 int iShapeSupportID, iBaseNodeID;
233 //printf("\n\n*** Base Face\n");
235 for (j=0; j<myJSize; ++j) {
237 const StdMeshers_TNode& aTNode=myTNodes[ij];
238 iShapeSupportID=aTNode.ShapeSupportID();
239 iBaseNodeID=aTNode.BaseNodeID();
240 const gp_XYZ& aXYZ=aTNode.NormCoord();
241 printf("*** j:%d bID#%d iSS:%d { %lf %lf %lf }\n",
242 j, iBaseNodeID, iShapeSupportID, aXYZ.X(), aXYZ.Y(), aXYZ.Z());
249 // 3. Finding of Z-layers
250 vector<double> aZL(myISize);
251 vector<double>::iterator aItZL1, aItZL2 ;
253 const TopoDS_Shape& aE00z=myBlock.Shape(SMESH_Block::ID_E00z);
254 SMDS_NodeIteratorPtr aItaE00z =
255 pMesh->GetSubMeshContaining(aE00z)->GetSubMeshDS()->GetNodes();
259 while (aItaE00z->more()) {
260 const SMDS_MeshNode* aNode=aItaE00z->next();
261 aX=aNode->X(); aY=aNode->Y(); aZ=aNode->Z();
262 aP3D.SetCoord(aX, aY, aZ);
263 myBlock.ComputeParameters(aP3D, aE00z, aCoords);
264 iErr=myBlock.ErrorStatus();
266 MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
267 "SMESHBlock: ComputeParameters operation failed");
268 myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
279 // Sorting the layers
280 sort(aItZL1, aItZL2);
283 printf("** \n\n Layers begin\n");
284 for(i=0, aItZL=aItZL1; aItZL!=aItZL2; ++aItZL, ++i) {
285 printf(" #%d : %lf\n", i, *aItZL);
287 printf("** Layers end\n");
292 // 4. Fill the rest repers
295 SMESH_Block::TShapeID aSSID, aBNSSID;
296 StdMeshers_TNode aTN;
298 for (j=0; j<myJSize; ++j) {
299 for (i=1; i<myISize; ++i) {
302 const StdMeshers_TNode& aBN=myTNodes[j];
303 aBNSSID=(SMESH_Block::TShapeID)aBN.ShapeSupportID();
304 iBNID=aBN.BaseNodeID();
305 const gp_XYZ& aBNXYZ=aBN.NormCoord();
307 // fill current node info
310 // -normalized coordinates
314 aCoords.SetCoord(aX, aY, aZ);
316 // suporting shape ID
317 bIsUpperLayer=(i==(myISize-1));
318 ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID);
320 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
324 aTN.SetShapeSupportID(aSSID);
325 aTN.SetNormCoord(aCoords);
326 aTN.SetBaseNodeID(iBNID);
328 if (aSSID!=SMESH_Block::ID_NONE){
329 // try to find the node
330 const TopoDS_Shape& aS=myBlock.Shape((int)aSSID);
331 FindNodeOnShape(aS, aCoords, aTN);
334 // create node and get it id
335 CreateNode (bIsUpperLayer, aCoords, aTN);
338 MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
348 int iSSID, iBNID, aID;
350 for (i=0; i<myISize; ++i) {
351 printf(" Layer# %d\n", i);
352 for (j=0; j<myJSize; ++j) {
354 const StdMeshers_TNode& aTN=myTNodes[ij];
355 //const StdMeshers_TNode& aTN=aTNodes[ij];
356 const gp_XYZ& aXYZ=aTN.NormCoord();
357 iSSID=aTN.ShapeSupportID();
358 iBNID=aTN.BaseNodeID();
360 const SMDS_MeshNode* aNode=aTN.Node();
365 printf("*** j:%d BNID#%d iSSID:%d ID:%d { %lf %lf %lf }, { %lf %lf %lf }\n",
366 j, iBNID, iSSID, aID, aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aX, aY, aZ);
373 //=======================================================================
374 //function : FindNodeOnShape
376 //=======================================================================
377 void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
378 const gp_XYZ& aParams,
379 StdMeshers_TNode& aTN)
383 double aX, aY, aZ, aD, aTol2;
386 SMESH_Mesh* pMesh=GetMesh();
387 aTol2=myTol3D*myTol3D;
388 SMDS_MeshNode* pNode=NULL;
390 myBlock.Point(aParams, aS, aP1);
392 SMDS_NodeIteratorPtr ite=
393 pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
395 const SMDS_MeshNode* aNode = ite->next();
399 aP2.SetCoord(aX, aY, aZ);
400 aD=(double)aP1.SquareDistance(aP2);
401 //printf("** D=%lf ", aD, aTol2);
403 pNode=(SMDS_MeshNode*)aNode;
412 MESSAGE("StdMeshers_Penta_3D::FindNodeOnShape(), can not find the node");
413 myErrorStatus=11; // can not find the node;
416 //=======================================================================
417 //function : MakeVolumeMesh
419 //=======================================================================
420 void StdMeshers_Penta_3D::MakeVolumeMesh()
424 int i, j, ij, ik, i1, i2, aSSID;
427 TopExp_Explorer aExp;
429 SMESH_Mesh* pMesh =GetMesh();
430 SMESHDS_Mesh* meshDS=pMesh->GetMeshDS();
432 aExp.Init(myShape, TopAbs_SHELL);
433 for (; aExp.More(); aExp.Next()){
434 aShell=TopoDS::Shell(aExp.Current());
438 // 1. Set Node In Volume
440 for (i=1; i<ik; ++i){
441 for (j=0; j<myJSize; ++j){
443 const StdMeshers_TNode& aTN=myTNodes[ij];
444 aSSID=aTN.ShapeSupportID();
445 if (aSSID==SMESH_Block::ID_NONE) {
446 SMDS_MeshNode* aNode=(SMDS_MeshNode*)aTN.Node();
447 meshDS->SetNodeInVolume(aNode, aShell);
452 // 2. Make pentahedrons
454 vector<const SMDS_MeshNode*> aN;
456 SMDS_ElemIteratorPtr itf, aItNodes;
458 const TopoDS_Face& aFxy0=
459 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
460 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
461 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
463 itf=aSM0->GetElements();
465 const SMDS_MeshElement* pE0=itf->next();
467 int nbFaceNodes = pE0->NbNodes();
468 if ( aN.size() < nbFaceNodes * 2 )
469 aN.resize( nbFaceNodes * 2 );
472 aItNodes=pE0->nodesIterator();
473 while (aItNodes->more()) {
474 const SMDS_MeshElement* pNode=aItNodes->next();
476 aJ[k]=GetIndexOnLayer(aID0);
478 MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh");
485 for (i=0; i<ik; ++i){
488 for(j=0; j<nbFaceNodes; ++j) {
490 const StdMeshers_TNode& aTN1=myTNodes[ij];
491 const SMDS_MeshNode* aN1=aTN1.Node();
495 const StdMeshers_TNode& aTN2=myTNodes[ij];
496 const SMDS_MeshNode* aN2=aTN2.Node();
497 aN[j+nbFaceNodes]=aN2;
500 SMDS_MeshVolume* aV = 0;
501 switch ( nbFaceNodes ) {
503 aV = meshDS->AddVolume(aN[0], aN[1], aN[2],
504 aN[3], aN[4], aN[5]);
507 aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3],
508 aN[4], aN[5], aN[6], aN[7]);
513 meshDS->SetMeshElementOnShape(aV, aShell);
518 //=======================================================================
519 //function : MakeMeshOnFxy1
521 //=======================================================================
522 void StdMeshers_Penta_3D::MakeMeshOnFxy1()
526 int aID0, aJ, aLevel, ij, aNbNodes, k;
528 SMDS_NodeIteratorPtr itn;
529 SMDS_ElemIteratorPtr itf, aItNodes;
530 SMDSAbs_ElementType aElementType;
532 const TopoDS_Face& aFxy0=
533 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
534 const TopoDS_Face& aFxy1=
535 TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
537 SMESH_Mesh* pMesh=GetMesh();
538 SMESHDS_Mesh * meshDS = pMesh->GetMeshDS();
540 SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
541 SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
543 // set nodes on aFxy1
545 itn=aSM0->GetNodes();
546 aNbNodes=aSM0->NbNodes();
547 //printf("** aNbNodes=%d\n", aNbNodes);
549 const SMDS_MeshNode* aN0=itn->next();
551 aJ=GetIndexOnLayer(aID0);
553 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
557 ij=aLevel*myJSize+aJ;
558 const StdMeshers_TNode& aTN1=myTNodes[ij];
559 SMDS_MeshNode* aN1=(SMDS_MeshNode*)aTN1.Node();
561 meshDS->SetNodeOnFace(aN1, aFxy1);
564 // set elements on aFxy1
565 vector<const SMDS_MeshNode*> aNodes1;
567 itf=aSM0->GetElements();
569 const SMDS_MeshElement * pE0=itf->next();
570 aElementType=pE0->GetType();
571 if (!aElementType==SMDSAbs_Face) {
574 aNbNodes=pE0->NbNodes();
575 // if (aNbNodes!=3) {
578 if ( aNodes1.size() < aNbNodes )
579 aNodes1.resize( aNbNodes );
581 k=aNbNodes-1; // reverse a face
582 aItNodes=pE0->nodesIterator();
583 while (aItNodes->more()) {
584 const SMDS_MeshElement* pNode=aItNodes->next();
586 aJ=GetIndexOnLayer(aID0);
588 MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
592 ij=aLevel*myJSize+aJ;
593 const StdMeshers_TNode& aTN1=myTNodes[ij];
594 const SMDS_MeshNode* aN1=aTN1.Node();
598 SMDS_MeshFace * face = 0;
599 switch ( aNbNodes ) {
601 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
604 face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
609 meshDS->SetMeshElementOnShape(face, aFxy1);
612 //=======================================================================
613 //function : ClearMeshOnFxy1
615 //=======================================================================
616 void StdMeshers_Penta_3D::ClearMeshOnFxy1()
620 SMESH_subMesh* aSubMesh;
621 SMESH_Mesh* pMesh=GetMesh();
623 const TopoDS_Shape& aFxy1=myBlock.Shape(SMESH_Block::ID_Fxy1);
624 aSubMesh = pMesh->GetSubMeshContaining(aFxy1);
626 aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
629 //=======================================================================
630 //function : GetIndexOnLayer
632 //=======================================================================
633 int StdMeshers_Penta_3D::GetIndexOnLayer(const int aID)
638 StdMeshers_IteratorOfDataMapOfIntegerInteger aMapIt;
640 aMapIt=myConnectingMap.find(aID);
641 if (aMapIt==myConnectingMap.end()) {
648 //=======================================================================
649 //function : MakeConnectingMap
651 //=======================================================================
652 void StdMeshers_Penta_3D::MakeConnectingMap()
656 for (j=0; j<myJSize; ++j) {
657 const StdMeshers_TNode& aBN=myTNodes[j];
658 aBNID=aBN.BaseNodeID();
659 myConnectingMap[aBNID]=j;
662 //=======================================================================
663 //function : CreateNode
665 //=======================================================================
666 void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
667 const gp_XYZ& aParams,
668 StdMeshers_TNode& aTN)
677 SMDS_MeshNode* pNode=NULL;
681 // point on face Fxy1
682 const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_Fxy1);
683 myBlock.Point(aParams, aS, aP);
686 // point inside solid
687 myBlock.Point(aParams, aP);
690 iErr=myBlock.ErrorStatus();
692 myErrorStatus=12; // can not find the node point;
696 aX=aP.X(); aY=aP.Y(); aZ=aP.Z();
698 SMESH_Mesh* pMesh=GetMesh();
699 SMESHDS_Mesh* pMeshDS=pMesh->GetMeshDS();
701 pNode = pMeshDS->AddNode(aX, aY, aZ);
704 //=======================================================================
705 //function : ShapeSupportID
707 //=======================================================================
708 void StdMeshers_Penta_3D::ShapeSupportID(const bool bIsUpperLayer,
709 const SMESH_Block::TShapeID aBNSSID,
710 SMESH_Block::TShapeID& aSSID)
715 case SMESH_Block::ID_V000:
716 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z;
718 case SMESH_Block::ID_V100:
719 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V101 : SMESH_Block::ID_E10z;
721 case SMESH_Block::ID_V110:
722 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V111 : SMESH_Block::ID_E11z;
724 case SMESH_Block::ID_V010:
725 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V011 : SMESH_Block::ID_E01z;
727 case SMESH_Block::ID_Ex00:
728 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex01 : SMESH_Block::ID_Fx0z;
730 case SMESH_Block::ID_Ex10:
731 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex11 : SMESH_Block::ID_Fx1z;
733 case SMESH_Block::ID_E0y0:
734 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E0y1 : SMESH_Block::ID_F0yz;
736 case SMESH_Block::ID_E1y0:
737 aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E1y1 : SMESH_Block::ID_F1yz;
739 case SMESH_Block::ID_Fxy0:
740 aSSID=SMESH_Block::ID_NONE;//(bIsUpperLayer) ? Shape_ID_Fxy1 : Shape_ID_NONE;
743 aSSID=SMESH_Block::ID_NONE;
744 myErrorStatus=10; // Can not find supporting shape ID
749 //=======================================================================
750 //function : MakeBlock
752 //=======================================================================
753 void StdMeshers_Penta_3D::MakeBlock()
758 int i, j, iNbEV, iNbE, iErr, iCnt, iNbNodes, iNbF;
760 TopoDS_Vertex aV000, aV001;
762 TopTools_IndexedDataMapOfShapeListOfShape aMVES;
763 TopTools_IndexedMapOfShape aME ,aMEV, aM;
764 TopTools_ListIteratorOfListOfShape aIt;
766 TopExp::MapShapes(myShape, TopAbs_FACE, aM);
768 // 0. Find triangulated face aFTr
769 SMDSAbs_ElementType aElementType;
770 SMESH_Mesh* pMesh=GetMesh();
774 for (i=1; i<=iNbF; ++i) {
775 const TopoDS_Shape& aF=aM(i);
776 SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF);
778 SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
779 SMDS_ElemIteratorPtr itf=aSM->GetElements();
781 const SMDS_MeshElement * pElement=itf->next();
782 aElementType=pElement->GetType();
783 if (aElementType==SMDSAbs_Face) {
784 iNbNodes=pElement->NbNodes();
789 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
790 myErrorStatus=5; // more than one face has triangulation
799 // 1. Vetrices V00, V001;
801 TopExp::MapShapes(aFTr, TopAbs_EDGE, aME);
802 TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVES);
804 // 1.1 Base vertex V000
807 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
808 myErrorStatus=7; // too few edges are in base face aFTr
811 const TopoDS_Edge& aE1=TopoDS::Edge(aME(1));
812 aV000=TopExp::FirstVertex(aE1);
814 const TopTools_ListOfShape& aLE=aMVES.FindFromKey(aV000);
816 for (; aIt.More(); aIt.Next()) {
817 const TopoDS_Shape& aEx=aIt.Value();
822 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
823 myErrorStatus=7; // too few edges meet in base vertex
829 for (j=1; j<=iNbEV; ++j) {
830 const TopoDS_Shape& aEx=aMEV(j);
831 if (!aME.Contains(aEx)) {
834 const TopoDS_Edge& aE=TopoDS::Edge(aEx);
835 TopExp::Vertices(aE, aV[0], aV[1]);
836 for (i=0; i<2; ++i) {
837 if (!aV[i].IsSame(aV000)) {
847 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
848 myErrorStatus=8; // can not find reper V001
852 //gp_Pnt aP000, aP001;
854 //aP000=BRep_Tool::Pnt(TopoDS::Vertex(aV000));
855 //printf("*** aP000 { %lf, %lf, %lf }\n", aP000.X(), aP000.Y(), aP000.Z());
856 //aP001=BRep_Tool::Pnt(TopoDS::Vertex(aV001));
857 //printf("*** aP001 { %lf, %lf, %lf }\n", aP001.X(), aP001.Y(), aP001.Z());
861 TopExp::MapShapes(myShape, TopAbs_SHELL, aME);
864 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
865 myErrorStatus=9; // number of shells in source shape !=1
870 const TopoDS_Shell& aShell=TopoDS::Shell(aME(1));
871 myBlock.Load(aShell, aV000, aV001);
872 iErr=myBlock.ErrorStatus();
874 MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
875 myErrorStatus=100; // SMESHBlock: Load operation failed
879 //=======================================================================
880 //function : CheckData
882 //=======================================================================
883 void StdMeshers_Penta_3D::CheckData()
888 int iNbEx[]={8, 12, 6};
890 TopAbs_ShapeEnum aST;
891 TopAbs_ShapeEnum aSTEx[]={
892 TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE
894 TopTools_IndexedMapOfShape aM;
896 if (myShape.IsNull()){
897 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
898 myErrorStatus=2; // null shape
902 aST=myShape.ShapeType();
903 if (!(aST==TopAbs_SOLID || aST==TopAbs_SHELL)) {
904 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
905 myErrorStatus=3; // not compatible type of shape
909 for (i=0; i<3; ++i) {
911 TopExp::MapShapes(myShape, aSTEx[i], aM);
914 MESSAGE("StdMeshers_Penta_3D::CheckData() ");
915 myErrorStatus=4; // number of subshape is not compatible
920 //////////////////////////////////////////////////////////////////////////
922 // StdMeshers_SMESHBlock
925 #include <TopTools_IndexedMapOfOrientedShape.hxx>
926 #include <TopoDS_Vertex.hxx>
928 //=======================================================================
929 //function : StdMeshers_SMESHBlock
931 //=======================================================================
932 StdMeshers_SMESHBlock::StdMeshers_SMESHBlock()
936 //=======================================================================
937 //function : ErrorStatus
939 //=======================================================================
940 int StdMeshers_SMESHBlock::ErrorStatus() const
942 return myErrorStatus;
944 //=======================================================================
947 //=======================================================================
948 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell)
951 TopoDS_Vertex aV000, aV001;
953 Load(theShell, aV000, aV001);
955 //=======================================================================
958 //=======================================================================
959 void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell,
960 const TopoDS_Vertex& theV000,
961 const TopoDS_Vertex& theV001)
969 myShapeIDMap.Clear();
970 bOk=myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
976 //=======================================================================
977 //function : ComputeParameters
979 //=======================================================================
980 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
983 ComputeParameters(thePnt, myShell, theXYZ);
985 //=======================================================================
986 //function : ComputeParameters
988 //=======================================================================
989 void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
990 const TopoDS_Shape& theShape,
998 aID=ShapeID(theShape);
1002 bOk=myTBlock.ComputeParameters(thePnt, theXYZ, aID);
1004 myErrorStatus=4; // problems with computation Parameters
1008 //=======================================================================
1011 //=======================================================================
1012 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1017 Point(theParams, aS, aP3D);
1019 //=======================================================================
1022 //=======================================================================
1023 void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams,
1024 const TopoDS_Shape& theShape,
1031 gp_XYZ aXYZ(99.,99.,99.);
1034 if (theShape.IsNull()) {
1035 bOk=myTBlock.ShellPoint(theParams, aXYZ);
1039 aID=ShapeID(theShape);
1040 if (myErrorStatus) {
1044 if (SMESH_Block::IsVertexID(aID)) {
1045 bOk=myTBlock.VertexPoint(aID, aXYZ);
1047 else if (SMESH_Block::IsEdgeID(aID)) {
1048 bOk=myTBlock.EdgePoint(aID, theParams, aXYZ);
1051 else if (SMESH_Block::IsFaceID(aID)) {
1052 bOk=myTBlock.FacePoint(aID, theParams, aXYZ);
1056 myErrorStatus=4; // problems with point computation
1061 //=======================================================================
1062 //function : ShapeID
1064 //=======================================================================
1065 int StdMeshers_SMESHBlock::ShapeID(const TopoDS_Shape& theShape)
1070 TopoDS_Shape aSF, aSR;
1073 aSF.Orientation(TopAbs_FORWARD);
1075 aSR.Orientation(TopAbs_REVERSED);
1077 if (myShapeIDMap.Contains(aSF)) {
1078 aID=myShapeIDMap.FindIndex(aSF);
1081 if (myShapeIDMap.Contains(aSR)) {
1082 aID=myShapeIDMap.FindIndex(aSR);
1085 myErrorStatus=2; // unknown shape;
1088 //=======================================================================
1091 //=======================================================================
1092 const TopoDS_Shape& StdMeshers_SMESHBlock::Shape(const int theID)
1098 aNb=myShapeIDMap.Extent();
1099 if (theID<1 || theID>aNb) {
1100 myErrorStatus=3; // ID is out of range
1101 return myEmptyShape;
1104 const TopoDS_Shape& aS=myShapeIDMap.FindKey(theID);