#include <primitive.h>
Inheritance diagram for NLLIGO::CPrimZone:
Public Types | |
enum | { NotAnArray, AtTheEnd = 0xffffffff } |
Public Member Functions | |
bool | contains (const NLMISC::CVector &v, float &distance, NLMISC::CVector &nearPos, bool isPath) const |
bool | contains (const NLMISC::CVector &v) const |
void | getAABox (NLMISC::CVector &cornerMin, NLMISC::CVector &cornerMax) const |
Returns the smallest axis-aligned box containing the zone. | |
NLMISC::CVector | getBarycentre () const |
Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex. | |
virtual std::string | getClassName ()=0 |
NLMISC_DECLARE_CLASS (CPrimZone) | |
void | serial (NLMISC::IStream &f) |
Hierarchy | |
bool | getChild (IPrimitive *&result, uint childId) |
bool | getChild (const IPrimitive *&result, uint childId) const |
bool | getChildId (uint &childId, const IPrimitive *child) const |
uint | getNumChildren () const |
const IPrimitive * | getParent () const |
IPrimitive * | getParent () |
bool | insertChild (IPrimitive *primitive, uint index=AtTheEnd) |
bool | removeChild (uint childId) |
void | removeChildren () |
Properties | |
bool | addPropertyByName (const char *property_name, IProperty *result) |
uint | getNumProperty () const |
bool | getProperty (uint index, std::string &property_name, IProperty *&result) |
bool | getProperty (uint index, std::string &property_name, const IProperty *&result) const |
bool | getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const |
bool | getPropertyByName (const char *property_name, const std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string &result) const |
bool | getPropertyByName (const char *property_name, std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string *&result) const |
bool | getPropertyByName (const char *property_name, IProperty *&result) const |
bool | getPropertyByName (const char *property_name, const IProperty *&result) const |
void | removeProperties () |
bool | removeProperty (uint index) |
bool | removePropertyByName (const char *property_name) |
Hierarchy | |
bool | getChild (IPrimitive *&result, uint childId) |
bool | getChild (const IPrimitive *&result, uint childId) const |
bool | getChildId (uint &childId, const IPrimitive *child) const |
uint | getNumChildren () const |
const IPrimitive * | getParent () const |
IPrimitive * | getParent () |
bool | insertChild (IPrimitive *primitive, uint index=AtTheEnd) |
bool | removeChild (uint childId) |
void | removeChildren () |
Properties | |
bool | addPropertyByName (const char *property_name, IProperty *result) |
uint | getNumProperty () const |
bool | getProperty (uint index, std::string &property_name, IProperty *&result) |
bool | getProperty (uint index, std::string &property_name, const IProperty *&result) const |
bool | getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const |
bool | getPropertyByName (const char *property_name, const std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string &result) const |
bool | getPropertyByName (const char *property_name, std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string *&result) const |
bool | getPropertyByName (const char *property_name, IProperty *&result) const |
bool | getPropertyByName (const char *property_name, const IProperty *&result) const |
void | removeProperties () |
bool | removeProperty (uint index) |
bool | removePropertyByName (const char *property_name) |
Hierarchy | |
bool | getChild (IPrimitive *&result, uint childId) |
bool | getChild (const IPrimitive *&result, uint childId) const |
bool | getChildId (uint &childId, const IPrimitive *child) const |
uint | getNumChildren () const |
const IPrimitive * | getParent () const |
IPrimitive * | getParent () |
bool | insertChild (IPrimitive *primitive, uint index=AtTheEnd) |
bool | removeChild (uint childId) |
void | removeChildren () |
Properties | |
bool | addPropertyByName (const char *property_name, IProperty *result) |
uint | getNumProperty () const |
bool | getProperty (uint index, std::string &property_name, IProperty *&result) |
bool | getProperty (uint index, std::string &property_name, const IProperty *&result) const |
bool | getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const |
bool | getPropertyByName (const char *property_name, const std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string &result) const |
bool | getPropertyByName (const char *property_name, std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string *&result) const |
bool | getPropertyByName (const char *property_name, IProperty *&result) const |
bool | getPropertyByName (const char *property_name, const IProperty *&result) const |
void | removeProperties () |
bool | removeProperty (uint index) |
bool | removePropertyByName (const char *property_name) |
Hierarchy | |
bool | getChild (IPrimitive *&result, uint childId) |
bool | getChild (const IPrimitive *&result, uint childId) const |
bool | getChildId (uint &childId, const IPrimitive *child) const |
uint | getNumChildren () const |
const IPrimitive * | getParent () const |
IPrimitive * | getParent () |
bool | insertChild (IPrimitive *primitive, uint index=AtTheEnd) |
bool | removeChild (uint childId) |
void | removeChildren () |
Static Public Member Functions | |
bool | contains (const NLMISC::CVector &v, const std::vector< CPrimVector > &points, float &distance, NLMISC::CVector &nearPos, bool isPath) |
bool | contains (const NLMISC::CVector &v, const std::vector< CPrimVector > &points) |
bool | contains (const NLMISC::CVector &v, const std::vector< NLMISC::CVector > &points, float &distance, NLMISC::CVector &nearPos, bool isPath) |
bool | contains (const NLMISC::CVector &v, const std::vector< NLMISC::CVector > &points) |
float | getSegmentDist (const NLMISC::CVector v, const NLMISC::CVector &p1, const NLMISC::CVector &p2, NLMISC::CVector &nearPos) |
Data Fields | |
bool | Expanded |
std::string | Layer |
std::string | Name |
std::vector< CPrimVector > | VPoints |
Private Member Functions | |
virtual IPrimitive * | copy () const |
virtual uint | getNumVector () const |
virtual CPrimVector * | getPrimVector () |
virtual const CPrimVector * | getPrimVector () const |
virtual bool | read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) |
virtual void | write (xmlNodePtr xmlNode, const char *filename) const |
|
Definition at line 165 of file primitive.h.
00166 { 00167 NotAnArray, 00168 AtTheEnd = 0xffffffff, 00169 }; |
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Definition at line 1384 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties. Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::read().
01385 { 01386 bool inserted = _Properties.insert (std::map<std::string, IProperty*>::value_type (property_name, result)).second; 01387 if (inserted) 01388 { 01389 return true; 01390 } 01391 return false; 01392 } |
|
Definition at line 649 of file primitive.cpp. References getSegmentDist(), H_AUTO, min, uint, uint32, and v.
00650 { 00651 H_AUTO(NLLIGO_Contains1) 00652 uint32 i; 00653 CVector vMin, vMax; 00654 float nearest = FLT_MAX; 00655 CVector pos; 00656 00657 // Point or line can't contains ! 00658 if (points.size() < 3 || isPath) 00659 { 00660 // only compute the distance. 00661 if (points.size() == 1) 00662 { 00663 distance = (points[0] - v).norm(); 00664 nearPos = points[0]; 00665 } 00666 else if (points.size() == 2) 00667 { 00668 distance = getSegmentDist(v, points[0], points[1], nearPos); 00669 } 00670 else 00671 { 00672 // compute nearest segment 00673 for (i = 0; i < points.size()-1; ++i) 00674 { 00675 const CVector &p1 = points[i]; 00676 const CVector &p2 = points[i+1]; 00677 00678 float dist = getSegmentDist(v, p1, p2, pos); 00679 if( dist < nearest) 00680 { 00681 nearest = dist; 00682 nearPos = pos; 00683 } 00684 } 00685 distance = nearest; 00686 } 00687 return false; 00688 } 00689 00690 // Get the bounding rectangle of the zone 00691 vMax = vMin = points[0]; 00692 for (i = 0; i < points.size(); ++i) 00693 { 00694 vMin.x = min(vMin.x, points[i].x); 00695 vMin.y = min(vMin.y, points[i].y); 00696 vMax.x = max(vMax.x, points[i].x); 00697 vMax.y = max(vMax.y, points[i].y); 00698 } 00699 00700 if ((v.x < vMin.x) || (v.y < vMin.y) || (v.x > vMax.x) || (v.y > vMax.y)) 00701 { 00702 // find the nearest distance of all segment 00703 for (uint i=0; i<points.size(); ++i) 00704 { 00705 float dist = getSegmentDist(v, points[i], points[(i+1) % points.size()], pos); 00706 00707 if (dist < nearest) 00708 { 00709 nearest = dist; 00710 nearPos = pos; 00711 } 00712 } 00713 distance = nearest; 00714 return false; 00715 } 00716 00717 uint32 nNbIntersection = 0; 00718 for (i = 0; i < points.size(); ++i) 00719 { 00720 const CVector &p1 = points[i]; 00721 const CVector &p2 = points[(i+1)%points.size()]; 00722 00723 float dist = getSegmentDist(v, p1, p2, pos); 00724 if( dist < nearest) 00725 { 00726 nearest = dist; 00727 nearPos = pos; 00728 } 00729 00730 if (((p1.y-v.y) <= 0.0)&&((p2.y-v.y) <= 0.0)) 00731 continue; 00732 if (((p1.y-v.y) > 0.0)&&((p2.y-v.y) > 0.0)) 00733 continue; 00734 float xinter = p1.x + (p2.x-p1.x) * ((v.y-p1.y)/(p2.y-p1.y)); 00735 if (xinter > v.x) 00736 ++nNbIntersection; 00737 } 00738 00739 distance = nearest; 00740 if ((nNbIntersection&1) == 1) // odd intersections so the vertex is inside 00741 return true; 00742 else 00743 return false; 00744 } |
|
Definition at line 270 of file primitive.cpp.
00271 { 00272 uint32 i; 00273 CVector vMin, vMax; 00274 00275 // Point or line can't contains ! 00276 if (points.size() < 3) 00277 return false; 00278 00279 // Get the bounding rectangle of the zone 00280 vMax = vMin = points[0]; 00281 for (i = 0; i < points.size(); ++i) 00282 { 00283 if (vMin.x > points[i].x) 00284 vMin.x = points[i].x; 00285 if (vMin.y > points[i].y) 00286 vMin.y = points[i].y; 00287 00288 if (vMax.x < points[i].x) 00289 vMax.x = points[i].x; 00290 if (vMax.y < points[i].y) 00291 vMax.y = points[i].y; 00292 } 00293 00294 if ((v.x < vMin.x) || (v.y < vMin.y) || (v.x > vMax.x) || (v.y > vMax.y)) 00295 return false; 00296 00297 uint32 nNbIntersection = 0; 00298 for (i = 0; i < points.size(); ++i) 00299 { 00300 const CVector &p1 = points[i]; 00301 const CVector &p2 = points[(i+1)%points.size()]; 00302 00303 if (((p1.y-v.y) <= 0.0)&&((p2.y-v.y) <= 0.0)) 00304 continue; 00305 if (((p1.y-v.y) > 0.0)&&((p2.y-v.y) > 0.0)) 00306 continue; 00307 float xinter = p1.x + (p2.x-p1.x) * ((v.y-p1.y)/(p2.y-p1.y)); 00308 if (xinter > v.x) 00309 ++nNbIntersection; 00310 } 00311 if ((nNbIntersection&1) == 1) // odd intersections so the vertex is inside 00312 return true; 00313 else 00314 return false; 00315 } |
|
Definition at line 748 of file primitive.cpp. References getSegmentDist(), H_AUTO, min, uint, uint32, and v.
00749 { 00750 H_AUTO(NLLIGO_Contains2) 00751 uint32 i; 00752 CVector vMin, vMax; 00753 float nearest = FLT_MAX; 00754 CVector pos; 00755 00756 // Point or line can't contains ! 00757 if (points.size() < 3 || isPath) 00758 { 00759 // only compute the distance. 00760 if (points.size() == 1) 00761 { 00762 distance = (points[0] - v).norm(); 00763 nearPos = points[0]; 00764 } 00765 else if (points.size() == 2) 00766 { 00767 distance = getSegmentDist(v, points[0], points[1], nearPos); 00768 } 00769 else 00770 { 00771 // compute nearest segment 00772 for (i = 0; i < points.size()-1; ++i) 00773 { 00774 const CVector &p1 = points[i]; 00775 const CVector &p2 = points[i+1]; 00776 00777 float dist = getSegmentDist(v, p1, p2, pos); 00778 if( dist < nearest) 00779 { 00780 nearest = dist; 00781 nearPos = pos; 00782 } 00783 } 00784 distance = nearest; 00785 } 00786 return false; 00787 } 00788 00789 // Get the bounding rectangle of the zone 00790 vMax = vMin = points[0]; 00791 for (i = 0; i < points.size(); ++i) 00792 { 00793 vMin.x = min(vMin.x, points[i].x); 00794 vMin.y = min(vMin.y, points[i].y); 00795 vMax.x = max(vMax.x, points[i].x); 00796 vMax.y = max(vMax.y, points[i].y); 00797 } 00798 00799 if ((v.x < vMin.x) || (v.y < vMin.y) || (v.x > vMax.x) || (v.y > vMax.y)) 00800 { 00801 // find the nearest distance of all segment 00802 for (uint i=0; i<points.size(); ++i) 00803 { 00804 float dist = getSegmentDist(v, points[i], points[(i+1) % points.size()], pos); 00805 00806 if (dist < nearest) 00807 { 00808 nearest = dist; 00809 nearPos = pos; 00810 } 00811 } 00812 distance = nearest; 00813 return false; 00814 } 00815 00816 uint32 nNbIntersection = 0; 00817 for (i = 0; i < points.size(); ++i) 00818 { 00819 const CVector &p1 = points[i]; 00820 const CVector &p2 = points[(i+1)%points.size()]; 00821 00822 float dist = getSegmentDist(v, p1, p2, pos); 00823 if( dist < nearest) 00824 { 00825 nearest = dist; 00826 nearPos = pos; 00827 } 00828 00829 if (((p1.y-v.y) <= 0.0)&&((p2.y-v.y) <= 0.0)) 00830 continue; 00831 if (((p1.y-v.y) > 0.0)&&((p2.y-v.y) > 0.0)) 00832 continue; 00833 float xinter = p1.x + (p2.x-p1.x) * ((v.y-p1.y)/(p2.y-p1.y)); 00834 if (xinter > v.x) 00835 ++nNbIntersection; 00836 } 00837 00838 distance = nearest; 00839 if ((nNbIntersection&1) == 1) // odd intersections so the vertex is inside 00840 return true; 00841 else 00842 return false; 00843 } |
|
Definition at line 319 of file primitive.cpp.
00320 { 00321 uint32 i; 00322 CVector vMin, vMax; 00323 00324 // Point or line can't contains ! 00325 if (points.size() < 3) 00326 return false; 00327 00328 // Get the bounding rectangle of the zone 00329 vMax = vMin = points[0]; 00330 for (i = 0; i < points.size(); ++i) 00331 { 00332 if (vMin.x > points[i].x) 00333 vMin.x = points[i].x; 00334 if (vMin.y > points[i].y) 00335 vMin.y = points[i].y; 00336 00337 if (vMax.x < points[i].x) 00338 vMax.x = points[i].x; 00339 if (vMax.y < points[i].y) 00340 vMax.y = points[i].y; 00341 } 00342 00343 if ((v.x < vMin.x) || (v.y < vMin.y) || (v.x > vMax.x) || (v.y > vMax.y)) 00344 return false; 00345 00346 uint32 nNbIntersection = 0; 00347 for (i = 0; i < points.size(); ++i) 00348 { 00349 const CVector &p1 = points[i]; 00350 const CVector &p2 = points[(i+1)%points.size()]; 00351 00352 if (((p1.y-v.y) <= 0.0)&&((p2.y-v.y) <= 0.0)) 00353 continue; 00354 if (((p1.y-v.y) > 0.0)&&((p2.y-v.y) > 0.0)) 00355 continue; 00356 float xinter = p1.x + (p2.x-p1.x) * ((v.y-p1.y)/(p2.y-p1.y)); 00357 if (xinter > v.x) 00358 ++nNbIntersection; 00359 } 00360 if ((nNbIntersection&1) == 1) // odd intersections so the vertex is inside 00361 return true; 00362 else 00363 return false; 00364 } |
|
Definition at line 449 of file primitive.h. References v.
00449 { return CPrimZone::contains(v, VPoints, distance, nearPos, isPath); }
|
|
Definition at line 448 of file primitive.h. References v.
00448 { return CPrimZone::contains(v, VPoints); }
|
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Implements NLLIGO::IPrimitive. Definition at line 598 of file primitive.cpp.
00599 { 00600 return new CPrimZone (*this); 00601 } |
|
Returns the smallest axis-aligned box containing the zone.
Definition at line 889 of file primitive.cpp. References uint, NLMISC::CVector::x, and NLMISC::CVector::y.
00890 { 00891 cornerMin.x = FLT_MAX; 00892 cornerMin.y = FLT_MAX; 00893 cornerMax.x = -FLT_MAX; 00894 cornerMax.y = -FLT_MAX; 00895 for ( uint i=0; i!=VPoints.size(); ++i ) 00896 { 00897 const CVector& p = VPoints[i]; 00898 if ( p.x < cornerMin.x ) 00899 cornerMin.x = p.x; 00900 if ( p.x > cornerMax.x ) 00901 cornerMax.x = p.x; 00902 if ( p.y < cornerMin.y ) 00903 cornerMin.y = p.y; 00904 if ( p.y > cornerMax.y ) 00905 cornerMax.y = p.y; 00906 } 00907 } |
|
Returns the barycenter of the zone (warning, it may be outside of the zone if it is not convex). Returns CVector::Null if there is no vertex.
Definition at line 874 of file primitive.cpp. References uint.
|
|
Get a child primitive Definition at line 1303 of file primitive.cpp. References nlwarning, and uint.
01304 { 01305 if (childId < _Children.size ()) 01306 { 01307 result = _Children[childId]; 01308 return true; 01309 } 01310 else 01311 { 01312 nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); 01313 } 01314 return false; 01315 } |
|
Get a child primitive Definition at line 1287 of file primitive.cpp. References nlwarning, and uint. Referenced by NLLIGO::CPrimitives::convertPrimitive(), NLSOUND::CBackgroundSoundManager::loadAudioFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadEffectsFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSamplesFromPrimitives(), and NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives().
01288 { 01289 if (childId < _Children.size ()) 01290 { 01291 result = _Children[childId]; 01292 return true; 01293 } 01294 else 01295 { 01296 nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ()); 01297 } 01298 return false; 01299 } |
|
Get the id of the child, return 0xffffffff if not found Definition at line 1713 of file primitive.cpp. References NLLIGO::IPrimitive::_ChildId, and uint.
01714 { 01715 childId = child->_ChildId; 01716 return true; 01717 } |
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
Get the children primitive count Definition at line 183 of file primitive.h. References uint. Referenced by NLLIGO::CPrimitives::convertPrimitive(), NLSOUND::CBackgroundSoundManager::loadAudioFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadEffectsFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSamplesFromPrimitives(), and NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives().
00184 {
00185 return _Children.size ();
00186 }
|
|
Get a num properties Definition at line 1721 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, and uint.
01722 {
01723 return _Properties.size ();
01724 }
|
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Implements NLLIGO::IPrimitive. Definition at line 584 of file primitive.cpp. References uint.
00585 { 00586 return VPoints.size (); 00587 } |
|
Get a child primitive Definition at line 199 of file primitive.h.
00200 {
00201 return _Parent;
00202 }
|
|
Get the parent primtive Definition at line 195 of file primitive.h. Referenced by NLLIGO::CLigoConfig::canBeChild(), and NLLIGO::CLigoConfig::getPrimitiveClass().
00196 {
00197 return _Parent;
00198 }
|
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Implements NLLIGO::IPrimitive. Definition at line 605 of file primitive.cpp.
00606 { 00607 return &(VPoints[0]); 00608 } |
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Implements NLLIGO::IPrimitive. Definition at line 591 of file primitive.cpp.
00592 { 00593 return &(VPoints[0]); 00594 } |
|
Get a properties by its index This is method (iterate a list) is slower than getPropertyByName (look up in a map). Definition at line 1081 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.
01082 { 01083 // Look for the property 01084 std::map<std::string, IProperty*>::iterator ite = _Properties.begin (); 01085 while (ite != _Properties.end ()) 01086 { 01087 if (index == 0) 01088 { 01089 property_name = ite->first; 01090 result = ite->second; 01091 return true; 01092 } 01093 index--; 01094 ite ++; 01095 } 01096 nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ()); 01097 return false; 01098 } |
|
Get a properties by its index This is method (iterate a list) is slower than getPropertyByName (look up in a map). Definition at line 1060 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.
01061 { 01062 // Look for the property 01063 std::map<std::string, IProperty*>::const_iterator ite = _Properties.begin (); 01064 while (ite != _Properties.end ()) 01065 { 01066 if (index == 0) 01067 { 01068 property_name = ite->first; 01069 result = ite->second; 01070 return true; 01071 } 01072 index--; 01073 ite ++; 01074 } 01075 nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ()); 01076 return false; 01077 } |
|
Get a color property with its name. Return false if the property is not found or is not a string array property. Definition at line 1218 of file primitive.cpp. References NLLIGO::CPropertyColor::Color, NLLIGO::IPrimitive::getPropertyByName(), and nlwarning.
01219 { 01220 // Get the property 01221 IProperty *prop; 01222 if (getPropertyByName (property_name, prop)) 01223 { 01224 const CPropertyColor *colorProp = dynamic_cast<const CPropertyColor *> (prop); 01225 if (colorProp) 01226 { 01227 result = colorProp->Color; 01228 return true; 01229 } 01230 else 01231 { 01232 nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name); 01233 } 01234 } 01235 return false; 01236 } |
|
Get a string array property with its name. Return false if the property is not found or is not a string array property. Definition at line 1196 of file primitive.cpp. References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyStringArray::StringArray.
01197 { 01198 // Get the property 01199 IProperty *prop; 01200 if (getPropertyByName (property_name, prop)) 01201 { 01202 const CPropertyStringArray *strProp = dynamic_cast<const CPropertyStringArray *> (prop); 01203 if (strProp) 01204 { 01205 result = &(strProp->StringArray); 01206 return true; 01207 } 01208 else 01209 { 01210 nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); 01211 } 01212 } 01213 return false; 01214 } |
|
Get a string property with its name. Return false if the property is not found or is not a string property. Definition at line 1152 of file primitive.cpp. References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyString::String.
01153 { 01154 // Get the property 01155 const IProperty *prop; 01156 if (getPropertyByName (property_name, prop)) 01157 { 01158 const CPropertyString *strProp = dynamic_cast<const CPropertyString *> (prop); 01159 if (strProp) 01160 { 01161 result = strProp->String; 01162 return true; 01163 } 01164 else 01165 { 01166 nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); 01167 } 01168 } 01169 return false; 01170 } |
|
Get a string array property with its name. Return false if the property is not found or is not a string array property. Definition at line 1174 of file primitive.cpp. References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyStringArray::StringArray.
01175 { 01176 // Get the property 01177 IProperty *prop; 01178 if (getPropertyByName (property_name, prop)) 01179 { 01180 CPropertyStringArray *strProp = dynamic_cast<CPropertyStringArray *> (prop); 01181 if (strProp) 01182 { 01183 result = &(strProp->StringArray); 01184 return true; 01185 } 01186 else 01187 { 01188 nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); 01189 } 01190 } 01191 return false; 01192 } |
|
Get a string property with its name. Return false if the property is not found or is not a string property. Definition at line 1130 of file primitive.cpp. References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyString::String.
01131 { 01132 // Get the property 01133 IProperty *prop; 01134 if (getPropertyByName (property_name, prop)) 01135 { 01136 CPropertyString *strProp = dynamic_cast<CPropertyString *> (prop); 01137 if (strProp) 01138 { 01139 result = &(strProp->String); 01140 return true; 01141 } 01142 else 01143 { 01144 nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name); 01145 } 01146 } 01147 return false; 01148 } |
|
Get a property with its name Definition at line 1116 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties.
01117 { 01118 // Look for the property 01119 std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name); 01120 if (ite != _Properties.end ()) 01121 { 01122 result = ite->second; 01123 return true; 01124 } 01125 return false; 01126 } |
|
|
Definition at line 847 of file primitive.cpp. References NLMISC::CVector::norm(), t, and v. Referenced by contains().
00848 { 00849 // too point, compute distance to the segment. 00850 CVector V = (p2-p1).normed(); 00851 float t = ((v-p1)*V)/(p2-p1).norm(); 00852 float distance; 00853 if (t < 0.0f) 00854 { 00855 nearPos = p1; 00856 distance = (p1-v).norm(); 00857 } 00858 else if (t > 1.0f) 00859 { 00860 nearPos = p2; 00861 distance = (p2-v).norm(); 00862 } 00863 else 00864 { 00865 nearPos = p1 + t*(p2-p1); 00866 distance = (v-nearPos).norm(); 00867 } 00868 00869 return distance; 00870 } |
|
Insert a child primitive before the index. The pointer will be deleted by the parent primitive using the ::delete operator. return false if the index is invalid Definition at line 1349 of file primitive.cpp. References NLLIGO::IPrimitive::_Parent, NLLIGO::IPrimitive::AtTheEnd, index, uint, and NLLIGO::IPrimitive::updateChildId(). Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::read().
01350 { 01351 // At the end ? 01352 if (index == AtTheEnd) 01353 index = _Children.size (); 01354 01355 // Index valid ? 01356 if (index>_Children.size ()) 01357 return false; 01358 01359 // Insert 01360 _Children.insert (_Children.begin () + index, primitive); 01361 01362 // Update child id 01363 updateChildId (index); 01364 01365 // Link to the parent 01366 primitive->_Parent = this; 01367 01368 return true; 01369 } |
|
|
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Reimplemented from NLLIGO::IPrimitive. Definition at line 612 of file primitive.cpp. References NLLIGO::ReadVector(), and uint.
00613 { 00614 // Read points 00615 VPoints.clear (); 00616 VPoints.reserve (CIXml::countChildren (xmlNode, "PT")); 00617 xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "PT"); 00618 if (ptNode) 00619 { 00620 do 00621 { 00622 // Read a vector 00623 VPoints.push_back (CPrimVector ()); 00624 if (!ReadVector (VPoints.back (), filename, ptNode)) 00625 return false; 00626 } 00627 while ((ptNode = CIXml::getNextChildNode (ptNode, "PT"))); 00628 } 00629 00630 return IPrimitive::read (xmlNode, filename, version, config); 00631 } |
|
Remove a child primitive Definition at line 1319 of file primitive.cpp. References nlwarning, uint, and NLLIGO::IPrimitive::updateChildId().
01320 { 01321 if (childId < _Children.size ()) 01322 { 01323 delete _Children[childId]; 01324 _Children.erase (_Children.begin()+childId); 01325 updateChildId (childId); 01326 return true; 01327 } 01328 else 01329 { 01330 nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %d, size %d).", childId, _Children.size ()); 01331 } 01332 return false; 01333 } |
|
Remove all children primitives Definition at line 1337 of file primitive.cpp. References uint. Referenced by NLLIGO::CPrimitives::convert(), NLLIGO::IPrimitive::operator=(), NLLIGO::CPrimitives::read(), and NLLIGO::IPrimitive::~IPrimitive().
01338 { 01339 // Erase children 01340 for (uint i=0; i<_Children.size (); i++) 01341 { 01342 delete _Children[i]; 01343 } 01344 _Children.clear (); 01345 } |
|
Remove all the properties Definition at line 1274 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties. Referenced by NLLIGO::CPrimitives::convert(), NLLIGO::IPrimitive::operator=(), NLLIGO::CPrimitives::read(), and NLLIGO::IPrimitive::~IPrimitive().
01275 { 01276 std::map<std::string, IProperty*>::iterator ite = _Properties.begin (); 01277 while (ite != _Properties.end ()) 01278 { 01279 delete ite->second; 01280 ite++; 01281 } 01282 _Properties.clear (); 01283 } |
|
Remove a property This is method (iterate a list) is slower than removePropertyByName (look up in a map). Definition at line 1240 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.
01241 { 01242 // Look for the property 01243 std::map<std::string, IProperty*>::iterator ite = _Properties.begin (); 01244 while (ite != _Properties.end ()) 01245 { 01246 if (index == 0) 01247 { 01248 _Properties.erase (ite); 01249 return true; 01250 } 01251 index--; 01252 ite ++; 01253 } 01254 nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %d, size : %d).", index, _Properties.size ()); 01255 return false; 01256 } |
|
Remove a property by its name Definition at line 1260 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties.
01261 { 01262 // Look for the property 01263 std::map<std::string, IProperty*>::iterator ite = _Properties.find (property_name); 01264 if (ite != _Properties.end ()) 01265 { 01266 _Properties.erase (ite); 01267 return true; 01268 } 01269 return false; 01270 } |
|
Definition at line 912 of file primitive.cpp.
00913 { 00914 f.xmlPushBegin ("ZONE"); 00915 00916 f.xmlSetAttrib ("NAME"); 00917 f.serial (Name); 00918 f.xmlSetAttrib ("LAYER"); 00919 f.serial (Layer); 00920 f.xmlPushEnd (); 00921 00922 f.serialCont (VPoints); 00923 00924 f.xmlPop (); 00925 } |
|
Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator. Reimplemented from NLLIGO::IPrimitive. Definition at line 635 of file primitive.cpp. References uint, and NLLIGO::WriteVector().
00636 { 00637 // Save the points 00638 for (uint i=0; i<VPoints.size (); i++) 00639 { 00640 xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PT", NULL); 00641 WriteVector (VPoints[i], ptNode); 00642 } 00643 00644 IPrimitive::write (xmlNode, filename); 00645 } |
|
Definition at line 163 of file primitive.h. Referenced by NLLIGO::IPrimitive::operator=(), NLLIGO::IPrimitive::read(), and NLLIGO::IPrimitive::write(). |
|
Definition at line 159 of file primitive.h. Referenced by NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::operator=(). |
|
Definition at line 160 of file primitive.h. Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), and NLLIGO::IPrimitive::operator=(). |
|
Definition at line 442 of file primitive.h. |