コード例 #1
0
ファイル: BaseFilter.cpp プロジェクト: eile/trunk
void BaseFilter::getAllEntitiesThatHaveMetaData(QString key, ccHObject::Container &entities)
{
    entities.clear(); //better be sure
    ccHObject::Container tempContainer;
    getAllEntitiesOfType(CC_TYPES::HIERARCHY_OBJECT, tempContainer);

    for (ccHObject::Container::const_iterator it = tempContainer.begin(); it != tempContainer.end(); ++it )
    {
        if ((*it)->hasMetaData(key))
            entities.push_back(*it);
    }
}
コード例 #2
0
ファイル: ShpFilter.cpp プロジェクト: sniperx2/trunk
void GetSupportedShapes(ccHObject* baseEntity, ccHObject::Container& shapes, ESRI_SHAPE_TYPE& shapeType)
{
	shapeType = SHP_NULL_SHAPE;
	if (!baseEntity)
	{
		assert(false);
		shapes.clear();
		return;
	}

	switch (baseEntity->getClassID())
	{
	case CC_TYPES::POINT_CLOUD:
		{
			unsigned count = ccHObjectCaster::ToGenericPointCloud(baseEntity)->size();
			if (count != 0)
			{
				shapeType = SHP_MULTI_POINT_Z;
				shapes.push_back(baseEntity);
			}
		}
		break;
	//DGM: TODO
	//case CC_MESH:
	//case CC_SUB_MESH:
	//	{
	//		unsigned count = ccHObjectCaster::ToGenericMesh(baseEntity)->size();
	//		if (count != 0)
	//		{
	//			shapeType = SHP_MULTI_PATCH;
	//			shapes.push_back(baseEntity);
	//		}
	//	}
	//	break;
	case CC_TYPES::POLY_LINE:
		{
			ccPolyline* poly = static_cast<ccPolyline*>(baseEntity);
			shapeType = poly->is2DMode() ? SHP_POLYLINE : SHP_POLYLINE_Z;
			shapes.push_back(baseEntity);
			break;
		}
	case CC_TYPES::HIERARCHY_OBJECT:
		//we only allow groups with children of the same type!
		if (baseEntity->getChildrenNumber())
		{
			ccHObject* child = baseEntity->getChild(0);
			assert(child);
			if (!child)
				return;

			//first we check that all entities have the same type
			{
				for (unsigned i=1; i<baseEntity->getChildrenNumber(); ++i)
				{
					if (baseEntity->getChild(i) && baseEntity->getChild(i)->getClassID() != child->getClassID())
					{
						//mixed shapes are not allowed in shape files (yet?)
						return;
					}
				}
			}

			//call the same method on the first child so as to get its type
			GetSupportedShapes(child,shapes,shapeType/*,closedPolylinesAsPolygons*/);
			if (shapeType == SHP_NULL_SHAPE)
				return;

			//then add the remaining children
			{
				for (unsigned i=1; i<baseEntity->getChildrenNumber(); ++i)
				{
					ESRI_SHAPE_TYPE otherShapeType = SHP_NULL_SHAPE;
					ccHObject* child = baseEntity->getChild(i);
					if (child)
						GetSupportedShapes(child,shapes,otherShapeType);
					
					if (otherShapeType != shapeType)
					{
						if (child)
							ccLog::Warning(QString("[SHP] Entity %1 has not the same type (%1) as the others in the selection (%2)! Can't mix types...")
								.arg(child->getName())
								.arg(ToString(otherShapeType))
								.arg(ToString(shapeType)));
						//mixed shapes are not allowed in shape files (yet?)
						shapes.clear();
						return;
					}
				}
			}
		}
		break;
	default:
		//nothing to do
		break;
	}
}