⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwzsegmenttest.html

📁 Delaunay三角形的网格剖分程序
💻 HTML
字号:
<TITLE>WZ 1.1: Segments</TITLE><h1>Segments</h1><PRE>#include "<A HREF="wzsegment.hxx">wzsegment.hxx</A>"#include &lt;fstream.h&gt;</PRE> <P>There are four different types of segments: regions(<B>wzRegion</B>), faces (<B>wzFace</B>), edges (<B>wzEdge</B>) andvertices (<B>wzVertex</B>).  Essentially these are simply numbers. <P>The simplest way is to use them only as indices initialized withpositive numbers.  Note that region 0 is forbidden.  The defaultregion 1 has usually the meaning "outside", and therefore in the mostcommon standard applications with only one body we have slightlyunusual numbers for the regions: the body itself ("inside") has regionnumber 2 instead of 1.  (You are free to make other choices, but 0remains forbidden and a region outside is usually necessary in thegeometry description.)<PRE>void test(){  wzSegment outside  = wzRegion(1);  wzSegment inside   = wzRegion(2);  wzSegment boundary = wzFace(1);  now(boundary.isFace());  now(outside.isRegion());  now(outside.index()==1);}</PRE><H2>Names, Materials, Colors</H2> <P>Now, it is possible to assign names, materials, and colors to thesegments.  This requires a segment description.  That means, if wewant to use the <A HREF="maingridviewtest.html">colors</A> or <A HREF="mainmaterialtest.html">materials</A>, it is <b>required</b>to declare at least one instance of the class<b>wzSegmentDescription</b> which assigns colors and material numbersto regions.  There is a class wzDefaultSegmentDescription which maybe used. <P>But for your own application we recommend to use your own segmentdescription in the following way: <ol> <li> define a derived class of wzSegmentDescription (wzSegmentTest) <li> include all materials, boundary conditions and material functionsinto this class. <li> create one instance (test_segments) </ol><h2>Test Example for Segment Description</h2>We need an instance of the class <B>wzSegmentDescription</B>. Thisinstance has to be initialized before the call of <A HREF="maingridviewtest.html">graphics</A>.   Another example ofapplication of the segment description is its use to write out <A HREF="mainmaterialtest.html">material numbers</A> instead ofregion numbers. <P>For this purpose we define here a derived class<B>wzSegmentTest</B> so that the constructor initializes the colors.Then we declare one instance <B>test</B> as a static variable.<PRE>#include "<A HREF="wzsegment.hxx">wzsegment.hxx</A>"class test_segment_description: public wzSegmentDescription{public:	test_segment_description();};</PRE> <P>Now, the names, materials and colors have to be defined.Colors and materials may be defined separately.<PRE>test_segment_description::test_segment_description():wzSegmentDescription(){  int i; wzRegion r,r1,r2,r3; wzFace f,f1,f2; wzEdge e; wzVertex v;  r  = wzRegion("air","#099011311");  r1 = wzRegion("ground","#210");  r2 = wzRegion("water");  r3 = wzRegion("layer1",r1);  f  = wzFace("Dirichlet b.c.","#099011311");  f1 = wzFace("natural b.c.");  f2 = wzFace("Neumann b.c.");  e = wzEdge("default edge");  v = wzVertex("default vertex");  wzRegion( 2).color()="#00a";  wzRegion( 3).color()="#320";  wzFace  ( 2).color()="#201000";  wzFace  ( 3).color()="#000300611";  wzEdge  ( 1).color()="#099011311";  wzVertex( 1).color()="#099011311";}</PRE> <P>Now, before the output one instance of <B>wzSegmentTest</B> has tobe defined. This calls the constructor. Only after this, the colors,names and materials are appropriately initialized.<PRE>test_segment_description test_segments;</PRE><A NAME="End"> <hr></A><PRE>int main(){  test_segments.print();  test();  fine();}</PRE> <P>You can test this code with: <BR> <BR><B>&gt;cog main wzsegment</B> <BR> <BR>The output should be: <BR>Region air                  (#099011311) <BR>Region ground               (#000000a00) <BR>Region water                (#300200000) <BR>Region layer1               (#200100000) <BR>Face   Dirichlet b.c.       (#099011311) <BR>Face   natural b.c.         (#200100000) <BR>Face   Neumann b.c.         (#000300611) <BR>Edge   default edge         (#099011311) <BR>Vertex default vertex       (#099011311) <BR>success

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -