예제 #1
0
파일: femesh.C 프로젝트: anilkunwar/OOF2
Node *FEMesh::closestNode(const double x, const double y, const double z=0)
#endif
{
  double min=1.;   // (initial value provided to suppress compiler warnings)
  Node *node, *thenode=0;
  for(NodeIterator ni = node_iterator(); !ni.end(); ++ni) {
    node = ni.node();
    double dx = node->position()(0) - x;
    double dy = node->position()(1) - y;
#if DIM==2
    double dist = dx*dx + dy*dy;
#elif DIM==3
    double dz = node->position()(2) - z;
    double dist = dx*dx + dy*dy + dz*dz;
#endif
    if (ni.begin()) {
      min = dist;
      thenode = node;
    }
    else {
      if (dist <= min) {
	min = dist;
	thenode = node;
      }
    }
  }
  return thenode;
}
예제 #2
0
bool Scene::Add( freyja::Node* node )
{
	bool ret = false;

	if ( node )
	{
		mstl::String key = node->GetType();
		SceneResource* resource = mResourceDict.find( key );

		if ( resource )
		{
			bool found = false;
			for ( NodeIterator it = resource->GetIterator(), end = it.end(); it != end; it++ )
			{
				if ( *it == node )
				{
					found = true;
					break;
				}
			}

			if ( !found )
			{					
				// FIXME: Check for name collision!
				node->SetScene( this );
				resource->GetList().push_back( node );
				key = node->GetName();
				resource->GetDictionary().insert( key, node );
			}

			ret = true;
		}
	}

	return ret;
}