It sounds like your 'sphere' Set has too few samples. Try
a more densely sampled sphere.
On Mon, 27 May 2002, johnyao wrote:
> Hi Bill,
> Thanks for the pointer. I did try the method that you suggested of using
> IsoContour to get a single iso-line to represent the intersection of a 3D
> surface and a plane. However, iso-line doesn't seem to properly capture the
> cross-section. For example, when I tried to cut a sphere with a plane having
> a normal vector of <0,1,0>, the iso-line at times showed a distorted diamond
> and other times nothing at all depending on the position of the plane along
> the y-axis. Initially I thought this was occurring because we are setting the
> base contour = d (from ax+by+cz=d and in my case the equation reduces to y
> d), only a few points computed from domain Set of the manifold dimension=2
> Gridded3Dset can actually be used for the contour. In other words, maybe the
> plane wasn't "catching" the points I have used for the 3D shape.
> So the next thing I tried was to generate my shape with the Gridded3DSet by
> moving along the y-axis. I would create the sphere by drawing circles as I
> move up the y-axis incrementally. Now, in theory if I set the base contour
> equal to one of the y increment that I used to construct sphere, the iso-line
> should be a circle, but the same problem described above persisted.
> I am not sure where the problem might be or maybe I didn't code it properly.
> I have included the piece of code in case you would like to take a look.
> Thanks in advance for any comments.
> float a = 0.f;
> float b = 1.f;
> float c = 0.f;
> if (p == null) p = new RealType("plane", null, null);
> FunctionType pfunction = new FunctionType(xyz, p);
> FlatField fplane = new FlatField(pfunction, set);
> float set_samples = set.getSamples(true); //getting domain samples
> from the 3D shape.
> float p_samples = new float[Mfold*Mfold];
> //Computing ax+by+cz = d
> for(int i=0;i<p_samples.length;i++)
> display2D = new DisplayImplJ2D("display1");
> // Get display's graphics mode control and draw scales
> GraphicsModeControl dispGMC = (GraphicsModeControl)
> ScalarMap tempzMap = new ScalarMap( z, Display.YAxis );
> ScalarMap tempxMap = new ScalarMap( x, Display.XAxis );
> ScalarMap tempIsoMap = new ScalarMap( p, Display.IsoContour );
> ScalarMap tempRGBMap = new ScalarMap( p, Display.RGB );
> // Add maps to display
> display2D.addMap( tempzMap );
> display2D.addMap( tempxMap );
> display2D.addMap( tempIsoMap );
> display2D.addMap( tempRGBMap );
> // The ContourControl
> // Note that we get the control from the IsoContour map
> ContourControl isoControl = (ContourControl) tempIsoMap.getControl();
> // Define some parameters for contour lines
> float interval = 100.f; // interval between lines
> float lowValue = -100.f; // lowest value
> float highValue = 100.f; // highest value
> float base = p_samples; // starting at this base value
> System.out.println("base = "+base);
> System.out.println("set_samples = "+set_samples); //the y values
> of the 3D shape.
> //the above lines give the same value.
> // ...and set the lines with the method
> isoControl.setContourInterval(interval, lowValue, highValue, base);
> // Create a data reference and set the FlatField as our data
> DataReference p_ref = new DataReferenceImpl("p_ref");
> p_ref.setData( fplane );
> // Add reference to display
> display2D.addReference( p_ref );
> >===== Original Message From Bill Hibbard <billh@xxxxxxxxxxxxx> ====
> >Hi John,
> >VisAD doesn't currently include operations for computing
> >the intersections of surfaces and planes in 3-D. However,
> >you might hack it as follows. Your plance can be defined by:
> > ax + by + cz = d
> >So define a FlatField with MathType:
> > ((x, y, z) -> plane)
> >and with your mainfold dimension = 2 Gridded3DSet as its
> >domain Set. Compute the 'plane' value at each sample
> >location as:
> > ax + by + cz
> >Then create the ScalarMap plane -> IsoContour and set the
> >base contour = d (with a very large contour interval so you
> >only get one contour curve). That is, the IsoContour will
> >be a set of iso-lines on the surface (not an iso-surface),
> >but you only want one iso-line.
> >Good luck,