1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
#include <acisgeom.hpp>
#ifdef ACIS_R17
extern void unlock_spatial_products_661();
#endif
namespace netgen {
ACISGeometry * acisgeometry = NULL;
static VisualSceneACISGeometry vsacisgeom;
extern int ACISGenerateMesh (ACISGeometry & geometry, Mesh*& mesh,
int perfstepsstart, int perfstepsend, char* optstring);
int Ng_ACISCommand (ClientData /* clientData */,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
if (argc >= 2)
{
if (strcmp (argv[1], "isACISavailable") == 0)
{
Tcl_SetResult (interp, (char*)"yes", TCL_STATIC);
return TCL_OK;
}
}
if (!acisgeometry)
{
Tcl_SetResult (interp, (char*)"This operation needs an ACIS geometry", TCL_STATIC);
return TCL_ERROR;
}
if (argc >= 2 && strcmp (argv[1], "getentities") == 0)
{
stringstream str;
const ENTITY_LIST & entlist = acisgeometry -> entlist;
ENTITY_LIST cellList;
api_ct_get_all_cells( entlist, cellList );
for(int j=0; j<cellList.count(); j++)
{
str << "cell" << j << " {Cell " << j << "} \n";
ATTRIB * ap = cellList[j]->attrib();
int k = 0;
while (ap)
{
ATTRIB_GEN_INTEGER * aip = dynamic_cast<ATTRIB_GEN_INTEGER *>(ap);
if (aip)
str << "cell" << j << "/attrib" << k
<< " { name = " << aip->name() << " val = " << aip->value() << "} \n";
else
str << "cell" << j << "/attrib" << k
<< " { typename = " << ap->type_name() << "} \n";
ap = ap->next();
k++;
}
}
for (int i = 0; i < entlist.count(); i++)
{
str << "entity" << i << " {Entity " << i << "} \n";
ENTITY_LIST faceList;
ENTITY_LIST edgeList;
api_get_faces_from_all_entities(entlist[i], faceList);
for(int j=0; j<faceList.count(); j++)
{
FACE * face = (FACE*) faceList[j];
str << "entity" << i << "/face" << j << " {Face " << j << "} \n";
ATTRIB * ap = faceList[j]->attrib();
int k = 0;
while (ap)
{
ATTRIB_GEN_INTEGER * aip = dynamic_cast<ATTRIB_GEN_INTEGER *>(ap);
if (aip)
str << "entity" << i << "/face" << j << "/attrib" << k
<< " { name = " << aip->name() << " val = " << aip->value() << "} \n";
else
str << "entity" << i << "/face" << j << "/attrib" << k
<< " { typename = " << ap->type_name() << "} \n";
ap = ap->next();
k++;
}
SPAbox * box = face->bound();
str << "entity" << i << "/face" << j << "/bbox"
<< " { BBox ("
<< box->low().x() << ", " << box->low().y() << ", " << box->low().z() << ";"
<< box->high().x() << ", " << box->high().y() << ", " << box->high().z() << ")"
<< " }\n";
}
api_get_edges_from_all_entities(entlist[i], edgeList);
for(int j=0; j<edgeList.count(); j++)
{
str << "entity" << i << "/edge" << j << " {Edge " << j << "} \n";
}
}
Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
return TCL_OK;
}
if (argc >= 2 && strcmp (argv[1], "selectentity") == 0)
{
int ientry = -1, iface = -1;
string select = argv[2];
cout << "ACIS selectentity: " << select << endl;
int pos_ent1 = select.find("entity", 0);
int pos_ent2 = select.find("/", pos_ent1);
if (pos_ent1 != -1 && pos_ent2 == -1) pos_ent2 = select.length();
if (pos_ent1 != -1) ientry = atoi (select.substr(pos_ent1+6, pos_ent2).c_str());
int pos_face1 = select.find("face", 0);
int pos_face2 = select.find("/", pos_face1);
if (pos_face1 != -1 && pos_face2 == -1) pos_face2 = select.length();
if (pos_face1 != -1) iface = atoi (select.substr(pos_face1+4, pos_face2).c_str());
cout << "entry = " << ientry << ", face = " << iface << endl;
const ENTITY_LIST & entlist = acisgeometry -> entlist;
if (ientry != -1 && iface == -1)
vsacisgeom.SelectEntity (entlist[ientry]);
if (iface != -1)
{
ENTITY_LIST faceList;
api_get_faces_from_all_entities(entlist[ientry], faceList);
vsacisgeom.SelectEntity (faceList[iface]);
}
}
if (argc >= 2 && strcmp (argv[1], "createct") == 0)
{
acisgeometry -> CreateCT();
}
if (argc >= 2 && strcmp (argv[1], "combineall") == 0)
{
cout << "combineall " << endl;
acisgeometry -> Combine();
}
if (argc >= 4)
{
if (strcmp (argv[1], "subtract") == 0)
{
cout << "subtract " << argv[2] << " minus " << argv[3] << endl;
acisgeometry -> Subtract (atoi (argv[2])-1, atoi (argv[3])-1);
}
}
return TCL_OK;
}
}
|