bool Sample_MeshLod::getResourceFullPath(MeshPtr& mesh, String& outPath) { ResourceGroupManager& resourceGroupMgr = ResourceGroupManager::getSingleton(); String group = mesh->getGroup(); String name = mesh->getName(); Ogre::FileInfo* info = NULL; FileInfoListPtr locPtr = resourceGroupMgr.listResourceFileInfo(group); FileInfoList::iterator it, itEnd; it = locPtr->begin(); itEnd = locPtr->end(); for (; it != itEnd; it++) { if (stricmp(name.c_str(), it->filename.c_str()) == 0) { info = &*it; break; } } if(!info) { outPath = name; return false; } outPath = info->archive->getName(); if (outPath[outPath .size()-1] != '/' && outPath[outPath .size()-1] != '\\') { outPath += '/'; } outPath += info->path; if (outPath[outPath .size()-1] != '/' && outPath[outPath .size()-1] != '\\') { outPath += '/'; } outPath += info->filename; return (info->archive->getType() == "FileSystem"); }
MeshNode* SceneCreator::CreateCornellBox() { MeshPtr box = MeshCreator::CreateCube(10, 1, Vector<3,float>(1.0f, 1.0f, 1.0f), true); IDataBlockPtr color = Float4DataBlockPtr(new DataBlock<4, float>(box->GetGeometrySet()->GetSize())); for (unsigned int i = 0; i < color->GetSize(); ++i) color->SetElement(i, Vector<4, float>(1.0, 1.0, 1.0, 1.0)); box->GetGeometrySet()->AddAttributeList("color", color); IDataBlockPtr colors = box->GetGeometrySet()->GetColors(); Vector<4,float> red(1.0f, 0.0f, 0.0f, 1.0f); colors->SetElement(8, red); colors->SetElement(9, red); colors->SetElement(10, red); colors->SetElement(11, red); Vector<4,float> blue(0.0f, 0.0f, 0.8f, 1.0f); colors->SetElement(12, blue); colors->SetElement(13, blue); colors->SetElement(14, blue); colors->SetElement(15, blue); // Vector<4,float> transparent(0.0f, 0.0f, 0.8f, 0.0f); // colors->SetElement(16, transparent); // colors->SetElement(17, transparent); // colors->SetElement(18, transparent); // colors->SetElement(19, transparent); return new MeshNode(box); }
void ClippingConverter::convert(const QByteArray &clippingData, const QString &directory) { QDataStream stream(clippingData); stream.setFloatingPointPrecision(QDataStream::SinglePrecision); stream.setByteOrder(QDataStream::LittleEndian); QString newDirectory = directory; newDirectory.replace('\\', '/'); if (!newDirectory.endsWith('/')) newDirectory.append('/'); int objectCount, instanceCount; stream >> objectCount >> instanceCount; for (int i = 0; i < objectCount; ++i) { MeshPtr mesh = importObject(stream); // Serialize to a temporary file, then read it in again QTemporaryFile tempFile; if (!tempFile.open()) { qWarning("Unable to open the temporary %s file.", qPrintable(tempFile.fileName())); continue; } d->ogre->meshSerializer->exportMesh(mesh.getPointer(), tempFile.fileName().toStdString()); QByteArray meshData = tempFile.readAll(); QString meshFilename = QString("%1clipping/mesh-%2.mesh").arg(newDirectory).arg(i+1); d->output->writeFile(meshFilename, meshData); } QByteArray instances; instances.append("["); for (int i = 0; i < instanceCount; ++i) { QVector4D position; int index; stream >> position >> index; QString line = QString("{\"position\":[%1,%2,%3],\"file\":\"%5mesh-%4.mesh\"}") .arg(position.x()) .arg(position.y()) .arg(position.z()) .arg(index+1) .arg(newDirectory); if (i > 0) instances.append(","); instances.append(line.toAscii()); } instances.append("]"); d->output->writeFile(newDirectory + "clipping.json", instances); }
TimeIntegrator::TimeIntegrator(BFPtr steadyJacobian, SteadyResidual &steadyResidual, MeshPtr mesh, BCPtr bc, IPPtr ip, map<int, TFunctionPtr<double>> initialCondition, bool nonlinear) : _steadyJacobian(steadyJacobian), _steadyResidual(steadyResidual), _bc(bc), _nonlinear(nonlinear) { _t = 0; _dt = 1e-3; _timestep = 0; _nlTolerance = 1e-6; _nlIterationMax = 20; _commRank = Teuchos::GlobalMPISession::getRank(); _rhs = RHS::rhs(); _solution = Teuchos::rcp( new TSolution<double>(mesh, _bc, _rhs, ip) ); BCPtr nullBC = Teuchos::rcp((BC*)NULL); RHSPtr nullRHS = Teuchos::rcp((RHS*)NULL); IPPtr nullIP = Teuchos::rcp((IP*)NULL); _prevTimeSolution = Teuchos::rcp(new TSolution<double>(mesh, nullBC, nullRHS, nullIP) ); _prevTimeSolution->projectOntoMesh(initialCondition); if (_nonlinear) { _prevNLSolution = Teuchos::rcp(new TSolution<double>(mesh, nullBC, nullRHS, nullIP) ); _prevNLSolution->setSolution(_prevTimeSolution); } _invDt = Teuchos::rcp( new InvDtFunction(_dt) ); mesh->registerSolution(_prevTimeSolution); mesh->registerSolution(_prevNLSolution); if (_nonlinear) { _rhs->addTerm( -_steadyResidual.createResidual(_prevNLSolution, false) ); } }
void values(FieldContainer<double> &values, BasisCachePtr basisCache) { int numCells = values.dimension(0); int numPoints = values.dimension(1); MeshPtr mesh = basisCache->mesh(); vector<int> cellIDs = basisCache->cellIDs(); double tol=1e-14; for (int cellIndex=0; cellIndex<numCells; cellIndex++) { double h = 1.0; if (_spatialCoord==0) { h = mesh->getCellXSize(cellIDs[cellIndex]); } else if (_spatialCoord==1) { h = mesh->getCellYSize(cellIDs[cellIndex]); } for (int ptIndex=0; ptIndex<numPoints; ptIndex++) { values(cellIndex,ptIndex) = sqrt(h); } } }
void GeomUtils::createSphere( const String& strName , const float radius , const int nRings, const int nSegments , bool bNormals , bool bTexCoords) { MeshPtr pSphere = MeshManager::getSingleton().createManual(strName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); SubMesh *pSphereVertex = pSphere->createSubMesh(); pSphere->sharedVertexData = new VertexData(); createSphere(pSphere->sharedVertexData, pSphereVertex->indexData , radius , nRings, nSegments , bNormals // need normals , bTexCoords // need texture co-ordinates ); // Generate face list pSphereVertex->useSharedVertices = true; // the original code was missing this line: pSphere->_setBounds( AxisAlignedBox( Vector3(-radius, -radius, -radius), Vector3(radius, radius, radius) ), false ); pSphere->_setBoundingSphereRadius(radius); // this line makes clear the mesh is loaded (avoids memory leaks) pSphere->load(); }
//----------------------------------------------------------------------- PatchMeshPtr MeshManager::createBezierPatch(const String& name, const String& groupName, void* controlPointBuffer, VertexDeclaration *declaration, size_t width, size_t height, size_t uMaxSubdivisionLevel, size_t vMaxSubdivisionLevel, PatchSurface::VisibleSide visibleSide, HardwareBuffer::Usage vbUsage, HardwareBuffer::Usage ibUsage, bool vbUseShadow, bool ibUseShadow) { if (width < 3 || height < 3) { OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Bezier patch require at least 3x3 control points", "MeshManager::createBezierPatch"); } MeshPtr pMesh = getByName(name); if (!pMesh.isNull()) { OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, "A mesh called " + name + " already exists!", "MeshManager::createBezierPatch"); } PatchMesh* pm = OGRE_NEW PatchMesh(this, name, getNextHandle(), groupName); pm->define(controlPointBuffer, declaration, width, height, uMaxSubdivisionLevel, vMaxSubdivisionLevel, visibleSide, vbUsage, ibUsage, vbUseShadow, ibUseShadow); pm->load(); ResourcePtr res(pm); addImpl(res); return res.staticCast<PatchMesh>(); }
//----------------------------------------------------------------------- MeshPtr MeshManager::createPlane( const String& name, const String& groupName, const Plane& plane, Real width, Real height, int xsegments, int ysegments, bool normals, unsigned short numTexCoordSets, Real xTile, Real yTile, const Vector3& upVector, HardwareBuffer::Usage vertexBufferUsage, HardwareBuffer::Usage indexBufferUsage, bool vertexShadowBuffer, bool indexShadowBuffer) { // Create manual mesh which calls back self to load MeshPtr pMesh = createManual(name, groupName, this); // Planes can never be manifold pMesh->setAutoBuildEdgeLists(false); // store parameters MeshBuildParams params; params.type = MBT_PLANE; params.plane = plane; params.width = width; params.height = height; params.xsegments = xsegments; params.ysegments = ysegments; params.normals = normals; params.numTexCoordSets = numTexCoordSets; params.xTile = xTile; params.yTile = yTile; params.upVector = upVector; params.vertexBufferUsage = vertexBufferUsage; params.indexBufferUsage = indexBufferUsage; params.vertexShadowBuffer = vertexShadowBuffer; params.indexShadowBuffer = indexShadowBuffer; mMeshBuildParams[pMesh.getPointer()] = params; // to preserve previous behaviour, load immediately pMesh->load(); return pMesh; }
//------------------------------------------------------------------------------------------------ void StaticMeshToShapeConverter::addMesh(const MeshPtr &mesh, const Matrix4 &transform) { // Each entity added need to reset size and radius // next time getRadius and getSize are asked, they're computed. mBounds = Ogre::Vector3(-1,-1,-1); mBoundRadius = -1; //_entity = entity; //_node = (SceneNode*)(_entity->getParentNode()); mTransform = transform; if (mesh->hasSkeleton ()) Ogre::LogManager::getSingleton().logMessage("MeshToShapeConverter::addMesh : Mesh " + mesh->getName () + " as skeleton but added to trimesh non animated"); if (mesh->sharedVertexData) { VertexIndexToShape::addStaticVertexData (mesh->sharedVertexData); } for(unsigned int i = 0;i < mesh->getNumSubMeshes();++i) { SubMesh *sub_mesh = mesh->getSubMesh(i); if (!sub_mesh->useSharedVertices) { VertexIndexToShape::addIndexData(sub_mesh->indexData, mVertexCount); VertexIndexToShape::addStaticVertexData (sub_mesh->vertexData); } else { VertexIndexToShape::addIndexData (sub_mesh->indexData); } } }
void pcl::ihs::Integration::age (const MeshPtr& mesh, const bool cleanup) const { for (unsigned int i=0; i<mesh->sizeVertices (); ++i) { PointIHS& pt = mesh->getVertexDataCloud () [i]; if (pt.age < max_age_) { // Point survives ++(pt.age); } else if (pt.age == max_age_) // Judgement Day { if (pcl::ihs::countDirections (pt.directions) < min_directions_) { // Point dies (no need to transform it) mesh->deleteVertex (VertexIndex (i)); } else { // Point becomes immortal pt.age = std::numeric_limits <unsigned int>::max (); } } } if (cleanup) { mesh->cleanUp (); } }
//----------------------------------------------------------------------- void MeshInformer::getMeshTriangles(const MeshPtr& mesh, std::vector<Vector3>& vertices, std::vector<size_t>& indices, std::vector<size_t>* indexOffsets) { size_t numVertices = 0, numIndices = 0; getMeshStatistics(mesh, numVertices, numIndices); size_t vertex_offset = vertices.size(); size_t index_offset = indices.size(); vertices.resize(vertex_offset + numVertices); indices.resize(index_offset + numIndices); Vector3* pVertices = &vertices[0]; size_t* pIndices = &indices[0]; size_t shared_vertex_offset = vertex_offset; bool added_shared_vertex = false; size_t numSubMeshes = mesh->getNumSubMeshes(); for (size_t i = 0; i < numSubMeshes; ++i) { SubMesh* subMesh = mesh->getSubMesh(i); if (indexOffsets) { indexOffsets->push_back(index_offset); } if (subMesh->operationType == RenderOperation::OT_TRIANGLE_LIST || subMesh->operationType == RenderOperation::OT_TRIANGLE_STRIP || subMesh->operationType == RenderOperation::OT_TRIANGLE_FAN) { size_t current_vertex_offset; if (subMesh->useSharedVertices) { if (!added_shared_vertex) { size_t vertexCount = getVertices(pVertices + vertex_offset, subMesh->parent->sharedVertexData); shared_vertex_offset = vertex_offset; vertex_offset += vertexCount; added_shared_vertex = true; } current_vertex_offset = shared_vertex_offset; } else { size_t vertexCount = getVertices(pVertices + vertex_offset, subMesh->vertexData); current_vertex_offset = vertex_offset; vertex_offset += vertexCount; } size_t index_count = getTriangles(pIndices + index_offset, subMesh->indexData, current_vertex_offset, subMesh->operationType); index_offset += index_count; } } }
double getMinCellMeasure(){ double minMeasure = 1e7; vector<ElementPtr> elems = _mesh->activeElements(); for (vector<ElementPtr>::iterator elemIt = elems.begin();elemIt!=elems.end();elemIt++){ minMeasure = min(minMeasure, _mesh->getCellMeasure((*elemIt)->cellID())); } return minMeasure; }
//-------------------------------------------------------------------------- void MeshLodTests::TearDown() { if (mMesh) { mMesh->unload(); mMesh.reset(); } OGRE_DELETE MeshLodGenerator::getSingletonPtr(); RootWithoutRenderSystemFixture::TearDown(); }
MeshPtr ResourceStorage::getMesh(const std::wstring& path) { MeshPtr mesh = getResource<Mesh>(path); if (mesh.isNull()) { mesh = loadMesh(path); } return mesh; }
void SthenoCore::createLocalServiceReplica( UUIDPtr& sid, ServiceParamsPtr& params, ServiceAbstractPtr& sPtr) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } FaultTolerancePtr ftToleranceSvc; try { m_overlay->getFaultTolerance(ftToleranceSvc); } catch (OverlayException& ex) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } UUIDPtr iid(UUID::generateUUID()); createServiceInstance(sid, iid, sPtr); //QoSResources* qos = sPtr->calculateQoSResources(params); printf("INFO: createLocalServiceReplica() - SID=%s before open service!\n", sid->toString().c_str()); QoSManagerInterface* qosManager = 0; if (m_reservationFlag) { UUIDPtr serviceCgroupUUID(UUID::generateUUID()); String path = "service_" + sid->toString() + "_" + serviceCgroupUUID->toString(); qosManager = m_serviceQosManager->createSubDomainQoSManager(path, 200, m_runtimePeriod); //String ftPath = "/FT"; String ftPath = Cgroup::getSep(); ftPath += "FT"; //HierarchicalPath::appendPaths(path, "/FT"); QoSManagerInterface* qosFTManager = 0; qosFTManager = qosManager->createSubDomainQoSManager(ftPath, 100, m_runtimePeriod); String servicePath = Cgroup::getSep(); servicePath += "service"; //HierarchicalPath::appendPaths(path, "/service"); QoSManagerInterface* qosServiceManager = 0; qosServiceManager = qosManager->createSubDomainQoSManager(servicePath, 100, m_runtimePeriod); //String path = "service_" + sid->toString() + "_" + serviceCgroupUUID->toString(); //qosManager = m_serviceQosManager->createSubDomainQoSManager(path, 10000, QoSManagerInterface::DEFAULT_PERIOD); } sPtr->open(params, ServiceAbstract::FT_REPLICA, qosManager); printf("INFO: createLocalServiceReplica() SID=%s after open service!\n", sid->toString().c_str()); ServiceInstanceInfoPtr info; //UUIDPtr iid = sPtr->getIID(); this->getInstanceOfService(sid, iid, info); MeshPtr meshPtr; try { getOverlay()->getMesh(meshPtr); } catch (OverlayException& ex) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } meshPtr->onServiceCreation(info); }
//----------------------------------------------------------------------- bool HardwareSkinningFactory::extractSkeletonData(const Entity* pEntity, size_t subEntityIndex, ushort& boneCount, ushort& weightCount) { bool isValidData = false; boneCount = 0; weightCount = 0; //Check if we have pose animation which the HS sub render state does not //know how to handle bool hasVertexAnim = pEntity->getMesh()->hasVertexAnimation(); //gather data on the skeleton if (!hasVertexAnim && pEntity->hasSkeleton()) { //get weights count MeshPtr pMesh = pEntity->getMesh(); RenderOperation ro; SubMesh* pSubMesh = pMesh->getSubMesh(subEntityIndex); pSubMesh->_getRenderOperation(ro,0); //get the largest bone assignment boneCount = ushort(std::max(pMesh->sharedBlendIndexToBoneIndexMap.size(), pSubMesh->blendIndexToBoneIndexMap.size())); //go over vertex deceleration //check that they have blend indices and blend weights const VertexElement* pDeclWeights = ro.vertexData->vertexDeclaration->findElementBySemantic(VES_BLEND_WEIGHTS,0); const VertexElement* pDeclIndexes = ro.vertexData->vertexDeclaration->findElementBySemantic(VES_BLEND_INDICES,0); if ((pDeclWeights != NULL) && (pDeclIndexes != NULL)) { isValidData = true; switch (pDeclWeights->getType()) { case VET_FLOAT1: weightCount = 1; break; case VET_USHORT2_NORM: case VET_FLOAT2: weightCount = 2; break; case VET_FLOAT3: weightCount = 3; break; case VET_USHORT4_NORM: case VET_UBYTE4_NORM: case VET_FLOAT4: weightCount = 4; break; default: isValidData = false; break; } } } return isValidData; }
//----------------------------------------------------------------------- MeshPtr MeshManager::load( const String& filename, const String& groupName, HardwareBuffer::Usage vertexBufferUsage, HardwareBuffer::Usage indexBufferUsage, bool vertexBufferShadowed, bool indexBufferShadowed) { MeshPtr pMesh = createOrRetrieve(filename,groupName,false,0,0, vertexBufferUsage,indexBufferUsage, vertexBufferShadowed,indexBufferShadowed).first.staticCast<Mesh>(); pMesh->load(); return pMesh; }
void MeshLoader_v1::ReadSkelAnim(MeshPtr mesh, DataStreamPtr & stream) { Skeleton * skel = mesh->GetSkeleton(); int version = -1; stream->Read(&version, sizeof (int)); d_assert (version == K_SkelAnim_Version); char name[128]; stream->Read(name, 128); Animation * anim = mesh->CreateAnimation(name); int numAnims = 0; stream->Read(&numAnims, sizeof(int)); for (int i = 0; i < numAnims; ++i) { int boneId, count; stream->Read(&boneId, sizeof(int)); stream->Read(&count, sizeof(int)); if (count == 0) continue; SkeletonAnimation * skel_anim; skel_anim = anim->CreateSkeletonAnimation(boneId); KeyFrame * kf; float time; Vec3 trans; Quat rotate; Vec3 scale; for (int i = 0; i < count; ++i) { stream->Read(&time, sizeof(float)); stream->Read(&trans, sizeof(float) * 3); stream->Read(&rotate, sizeof(float) * 4); stream->Read(&scale, sizeof(float) * 3); kf = skel_anim->CreateKeyFrame(); kf->SetTime(time); kf->SetTranslate(trans); kf->SetRotation(rotate); kf->SetScale(scale); } } anim->_calcuLength(); }
MeshPtr MeshGenerator::cubeMesh(float size) { auto rawMesh = MeshGenerator::cube(size); MeshPtr mesh = std::make_shared<Mesh>(); if (mesh->loadFromData(rawMesh)) { return mesh; } else { return nullptr; } }
bool MeshTestUtility::checkConstraintConsistency(MeshPtr meshMinimumRule) { MeshTopologyViewPtr meshTopo = meshMinimumRule->getTopology(); GDAMinimumRule* minRule = dynamic_cast<GDAMinimumRule*>(meshMinimumRule->globalDofAssignment().get()); bool consistent = true; for (IndexType cellID : meshMinimumRule->cellIDsInPartition()) { CellConstraints constraints = minRule->getCellConstraints(cellID); CellPtr cell = meshTopo->getCell(cellID); CellTopoPtr cellTopo = cell->topology(); for (int d=0; d<cellTopo->getDimension(); d++) { int scCount = cellTopo->getSubcellCount(d); for (int scord=0; scord<scCount; scord++) { IndexType entityIndex = cell->entityIndex(d, scord); AnnotatedEntity constrainingEntity = constraints.subcellConstraints[d][scord]; bool isConsistent = constraintIsConsistent(meshTopo, constrainingEntity, d, entityIndex, true); if (!isConsistent) { cout << "Failed consistency test for standard constraints on cell " << cellID << ", " << CamelliaCellTools::entityTypeString(d) << " " << scord << endl; consistent = false; break; } // now, check space-only constraints (for space-time meshes), if these are defined for this subcell if (constraints.spatialSliceConstraints != Teuchos::null) { AnnotatedEntity constrainingEntityForSpatialSlice = constraints.spatialSliceConstraints->subcellConstraints[d][scord]; if (constrainingEntityForSpatialSlice.cellID != -1) { isConsistent = constraintIsConsistent(meshTopo, constrainingEntityForSpatialSlice, d, entityIndex, true); } if (!isConsistent) { cout << "Failed consistency test for spatial slice on cell " << cellID << ", " << CamelliaCellTools::entityTypeString(d) << " " << scord << endl; consistent = false; break; } } } if (!consistent) break; } if (!consistent) break; } return consistent; }
//------------------------------------------------------------------------- void MeshManager::createPrefabSphere(void) { MeshPtr msh = create( "Prefab_Sphere", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, true, // manually loaded this); // to preserve previous behaviour, load immediately msh->load(); }
ISceneNode* SceneCreator::CreateSmallBox() { MeshPtr box = MeshCreator::CreateCube(3, 1, Vector<3,float>(1.0f, 1.0f, 1.0f)); IDataBlockPtr color = Float4DataBlockPtr(new DataBlock<4, float>(box->GetGeometrySet()->GetSize())); for (unsigned int i = 0; i < color->GetSize(); ++i) color->SetElement(i, Vector<4, float>(1.0, 1.0, 1.0, 1.0)); box->GetGeometrySet()->AddAttributeList("color", color); return new MeshNode(box); }
MeshPtr MeshTools::timeSliceMesh(MeshPtr spaceTimeMesh, double t, map<GlobalIndexType, GlobalIndexType> &sliceCellIDToSpaceTimeCellID, int H1OrderForSlice) { MeshTopologyPtr meshTopo = spaceTimeMesh->getTopology(); set<IndexType> cellIDsToCheck = meshTopo->getRootCellIndices(); set<IndexType> activeCellIDsForTime; set<IndexType> allActiveCellIDs = meshTopo->getActiveCellIndices(); int spaceDim = meshTopo->getSpaceDim() - 1; // # of true spatial dimensions MeshTopologyPtr sliceTopo = Teuchos::rcp( new MeshTopology(spaceDim) ); set<IndexType> rootCellIDs = meshTopo->getRootCellIndices(); for (set<IndexType>::iterator rootCellIt = rootCellIDs.begin(); rootCellIt != rootCellIDs.end(); rootCellIt++) { IndexType rootCellID = *rootCellIt; FieldContainer<double> physicalNodes = spaceTimeMesh->physicalCellNodesForCell(rootCellID); if (cellMatches(physicalNodes, t)) { // cell and some subset of its descendents should be included in slice mesh vector< vector< double > > sliceNodes = timeSliceForCell(physicalNodes, t); CellTopoPtrLegacy cellTopo = getBottomTopology(meshTopo, rootCellID); CellPtr sliceCell = sliceTopo->addCell(cellTopo, sliceNodes); sliceCellIDToSpaceTimeCellID[sliceCell->cellIndex()] = rootCellID; } } MeshPtr sliceMesh = Teuchos::rcp( new Mesh(sliceTopo, spaceTimeMesh->bilinearForm(), H1OrderForSlice, spaceDim) ); // process refinements. For now, we assume isotropic refinements, which means that each refinement in spacetime induces a refinement in the spatial slice set<IndexType> sliceCellIDsToCheckForRefinement = sliceTopo->getActiveCellIndices(); while (sliceCellIDsToCheckForRefinement.size() > 0) { set<IndexType>::iterator cellIt = sliceCellIDsToCheckForRefinement.begin(); IndexType sliceCellID = *cellIt; sliceCellIDsToCheckForRefinement.erase(cellIt); CellPtr sliceCell = sliceTopo->getCell(sliceCellID); CellPtr spaceTimeCell = meshTopo->getCell(sliceCellIDToSpaceTimeCellID[sliceCellID]); if (spaceTimeCell->isParent()) { set<GlobalIndexType> cellsToRefine; cellsToRefine.insert(sliceCellID); sliceMesh->hRefine(cellsToRefine, RefinementPattern::regularRefinementPattern(sliceCell->topology()->getKey())); vector<IndexType> spaceTimeChildren = spaceTimeCell->getChildIndices(); for (int childOrdinal=0; childOrdinal<spaceTimeChildren.size(); childOrdinal++) { IndexType childID = spaceTimeChildren[childOrdinal]; FieldContainer<double> childNodes = meshTopo->physicalCellNodesForCell(childID); if (cellMatches(childNodes, t)) { vector< vector<double> > childSlice = timeSliceForCell(childNodes, t); CellPtr childSliceCell = sliceTopo->findCellWithVertices(childSlice); sliceCellIDToSpaceTimeCellID[childSliceCell->cellIndex()] = childID; sliceCellIDsToCheckForRefinement.insert(childSliceCell->cellIndex()); } } } } return sliceMesh; }
vector<int> getMinCellSizeCellIDs(){ double minMeasure = getMinCellMeasure(); vector<int> minMeasureCellIDs; vector<ElementPtr> elems = _mesh->activeElements(); for (vector<ElementPtr>::iterator elemIt = elems.begin();elemIt!=elems.end();elemIt++){ if (minMeasure <= _mesh->getCellMeasure((*elemIt)->cellID())){ minMeasureCellIDs.push_back((*elemIt)->cellID()); } } return minMeasureCellIDs; }
//----------------------------------------------------------------------- void MeshManager::createPrefabPlane(void) { MeshPtr msh = create( "Prefab_Plane", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, true, // manually loaded this); // Planes can never be manifold msh->setAutoBuildEdgeLists(false); // to preserve previous behaviour, load immediately msh->load(); }
void loadMeshFromToolTransforms(PatientModelServicePtr dataManager, TimedTransformMap transforms_prMt) { //create polydata from positions Transform3D rMpr = dataManager->get_rMpr(); vtkPolyDataPtr centerlinePolydata = polydataFromTransforms(transforms_prMt, rMpr); QString uid = "tool_positions_mesh_%1"; QString name = "Tool positions mesh %1"; MeshPtr mesh = dataManager->createSpecificData<Mesh>(uid, name); mesh->setVtkPolyData(centerlinePolydata); mesh->setColor(QColor("red")); dataManager->insertData(mesh); }
void SthenoCore::startService(const UUIDPtr& sid, ServiceParamsPtr& params, UUIDPtr& iid, UUIDPtr& deployUUIDD) throw (RuntimeException&, ServiceException&) { ACE_Time_Value start = ACE_OS::gettimeofday(); if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } list<UUIDPtr> filterList; UUIDPtr runtimeUUID; this->getUUID(runtimeUUID); LaunchServiceSiteQuery* query = new LaunchServiceSiteQuery(runtimeUUID, sid, filterList); DiscoveryPtr discovery; try { m_overlay->getDiscovery(discovery); } catch (OverlayException& ex) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } //DiscoveryQueryReply* reply = m_overlay->getDiscovery()->executeQuery(query); DiscoveryQueryReply* reply = discovery->executeQuery(query); if (reply == 0) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } LaunchServiceSiteQueryReply* replyNarrow = new LaunchServiceSiteQueryReply(reply); //printf("PoL UUID=%s\n", replyNarrow->getUUID()->toString().c_str()); deployUUIDD = replyNarrow->getUUID(); //printf("Before service remote deployment\n"); MeshPtr meshPtr; try { getOverlay()->getMesh(meshPtr); } catch (OverlayException& ex) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } //getOverlay()->getMesh()->createRemoteService(replyNarrow->getMeshSAPInfo().get(), replyNarrow->getUUID(), sid, params, iid); try { meshPtr->createRemoteService(replyNarrow->getMeshSAPInfo().get(), replyNarrow->getUUID(), sid, params, iid); } catch (ServiceException& se) { delete replyNarrow; throw se; } //printf("After service remote deployment\n"); ACE_Time_Value end = ACE_OS::gettimeofday(); end -= start; if (trace()) { MeshPtr meshPtr; this->getOverlay()->getMesh(meshPtr); UUIDPtr fid; meshPtr->getFID(fid); if (params->getFTParams().null()) { TraceRuntimeSingleton::instance()->logRemoteServiceCreation(this->m_peerID, fid, sid, iid, end); } else { TraceRuntimeSingleton::instance()->logRemoteServiceCreationFT(this->m_peerID, fid, sid, iid, end); } } delete replyNarrow; }
//----------------------------------------------------------------------- void Node::getRenderOperation(RenderOperation& op) { SubMesh* pSubMesh = 0; MeshPtr pMesh = MeshManager::getSingleton().getByName("axes.mesh"); if (pMesh.isNull()) { pMesh = MeshManager::getSingleton().load("axes.mesh", ResourceGroupManager::BOOTSTRAP_RESOURCE_GROUP_NAME); } pSubMesh = pMesh->getSubMesh(0); pSubMesh->_getRenderOperation(op); }
void MeshManager::add(const MeshPtr &mesh) { if (!contains(mesh->get_name())) { meshes.insert(std::make_pair(mesh->get_name(), mesh)); } else { clan::StringFormat message = clan::StringFormat("Mesh manager already contains a mesh by name (%1)"); message.set_arg(1, mesh->get_name()); throw clan::Exception(message.get_result()); } }
void MeshLoader_v0::ReadBounds(MeshPtr mesh, DataStreamPtr & stream) { Vec3 vMin, vMax, vCenter; float fRadius; stream->Read(&vMin, sizeof(Vec3)); stream->Read(&vMax, sizeof(Vec3)); stream->Read(&vCenter, sizeof(Vec3)); stream->Read(&fRadius, sizeof(float)); mesh->SetAabb(vMin, vMax); mesh->SetBoundingSphere(vCenter, fRadius); }