inline SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::SlicedCartesian( void) :numVertices(0), numSlices(0), slices(0), numCells(0), cellSize(Scalar(0)), domainBox(Box::empty) { /* Initialize vertex stride array: */ for(int i=0;i<dimension;++i) vertexStrides[i]=0; /* Initialize vertex offset array: */ for(int i=0;i<CellTopology::numVertices;++i) vertexOffsets[i]=0; /* Initialize vertex list bounds: */ Index vertexIndex(0); firstVertex=VertexIterator(this,vertexIndex); lastVertex=VertexIterator(this,vertexIndex); /* Initialize cell list bounds: */ Index cellIndex(0); firstCell=CellIterator(this,cellIndex); lastCell=CellIterator(this,cellIndex); }
VertexMapper::iterator VertexMapper::end() { if(buffer) { void* endptr = ADVANCE_VOID_PTR(data, element_size * buffer->count()); return VertexIterator(endptr, this); } return begin(); }
typename PolygonMesh<PointType>::VertexIterator PolygonMesh<PointType>::splitFace(const typename PolygonMesh<PointType>::FaceIterator& faceIt,typename PolygonMesh<PointType>::Vertex* facePoint) { /* Link the face point to the mesh: */ facePoint->pred=lastVertex; facePoint->succ=0; if(lastVertex!=0) lastVertex->succ=facePoint; else vertices=facePoint; lastVertex=facePoint; /* Create a fan of triangles around the face point: */ Edge* firstOuterEdge=faceIt->getEdge(); deleteFace(faceIt.face); Edge* outerEdge=firstOuterEdge; Edge* firstInnerEdge; Edge* lastInnerEdge=0; do { Edge* nextOuterEdge=outerEdge->getFaceSucc(); /* Create a new triangle: */ Face* triangle=newFace(); Edge* innerEdge1=newEdge(); Edge* innerEdge2=newEdge(); facePoint->setEdge(innerEdge1); innerEdge1->set(facePoint,triangle,innerEdge2,outerEdge,lastInnerEdge); innerEdge1->sharpness=0; if(lastInnerEdge!=0) lastInnerEdge->setOpposite(innerEdge1); else firstInnerEdge=innerEdge1; innerEdge2->set(outerEdge->getEnd(),triangle,outerEdge,innerEdge1,0); innerEdge2->sharpness=0; outerEdge->setFace(triangle); outerEdge->setFacePred(innerEdge1); outerEdge->setFaceSucc(innerEdge2); triangle->setEdge(outerEdge); #ifndef NDEBUG triangle->checkFace(); #endif lastInnerEdge=innerEdge2; outerEdge=nextOuterEdge; } while(outerEdge!=firstOuterEdge); /* Close the fan by connecting the first and last inner edges: */ lastInnerEdge->setOpposite(firstInnerEdge); firstInnerEdge->setOpposite(lastInnerEdge); #ifndef NDEBUG facePoint->checkVertex(); #endif return VertexIterator(facePoint); }
typename PolygonMesh<PointType>::VertexIterator PolygonMesh<PointType>::splitEdge(const typename PolygonMesh<PointType>::EdgeIterator& edgeIt,typename PolygonMesh<PointType>::Vertex* edgePoint) { /* Link vertex to mesh: */ edgePoint->pred=lastVertex; edgePoint->succ=0; if(lastVertex!=0) lastVertex->succ=edgePoint; else vertices=edgePoint; lastVertex=edgePoint; Edge* edge1=edgeIt.edge; Vertex* vertex1=edge1->getStart(); Edge* edge2=edge1->getOpposite(); Vertex* vertex2=edge2->getStart(); Edge* edge3=newEdge(); Edge* edge4=newEdge(); /* Split edge1 and edge2: */ edgePoint->setEdge(edge3); edge3->set(edgePoint,edge1->getFace(),edge1,edge1->getFaceSucc(),edge2); edge3->sharpness=edge1->sharpness; edge4->set(edgePoint,edge2->getFace(),edge2,edge2->getFaceSucc(),edge1); edge4->sharpness=edge2->sharpness; edge1->setFaceSucc(edge3); edge1->setOpposite(edge4); edge2->setFaceSucc(edge4); edge2->setOpposite(edge3); edge3->getFaceSucc()->setFacePred(edge3); edge4->getFaceSucc()->setFacePred(edge4); #ifndef NDEBUG vertex1->checkVertex(); vertex2->checkVertex(); edgePoint->checkVertex(); edge1->getFace()->checkFace(); edge2->getFace()->checkFace(); #endif return VertexIterator(edgePoint); }
inline void SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::setData( const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Index& sNumVertices, int sNumSlices, const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Size& sCellSize, const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Value* sVertexValues) { /* Destroy the slice arrays: */ if(numSlices>0) delete[] slices; /* Re-initialize the slice arrays: */ numVertices=sNumVertices; numSlices=sNumSlices; slices=new Array[numSlices]; for(int slice=0;slice<numSlices;++slice) slices[slice].resize(numVertices); /* Initialize vertex stride array: */ for(int i=0;i<dimension;++i) vertexStrides[i]=slices[0].getIncrement(i); /* Initialize the cell size: */ cellSize=sCellSize; /* Calculate number of cells: */ for(int i=0;i<dimension;++i) numCells[i]=numVertices[i]-1; /* Initialize vertex offset array: */ for(int i=0;i<CellTopology::numVertices;++i) { /* Vertex indices are, as usual, bit masks of a vertex' position in cell coordinates: */ vertexOffsets[i]=0; for(int j=0;j<dimension;++j) if(i&(1<<j)) vertexOffsets[i]+=vertexStrides[j]; } /* Initialize vertex list bounds: */ Index vertexIndex(0); firstVertex=VertexIterator(this,vertexIndex); vertexIndex[0]=numVertices[0]; lastVertex=VertexIterator(this,vertexIndex); /* Initialize cell list bounds: */ Index cellIndex(0); firstCell=CellIterator(this,cellIndex); cellIndex[0]=numCells[0]; lastCell=CellIterator(this,cellIndex); /* Initialize domain bounding box: */ Point domainMax; for(int i=0;i<dimension;++i) domainMax[i]=Scalar(numCells[i])*cellSize[i]; domainBox=Box(Point::origin,domainMax); /* Copy source vertex values, if present: */ if(sVertexValues!=0) { const VScalar* sPtr=sVertexValues; size_t totalNumVertices=slices[slice].getNumElements(); for(int slice=0;slice<numSlices;++slice) { /* Copy all slice vertex values: */ VScalar* vPtr=slices[slice].getArray(); for(size_t i=0;i<totalNumVertices;++i,++vPtr,++sPtr) *vPtr=*sPtr; } } }
VertexMapper::iterator VertexMapper::begin() { return VertexIterator(data, this); }