MeshKit  1.0
createpincell.cpp
Go to the documentation of this file.
00001 
00002 #include "meshkit/AssyGen.hpp"
00003 
00004 namespace MeshKit
00005 {
00006 
00007   void AssyGen::CreatePinCell(int i, double dX, double dY, double dZ)
00008   //---------------------------------------------------------------------------
00009   //Function: Create pincell i in location dX dY and dZ
00010   //Input:    none
00011   //Output:   none
00012   //---------------------------------------------------------------------------
00013   {
00014     int nRadii=0, nCyl=0, nCells = 0;
00015     double dCylMoveX = 0.0, dCylMoveY = 0.0, dHeightTotal = 0.0;
00016     double dHeight =0.0,dZMove = 0.0, PX = 0.0,PY = 0.0,PZ = 0.0, dP=0.0;
00017     CVector<double> dVCylZPos(2), dVCylXYPos(2), dVStartZ, dVEndZ;;
00018     CVector<std::string> szVCellMat;
00019     iBase_EntityHandle cell = NULL, cyl= NULL, tmp_vol= NULL,tmp_vol1= NULL, tmp_new= NULL;
00020     (void) tmp_vol;
00021     std::vector<iBase_EntityHandle> cp_in;
00022     // name tag handle
00023     iBase_TagHandle this_tag= NULL;
00024 
00025     std::string sMatName = "";
00026     std::string sMatName1 = "";
00027     int nDuctIndex = -1;
00028 
00029     if(strcmp(m_szInfo.c_str(),"on") == 0){
00030         std::ostringstream os;
00031         pin_name = "_xp";
00032         os << (m_nTotalPincells + m_nStartpinid - 1);
00033         os << "_";
00034         std::string pid = os.str(); //retrieve as a string
00035         pin_name+=pid;
00036       }
00037 
00038     // get tag handle for 'NAME' tag, already created as iGeom instance is created
00039 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00040     char* tag_name = (char*)"NAME";    
00041     iGeom_getTagHandle(igeomImpl->instance(), tag_name, &this_tag, &err, 4);
00042 #endif
00043 
00044     // get cell material
00045     m_Pincell(i).GetCellMatSize(nCells);
00046     SimpleArray<iBase_EntityHandle> cells(nCells);
00047 
00048     // branch when cells are present
00049     if(nCells > 0){
00050         dVStartZ.SetSize(nCells);
00051         dVEndZ.SetSize(nCells);
00052         szVCellMat.SetSize(nCells);
00053         m_Pincell(i).GetCellMat(dVStartZ, dVEndZ, szVCellMat);
00054 
00055         // get cylinder data
00056         m_Pincell(i).GetNumCyl(nCyl);
00057 
00058         for(int n=1;n<=nCells; n++){
00059             // get cylinder locations
00060             if(nCyl > 0){
00061                 m_Pincell(i).GetCylZPos(n, dVCylZPos);
00062                 nDuctIndex = -1;
00063 
00064                 // get the index for cp_inpins based on Z-heights
00065                 for (int dd = 1; dd <= m_nDuct; dd++){
00066                     if((m_dMZAssm(dd, 2)) >= (dVCylZPos(2)) && (m_dMZAssm(dd, 1)) >= (dVCylZPos(1)))
00067                       nDuctIndex = dd;
00068                     if (nDuctIndex != -1)
00069                       break;
00070                   }
00071               }
00072             dHeight = fabs(dVEndZ(n) - dVStartZ(n));
00073             m_PyCubGeomFile << "cells = []\ncyls = []\ncp_in = []" << std::endl;
00074             m_PyCubGeomFile << "sub1 = [] \nsub2 = []" << std::endl;
00075             
00076             if(m_szGeomType =="hexagonal"){
00077 
00078                 m_Pincell(i).GetPitch(dP, dHeightTotal); // this dHeight is not used in creation
00079                 double dSide = dP/(sqrt(3));
00080 
00081                 if(nCells >0){
00082                     // create prism
00083 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00084                     iGeom_createPrism(igeomImpl->instance(), dHeight, 6,
00085                                       dSide, dSide,
00086                                       &cell, &err);
00087 #endif
00088                     m_PyCubGeomFile << "cell = cubit.prism( " << dHeight << ", 6, " << dSide << ", " << dSide << ")" << std::endl;
00089                   }
00090               }
00091             // if rectangular geometry
00092             if(m_szGeomType =="rectangular"){
00093 
00094                 m_Pincell(i).GetPitch(PX, PY, PZ);
00095 
00096                 if(nCells >0){
00097 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00098                     // create brick
00099                     iGeom_createBrick( igeomImpl->instance(),PX,PY,dHeight,&cell,&err );
00100 #endif
00101                     m_PyCubGeomFile << "cell = cubit.brick( " << PX << ", " << PY << ", " << dHeight << ")" << std::endl;
00102                   }
00103               }
00104 
00105             dZMove = (dVStartZ(n)+dVEndZ(n))/2.0;
00106             if(nCells > 0){
00107                 // position the brick in assembly
00108 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00109                 iGeom_moveEnt(igeomImpl->instance(), cell, dX, dY, dZMove, &err);
00110 #endif
00111                 m_PyCubGeomFile << "vector = [" << dX << ", " << dY << ", " << dZMove << "]" << std::endl;
00112                 m_PyCubGeomFile << "cubit.move( cell, vector)" << std::endl;
00113 
00114                 m_PyCubGeomFile << "cells.append(cell)" << std::endl;
00115                 cells[n-1]=cell;
00116 
00117                 //search for the full name of the abbreviated Cell Mat and set name
00118                 for(int p=1;p<= m_szAssmMatAlias.GetSize();p++){
00119                     if(strcmp (szVCellMat(n).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00120                         sMatName = m_szAssmMat(p);
00121                       }
00122                   }
00123                 std::cout << "created: " << sMatName << std::endl;
00124 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00125                 iGeom_setData(igeomImpl->instance(), cell, this_tag,
00126                               sMatName.c_str(), sMatName.size(), &err);
00127 #endif
00128                 m_PyCubGeomFile  << "lid = cells[0].id()" << std::endl;
00129                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00130 
00131                                    if(strcmp(m_szInfo.c_str(),"on") == 0){
00132 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00133                     iGeom_setData(igeomImpl->instance(), cell, this_tag,
00134                                   pin_name.c_str(), pin_name.size(), &err);
00135 #endif
00136                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00137                     std::cout << "Naming pin body :" <<  pin_name << std::endl;
00138                   }
00139 
00140 
00141                 Name_Faces(sMatName, cell, this_tag);
00142                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", cell) " << std::endl;
00143               }
00144             // loop and create cylinders
00145             if(nCyl > 0){
00146                 m_Pincell(i).GetCylSizes(n, nRadii);
00147                 SimpleArray<iBase_EntityHandle> cyls(nRadii);
00148 
00149                 //declare variables
00150                 CVector<double> dVCylRadii(2*nRadii);
00151                 CVector<std::string> szVMat(nRadii);
00152                 CVector<std::string> szVCylMat(nRadii);
00153                 int nType = 0;
00154                 //get values
00155                 m_Pincell(i).GetCylRadii(n, dVCylRadii);
00156                 m_Pincell(i).GetCylPos(n, dVCylXYPos);
00157                 m_Pincell(i).GetCylMat(n, szVCylMat);
00158                 m_Pincell(i).GetCylZPos(n, dVCylZPos);
00159                 m_Pincell(i).GetCellType(n, nType);
00160 
00161                 dHeight = dVCylZPos(2)-dVCylZPos(1);
00162 
00163                 for (int m=1; m<=nRadii; m++){
00164 
00165                     if (nType == 0){
00166 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00167                         iGeom_createCylinder(igeomImpl->instance(), dHeight, dVCylRadii(m), dVCylRadii(m),
00168                                              &cyl, &err);
00169 #endif
00170                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ")" << std::endl;
00171                         std::cout << m << ": Creating cylinder with radii " << dVCylRadii(m) << std::endl;
00172                       }
00173                     else{
00174 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00175                         iGeom_createCone(igeomImpl->instance(), dHeight, dVCylRadii(2*m-1), dVCylRadii(2*m-1), dVCylRadii(2*m),
00176                                          &cyl, &err);
00177 #endif
00178                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m) << ")" << std::endl;
00179                       }
00180                     // move their centers and also move to the assembly location  ! Modify if cyl is outside brick
00181                     dCylMoveX = dVCylXYPos(1)+dX;
00182                     dCylMoveY = dVCylXYPos(2)+dY;
00183                     dZMove = (dVCylZPos(1)+dVCylZPos(2))/2.0;
00184 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00185                     iGeom_moveEnt(igeomImpl->instance(), cyl, dCylMoveX,dCylMoveY,dZMove, &err);
00186 #endif
00187                     m_PyCubGeomFile << "cyls.append(cyl)" << std::endl;
00188 
00189                     m_PyCubGeomFile << "vector = [" << dCylMoveX << ", " << dCylMoveY << ", " << dZMove << "]" << std::endl;
00190                     m_PyCubGeomFile << "cubit.move(cyl, vector)" << std::endl;
00191                     cyls[m-1] = cyl;
00192                   }
00193 
00194                 m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl;
00195 
00196                 if(nCells > 0){
00197                     // copy cyl before subtract
00198 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00199                     iGeom_copyEnt(igeomImpl->instance(), cyls[nRadii-1], &tmp_vol, &err);
00200 #endif
00201                     m_PyCubGeomFile << "tmp_vol = cubit.copy_body(cyls[" << nRadii-1 << "])" << std::endl;
00202 
00203                     // subtract outer most cyl from brick
00204 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00205                     iGeom_subtractEnts(igeomImpl->instance(), cells[n-1], tmp_vol, &tmp_new, &err);
00206 #endif
00207                     m_PyCubGeomFile << "sub1.append(cells[" << n-1 << "])\nsub2.append(tmp_vol)" << std::endl;
00208                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00209                     m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl;
00210 
00211                     m_PyCubGeomFile << "cells.append(tmp_new[0]) \ncell = tmp_new[0]" << std::endl;
00212 
00213                     // copy the new into the cyl array
00214                     cells[n-1] = tmp_new; cell = tmp_new;
00215 
00216                   }
00217                 cp_in.push_back(tmp_new);
00218                 m_PyCubGeomFile << "cp_in.append(tmp_new[0])" << std::endl;
00219 
00220                 //set tag on inner most cylinder, search for the full name of the abbreviated Cell Mat
00221                 for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00222                     if(strcmp (szVCylMat(1).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00223                         sMatName = m_szAssmMat(p);
00224                       }
00225                   }
00226                 tmp_vol1=cyls[0]; //inner most cyl
00227                 cp_in.push_back(tmp_vol1);
00228                 m_PyCubGeomFile << "tmp_vol1 = cyls[0]\ncp_in.append(tmp_vol1)" << std::endl;
00229 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00230                 iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00231                               sMatName.c_str(), 10, &err);
00232 #endif
00233                 m_PyCubGeomFile  << "lid = tmp_vol1.id()" << std::endl;
00234                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00235 
00236                  if(strcmp(m_szInfo.c_str(),"on") == 0){
00237 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00238                     iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00239                                   pin_name.c_str(), pin_name.size(), &err);
00240 #endif
00241                     std::cout << "Naming pin body :" <<  pin_name << std::endl;
00242                   }
00243 
00244                 Name_Faces(sMatName, tmp_vol1, this_tag);
00245                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_vol1) " << std::endl;
00246 
00247                 // other cyl annulus after substraction
00248                 for (int b=nRadii; b>1; b--){
00249 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00250                     iGeom_copyEnt(igeomImpl->instance(), cyls[b-2], &tmp_vol, &err);
00251 #endif
00252                     m_PyCubGeomFile << "tmp_vol = cubit.copy_body(cyls[" << b-2 << "])" << std::endl;
00253 
00254                     //subtract tmp vol from the outer most
00255 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00256                     iGeom_subtractEnts(igeomImpl->instance(), cyls[b-1], tmp_vol, &tmp_new, &err);
00257 #endif
00258                     m_PyCubGeomFile << "sub1.append(cyls[" << b-1 << "])\nsub2.append(tmp_vol)" << std::endl;
00259                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00260                     m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl;
00261 
00262                     // now search for the full name of the abbreviated Cell Mat
00263                     //    int tag_no;
00264                     for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00265                         if(strcmp (szVCylMat(b).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00266                             //        tag_no = p;
00267                             sMatName =  m_szAssmMat(p);
00268                           }
00269                       }
00270                     std::cout << "created: " << sMatName << std::endl;
00271                     cp_in.push_back(tmp_new);
00272                     m_PyCubGeomFile << "cp_in.append(tmp_new[0])" << std::endl;
00273 
00274                     // set the name of the annulus
00275 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00276                     iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00277                                   sMatName.c_str(),sMatName.size(), &err);
00278 #endif
00279                     m_PyCubGeomFile  << "lid = tmp_new[0].id()" << std::endl;
00280                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00281 
00282                     if(strcmp(m_szInfo.c_str(),"on") == 0){
00283 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00284                         iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00285                                       pin_name.c_str(), pin_name.size(), &err);
00286 #endif
00287                         std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00288 
00289                         m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00290                       }
00291                     Name_Faces(sMatName, tmp_new, this_tag);
00292                     m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new[0]) " << std::endl;
00293                     m_PyCubGeomFile << "cyls[" << b-1 << "] = tmp_new" << std::endl;
00294 
00295                     // copy the new into the cyl array
00296                     cyls[b-1] = tmp_new;
00297                     tmp_vol=NULL;
00298                   }
00299               }
00300             if(nDuctIndex > 0){
00301                 m_PyCubGeomFile << "cp_inpins.append([])" << std::endl;
00302                 for (int count = 0; count < (int) cp_in.size(); count++){
00303                     cp_inpins[nDuctIndex-1].push_back(cp_in[count]);
00304                     m_PyCubGeomFile << "cp_inpins[" << nDuctIndex-1 << "].append(cp_in[" << count << "])" << std::endl;
00305                   }
00306               }
00307             cp_in.clear();
00308             m_PyCubGeomFile << "cp_in[:] =[]" << std::endl;
00309           }
00310       }
00311     // this branch of the routine is responsible for creating cylinders with '0' cells
00312     if(nCells == 0){
00313 
00314         // get cylinder data
00315         m_Pincell(i).GetNumCyl(nCyl);
00316         nCells = nCyl;
00317 
00318         for(int n=1;n<=nCells; n++){
00319             nDuctIndex = -1;
00320             if(m_szGeomType =="hexagonal"){
00321 
00322                 m_Pincell(i).GetPitch(dP, dHeightTotal); // this dHeight is not used in creation
00323               }
00324             // if rectangular geometry
00325             if(m_szGeomType =="rectangular"){
00326 
00327                 m_Pincell(i).GetPitch(PX, PY, PZ);
00328               }
00329 
00330             // loop and create cylinders
00331             if(nCyl > 0){
00332                 m_Pincell(i).GetCylSizes(n, nRadii);
00333                 SimpleArray<iBase_EntityHandle> cyls(nRadii);
00334 
00335                 //declare variables
00336                 CVector<double> dVCylRadii(2*nRadii);
00337                 CVector<std::string> szVMat(nRadii);
00338                 CVector<std::string> szVCylMat(nRadii);
00339                 int nType = 0;
00340                 //get values
00341                 m_Pincell(i).GetCylRadii(n, dVCylRadii);
00342                 m_Pincell(i).GetCylPos(n, dVCylXYPos);
00343                 m_Pincell(i).GetCylMat(n, szVCylMat);
00344                 m_Pincell(i).GetCylZPos(n, dVCylZPos);
00345                 m_Pincell(i).GetCellType(n, nType);
00346 
00347                 dHeight = dVCylZPos(2)-dVCylZPos(1);
00348 
00349                 // get the index for cp_inpins based on Z-heights
00350                 for (int dd = 1; dd <= m_nDuct; dd++){
00351                     if((m_dMZAssm(dd, 2)) >= (dVCylZPos(2)) && (m_dMZAssm(dd, 1)) >= (dVCylZPos(1)))
00352                       nDuctIndex = dd;
00353                     if (nDuctIndex != -1)
00354                       break;
00355                   }
00356 
00357                 m_PyCubGeomFile << "cyls = [] \ncp_in = []" << std::endl;
00358                 m_PyCubGeomFile << "sub1 = [] \nsub2 = []" << std::endl;
00359 
00360                 for (int m=1; m<=nRadii; m++){
00361                     if (nType == 0){
00362 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00363                         iGeom_createCylinder(igeomImpl->instance(), dHeight, dVCylRadii(m), dVCylRadii(m),
00364                                              &cyl, &err);
00365 #endif
00366                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ")" << std::endl;
00367                       }
00368                     else{
00369 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00370                         iGeom_createCone(igeomImpl->instance(), dHeight, dVCylRadii(2*m - 1), dVCylRadii(2*m - 1), dVCylRadii(2*m),
00371                                          &cyl, &err);
00372 #endif
00373                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m) << ")" << std::endl;
00374                       }
00375 
00376                     // move their centers and also move to the assembly location  ! Modify if cyl is outside brick
00377                     dCylMoveX = dVCylXYPos(1)+dX;
00378                     dCylMoveY = dVCylXYPos(2)+dY;
00379                     dZMove = (dVCylZPos(1)+dVCylZPos(2))/2.0;
00380 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00381                     iGeom_moveEnt(igeomImpl->instance(), cyl, dCylMoveX, dCylMoveY, dZMove, &err);
00382 #endif
00383                     m_PyCubGeomFile << "vector = [" << dCylMoveX << ", " << dCylMoveY << ", " << dZMove << "]" << std::endl;
00384                     m_PyCubGeomFile << "cubit.move( cyl, vector)" << std::endl;
00385                     m_PyCubGeomFile << "cyls.append(cyl)" << std::endl;
00386                     cyls[m-1] = cyl;
00387                   }
00388 
00389                 //set tag on inner most cylinder, search for the full name of the abbreviated Cell Mat
00390                 for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00391                     if(strcmp (szVCylMat(1).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00392                         sMatName = m_szAssmMat(p);
00393                       }
00394                   }
00395                 std::cout << "created: " << sMatName << std::endl;
00396                 tmp_vol1=cyls[0]; //inner most cyl
00397 
00398                 cp_in.push_back(tmp_vol1);
00399                 m_PyCubGeomFile << "tmp_vol1 = cyls[0] \ncp_in.append(tmp_vol1)" << std::endl;
00400 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00401                 iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00402                               sMatName.c_str(), 10, &err);
00403 #endif
00404                 m_PyCubGeomFile  << "lid =cyls[0].id()" << std::endl;
00405                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00406 
00407 
00408                 if(strcmp(m_szInfo.c_str(),"on") == 0){
00409 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00410                     iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00411                                   pin_name.c_str(), pin_name.size(), &err);
00412 #endif
00413                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00414 
00415                     std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00416                   }
00417 
00418                 Name_Faces(sMatName, tmp_vol1, this_tag);
00419                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_vol1) " << std::endl;
00420 
00421                 // other cyl annulus after substraction
00422                 for (int b=nRadii; b>1; b--){
00423 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00424                     iGeom_copyEnt(igeomImpl->instance(), cyls[b-2], &tmp_vol, &err);
00425 #endif
00426                     m_PyCubGeomFile << "# SUBTRACTING ANNULUS ##\ntmp_vol = cubit.copy_body(cyls[" << b-2 << "])" << std::endl;
00427 
00428                     //subtract tmp vol from the outer most
00429 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00430                     iGeom_subtractEnts(igeomImpl->instance(), cyls[b-1], tmp_vol, &tmp_new, &err);
00431 #endif
00432                     m_PyCubGeomFile << "sub1.append(cyls[" << b-1 << "])\nsub2.append(tmp_vol)" << std::endl;
00433                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00434                     m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl;
00435 
00436                     // now search for the full name of the abbreviated Cell Mat
00437                     for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00438                         if(strcmp (szVCylMat(b).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00439                             sMatName =  m_szAssmMat(p);
00440                           }
00441                       }
00442                     std::cout <<"created: " << sMatName << std::endl;
00443 
00444                     cp_in.push_back(tmp_new);
00445                     m_PyCubGeomFile << "cp_in.append(tmp_new[0])" << std::endl;
00446 
00447                     // set the name of the annulus
00448 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00449                     iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00450                                   sMatName.c_str(),sMatName.size(), &err);
00451 #endif
00452                     m_PyCubGeomFile  << "lid = tmp_new[0].id()" << std::endl;
00453                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00454                     if(strcmp(m_szInfo.c_str(),"on") == 0){
00455 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00456                         iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00457                                       pin_name.c_str(), pin_name.size(), &err);
00458 #endif
00459                         m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00460 
00461                         std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00462                       }
00463 
00464                     Name_Faces(sMatName, tmp_new, this_tag);
00465                     m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new[0]) " << std::endl;
00466                     m_PyCubGeomFile << "cyls[" << b-1 << "] = tmp_new" << std::endl;
00467 
00468                     // copy the new into the cyl array
00469                     cyls[b-1] = tmp_new;
00470                   }
00471               }
00472             if(nDuctIndex > 0){
00473                 m_PyCubGeomFile << "cp_inpins.append([])" << std::endl;
00474                 for (int count = 0; count < (int) cp_in.size(); count++){
00475                     cp_inpins[nDuctIndex-1].push_back(cp_in[count]);
00476                     m_PyCubGeomFile << "cp_inpins["<< nDuctIndex -1 << "].append(cp_in[" << count << "])" << std::endl;
00477 
00478                   }
00479               }
00480             cp_in.clear();
00481             m_PyCubGeomFile << "cp_in[:] =[]" << std::endl;
00482 
00483           }
00484       }
00485 
00486   }
00487 
00488 
00489   void AssyGen::CreatePinCell_Intersect(int i, double dX, double dY, double dZ)
00490   //---------------------------------------------------------------------------
00491   //Function: Create pincell i in location dX dY and dZ
00492   //Input:    none
00493   //Output:   none
00494   //---------------------------------------------------------------------------
00495   {
00496     int nRadii=0, nCyl=0, nCells = 0;
00497     double dCylMoveX = 0.0, dCylMoveY = 0.0, dHeightTotal = 0.0;
00498     double dHeight =0.0,dZMove = 0.0, PX = 0.0,PY = 0.0,PZ = 0.0, dP=0.0;
00499     CVector<double> dVCylZPos(2), dVCylXYPos(2), dVEndZ, dVStartZ;
00500     CVector<std::string> szVCellMat;
00501     iBase_EntityHandle cell = NULL, cyl= NULL, tmp_vol1= NULL, tmp_new= NULL, cell_copy = NULL, intersec = NULL;
00502     std::vector<iBase_EntityHandle> cp_in;
00503 
00504     // name tag handle
00505     iBase_TagHandle this_tag= NULL;
00506     std::string sMatName = "";
00507     std::string sMatName0 = "";
00508     std::string sMatName1 = "";
00509     int nDuctIndex = -1;
00510 
00511     if(strcmp(m_szInfo.c_str(),"on") == 0){
00512         std::ostringstream os;
00513         pin_name = "_xp";
00514         os << (m_nTotalPincells + m_nStartpinid - 1);
00515         os << "_";
00516         std::string pid = os.str(); //retrieve as a string
00517         pin_name+=pid;
00518       }
00519 
00520     // get tag handle for 'NAME' tag, already created as iGeom instance is created
00521 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00522     char* tag_name = (char*)"NAME";    
00523     iGeom_getTagHandle(igeomImpl->instance(), tag_name, &this_tag, &err, 4);
00524 #endif
00525 
00526     // get cell material
00527     m_Pincell(i).GetCellMatSize(nCells);
00528     m_Pincell(i).GetNumCyl(nCyl);
00529     SimpleArray<iBase_EntityHandle> cells(nCells);
00530 
00531     // branch when cells are present
00532     if(nCells > 0){
00533         dVStartZ.SetSize(nCells);
00534         dVEndZ.SetSize(nCells);
00535         szVCellMat.SetSize(nCells);
00536         m_Pincell(i).GetCellMat(dVStartZ, dVEndZ, szVCellMat);
00537 
00538         // get cylinder data
00539         m_Pincell(i).GetNumCyl(nCyl);
00540         m_PyCubGeomFile << "cells = []\ncyls = []\ncp_in = []" << std::endl;
00541 
00542         for(int n=1;n<=nCells; n++){
00543 
00544             dHeight = fabs(dVEndZ(n) - dVStartZ(n));
00545             // get the index for cp_inpins based on Z-heights
00546             for (int dd = 1; dd <= m_nDuct; dd++){
00547                 if((m_dMZAssm(dd, 2)) >= (dVCylZPos(2)) && (m_dMZAssm(dd, 1)) >= (dVCylZPos(1)))
00548                   nDuctIndex = dd;
00549                 if (nDuctIndex != -1)
00550                   break;
00551               }
00552             if(m_szGeomType =="hexagonal"){
00553 
00554                 m_Pincell(i).GetPitch(dP, dHeightTotal); // this dHeight is not used in creation
00555 
00556                 double dSide = dP/(sqrt(3));
00557 
00558                 if(nCells >0){
00559                     // create prism
00560 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00561                     iGeom_createPrism(igeomImpl->instance(), dHeight, 6,
00562                                       dSide, dSide,
00563                                       &cell, &err);
00564 #endif
00565                     m_PyCubGeomFile << "cell = cubit.prism(' " << dHeight << ", 6, " << dSide << ", " << dSide << ")" << std::endl;                  }
00566               }
00567             // if rectangular geometry
00568             if(m_szGeomType =="rectangular"){
00569 
00570                 m_Pincell(i).GetPitch(PX, PY, PZ);
00571 
00572                 if(nCells >0){
00573                     // create brick
00574 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00575                     iGeom_createBrick( igeomImpl->instance(),PX,PY,dHeight,&cell,&err );
00576 #endif
00577                     m_PyCubGeomFile << "cell = cubit.brick(' " << PX << ", " << PY << ", " << dHeight << ")" << std::endl;                  }
00578               }
00579 
00580             dZMove = (dVStartZ(n)+dVEndZ(n))/2.0;
00581 
00582             if(nCells > 0){
00583                 // position the brick in assembly
00584 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00585                 iGeom_moveEnt(igeomImpl->instance(), cell, dX, dY, dZMove, &err);
00586 #endif
00587                 m_PyCubGeomFile << "vector = [" << dX << ", " << dY << ", " << dZMove << "]" << std::endl;
00588                 m_PyCubGeomFile << "cubit.move( cell, vector)" << std::endl;
00589                 m_PyCubGeomFile << "cells.append(cell)" << std::endl;
00590 
00591                 cells[n-1]=cell;
00592               }
00593             // loop and create cylinders
00594             if(nCyl > 0){
00595                 m_Pincell(i).GetCylSizes(n, nRadii);
00596                 SimpleArray<iBase_EntityHandle> cyls(nRadii);
00597                 SimpleArray<iBase_EntityHandle> cell_copys(nRadii);
00598                 SimpleArray<iBase_EntityHandle> intersec_main(nRadii);
00599                 iBase_EntityHandle  tmp_intersec = NULL;
00600                 (void) tmp_intersec;
00601                 //declare variables
00602                 CVector<double> dVCylRadii(2*nRadii);
00603                 CVector<std::string> szVMat(nRadii);
00604                 CVector<std::string> szVCylMat(nRadii);
00605                 int nType = 0;
00606                 //get values
00607                 m_Pincell(i).GetCylRadii(n, dVCylRadii);
00608                 m_Pincell(i).GetCylPos(n, dVCylXYPos);
00609                 m_Pincell(i).GetCylMat(n, szVCylMat);
00610                 m_Pincell(i).GetCylZPos(n, dVCylZPos);
00611                 m_Pincell(i).GetCellType(n, nType);
00612 
00613                 dHeight = dVCylZPos(2)-dVCylZPos(1);
00614 
00615                 m_PyCubGeomFile << "cells_copy=[]\nintersec_main=[]" << std::endl;
00616                 m_PyCubGeomFile << "cyls = [] \ncp_in = []" << std::endl;
00617                 m_PyCubGeomFile << "sub1 = [] \nsub2 = []" << std::endl;
00618                 for (int m=1; m<=nRadii; m++){
00619                     if (nType == 0){
00620 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00621                         iGeom_createCylinder(igeomImpl->instance(), dHeight, dVCylRadii(m), dVCylRadii(m),
00622                                              &cyl, &err);
00623 #endif
00624                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ")" << std::endl;
00625                       }
00626                     else{
00627 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00628                         iGeom_createCone(igeomImpl->instance(), dHeight, dVCylRadii(2*m-1), dVCylRadii(2*m-1), dVCylRadii(2*m),
00629                                          &cyl, &err);
00630 #endif
00631                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m) << ")" << std::endl;
00632                       }
00633 
00634                     // move their centers and also move to the assembly location  ! Modify if cyl is outside brick
00635                     dCylMoveX = dVCylXYPos(1)+dX;
00636                     dCylMoveY = dVCylXYPos(2)+dY;
00637                     dZMove = (dVCylZPos(1)+dVCylZPos(2))/2.0;
00638 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00639                     iGeom_moveEnt(igeomImpl->instance(), cyl, dCylMoveX,dCylMoveY,dZMove, &err);
00640 #endif
00641                     m_PyCubGeomFile << "vector = [" << dCylMoveX << ", " << dCylMoveY << ", " << dZMove << "]" << std::endl;
00642                     m_PyCubGeomFile << "cubit.move( cell, vector)" << std::endl;
00643                     m_PyCubGeomFile << "cyls.append(cyl)" << std::endl;
00644                     cyls[m-1] = cyl;
00645 
00646 
00647                     //copy cell nRadii  times for intersection with cylinders
00648 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00649                     iGeom_copyEnt(igeomImpl->instance(), cells[n-1], &cell_copy, &err);
00650 #endif
00651                     m_PyCubGeomFile << "cell_copy = cubit.copy_body(cells[" << n-1 << "])" << std::endl;
00652                     m_PyCubGeomFile << "cells_copy.append(cell_copy)" << std::endl;
00653                     cell_copys[m-1] = cell_copy;
00654 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00655                     iGeom_intersectEnts(igeomImpl->instance(), cell_copys[m-1], cyls[m-1],&intersec,&err);
00656 #endif
00657                     m_PyCubGeomFile << "tmpunite = cubit.unite(cells_copy[" << m-1 << "]\ncyls [" << m-1 << "])" << std::endl;
00658                     m_PyCubGeomFile << "intersec = cubit.subtract(tmpunite, cells_copy[" << m-1 << "])" << std::endl;
00659                     m_PyCubGeomFile << "intersec_main.append(intersec)" << std::endl;
00660                     intersec_main[m-1] = intersec;
00661                     intersec = NULL;
00662                   }
00663 
00664                 //set tag on inner most cylinder, search for the full name of the abbreviated Cell Mat
00665                 tmp_vol1=intersec_main[0];
00666                 m_PyCubGeomFile << "tmp_vol1 = intersec_main[0]" << std::endl;
00667                 for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00668                     if(strcmp (szVCylMat(1).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00669                         sMatName = m_szAssmMat(p);
00670                       }
00671                   }
00672                 m_PyCubGeomFile << "tmp_vol1 = cyls[0] \ncp_in.append(tmp_vol1)" << std::endl;
00673                 cp_in.push_back(tmp_vol1);
00674 
00675 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00676                 iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00677                               sMatName.c_str(), 10, &err);
00678 #endif
00679                 m_PyCubGeomFile  << "lid =tmp_vol1.id()" << std::endl;
00680                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00681 
00682                 if(strcmp(m_szInfo.c_str(),"on") == 0){
00683 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00684                     iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00685                                   pin_name.c_str(), pin_name.size(), &err);
00686 #endif
00687                     std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00688                   }
00689                 Name_Faces(sMatName, tmp_vol1, this_tag);
00690                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_vol1) " << std::endl;
00691 
00692                 // copy the outermost cyl
00693 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00694                 iGeom_copyEnt(igeomImpl->instance(), intersec_main[nRadii-1], &tmp_intersec, &err);
00695 #endif
00696                 m_PyCubGeomFile << "tmp_intersec = cubit.copy_body(intersec_main[" << nRadii-1 << "])" << std::endl;
00697 
00698                 // subtract the outermost cyl from the cell
00699 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00700                 iGeom_subtractEnts(igeomImpl->instance(), cells[n-1], tmp_intersec, &tmp_new, &err);
00701 #endif
00702                 m_PyCubGeomFile << "sub1.append(tmp_intersec\nsub2.append(cells["<< n-1 << "])" << std::endl;
00703                 m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00704                 m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl;                
00705                 // now search for the full name of the abbreviated Cell Mat
00706                 //  int tag_no;
00707                 for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00708                     if(strcmp (szVCellMat(n).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00709                         //      tag_no = p;
00710                         sMatName =  m_szAssmMat(p);
00711                       }
00712                   }
00713                 std::cout << "created: " << sMatName << std::endl;
00714 
00715                 cp_in.push_back(tmp_new);
00716                 m_PyCubGeomFile << "cp_in.append(tmp_new)" << std::endl;
00717 
00718                 // set the name of the annulus
00719 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00720                 iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00721                               sMatName.c_str(),sMatName.size(), &err);
00722 #endif
00723                 m_PyCubGeomFile  << "lid =tmp_new.id()" << std::endl;
00724                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00725 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00726                 iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00727                               pin_name.c_str(), pin_name.size(), &err);
00728 #endif
00729                 std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00730                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00731 
00732                 Name_Faces(sMatName, tmp_new, this_tag);
00733                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new) " << std::endl;
00734 
00735                 for (int b=nRadii; b>1; b--){
00736 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00737                     iGeom_copyEnt(igeomImpl->instance(), intersec_main[b-2], &tmp_intersec, &err);
00738 #endif
00739                     m_PyCubGeomFile << "tmp_intersec = cubit.copy_body(intersec_main[" << b-1 << "])" << std::endl;
00740 
00741                     //subtract tmp vol from the outer most
00742 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00743                     iGeom_subtractEnts(igeomImpl->instance(), intersec_main[b-1], tmp_intersec, &tmp_new, &err);
00744 #endif
00745                     m_PyCubGeomFile << "sub1.append(tmp_intersec\nsub2.append(intersec_main["<< b-1 << "])" << std::endl;
00746                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00747                     m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl; 
00748                     // now search for the full name of the abbreviated Cell Mat
00749                     //    int tag_no;
00750                     for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00751                         if(strcmp (szVCylMat(b).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00752                             //        tag_no = p;
00753                             sMatName =  m_szAssmMat(p);
00754                           }
00755                       }
00756                     std::cout << "created: " << sMatName << std::endl;
00757 
00758                     cp_in.push_back(tmp_new);
00759                     m_PyCubGeomFile << "cp_in.append(tmp_new)" << std::endl;
00760 
00761                     // set the name of the annulus
00762 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00763                     iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00764                                   sMatName.c_str(),sMatName.size(), &err);
00765 #endif
00766                     m_PyCubGeomFile  << "lid =tmp_new.id()" << std::endl;
00767                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00768 
00769                     if(strcmp(m_szInfo.c_str(),"on") == 0){
00770 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00771                         iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00772                                       pin_name.c_str(), pin_name.size(), &err);
00773 #endif
00774                         std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00775                       }
00776                     Name_Faces(sMatName, tmp_new, this_tag);
00777                     m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new) " << std::endl;
00778                     m_PyCubGeomFile << "cyls[" << b-1 << "] = tmp_new" << std::endl;
00779 
00780                     // copy the new into the cyl array
00781                     cyls[b-1] = tmp_new;
00782 
00783                   }
00784               }
00785             if(nDuctIndex > 0){
00786                 for (int count = 0; count < (int) cp_in.size(); count++){
00787                   cp_inpins[nDuctIndex-1].push_back(cp_in[count]);
00788                   m_PyCubGeomFile << "cp_inpins["<< nDuctIndex -1 << "].append(cp_in[" << count << "])" << std::endl;
00789                 }
00790 
00791               }
00792             cp_in.clear();
00793             m_PyCubGeomFile << "cp_in[:] =[]" << std::endl;
00794 
00795           }
00796       }
00797     // this branch of the routine is responsible for creating cylinders with '0' cells
00798     if(nCells == 0){
00799 
00800         // get cylinder data
00801         m_Pincell(i).GetNumCyl(nCyl);
00802         nCells = nCyl;
00803         cells.resize(nCells);
00804 
00805         for(int n=1;n<=nCells; n++){
00806 
00807             // get some cylinder parameters to create the cell material for intersection
00808             m_Pincell(i).GetCylZPos(n, dVCylZPos);
00809             dHeight = dVCylZPos(2)-dVCylZPos(1);
00810             dZMove = (dVCylZPos(1)+dVCylZPos(2))/2.0;
00811 
00812             if(m_szGeomType =="hexagonal"){
00813 
00814                 m_Pincell(i).GetPitch(dP, dHeightTotal); // this dHeight is not used in creation
00815 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00816                 double dSide = dP/(sqrt(3));                
00817                 iGeom_createPrism(igeomImpl->instance(), dHeight, 6,
00818                                   dSide, dSide,
00819                                   &cell, &err);
00820 #endif
00821               }
00822             m_PyCubGeomFile << "cyls = [] \ncp_in = []\ncells = []" << std::endl;
00823             m_PyCubGeomFile << "sub1 = [] \nsub2 = []" << std::endl;
00824             // if rectangular geometry
00825             if(m_szGeomType =="rectangular"){
00826 
00827                 m_Pincell(i).GetPitch(PX, PY, PZ);
00828                 // create brick
00829 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00830                 iGeom_createBrick( igeomImpl->instance(),PX,PY,PZ, &cell,&err );
00831 #endif
00832                 m_PyCubGeomFile << "cell = cubit.brick(' " << PX << ", " << PY << ", " << PZ << ")" << std::endl;                 
00833               }
00834 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00835             iGeom_moveEnt(igeomImpl->instance(), cell, dX, dY, dZMove, &err);
00836 #endif
00837             m_PyCubGeomFile << "vector = [" << dX << ", " << dY << ", " << dZMove << "]" << std::endl;
00838             m_PyCubGeomFile << "cubit.move( cell, vector)" << std::endl;
00839             m_PyCubGeomFile << "cells.append(cell)" << std::endl;
00840             cells[n-1]=cell;
00841             // loop and create cylinders
00842             if(nCyl > 0){
00843                 m_Pincell(i).GetCylSizes(n, nRadii);
00844 
00845                 //declare variables
00846                 SimpleArray<iBase_EntityHandle> cyls(nRadii), cell_copys(nRadii), intersec_main(nRadii), intersec_copy(nRadii);
00847                 iBase_EntityHandle  tmp_intersec = NULL;
00848                 (void) tmp_intersec;
00849                 CVector<double> dVCylRadii(2*nRadii);
00850                 CVector<std::string> szVMat(nRadii), szVCylMat(nRadii);
00851                 int nType = 0;
00852                 //get values
00853                 m_Pincell(i).GetCylRadii(n, dVCylRadii);
00854                 m_Pincell(i).GetCylPos(n, dVCylXYPos);
00855                 m_Pincell(i).GetCylMat(n, szVCylMat);
00856                 m_Pincell(i).GetCellType(n, nType);
00857 
00858 
00859                 // get the index for cp_inpins based on Z-heights
00860                 for (int dd = 1; dd <= m_nDuct; dd++){
00861                     if((m_dMZAssm(dd, 2)) >= (dVCylZPos(2)) && (m_dMZAssm(dd, 1)) >= (dVCylZPos(1)))
00862                       nDuctIndex = dd;
00863                     if (nDuctIndex != -1)
00864                       break;
00865                   }
00866 
00867                 for (int m=1; m<=nRadii; m++){
00868                     if (nType == 0){
00869 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00870                         iGeom_createCylinder(igeomImpl->instance(), dHeight, dVCylRadii(m), dVCylRadii(m),
00871                                              &cyl, &err);
00872 #endif
00873                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ", " << dVCylRadii(m) << ")" << std::endl;
00874                       }
00875                     else{
00876 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00877                         iGeom_createCone(igeomImpl->instance(), dHeight, dVCylRadii(2*m-1), dVCylRadii(2*m-1), dVCylRadii(2*m),
00878                                          &cyl, &err);
00879 #endif
00880                         m_PyCubGeomFile << "#\n#\ncyl = cubit.cylinder(" << dHeight << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m-1) << ", " << dVCylRadii(2*m) << ")" << std::endl;
00881                       }
00882 
00883                     // move their centers and also move to the assembly location  ! Modify if cyl is outside brick
00884                     dCylMoveX = dVCylXYPos(1)+dX;
00885                     dCylMoveY = dVCylXYPos(2)+dY;
00886 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00887                     iGeom_moveEnt(igeomImpl->instance(), cyl, dCylMoveX,dCylMoveY,dZMove, &err);
00888 #endif
00889                     m_PyCubGeomFile << "vector = [" << dCylMoveX << ", " << dCylMoveY << ", " << dZMove << "]" << std::endl;
00890                     m_PyCubGeomFile << "cubit.move( cell, vector)" << std::endl;
00891                     m_PyCubGeomFile << "cyls.append(cyl)" << std::endl;
00892 
00893                     cyls[m-1] = cyl;
00894 
00895                     //copy cell nRadii  times for intersection with cylinders
00896 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00897                     iGeom_copyEnt(igeomImpl->instance(), cells[n-1], &cell_copy, &err);
00898 #endif
00899                     m_PyCubGeomFile << "cell_copy = cubit.copy_body(cells[" << n-1 << "])" << std::endl;
00900                     m_PyCubGeomFile << "cells_copy.append(cell_copy)" << std::endl;
00901 
00902                     cell_copys[m-1] = cell_copy;
00903 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00904                     iGeom_intersectEnts(igeomImpl->instance(), cell_copy, cyls[m-1],&intersec,&err);
00905 #endif
00906                     m_PyCubGeomFile << "tmpunite = cubit.unite(cells_copy[" << m-1 << "], cyls [" << m-1 << "])" << std::endl;
00907                     m_PyCubGeomFile << "intersec = cubit.subtract(tmpunite, cells_copy[" << m-1 << "])" << std::endl;
00908                     m_PyCubGeomFile << "intersec_main.append(intersec)" << std::endl;
00909 
00910                     intersec_main[m-1] = intersec;
00911                     intersec = NULL;
00912                   }
00913 
00914                 //set tag on inner most cylinder, search for the full name of the abbreviated Cell Mat
00915                 tmp_vol1=intersec_main[0];
00916                 m_PyCubGeomFile << "tmp_vol1 = intersec_main[0]" << std::endl;
00917 
00918                 for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00919                     if(strcmp (szVCylMat(1).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00920                         sMatName = m_szAssmMat(p);
00921                       }
00922                   }
00923 
00924                 m_PyCubGeomFile << "tmp_vol1 = cyls[0] \ncp_in.append(tmp_vol1)" << std::endl;
00925                 cp_in.push_back(tmp_vol1);
00926 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00927                 iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00928                               sMatName.c_str(), 10, &err);
00929 #endif
00930                 m_PyCubGeomFile  << "lid =tmp_vol1.id()" << std::endl;
00931                 m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00932 
00933                 if(strcmp(m_szInfo.c_str(),"on") == 0){
00934 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00935                     iGeom_setData(igeomImpl->instance(), tmp_vol1, this_tag,
00936                                   pin_name.c_str(), pin_name.size(), &err);
00937 #endif
00938                     std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00939                   }
00940 
00941                 Name_Faces(sMatName, tmp_vol1, this_tag);
00942                 m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_vol1) " << std::endl;
00943 
00944                 // delete the cell as this is the case when no. cell material is specified
00945 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00946                 iGeom_deleteEnt(igeomImpl->instance(), cells[n-1], &err);
00947 #endif
00948                 m_PyCubGeomFile << "cubit.cmd('delete vol << cells[" << n-1 << "].id()')" << std::endl;
00949 
00950 
00951                 // other cyl annulus after substraction
00952                 for (int b=nRadii; b>1; b--){
00953 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00954                     iGeom_copyEnt(igeomImpl->instance(), intersec_main[b-2], &tmp_intersec, &err);
00955 #endif
00956                     m_PyCubGeomFile << "tmp_intersec = cubit.copy_body(intersec_main[" << b-2 << "])" << std::endl;
00957 
00958                     //subtract tmp vol from the outer most
00959 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00960                     iGeom_subtractEnts(igeomImpl->instance(), intersec_main[b-1], tmp_intersec, &tmp_new, &err);
00961 #endif
00962                     m_PyCubGeomFile << "sub1.append(tmp_intersec\nsub2.append(intersec_main["<< b-1 << "])" << std::endl;
00963                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub2, sub1)" << std::endl;
00964                     m_PyCubGeomFile << "sub1[:] = []\nsub2[:] = []" << std::endl; 
00965 
00966                     // now search for the full name of the abbreviated Cell Mat
00967                     //    int tag_no;
00968                     for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
00969                         if(strcmp (szVCylMat(b).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
00970                             //        tag_no = p;
00971                             sMatName =  m_szAssmMat(p);
00972                           }
00973                       }
00974                     std::cout << "created: " << sMatName << std::endl;
00975 
00976                     m_PyCubGeomFile << "cp_in.append(tmp_new)" << std::endl;
00977                     cp_in.push_back(tmp_new);
00978 
00979                     // set the name of the annulus
00980 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00981                     iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00982                                   sMatName.c_str(),sMatName.size(), &err);
00983 #endif
00984 
00985                     m_PyCubGeomFile  << "lid =tmp_new.id()" << std::endl;
00986                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
00987                     
00988                     if(strcmp(m_szInfo.c_str(),"on") == 0){
00989 #if defined (HAVE_ACIS) || defined (HAVE_OCC)
00990                         iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
00991                                       pin_name.c_str(), pin_name.size(), &err);
00992 #endif
00993                         std::cout << "Naming pin body :" <<  pin_name<< std::endl;
00994                         m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << pin_name <<  "\" )" << std::endl;
00995                       }
00996 
00997                     Name_Faces(sMatName, tmp_new, this_tag);
00998                     m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new) " << std::endl;
00999                     m_PyCubGeomFile << "cyls[" << b-1 << "] = tmp_new" << std::endl;
01000 
01001                     // copy the new into the cyl array
01002                     cyls[b-1] = tmp_new;
01003 
01004                   }
01005               }
01006             if(nDuctIndex > 0){
01007                 for (int count = 0; count < (int) cp_in.size(); count++){
01008                   cp_inpins[nDuctIndex-1].push_back(cp_in[count]);
01009                   m_PyCubGeomFile << "cp_inpins["<< nDuctIndex -1 << "].append(cp_in[" << count << "])" << std::endl;
01010                 }
01011 
01012               }
01013             cp_in.clear();
01014             m_PyCubGeomFile << "cp_in[:] =[]" << std::endl;
01015 
01016           }
01017       }
01018 
01019   }
01020 
01021 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines