예제 #1
0
    /*! initialize an internal brick representation from input
        brickinfo and corresponding input data pointer */
    AMRData::Brick::Brick(const BrickInfo &info, const float *data)
    {
      this->box = info.box;
      this->level = info.level;
      this->cellWidth = info.cellWidth;

      this->value = data;
      this->dims  = this->box.size() + vec3i(1);
      this->gridToWorldScale = 1.f/this->cellWidth;
      this->worldBounds = box3f(vec3f(this->box.lower) * this->cellWidth,
                                vec3f(this->box.upper+vec3i(1)) * this->cellWidth);
      this->worldToGridScale = rcp(this->worldBounds.size());
      this->f_dims = vec3f(this->dims);
    }
예제 #2
0
파일: QuadMesh.cpp 프로젝트: ospray/OSPRay
    box3f QuadMesh::computeBounds() const
    {
      box3f bbox = bounds();

      if (bbox != box3f(empty))
        return bbox;

      if (hasChild("vertex")) {
        auto v = child("vertex").nodeAs<DataBuffer>();
        for (uint32_t i = 0; i < v->size(); i++)
          bbox.extend(v->get<vec3f>(i));
      }
      child("bounds") = bbox;
      return bbox;
    }
예제 #3
0
    box3f Cylinders::computeBounds() const
    {
      box3f bbox = bounds();

      if (bbox != box3f(empty))
        return bbox;

      if (hasChild("cylinders")) {
        auto cylinders = child("cylinders").nodeAs<DataBuffer>();

        auto *base = (byte_t*)cylinders->base();

        int cylinderBytes = 24;
        if (hasChild("bytes_per_cylinder"))
          cylinderBytes = child("bytes_per_cylinder").valueAs<int>();

        int offset_v0 = 0;
        if (hasChild("offset_v0"))
          offset_v0 = child("offset_v0").valueAs<int>();

        int offset_v1 = 12;
        if (hasChild("offset_v1"))
          offset_v1 = child("offset_v1").valueAs<int>();

        int offset_radius = -1;
        if (hasChild("offset_radius"))
          offset_radius = child("offset_radius").valueAs<int>();

        float radius = 0.01f;
        if (hasChild("radius"))
          radius = child("radius").valueAs<float>();

        for (size_t i = 0; i < cylinders->numBytes(); i += cylinderBytes) {
          vec3f &v0 = *(vec3f*)(base + i + offset_v0);
          vec3f &v1 = *(vec3f*)(base + i + offset_v1);
          if (offset_radius >= 0)
            radius = *(float*)(base + i + offset_radius);
          // TODO less conservative bbox
          box3f cylinderBounds(ospcommon::min(v0, v1) - radius,
                               ospcommon::max(v0, v1) + radius);
          bbox.extend(cylinderBounds);
        }
      }

      child("bounds") = bbox;

      return bbox;
    }
예제 #4
0
파일: Model.cpp 프로젝트: ospray/OSPRay
    void Model::postCommit(RenderContext &ctx)
    {
      auto model = valueAs<OSPModel>();
      ctx.currentOSPModel = model;

      //instancegroup caches render calls in commit.
      for (auto &child : properties.children)
        child.second->finalize(ctx);

      ospCommit(model);
      ctx.currentOSPModel = stashedModel;

      // reset bounding box
      child("bounds") = box3f(empty);
      computeBounds();
    }
예제 #5
0
    void DistributedModel::commit()
    {
      othersRegions.clear();

      // TODO: We may need to override the ISPC calls made
      // to the Model or customize the model struct on the ISPC
      // side. In which case we need some ISPC side inheritence
      // for the model type. Currently the code is actually identical.
      Model::commit();
      // Send my bounding boxes to other nodes, recieve theirs for a
      // "full picture" of what geometries live on what nodes
      Data *regionData = getParamData("regions");
      Data *ghostRegionData = getParamData("ghostRegions");

      // The box3f data is sent as data of FLOAT3 items
      // TODO: It's a little awkward to copy the boxes again like this, maybe
      // can re-thinkg the send side of the bcast call? One that takes
      // a ptr and a size since we know we won't be writing out to it?
      // TODO: For now it doesn't matter that we don't know who owns the
      // other boxes, just that we know they exist and their bounds, and that
      // they aren't ours.
      if (regionData) {
        box3f *boxes = reinterpret_cast<box3f*>(regionData->data);
        myRegions = std::vector<box3f>(boxes, boxes + regionData->numItems / 2);
      }

      // If the user hasn't set any regions, there's an implicit infinitely
      // large region box we can place around the entire world.
      if (myRegions.empty()) {
        postStatusMsg("No regions found, making implicit "
                      "infinitely large region", 1);
        myRegions.push_back(box3f(vec3f(neg_inf), vec3f(pos_inf)));
      }

      // Check if we've got ghost regions set, otherwise just use the regions
      if (ghostRegionData) {
        box3f *boxes = reinterpret_cast<box3f*>(ghostRegionData->data);
        ghostRegions = std::vector<box3f>(boxes, boxes + ghostRegionData->numItems / 2);
      } else {
        ghostRegions = myRegions;
      }

      for (int i = 0; i < mpicommon::numGlobalRanks(); ++i) {
        if (i == mpicommon::globalRank()) {
          messaging::bcast(i, myRegions);
        } else {
          std::vector<box3f> recv;
          messaging::bcast(i, recv);
          std::copy(recv.begin(), recv.end(),
                    std::back_inserter(othersRegions));
        }
      }

      if (logLevel() >= 1) {
        for (int i = 0; i < mpicommon::numGlobalRanks(); ++i) {
          if (i == mpicommon::globalRank()) {
            postStatusMsg(1) << "Rank " << mpicommon::globalRank()
              << ": Got regions from others {";
            for (const auto &b : othersRegions) {
              postStatusMsg(1) << "\t" << b << ",";
            }
            postStatusMsg(1) << "}";
          }
        }
      }
    }