int Region::ReadMatter(istream &input) { DeleteRegion(); char tmp[256],tmp1[256]; int k;NumIntPar=0; input>>tmp>>NumPnt>>tmp>>LftPnt>>tmp>>RgtPnt; #ifdef InternalPointsUrs input>>tmp>>NumIntPar; #endif input.getline(tmp,256); input>>tmp>>LftFree>>tmp>>RgtFree>>tmp>>TimeStability;input.getline(tmp1,256); input>>tmp>>Viscouse>>tmp>>Viscouse2; input>>tmp>>Order; input.getline(tmp1,256); input>>tmp>>NumMatter>>tmp; cout<<" NumMatter "<<NumMatter<<"\n"; for (k=1;k<NumMatter;k++) input>>BndMatter[k]; BndMatter[NumMatter]=NumPnt; BndMatter[0]=0; input.getline(tmp,256); for (k=1;k<=NumMatter;k++) if (!MatterRegister(input,Matter[k]) ) { cout<<"RegionIO::ReadIni; Could not register matter. Exiting.\n"; for (int i=1;i<k;i++) delete Matter[i]; exit(1); return 0; }//exit(1); for (k=1;k<=NumMatter;k++) B[k]=new Body(BndMatter[k]-BndMatter[k-1]+1,NumIntPar,Matter[k], Viscouse,Viscouse2); B[0]=NULL;B[NumMatter+1]=NULL; SetSkipBody(); return 1; };
static void FinishRegion( wrath_GLUtesselator *tess, ActiveRegion *reg ) /* * Delete a region from the sweep line. This happens when the upper * and lower chains of a region meet (at a vertex on the sweep line). * The "inside" flag is copied to the appropriate mesh face (we could * not do this before -- since the structure of the mesh is always * changing, this face may not have even existed until now). */ { GLUhalfEdge *e = reg->eUp; GLUface *f = e->Lface; f->inside = reg->inside; f->winding_number = reg->windingNumber; if(CALL_TESS_WINDING_OR_WINDING_DATA(f->winding_number) && !f->inside) { /* [WRATH-TODO]: Look at each of the vertices of the Face, if any of the vertices are marked as "DO NOT TRIANGULATE". This essentially means iterating over the vertex linked list f->next checking each of their Org to see if that vertex is a DO NOT TRIANGULATE vertex. */ } f->anEdge = e; /* optimization for glu_wrath_gl_meshTessellateMonoRegion() */ DeleteRegion( tess, reg ); }
static void ConnectLeftDegenerate( TESStesselator *tess, ActiveRegion *regUp, TESSvertex *vEvent ) /* * The event vertex lies exacty on an already-processed edge or vertex. * Adding the new vertex involves splicing it into the already-processed * part of the mesh. */ { TESShalfEdge *e, *eTopLeft, *eTopRight, *eLast; ActiveRegion *reg; e = regUp->eUp; if( VertEq( e->Org, vEvent )) { /* e->Org is an unprocessed vertex - just combine them, and wait * for e->Org to be pulled from the queue */ assert( TOLERANCE_NONZERO ); SpliceMergeVertices( tess, e, vEvent->anEdge ); return; } if( ! VertEq( e->Dst, vEvent )) { /* General case -- splice vEvent into edge e which passes through it */ if (tessMeshSplitEdge( tess->mesh, e->Sym ) == NULL) longjmp(tess->env,1); if( regUp->fixUpperEdge ) { /* This edge was fixable -- delete unused portion of original edge */ if ( !tessMeshDelete( tess->mesh, e->Onext ) ) longjmp(tess->env,1); regUp->fixUpperEdge = FALSE; } if ( !tessMeshSplice( tess->mesh, vEvent->anEdge, e ) ) longjmp(tess->env,1); SweepEvent( tess, vEvent ); /* recurse */ return; } /* vEvent coincides with e->Dst, which has already been processed. * Splice in the additional right-going edges. */ assert( TOLERANCE_NONZERO ); regUp = TopRightRegion( regUp ); reg = RegionBelow( regUp ); eTopRight = reg->eUp->Sym; eTopLeft = eLast = eTopRight->Onext; if( reg->fixUpperEdge ) { /* Here e->Dst has only a single fixable edge going right. * We can delete it since now we have some real right-going edges. */ assert( eTopLeft != eTopRight ); /* there are some left edges too */ DeleteRegion( tess, reg ); if ( !tessMeshDelete( tess->mesh, eTopRight ) ) longjmp(tess->env,1); eTopRight = eTopLeft->Oprev; } if ( !tessMeshSplice( tess->mesh, vEvent->anEdge, eTopRight ) ) longjmp(tess->env,1); if( ! EdgeGoesLeft( eTopLeft )) { /* e->Dst had no left-going edges -- indicate this to AddRightEdges() */ eTopLeft = NULL; } AddRightEdges( tess, regUp, eTopRight->Onext, eLast, eTopLeft, TRUE ); }
int Region::ReadData(istream &input) { char tmp[256]; cout<<" Reading Param RegionIO::ReadData Num "<<NumPnt<<" Coreleft "<<Coreleft()<<"\n"; input.getline(tmp,255);// EndIter input.getline(tmp,255);// Pos Pres... for (int k=1;k<=NumMatter;k++) if (!B[k]->ReadData(input)) {cout<<"Region::ReadData; Entered only part of points NumMatter i " <<k<<"\n"; DeleteRegion(); return 0; } return 1; };
static void FinishRegion( TESStesselator *tess, ActiveRegion *reg ) /* * Delete a region from the sweep line. This happens when the upper * and lower chains of a region meet (at a vertex on the sweep line). * The "inside" flag is copied to the appropriate mesh face (we could * not do this before -- since the structure of the mesh is always * changing, this face may not have even existed until now). */ { TESShalfEdge *e = reg->eUp; TESSface *f = e->Lface; f->inside = reg->inside; f->anEdge = e; /* optimization for tessMeshTessellateMonoRegion() */ DeleteRegion( tess, reg ); }
static void DoneEdgeDict( TESStesselator *tess ) { ActiveRegion *reg; while( (reg = (ActiveRegion *)dictKey( dictMin( tess->dict ))) != NULL ) { /* * At the end of all processing, the dictionary should contain * only the two sentinel edges, plus at most one "fixable" edge * created by ConnectRightVertex(). */ if( ! reg->sentinel ) { assert( reg->fixUpperEdge ); //assert( ++fixedEdges == 1 ); } assert( reg->windingNumber == 0 ); DeleteRegion( tess, reg ); /* tessMeshDelete( reg->eUp );*/ } dictDeleteDict( &tess->alloc, tess->dict ); }
static void DoneEdgeDict( GLUtesselator *tess ) { ActiveRegion *reg; int fixedEdges = 0; /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */ while( (reg = (ActiveRegion *)dictKey( dictMin( tess->dict ))) != NULL ) { /* * At the end of all processing, the dictionary should contain * only the two sentinel edges, plus at most one "fixable" edge * created by ConnectRightVertex(). */ if( ! reg->sentinel ) { assert( reg->fixUpperEdge ); assert( ++fixedEdges == 1 ); } assert( reg->windingNumber == 0 ); DeleteRegion( tess, reg ); /* __gl_meshDelete( reg->eUp );*/ } dictDeleteDict( tess->dict ); /* __gl_dictListDeleteDict */ }
/* * @implemented */ HRGN WINAPI CreateRectRgn(int x1, int y1, int x2, int y2) { PRGN_ATTR pRgn_Attr; HRGN hrgn; int tmp; /// <- //// Remove when Brush/Pen/Rgn Attr is ready! return NtGdiCreateRectRgn(x1,y1,x2,y2); //// /* Normalize points */ tmp = x1; if ( x1 > x2 ) { x1 = x2; x2 = tmp; } tmp = y1; if ( y1 > y2 ) { y1 = y2; y2 = tmp; } /* Check outside 24 bit limit for universal set. Chp 9 Areas, pg 560.*/ if ( x1 < -(1<<27) || y1 < -(1<<27) || x2 > (1<<27)-1 || y2 > (1<<27)-1 ) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } hrgn = hGetPEBHandle(hctRegionHandle, 0); if (!hrgn) hrgn = NtGdiCreateRectRgn(0, 0, 1, 1); if (!hrgn) return hrgn; if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) { DPRINT1("No Attr for Region handle!!!\n"); DeleteRegion(hrgn); return NULL; } if (( x1 == x2) || (y1 == y2)) { pRgn_Attr->iComplexity = NULLREGION; pRgn_Attr->Rect.left = pRgn_Attr->Rect.top = pRgn_Attr->Rect.right = pRgn_Attr->Rect.bottom = 0; } else { pRgn_Attr->iComplexity = SIMPLEREGION; pRgn_Attr->Rect.left = x1; pRgn_Attr->Rect.top = y1; pRgn_Attr->Rect.right = x2; pRgn_Attr->Rect.bottom = y2; } pRgn_Attr->AttrFlags = (ATTR_RGN_DIRTY|ATTR_RGN_VALID); return hrgn; }
static void WalkDirtyRegions( TESStesselator *tess, ActiveRegion *regUp ) /* * When the upper or lower edge of any region changes, the region is * marked "dirty". This routine walks through all the dirty regions * and makes sure that the dictionary invariants are satisfied * (see the comments at the beginning of this file). Of course * new dirty regions can be created as we make changes to restore * the invariants. */ { ActiveRegion *regLo = RegionBelow(regUp); TESShalfEdge *eUp, *eLo; for( ;; ) { /* Find the lowest dirty region (we walk from the bottom up). */ while( regLo->dirty ) { regUp = regLo; regLo = RegionBelow(regLo); } if( ! regUp->dirty ) { regLo = regUp; regUp = RegionAbove( regUp ); if( regUp == NULL || ! regUp->dirty ) { /* We've walked all the dirty regions */ return; } } regUp->dirty = FALSE; eUp = regUp->eUp; eLo = regLo->eUp; if( eUp->Dst != eLo->Dst ) { /* Check that the edge ordering is obeyed at the Dst vertices. */ if( CheckForLeftSplice( tess, regUp )) { /* If the upper or lower edge was marked fixUpperEdge, then * we no longer need it (since these edges are needed only for * vertices which otherwise have no right-going edges). */ if( regLo->fixUpperEdge ) { DeleteRegion( tess, regLo ); if ( !tessMeshDelete( tess->mesh, eLo ) ) longjmp(tess->env,1); regLo = RegionBelow( regUp ); eLo = regLo->eUp; } else if( regUp->fixUpperEdge ) { DeleteRegion( tess, regUp ); if ( !tessMeshDelete( tess->mesh, eUp ) ) longjmp(tess->env,1); regUp = RegionAbove( regLo ); eUp = regUp->eUp; } } } if( eUp->Org != eLo->Org ) { if( eUp->Dst != eLo->Dst && ! regUp->fixUpperEdge && ! regLo->fixUpperEdge && (eUp->Dst == tess->event || eLo->Dst == tess->event) ) { /* When all else fails in CheckForIntersect(), it uses tess->event * as the intersection location. To make this possible, it requires * that tess->event lie between the upper and lower edges, and also * that neither of these is marked fixUpperEdge (since in the worst * case it might splice one of these edges into tess->event, and * violate the invariant that fixable edges are the only right-going * edge from their associated vertex). */ if( CheckForIntersect( tess, regUp )) { /* WalkDirtyRegions() was called recursively; we're done */ return; } } else { /* Even though we can't use CheckForIntersect(), the Org vertices * may violate the dictionary edge ordering. Check and correct this. */ (void) CheckForRightSplice( tess, regUp ); } } if( eUp->Org == eLo->Org && eUp->Dst == eLo->Dst ) { /* A degenerate loop consisting of only two edges -- delete it. */ AddWinding( eLo, eUp ); DeleteRegion( tess, regUp ); if ( !tessMeshDelete( tess->mesh, eUp ) ) longjmp(tess->env,1); regUp = RegionAbove( regLo ); } } }
static void AddRightEdges( TESStesselator *tess, ActiveRegion *regUp, TESShalfEdge *eFirst, TESShalfEdge *eLast, TESShalfEdge *eTopLeft, int cleanUp ) /* * Purpose: insert right-going edges into the edge dictionary, and update * winding numbers and mesh connectivity appropriately. All right-going * edges share a common origin vOrg. Edges are inserted CCW starting at * eFirst; the last edge inserted is eLast->Oprev. If vOrg has any * left-going edges already processed, then eTopLeft must be the edge * such that an imaginary upward vertical segment from vOrg would be * contained between eTopLeft->Oprev and eTopLeft; otherwise eTopLeft * should be NULL. */ { ActiveRegion *reg, *regPrev; TESShalfEdge *e, *ePrev; int firstTime = TRUE; /* Insert the new right-going edges in the dictionary */ e = eFirst; do { assert( VertLeq( e->Org, e->Dst )); AddRegionBelow( tess, regUp, e->Sym ); e = e->Onext; } while ( e != eLast ); /* Walk *all* right-going edges from e->Org, in the dictionary order, * updating the winding numbers of each region, and re-linking the mesh * edges to match the dictionary ordering (if necessary). */ if( eTopLeft == NULL ) { eTopLeft = RegionBelow( regUp )->eUp->Rprev; } regPrev = regUp; ePrev = eTopLeft; for( ;; ) { reg = RegionBelow( regPrev ); e = reg->eUp->Sym; if( e->Org != ePrev->Org ) break; if( e->Onext != ePrev ) { /* Unlink e from its current position, and relink below ePrev */ if ( !tessMeshSplice( tess->mesh, e->Oprev, e ) ) longjmp(tess->env,1); if ( !tessMeshSplice( tess->mesh, ePrev->Oprev, e ) ) longjmp(tess->env,1); } /* Compute the winding number and "inside" flag for the new regions */ reg->windingNumber = regPrev->windingNumber - e->winding; reg->inside = IsWindingInside( tess, reg->windingNumber ); /* Check for two outgoing edges with same slope -- process these * before any intersection tests (see example in tessComputeInterior). */ regPrev->dirty = TRUE; if( ! firstTime && CheckForRightSplice( tess, regPrev )) { AddWinding( e, ePrev ); DeleteRegion( tess, regPrev ); if ( !tessMeshDelete( tess->mesh, ePrev ) ) longjmp(tess->env,1); } firstTime = FALSE; regPrev = reg; ePrev = e; } regPrev->dirty = TRUE; assert( regPrev->windingNumber - e->winding == reg->windingNumber ); if( cleanUp ) { /* Check for intersections between newly adjacent edges. */ WalkDirtyRegions( tess, regPrev ); } }
void CTrack_DSP::Delete_Selection(tint32 iCmd, tuint64 uiSelection_Pos, tuint64 uiSelection_Duration) { tint32 iNewRegionID = -1; miFade_Pos = 0; // List of regions to delete std::list<tuint32> lRegionsToDelete; // Look at all regions on track std::list<SChannelRegionInfo*>::iterator it = mRegionInfoList.begin(); for (; it != mRegionInfoList.end(); it++) { CRegion_DSP* pRegion_DSP = (*it)->pRegion; tint32 iRegionID = (*it)->uiRegionID; tuint64 uiSample_Duration = pRegion_DSP->Get_Duration(); std::string sSample_Name = pRegion_DSP->Get_Sample_Name(); tuint64 uiRegion_Pos = (*it)->uiTrack_Pos; tuint64 uiRegion_End = uiRegion_Pos + uiSample_Duration - 1; tuint64 uiSample_Offset = pRegion_DSP->Get_Sample_Offset(); tuint64 uiSelection_End = uiSelection_Pos + uiSelection_Duration; tfloat32 fVolume = pRegion_DSP->Volume(); tuint uiFade_Out_Duration = pRegion_DSP->Fade_Out_Duration(); // Prevent feedback on new fade in regions //!!! BUG? has to come up with somthing better //!!! Make list of regions to add //!!! find start sample and end sample, use it for fading if(iNewRegionID != iRegionID){ // delete region start if(uiSelection_Pos <= uiRegion_Pos && uiSelection_End < uiRegion_End && uiSelection_End > uiRegion_Pos){ uiSelection_Duration -= (uiRegion_Pos - uiSelection_Pos)-1; Resize_Region(iRegionID, uiRegion_Pos + uiSelection_Duration, uiSample_Offset + uiSelection_Duration, uiSample_Duration - uiSelection_Duration); mpDSP->Refresh_Region_GUI(iRegionID, miTrack); } // delete region else if(uiSelection_Pos <= uiRegion_Pos && uiSelection_End >= uiRegion_End){ lRegionsToDelete.insert(lRegionsToDelete.begin(), iRegionID); } // delete region end else if(uiSelection_Pos > uiRegion_Pos && uiSelection_End > uiRegion_End && uiRegion_End > uiSelection_Pos ){ uiSample_Duration = uiSelection_Pos - uiRegion_Pos; Resize_Region(iRegionID, uiRegion_Pos , uiSample_Offset , uiSample_Duration); mpDSP->Refresh_Region_GUI(iRegionID, miTrack); } // delete midt of region else if(uiSelection_Pos > uiRegion_Pos && uiSelection_End < uiRegion_End){ //delete region end tuint64 uiNew_Sample_Duration = uiSelection_Pos - uiRegion_Pos; Resize_Region(iRegionID, uiRegion_Pos , uiSample_Offset , uiNew_Sample_Duration); mpDSP->Refresh_Region_GUI(iRegionID, miTrack); // create new region tuint64 uiDelta = uiNew_Sample_Duration + uiSelection_Duration; mpDSP->CreateRegion(sSample_Name, miTrack, uiRegion_Pos + uiDelta, uiSample_Offset + uiDelta , uiSample_Duration - uiDelta, 0,uiFade_Out_Duration, fVolume ); } } } // Delete Regions on Channels and GUI and erase then from list to delete while (lRegionsToDelete.size()) { tint32 iRegionID = *(lRegionsToDelete.begin()); // Delet region DeleteRegion(iRegionID); // Delete region on GUI mpDSP->Delete_Region_View(miTrack, iRegionID); // Delete region from list of regions lRegionsToDelete.erase(lRegionsToDelete.begin()); } }