45 #define S_STREAM std::istrstream
48 #define S_STREAM std::istringstream
51 static string EGS_CDGEOMETRY_LOCAL typeStr(
"egs_cdgeometry");
52 string EGS_CDGeometry::type(typeStr);
54 static bool EGS_CDGEOMETRY_LOCAL inputSet =
false;
56 void EGS_CDGeometry::setMedia(
EGS_Input *,
int,
const int *) {
57 egsWarning(
"EGS_CDGeometry::setMedia: don't use this method. Use the\n"
58 " setMedia() methods of the geometry objects that make up this geometry\n");
61 void EGS_CDGeometry::setRelativeRho(
int start,
int end, EGS_Float rho) {
62 egsWarning(
"EGS_CDGeometry::setRelativeRho(): don't use this method\n"
63 " Use the setRelativeRho() methods of the geometry objects that make"
64 " up this geometry\n");
67 void EGS_CDGeometry::setRelativeRho(
EGS_Input *) {
68 egsWarning(
"EGS_CDGeometry::setRelativeRho(): don't use this method\n"
69 " Use the setRelativeRho() methods of the geometry objects that make"
70 " up this geometry\n");
73 void EGS_CDGeometry::setBScaling(
int start,
int end, EGS_Float bf) {
74 egsWarning(
"EGS_CDGeometry::setBScaling(): don't use this method\n"
75 " Use the setBScaling() methods of the geometry objects that make"
76 " up this geometry\n");
79 void EGS_CDGeometry::setBScaling(
EGS_Input *) {
80 egsWarning(
"EGS_CDGeometry::setBScaling(): don't use this method\n"
81 " Use the setBScaling() methods of the geometry objects that make"
82 " up this geometry\n");
85 void EGS_CDGeometry::setUpIndexing() {
88 for (j=0; j<nbase; j++) {
99 for (j=0; j<nbase; j++) {
103 for (
int i=0; i<n; i++) {
118 static void setInputs() {
121 setBaseGeometryInputs(
false);
123 geomBlockInput->getSingleInput(
"library")->setValues(vector<string>(1, typeStr));
126 geomBlockInput->addSingleInput(
"base geometry",
true,
"The name of the geometry that defines regions for this 'cutting device'. It is within these regions that other geometries will be placed to create a composite geometry.");
127 geomBlockInput->addSingleInput(
"set geometry",
true,
"The local region number in the base geometry, followed by the name of the geometry to place in that region. If this geometry extends beyond the region boundaries, it will be cut to size.");
128 geomBlockInput->addSingleInput(
"new indexing style",
false,
"Set to 1 to use a new region numbering algorithm. Defaults to 0, to use the original indexing style.");
131 EGS_CDGEOMETRY_EXPORT
string getExample() {
135 library = EGS_CDGeometry
137 base geometry = my_regions
138 # set geometry = 1 geom means:
139 # in region 1 of the basegeometry, use geometry named "geom"
140 set geometry = 0 my_geom1
141 set geometry = 1 my_geom2
147 EGS_CDGEOMETRY_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
151 return geomBlockInput;
156 egsWarning(
"createGeometry(CD_Geometry): null input?\n");
166 int err = input->
getInput(
"base geometry", bg_name);
168 egsWarning(
"createGeometry(CD_Geometry): no 'base geometry' input\n");
173 egsWarning(
"createGeometry(CD_Geometry): no geometry named %s is"
174 " defined\n",bg_name.c_str());
179 egsWarning(
"createGeometry(CD_Geometry): the base geometry has %d"
185 for (j=0; j<nreg; j++) {
197 if (aux.size() == 2) {
198 string auxx = aux[0];
202 S_STREAM in(auxx.c_str());
203 in >> istart >> name;
204 if (in.fail() || !in.good()) {
205 egsWarning(
"createGeometry(CD_Geometry): parse error in\n"
206 " set geometry = %s\n",auxx.c_str());
211 if (istart < 0 || istart > nreg-1) {
220 else if (aux.size() == 3) {
221 string auxx = aux[0];
227 S_STREAM in(auxx.c_str());
228 in >> istart >> iend >> name;
229 if (in.fail() || !in.good()) {
230 egsWarning(
"createGeometry(CD_Geometry): parse error in\n"
231 " set geometry = %s\n",auxx.c_str());
251 egsWarning(
"createGeometry(CD_Geometry): no geometry named %s"
252 " is defined\n",name.c_str());
256 for (
int j=istart; j<iend; j++) {
257 if (G[j] && G[j] != gj) {
275 egsWarning(
"createGeometry(CD_Geometry): %d errors\n",err);
276 for (j=0; j<nreg; j++) {
278 if (!G[j]->deref()) {
287 egsWarning(
"createGeometry(CD_Geometry): no geometries in addition to"
288 " the base geometry defined?\n"
289 " Hope you know what you are doing\n");
292 input->
getInput(
"new indexing style",indexing);
302 int EGS_CDGeometry::getGlobalRegionOffset(
const string geomName) {
304 for (
int i=0; i<nbase; i++) {
305 if (g[i] && g[i]->
getName() == geomName) {
318 for (
int i=0; i<nbase; i++) {
334 void EGS_CDGeometry::getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize) {
343 for (
int i=0; i<bgregs.size(); i++) {
346 if (bgregs[i] < nbase-1) {
354 rstart = bgregs[i]*nmax;
355 rend = (bgregs[i]+1)*nmax;
357 for (
int j=rstart; j<rend; j++) {
365 for (
int i=0; i<nbase; i++) {
380 for (
int j=0; j<gregs.size(); j++) {
385 regs.insert(regs.end(), gregs.begin(), gregs.end());
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual int getGlobalRegionOffset(const string geomName)
Get the global region number for the first region in the geometry.
int deref()
Decrease the reference count to this geometry.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
int nreg
Number of local regions in this geometry.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
const string & getName() const
Get the name of this geometry.
int regions() const
Returns the number of local regions in this geometry.
int setLabels(EGS_Input *input)
Set the labels from an input block.
int ref()
Increase the reference count to this geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
virtual void getLabelRegions(const string &str, vector< int > ®s, bool sanitize=true)
Get the list of all regions labeled with str.
A "combinatorial dimension" geometry.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.