bool Mesh::valueAt(uint elementIndex, double x, double y, double* value, const Output* output) const { if (output->type() == Output::TypeNode) { const NodeOutput* nodeOutput = static_cast<const NodeOutput*>(output); ScalarValueAccessor accessor(nodeOutput->values.constData()); return interpolate(elementIndex, x, y, value, nodeOutput, &accessor); } else { const ElementOutput* elemOutput = static_cast<const ElementOutput*>(output); ScalarValueAccessor accessor(elemOutput->values.constData()); return interpolateElementCentered(elementIndex, x, y, value, elemOutput, &accessor); } }
void setup_plastic_with_texture(void) { boost::shared_ptr<shade::shaders::Plastic> specular(new shade::shaders::Plastic(0.7, .3)); boost::shared_ptr<shade::shaders::ObjectSpace> object_space(new shade::shaders::ObjectSpace); boost::shared_ptr<shade::shaders::Texture2D> tex(new shade::shaders::Texture2D); tex->texture_unit.set(example::make_texture("examples/pattern.dds")); boost::shared_ptr<shade::shaders::UVCoord> uvcoord(new shade::shaders::UVCoord); tex->uv = uvcoord; specular->color = tex; specular->coordinate_system = object_space; shader->material = specular; { shaders::IlluminatedMaterial::LightList::Accessor accessor(specular->lights); boost::shared_ptr<shaders::PointLight> light(new shaders::PointLight); light->position.set_value(shade::vec3<>(30., 15., 10.)); light->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light); boost::shared_ptr<shaders::PointLight> light2(new shaders::PointLight); light2->position.set_value(shade::vec3<>(-15., -3, 0.)); light2->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light2); } }
void mitk::MorphologicalOperations::FillHoles(mitk::Image::Pointer &image) { MITK_INFO << "Start FillHole..."; int timeSteps = static_cast<int>(image->GetTimeSteps()); if (timeSteps > 1) { mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); timeSelector->SetInput(image); for (int t = 0; t < timeSteps; ++t) { MITK_INFO << " Processing time step " << t; timeSelector->SetTimeNr(t); timeSelector->Update(); mitk::Image::Pointer img3D = timeSelector->GetOutput(); img3D->DisconnectPipeline(); AccessByItk_1(img3D, itkFillHoles, img3D); mitk::ImageReadAccessor accessor(img3D); image->SetVolume(accessor.GetData(), t); } } else { AccessByItk_1(image, itkFillHoles, image); } MITK_INFO << "Finished FillHole"; }
boost::shared_ptr<shade::Program> setup_shading(boost::shared_ptr<shade::GLSLWrapper> state) { boost::shared_ptr<shade::shaders::Surface> shader(new shade::shaders::Surface); boost::shared_ptr<shade::Program> program(new shade::Program(shader, state)); boost::shared_ptr<shade::shaders::Plastic> specular(new shade::shaders::Plastic(0.4, .6)); boost::shared_ptr<shade::shaders::ObjectSpace> object_space(new shade::shaders::ObjectSpace); specular->color.set_value(shade::vec4<>(1., 0.4, 0.4, 1.)); specular->coordinate_system = object_space; shader->material = specular; { shade::shaders::IlluminatedMaterial::LightList::Accessor accessor(specular->lights); boost::shared_ptr<shade::shaders::PointLight> light(new shade::shaders::PointLight); boost::shared_ptr<shade::shaders::GLLightPosition> gl_light_pos(new shade::shaders::GLLightPosition); boost::shared_ptr<shade::shaders::Vec4ToVec3> light_pos(new shade::shaders::Vec4ToVec3); gl_light_pos->index.set(1); light_pos->value = gl_light_pos; light->position = light_pos; light->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light); boost::shared_ptr<shade::shaders::DirectionalLight> light2(new shade::shaders::DirectionalLight); light2->direction.set_value(shade::vec3<>(0., 1., 0.)); light2->color.set_value(shade::vec3<>(1., 0., 0.)); accessor->push_back(light2); } return program; }
int array_max(const void *arr, int len, const void * (*accessor)(const void *arr, int i), int (*comparator)(const void *a, const void *b)){ assert( len > 0 ); if(len == 1) return 0; int max = 0; int i, comp; for(i=1;i<len;++i){ comp = comparator(accessor(arr,i),accessor(arr,max)); if(comp > 0){ max = i; } } return max; }
void CIndexedComposite<T, Index>::Add(T& component) { Index accessor(component.GetIndex()); int Return = m_Components.erase(accessor); assert(!((bool)Return) && "Component already existed. Replaced."); m_Components[accessor] = &component; }
bool vHavokCachedShape::IsHktUpToDate(VBaseMesh *pMesh, hkpShape *pShape, const hkClass &expectedClass) { VASSERT(pMesh!=NULL && pShape!=NULL); const vHavokPhysicsModule *pModule = vHavokPhysicsModule::GetInstance(); VASSERT(pModule != NULL); const bool bForceHktShapeCaching = pModule->IsHktShapeCachingEnforced(); // Get the collision mesh const IVCollisionMesh *pColMesh = pMesh->GetCollisionMesh(true, true); VASSERT(pColMesh != NULL); // Get m_iFileTime member of custom Vision shape class via reflection hkClassMemberAccessor accessor(pShape, expectedClass, "iFileTime"); VASSERT(accessor.isOk()); hkInt64 iFileTime = accessor.asInt64(); // Check whether cached file is still up to date if (iFileTime != pColMesh->GetFileTime()) { if (!Vision::Editor.IsInEditor() && !bForceHktShapeCaching) hkvLog::Warning("vHavokCachedShape::Load for %s failed since HKT file is outdated. Please re-generate HKT file (see documentation for details).", pMesh->GetFilename()); return false; } return true; }
void ListClass<T>::splice(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { validate_argument_count_at_least(argc, 1); auto list = get_internal<T, ListClass<T>>(this_object); size_t size = list->size(); long index = std::min<long>(Value::to_number(ctx, arguments[0]), size); if (index < 0) { index = std::max<long>(size + index, 0); } size_t remove; if (argc < 2) { remove = size - index; } else { remove = std::max<long>(Value::to_number(ctx, arguments[1]), 0); remove = std::min<long>(remove, size - index); } std::vector<ValueType> removed_objects; removed_objects.reserve(remove); NativeAccessor<T> accessor(ctx, list->get_realm(), list->get_object_schema()); for (size_t i = 0; i < remove; i++) { auto realm_object = realm::Object(list->get_realm(), list->get_object_schema(), list->get(index)); removed_objects.push_back(RealmObjectClass<T>::create_instance(ctx, std::move(realm_object))); list->remove(index); } for (size_t i = 2; i < argc; i++) { list->insert(accessor, index + i - 2, arguments[i]); } return_value.set(Object::create_array(ctx, removed_objects)); }
void checkAggregationAvgGenericValueAccessor() { const GenericType &type = GenericType::Instance(true); initializeHandle(type); EXPECT_TRUE(aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_).isNull()); typename GenericType::cpptype sum; SetDataType(0, &sum); std::unique_ptr<ColumnVectorsValueAccessor> accessor(new ColumnVectorsValueAccessor()); accessor->addColumn(createColumnVectorGeneric<GenericType>(type, &sum)); std::unique_ptr<AggregationState> va_state( aggregation_handle_avg_->accumulateValueAccessor(accessor.get(), std::vector<attribute_id>(1, 0))); // Test the state generated directly by accumulateValueAccessor(), and also // test after merging back. CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *va_state); aggregation_handle_avg_->mergeStates(*va_state, aggregation_handle_avg_state_.get()); CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *aggregation_handle_avg_state_); }
void setup_plastic(void) { boost::shared_ptr<shade::GLSLTexture> texture(new shade::GLSLTexture(GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY_EXT)); texture->bind(); glTexParameterf(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); Texture texture_data("examples/patterns.dds", 4); texture_data.upload(); boost::shared_ptr<ArrayPlastic> specular(new ArrayPlastic(0.7, .3)); specular->texture_unit.set(texture); boost::shared_ptr<shade::shaders::ObjectSpace> object_space(new shade::shaders::ObjectSpace); specular->coordinate_system = object_space; boost::shared_ptr<shade::shaders::UVCoord> uvcoord(new shade::shaders::UVCoord); specular->uv = uvcoord; shader->material = specular; { shaders::IlluminatedMaterial::LightList::Accessor accessor(specular->lights); boost::shared_ptr<shaders::PointLight> light(new shaders::PointLight); light->position.set_value(shade::vec3<>(30., 15., 10.)); light->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light); boost::shared_ptr<shaders::PointLight> light2(new shaders::PointLight); light2->position.set_value(shade::vec3<>(-15., -3, 0.)); light2->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light2); } }
virtual Vector b(Real t) { Vector b(grid.vector()); // flow function at time t auto flow_t = curry<1 + Dimension + ControlDimension>(flow, t); Real args[Dimension + ControlDimension]; Index k = 0; for(auto node : accessor(grid, b)) { // Coordinates auto coords = &node; for(int i = 0; i < Dimension; ++i) { args[i] = coords[i]; } // Control coordinates for(int i = 0; i < ControlDimension; ++i) { args[Dimension + i] = (this->control(i))(k); } // Set value at node *node = (Negative ? -1. : 1.) * packAndCall<Dimension + ControlDimension>(flow_t, args); ++k; } return b; }
void test3DSurfaceIn4DImage() { mitk::SurfaceToImageFilter::Pointer surfaceToImageFilter = mitk::SurfaceToImageFilter::New(); mitk::Image::Pointer additionalInputImage = mitk::Image::New(); unsigned int* dims = new unsigned int[4]; dims[0] = 32; dims[1] = 32; dims[2] = 32; dims[3] = 2; additionalInputImage->Initialize( mitk::MakeScalarPixelType<unsigned int>(),4,dims); additionalInputImage->SetOrigin(m_Surface->GetGeometry()->GetOrigin()); additionalInputImage->GetGeometry()->SetIndexToWorldTransform(m_Surface->GetGeometry()->GetIndexToWorldTransform()); mitk::Image::Pointer secondStep = additionalInputImage->Clone(); unsigned int size = sizeof(unsigned char); for (unsigned int i = 0; i < secondStep->GetDimension(); ++i) size *= secondStep->GetDimension(i); mitk::ImageWriteAccessor accessor( secondStep ); memset( accessor.GetData(), 1, size ); additionalInputImage->GetTimeGeometry()->Expand(2); additionalInputImage->GetGeometry(1)->SetSpacing(secondStep->GetGeometry()->GetSpacing()); additionalInputImage->GetGeometry(1)->SetOrigin(secondStep->GetGeometry()->GetOrigin()); additionalInputImage->GetGeometry(1)->SetIndexToWorldTransform(secondStep->GetGeometry()->GetIndexToWorldTransform()); additionalInputImage->SetImportVolume(secondStep->GetData(),0); additionalInputImage->SetImportVolume(secondStep->GetData(),1); //Arrange the filter surfaceToImageFilter->MakeOutputBinaryOn(); surfaceToImageFilter->SetInput(m_Surface); surfaceToImageFilter->SetImage(additionalInputImage); surfaceToImageFilter->Update(); mitk::ImagePixelReadAccessor<unsigned char,4> outputReader(surfaceToImageFilter->GetOutput()); itk::Index<4> idx; bool valuesCorrect = true; //Values outside the ball should be 0 idx[0] = 0; idx[1] = 0, idx[2] = 0; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 0; idx[1] = 15, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 15; idx[1] = 15, idx[2] = 0; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 15; idx[1] = 0, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 5; idx[1] = 9, idx[2] = 23; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); //Values inside the ball should be 1 hould be 1 idx[0] = 15; idx[1] = 15, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); idx[0] = 31; idx[1] = 15, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); idx[0] = 2; idx[1] = 15, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); idx[0] = 15; idx[1] = 15, idx[2] = 2; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); idx[0] = 15; idx[1] = 2, idx[2] = 15; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); idx[0] = 6; idx[1] = 9, idx[2] = 23; idx[3] = 0; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 1); //Values inside the ball but in the second timestep hould be 0 idx[0] = 15; idx[1] = 15, idx[2] = 15; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 31; idx[1] = 15, idx[2] = 15; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 2; idx[1] = 15, idx[2] = 15; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 15; idx[1] = 15, idx[2] = 2; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 15; idx[1] = 2, idx[2] = 15; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); idx[0] = 6; idx[1] = 9, idx[2] = 23; idx[3] = 1; valuesCorrect = valuesCorrect && (outputReader.GetPixelByIndex(idx) == 0); CPPUNIT_ASSERT_MESSAGE("SurfaceToImageFilter_BallSurfaceAsInput_Output4DCorrect", valuesCorrect == true); }
const OrchestratorPtr OrchestratorFactory::create(const LineRenderer &renderer, const Pattern pattern) const{ RulesPtr livingRules(new LivingRules()); RulesPtr deadRules(new DeadRules()); AccessorPtr accessor(new RuleBasedGenerationAccessor(livingRules, deadRules)); OrchestratorPtr orchestratorPtr(new Orchestrator(accessor, renderer, pattern)); return orchestratorPtr; }
int main(int argc, char* argv[]) { terrama2::core::TerraMA2Init terramaRaii("example", 0); { //DataProvider information terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->uri = "file://"; dataProvider->uri += TERRAMA2_DATA_DIR; dataProvider->uri += "/geotiff"; dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "FILE"; dataProvider->active = true; auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); //DataSeries information terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries); dataSeries->semantics = semanticsManager.getSemantics("GRID-geotiff"); terrama2::core::DataSetGrid* dataSet = new terrama2::core::DataSetGrid(); dataSet->active = true; dataSet->format.emplace("mask", "L5219076_07620040908_r3g2b1.tif"); dataSeries->datasetList.emplace_back(dataSet); //empty filter terrama2::core::Filter filter; //accessing data terrama2::core::DataAccessorGeoTiff accessor(dataProviderPtr, dataSeriesPtr); auto remover = std::make_shared<terrama2::core::FileRemover>(); terrama2::core::GridSeriesPtr gridSeries = accessor.getGridSeries(filter, remover); assert(gridSeries->gridMap().size() == 1); auto raster = gridSeries->gridMap().begin()->second; assert(raster->getSRID() != 0); std::cout << "SRID: " << raster->getSRID() << std::endl; std::string output = TERRAMA2_DATA_DIR; output+="/grid_output.tif"; te::rp::Copy2DiskRaster(*raster, output); std::cout << "Tiff file copied to " << output << std::endl; } return 0; }
Vector image(F &&function) const { Vector v = vector(); for(auto node : accessor(*this, v)) { *node = packAndCall<Dimension>( std::forward<F>(function), (&node).data() ); } return v; }
// Utility for running timings of reads of the filebundle segment with // different caching. uint32 TestReadAll(FileBundleReaderSegment& segment, uint32 request_count, uint32 max_blocks, uint32 block_size, std::string prefix) { std::string buffer; buffer.reserve(block_size); buffer.resize(request_count); char* out_buffer = const_cast<char*>(buffer.data()); // Test Read uncached of entire filebundle CachedReadAccessor accessor(max_blocks < 2 ? 2 : max_blocks, block_size); khTimer_t begin = khTimer::tick(); uint32 read_count = 0; uint32 packet_count = 0; uint64 stats_bytes_read = 0; uint64 stats_disk_accesses = 0; for(uint32 offset = 0; offset < file_bundle_size_; offset += request_count) { uint32 size = std::min(request_count, file_bundle_size_ - offset); if (max_blocks == 0) { // No cache...read via the segment directly. segment.Pread(out_buffer, size, offset); stats_bytes_read += size; stats_disk_accesses++; } else { // Read via the accessor. accessor.Pread(segment, out_buffer, size, offset); } read_count += size; packet_count++; } khTimer_t end = khTimer::tick(); uint32 megabytes_per_second = static_cast<uint32>(read_count / (khTimer::delta_s(begin, end) * 1000000)); std::cerr << prefix << ": " << request_count << " bytes per packet " << packet_count << " packets " << megabytes_per_second << " MB/sec" << std::endl; // Print some basic stats to make sure the cache is doing it's job right. if (max_blocks >= 2) { stats_bytes_read = accessor.StatsBytesRead(); stats_disk_accesses = accessor.StatsDiskAccesses(); } uint64 chunk_sizes = block_size; if (max_blocks < 2) { chunk_sizes = request_count; } uint64 desired_disk_accesses = (file_bundle_size_ + chunk_sizes - 1) / chunk_sizes; TestAssertEquals(stats_bytes_read, static_cast<uint64>(file_bundle_size_)); TestAssertEquals(stats_disk_accesses, static_cast<uint64>(desired_disk_accesses)); std::cerr << "Read " << stats_bytes_read << " bytes from disk in " << stats_disk_accesses << " reads" << std::endl; return megabytes_per_second; }
/*--------------------------------------------------------------------------*/ int callSetProperty(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol, const char *propertyName) { setPropertyFunc accessor = searchSetHashtable(setHashTable, propertyName); if (accessor == NULL) { Scierror(999, _("Unknown property: %s.\n"), propertyName); return NULL; } return accessor(_pvCtx, iObjUID, _pvData, valueType, nbRow, nbCol); }
void ListClass<T>::unshift(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { validate_argument_count_at_least(argc, 1); auto list = get_internal<T, ListClass<T>>(this_object); NativeAccessor<T> accessor(ctx, list->get_realm(), list->get_object_schema()); for (size_t i = 0; i < argc; i++) { list->insert(accessor, i, arguments[i]); } return_value.set((uint32_t)list->size()); }
void JPDoubleType::setArrayRange(JPJavaFrame& frame, jarray a, int start, int length, vector<HostRef*>& vals) { JPPrimitiveArrayAccessor<array_t, type_t*> accessor(frame, a, &JPJavaFrame::GetDoubleArrayElements, &JPJavaFrame::ReleaseDoubleArrayElements); type_t* val = accessor.get(); for (int i = 0; i < length; i++) { HostRef* pv = vals[i]; val[start+i] = field(convertToJava(pv)); } accessor.commit(); }
void ServerContext::AnswerAttachment(RestApiOutput& output, const std::string& resourceId, FileContentType content) { FileInfo attachment; if (!index_.LookupAttachment(attachment, resourceId, content)) { throw OrthancException(ErrorCode_UnknownResource); } StorageAccessor accessor(area_); accessor.AnswerFile(output, attachment, GetFileContentMime(content)); }
int main(int argc, char* argv[]) { terrama2::core::TerraMA2Init terramaRaii("example", 0); { //DataProvider information terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->uri = "file://"; dataProvider->uri+=TERRAMA2_DATA_DIR; dataProvider->uri+="/PCD_serrmar_INPE"; dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "FILE"; dataProvider->active = true; //DataSeries information terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries); auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); dataSeries->semantics = semanticsManager.getSemantics("DCP-inpe"); terrama2::core::DataSetDcp* dataSet = new terrama2::core::DataSetDcp(); dataSet->active = true; dataSet->format.emplace("mask", "30885.txt"); dataSet->format.emplace("timezone", "+00"); dataSeries->datasetList.emplace_back(dataSet); //empty filter terrama2::core::Filter filter; filter.lastValue = true; //accessing data terrama2::core::DataAccessorDcpInpe accessor(dataProviderPtr, dataSeriesPtr); auto remover = std::make_shared<terrama2::core::FileRemover>(); terrama2::core::DcpSeriesPtr dcpSeries = accessor.getDcpSeries(filter, remover); assert(dcpSeries->dcpSeriesMap().size() == 1); auto series = dcpSeries->getSeries().begin()->second; auto teDataSet = series.syncDataSet->dataset(); std::cout << "dataset size: " << teDataSet->size() << std::endl; } return 0; }
vector<HostRef*> JPDoubleType::getArrayRange(JPJavaFrame& frame, jarray a, int start, int length) { JPPrimitiveArrayAccessor<array_t, type_t*> accessor(frame, a, &JPJavaFrame::GetDoubleArrayElements, &JPJavaFrame::ReleaseDoubleArrayElements); type_t* val = accessor.get(); vector<HostRef*> res; jvalue v; for (int i = 0; i < length; i++) { field(v) = val[i+start]; res.push_back(asHostObject(v)); } return res; }
static void __HandleIndexList(unsigned int idx, COLLADAFW::IndexList *indexList, Semantic semantic, bool shouldTriangulate, unsigned int count, unsigned int vcount, unsigned int *verticesCountArray, shared_ptr <GLTF::GLTFPrimitive> cvtPrimitive, IndicesVector &primitiveIndicesVector, shared_ptr<GLTFProfile> profile) { unsigned int triangulatedIndicesCount = 0; bool ownData = false; unsigned int *indices = indexList->getIndices().getData(); if (shouldTriangulate) { indices = createTrianglesFromPolylist(verticesCountArray, indices, vcount, &triangulatedIndicesCount); count = triangulatedIndicesCount; ownData = true; } //Why is OpenCOLLADA doing this ? why adding an offset the indices ?? //We need to offset it backward here. unsigned int initialIndex = (unsigned int)indexList->getInitialIndex(); if (initialIndex != 0) { unsigned int *bufferDestination = 0; if (!ownData) { bufferDestination = (unsigned int*)malloc(sizeof(unsigned int) * count); ownData = true; } else { bufferDestination = indices; } for (size_t idx = 0 ; idx < count ; idx++) { bufferDestination[idx] = indices[idx] - initialIndex; } indices = bufferDestination; } shared_ptr <GLTF::GLTFBufferView> uvBuffer = createBufferViewWithAllocatedBuffer(indices, 0, count * sizeof(unsigned int), ownData); shared_ptr <GLTFAccessor> accessor(new GLTFAccessor(profile, profile->getGLenumForString("UNSIGNED_SHORT"))); accessor->setBufferView(uvBuffer); accessor->setCount(count); __AppendIndices(cvtPrimitive, primitiveIndicesVector, accessor, semantic, idx); }
void ServerContext::ChangeAttachmentCompression(const std::string& resourceId, FileContentType attachmentType, CompressionType compression) { LOG(INFO) << "Changing compression type for attachment " << EnumerationToString(attachmentType) << " of resource " << resourceId << " to " << compression; FileInfo attachment; if (!index_.LookupAttachment(attachment, resourceId, attachmentType)) { throw OrthancException(ErrorCode_UnknownResource); } if (attachment.GetCompressionType() == compression) { // Nothing to do return; } std::string content; StorageAccessor accessor(area_); accessor.Read(content, attachment); FileInfo modified = accessor.Write(content.empty() ? NULL : content.c_str(), content.size(), attachmentType, compression, storeMD5_); try { StoreStatus status = index_.AddAttachment(modified, resourceId); if (status != StoreStatus_Success) { accessor.Remove(modified); throw OrthancException(ErrorCode_Database); } } catch (OrthancException&) { accessor.Remove(modified); throw; } }
void ezQtPropertyAnimAssetDocumentWindow::onEventTrackCpDeleted(ezUInt32 cpIdx) { ezPropertyAnimAssetDocument* pDoc = GetPropertyAnimDocument(); ezObjectCommandAccessor accessor(pDoc->GetCommandHistory()); const ezAbstractProperty* pTrackProp = ezGetStaticRTTI<ezPropertyAnimationTrackGroup>()->FindPropertyByName("EventTrack"); const ezUuid trackGuid = accessor.Get<ezUuid>(pDoc->GetPropertyObject(), pTrackProp); const ezDocumentObject* pTrackObj = accessor.GetObject(trackGuid); const ezVariant cpGuid = pTrackObj->GetTypeAccessor().GetValue("ControlPoints", cpIdx); if (!cpGuid.IsValid()) return; ezRemoveObjectCommand cmdSet; cmdSet.m_Object = cpGuid.Get<ezUuid>(); pDoc->GetCommandHistory()->AddCommand(cmdSet); }
void init(void) { shader = boost::shared_ptr<shaders::Surface>(new shaders::Surface); boost::shared_ptr<shade::shaders::Plastic> specular(new shade::shaders::Plastic(0.4, 0.6)); boost::shared_ptr<shade::shaders::TangentSpace> coordinate_system(new shade::shaders::TangentSpace); boost::shared_ptr<shade::shaders::Texture2D> tex_access(new shade::shaders::Texture2D); boost::shared_ptr<shade::GLSLTexture> texture(example::make_texture("examples/heightbump.dds")); tex_access->texture_unit.set(texture); boost::shared_ptr<shade::shaders::UVCoord> uvcoord(new shade::shaders::UVCoord); tex_access->uv = uvcoord; specular->color.set_value(shade::vec4<>(1., 0.4, 0.4, 1.)); specular->coordinate_system = coordinate_system; coordinate_system->normal_map = tex_access; shader->material = specular; { shaders::IlluminatedMaterial::LightList::Accessor accessor(specular->lights); boost::shared_ptr<shaders::PointLight> light(new shaders::PointLight); light->position.set_value(shade::vec3<>(30., 15., 10.)); light->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light); boost::shared_ptr<shaders::PointLight> light2(new shaders::PointLight); light2->position.set_value(shade::vec3<>(-15., -3, 0.)); light2->color.set_value(shade::vec3<>(1., 1., 1.)); accessor->push_back(light2); } boost::shared_ptr<Displacement> displacement = boost::shared_ptr<Displacement>(new Displacement); shader->geometry = displacement; displacement->coordinate_system = coordinate_system.get(); displacement->texture_unit.set(texture); state = shade::create_GLSL_wrapper(); state->init(); state->set_geometry_paramters(GL_TRIANGLES, GL_TRIANGLE_STRIP, 64); program = boost::shared_ptr<shade::Program>(new shade::Program(shader, state)); if (std::getenv("DISPLACE_WIREFRAME")) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); }
void JPDoubleType::setArrayRange(JPJavaFrame& frame, jarray a, int start, int length, PyObject* sequence) { if (setViaBuffer<array_t, type_t>(frame, a, start, length, sequence, &JPJavaFrame::SetDoubleArrayRegion)) return; JPPrimitiveArrayAccessor<array_t, type_t*> accessor(frame, a, &JPJavaFrame::GetDoubleArrayElements, &JPJavaFrame::ReleaseDoubleArrayElements); type_t* val = accessor.get(); for (Py_ssize_t i = 0; i < length; ++i) { PyObject* o = PySequence_GetItem(sequence, i); type_t v = (type_t) PyFloat_AsDouble(o); if (v == -1.) { CONVERSION_ERROR_HANDLE(i, o); } Py_DECREF(o); val[start+i] = v; } accessor.commit(); }
void query(DATATYPE *quy, unsigned size, DATATYPE *indices, DATATYPE *dists, unsigned type, unsigned K) { Matrix<DATATYPE>::Accessor accessor(data); Metric<DATATYPE> metric(data.getDim(), type); Scanner<lshbox::Matrix<DATATYPE>::Accessor> scanner( accessor, metric, K ); for (unsigned i = 0; i != size; ++i) { lsh.query(quy + i * data.getDim(), scanner); std::vector<std::pair<float, unsigned> > tmp = scanner.topk().getTopk(); for (unsigned j = 0; j != tmp.size(); ++j) { indices[i * K + j] = tmp[j].second; dists[i * K + j] = tmp[j].first; } } }
void ezQtPropertyAnimAssetDocumentWindow::onEventTrackCpMoved(ezUInt32 cpIdx, ezInt64 iTickX) { iTickX = ezMath::Max<ezInt64>(iTickX, 0); ezPropertyAnimAssetDocument* pDoc = GetPropertyAnimDocument(); ezObjectCommandAccessor accessor(pDoc->GetCommandHistory()); const ezAbstractProperty* pTrackProp = ezGetStaticRTTI<ezPropertyAnimationTrackGroup>()->FindPropertyByName("EventTrack"); const ezUuid trackGuid = accessor.Get<ezUuid>(pDoc->GetPropertyObject(), pTrackProp); const ezDocumentObject* pTrackObj = accessor.GetObject(trackGuid); const ezVariant cpGuid = pTrackObj->GetTypeAccessor().GetValue("ControlPoints", cpIdx); ezSetObjectPropertyCommand cmdSet; cmdSet.m_Object = cpGuid.Get<ezUuid>(); cmdSet.m_sProperty = "Tick"; cmdSet.m_NewValue = iTickX; pDoc->GetCommandHistory()->AddCommand(cmdSet); }
string IntlUtil::generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributesMap& map) { SpecificAttributesMap::Accessor accessor(&map); bool found = accessor.getFirst(); string s; while (found) { UCHAR c[sizeof(ULONG)]; ULONG size; SpecificAttribute* attribute = accessor.current(); s += escapeAttribute(cs, attribute->first); const USHORT equalChar = '='; size = cs->getConvFromUnicode().convert( sizeof(equalChar), (const UCHAR*) &equalChar, sizeof(c), c); s.append((const char*) &c, size); s += escapeAttribute(cs, attribute->second); found = accessor.getNext(); if (found) { const USHORT semiColonChar = ';'; size = cs->getConvFromUnicode().convert( sizeof(semiColonChar), (const UCHAR*) &semiColonChar, sizeof(c), c); s.append((const char*) &c, size); } } return s; }