Esempio n. 1
0
   bool process() {
      const Index numElem = m_grid->getNumElements();

      std::vector<Index> outputIdxV(numElem+1);
      auto outputIdx = outputIdxV.data();
      outputIdx[0] = 0;
#pragma omp parallel
      {
         Scalar tmin = std::numeric_limits<Scalar>::max();
         Scalar tmax = -std::numeric_limits<Scalar>::max();
#pragma omp for
         for (ssize_t elem=0; elem<numElem; ++elem) {

            Index n = 0;
            switch (tl[elem]) {
               case UnstructuredGrid::HEXAHEDRON: {
                  n = processHexahedron(elem, 0, true /* count only */, tmin, tmax);
               }
            }

            outputIdx[elem+1] = n;
         }
#pragma omp critical
         {
            if (tmin < gmin)
               gmin = tmin;
            if (tmax > gmax)
               gmax = tmax;
         }
      }

      for (Index elem=0; elem<numElem; ++elem) {
         outputIdx[elem+1] += outputIdx[elem];
      }

      Index numVert = outputIdx[numElem];

      //std::cerr << "IsoSurface: " << numVert << " vertices" << std::endl;

      m_triangles->cl().resize(numVert);
      out_cl = m_triangles->cl().data();
      m_triangles->x().resize(numVert);
      out_x = m_triangles->x().data();
      m_triangles->y().resize(numVert);
      out_y = m_triangles->y().data();
      m_triangles->z().resize(numVert);
      out_z = m_triangles->z().data();

      if (m_outData) {
         m_outData->x().resize(numVert);
         out_d = m_outData->x().data();
      }

#pragma omp parallel for
      for (Index elem = 0; elem<numElem; ++elem) {
         switch (tl[elem]) {
            case UnstructuredGrid::HEXAHEDRON: {
               processHexahedron(elem, outputIdx[elem], false, gmin, gmax);
            }
         }
      }

      //std::cerr << "CuttingSurface: << " << m_outData->x().size() << " vert, " << m_outData->x().size() << " data elements" << std::endl;

      return true;
   }
Esempio n. 2
0
   bool process() {

      processCoordinates();
      Index numCoordsIn = m_outCoords->getNumCoords();

      if (m_tri) {
         const Index numElem = haveCornerList ? m_tri->getNumCorners()/3 : m_tri->getNumCoords()/3;

         std::vector<Index> outIdxCorner(numElem+1), outIdxCoord(numElem+1);
         outIdxCorner[0] = 0;
         outIdxCoord[0] = numCoordsIn;
#pragma omp parallel for schedule (dynamic)
         for (ssize_t elem=0; elem<numElem; ++elem) {

            Index numCorner=0, numCoord=0;
            processTriangle(elem, numCorner, numCoord, true);

            outIdxCorner[elem+1] = numCorner;
            outIdxCoord[elem+1] = numCoord;
         }

         for (Index elem=0; elem<numElem; ++elem) {
            outIdxCoord[elem+1] += outIdxCoord[elem];
            outIdxCorner[elem+1] += outIdxCorner[elem];
         }

         Index numCoord = outIdxCoord[numElem];
         Index numCorner = outIdxCorner[numElem];

         if (haveCornerList) {
            m_outTri->cl().resize(numCorner);
            out_cl = m_outTri->cl().data();
         }

         m_outTri->setSize(numCoord);
         out_x = m_outTri->x().data();
         out_y = m_outTri->y().data();
         out_z = m_outTri->z().data();

         if (m_outData) {
            m_outData->x().resize(numCoord);
            out_d = m_outData->x().data();
         }

#pragma omp parallel for schedule (dynamic)
         for (ssize_t elem = 0; elem<numElem; ++elem) {
            processTriangle(elem, outIdxCorner[elem], outIdxCoord[elem], false);
         }
         //std::cerr << "CuttingSurface: << " << m_outData->x().size() << " vert, " << m_outData->x().size() << " data elements" << std::endl;

         return true;
      } else if (m_poly) {

         const Index numElem = m_poly->getNumElements();

         std::vector<Index> outIdxPoly(numElem+1), outIdxCorner(numElem+1), outIdxCoord(numElem+1);
         outIdxPoly[0] = 0;
         outIdxCorner[0] = 0;
         outIdxCoord[0] = numCoordsIn;
#pragma omp parallel for schedule (dynamic)
         for (ssize_t elem=0; elem<numElem; ++elem) {

            Index numPoly=0, numCorner=0, numCoord=0;
            processPolygon(elem, numPoly, numCorner, numCoord, true);
            outIdxPoly[elem+1] = numPoly;
            outIdxCorner[elem+1] = numCorner;
            outIdxCoord[elem+1] = numCoord;
         }

         for (Index elem=0; elem<numElem; ++elem) {
            outIdxPoly[elem+1] += outIdxPoly[elem];
            outIdxCorner[elem+1] += outIdxCorner[elem];
            outIdxCoord[elem+1] += outIdxCoord[elem];
         }
         Index numPoly = outIdxPoly[numElem];
         Index numCorner = outIdxCorner[numElem];
         Index numCoord = outIdxCoord[numElem];

         m_outPoly->el().resize(numPoly+1);
         out_el = m_outPoly->el().data();
         out_el[numPoly] = numCorner;
         m_outPoly->cl().resize(numCorner);
         out_cl = m_outPoly->cl().data();

         m_outPoly->setSize(numCoord);
         out_x = m_outPoly->x().data();
         out_y = m_outPoly->y().data();
         out_z = m_outPoly->z().data();

         if (m_outData) {
            m_outData->x().resize(numCoord);
            out_d = m_outData->x().data();
         }

#pragma omp parallel for schedule (dynamic)
         for (ssize_t elem = 0; elem<numElem; ++elem) {
            processPolygon(elem, outIdxPoly[elem], outIdxCorner[elem], outIdxCoord[elem], false);
         }

         //std::cerr << "CuttingSurface: << " << m_outData->x().size() << " vert, " << m_outData->x().size() << " data elements" << std::endl;

         return true;
      }

      return true;
   }