25 #include "../ObjectClass.h"
26 #include "../../segment/ObjectClassMemorySegment.h"
38 SECRelation::SECRelation(
const std::string& relationName,
const memoryx::ObjectClassList& possibleObjects1,
const memoryx::ObjectClassList& possibleObjects2)
43 objects1 = possibleObjects1;
44 objects2 = possibleObjects2;
47 SECRelation::SECRelation(
const std::string& relationName,
const ObjectClassBasePtr& possibleObject1,
const ObjectClassBasePtr& possibleObject2)
52 objects1.push_back(possibleObject1);
53 objects2.push_back(possibleObject2);
63 return _isEqual(other, ignoreName,
false);
104 if (!ignoreName &&
getName() != other->getName())
109 bool foundMatchObj1 =
false;
111 for (ObjectClassList::const_iterator it = objects1.begin(); it != objects1.end(); it++)
113 for (ObjectClassList::const_iterator itOther = other->objects1.begin(); itOther != other->objects1.end(); itOther++)
116 if ((*it)->compare(*itOther) == eEqualClass )
118 foundMatchObj1 =
true;
123 bool foundMatchObj2 =
false;
125 for (ObjectClassList::const_iterator it = objects2.begin(); it != objects2.end(); it++)
127 for (ObjectClassList::const_iterator itOther = other->objects2.begin(); itOther != other->objects2.end(); itOther++)
130 if ((*it)->compare(*itOther) == eEqualClass )
132 foundMatchObj2 =
true;
137 bool result = foundMatchObj1 && foundMatchObj2;
139 if (!result && !reversed)
141 SECRelationBasePtr inverseRelation =
new SECRelation(
getName(), other->objects2, other->objects1);
142 return _isEqual(inverseRelation, ignoreName,
true);
152 name =
"NoConnection";
156 :
SECRelation(
"NoConnection", possibleObjects1, possibleObjects2)
162 SECRelation(
"NoConnection", possibleObject1, possibleObject2)
173 :
SECRelation(
"Touching", possibleObjects1, possibleObjects2)
179 SECRelation(
"Touching", possibleObject1, possibleObject2)
189 :
SECRelation(
"BehindOf", possibleObjects1, possibleObjects2)
195 SECRelation(
"BehindOf", possibleObject1, possibleObject2)
205 :
SECRelation(
"LeftTo", possibleObjects1, possibleObjects2)
211 SECRelation(
"LeftTo", possibleObject1, possibleObject2)
221 :
SECRelation(
"RightTo", possibleObjects1, possibleObjects2)
227 SECRelation(
"RightTo", possibleObject1, possibleObject2)
235 result->name = getName();
237 for (ObjectClassList::const_iterator it = objects1.begin(); it != objects1.end(); it++)
239 result->objects1.push_back(ObjectClassBasePtr::dynamicCast((*it)->ice_clone()));
242 for (ObjectClassList::const_iterator it = objects2.begin(); it != objects2.end(); it++)
244 result->objects2.push_back(ObjectClassBasePtr::dynamicCast((*it)->ice_clone()));
252 return getName() +
" between " + objects1ToString() +
" and " + objects2ToString();
268 obj->setString(
"relationName", getName());
276 name = obj->getString(
"relationName");
277 Ice::StringSeq objectStrings1;
278 obj->getStringArray(
"objects1", objectStrings1);
280 for (Ice::StringSeq::iterator it = objectStrings1.begin(); it != objectStrings1.end(); it++)
283 newObj->setName(*it);
284 objects1.push_back(newObj);
287 Ice::StringSeq objectStrings2;
288 obj->getStringArray(
"objects2", objectStrings2);
290 for (Ice::StringSeq::iterator it = objectStrings2.begin(); it != objectStrings2.end(); it++)
293 newObj->setName(*it);
294 objects2.push_back(newObj);