How to add fillet between 2 curves in eyeshot - c#

I found the method for Chamfer and fillet but could not really understand the implementation of it.
Basically I am not able to evoke Fillet property.
http://documentation.devdept.com/100/WPF/topic4434.html
If anybody can guide.
Code:
ICurve line1 = new Line(0, 0, 0, 57.06, 0, 0);
ICurve line2 = new Line(0, 0, 0, 0, 45, 0);
So how do I fillet between these 2 lines. I cant locate Fillet method to pass these ICurves.
Adding the image, for better understanding of problem. As you can see I am not able to invoke Curve class and subsequently fillet property. I am using Eyeshot version 12
enter image description here
Image of all the dll added, but still same error
enter image description here
Thanks.

Here you go bud. Hopefully this is a decent start. I set flip 1 to be true, so that line1's end point is at the start of line 2. (I didn't actually plot this, but I think that's what they're asking for)
I also made the assumption you want to trim lines 1 and 2.
Eyeshots documentation on their website is pretty decent. Reading those can definitely help you understand the constructors a little better.
The output of the fillet command is an arc, which makes sense. You will most likely need to add myFillet seperately from lines 1 and 2 to the viewport, as they are all separate entities.
ICurve line1 = new Line(0, 0, 0, 57.06, 0, 0);
ICurve line2 = new Line(0, 0, 0, 0, 45, 0);
double radius = 10.0;
bool flip1 = true;
bool flip2 = false;
bool trim1 = true;
bool trim2 = true;
Arc myFillet;
Curve.Fillet(line1, line2, radius, flip1, flip2, trim1, trim2, out myFillet);

Related

How to create Screw shape using Eyeshot's functions

I need to create screw shape using Eyeshot's libraries in .NET application.
In SolidWorks this is easily accomplished with creating the shape/profile that needs to be swept/stretched, and helix curve which is used as a rail or direction.
In SolidWorks positioning helix start point to some point in profile's diameter and using "Sweep" command results that point to be driven/rotated around the helix and the wanted shape is created.
SolidWorks example
In Eyeshot I create my profile as a LinearPath entity and use
SweepAsSolid(ICurve rail, double tol, sweepMethodType sweepMethod = sweepMethodType.RotationMinimizingFrames)
function but the result is different. It seems that SweepAsSolid function position helix start point in the center of the profile and different shape is created.
Using helix as a rail:
Eyeshot example with helix as a rail
Using straight line as a rail:
Eyeshot example with straight line as a rail
Is there a way to get wanted shape with Eyeshot's libraries using the same procedure as in SolidWorks?
I think the method ExtrudeWithTwist() is what you are looking for:
Point3D moveText = new Point3D(0,3,0);
// new example
Line l1 = new Line(-3, 0, 3, 0);
Line l2 = new Line(3, 0, 3, 2);
Line l3 = new Line(3, 2, -3, 2);
Line l4 = new Line(-3, 2, -3, 0);
CompositeCurve cc1 = new CompositeCurve(l1, l2, l3, l4);
Surface[] loft1 = Surface.ExtrudeWithTwist(cc1, new Vector3D(0, 0, -10), new Point3D(0, 1, 0), Math.PI, 0.1);
foreach (Surface s in loft1)
{
s.Translate(10, 0, 0);
}
model.Entities.AddRange(loft1, 0, Color.Orange);

How can I find the code line where is located the code that put a yellow square in a windows control?

I am working with WinAppDrive library https://github.com/microsoft/WinAppDriver.
If someone have worked with that library know that it is usefull to capture user actions, generate the code that replicate those same actions and finally implement that code that replicate those actions. I have a problem: I need to get the code line that make to appear a yellow mark in the windows control. My porpuse is change the color and the time to wait to appear the yellow mark. Thanks a lot in advanced.
I searched for "Yellow" in the repository.
Maybe the result in "Tools/UIRecorder/UIXPathLib/UiTreeWalk.cpp" is what you are looking for?
void DrawYellowHighlightRect(HDC hdc, RECT rc)
{
HBRUSH hBr = SelectBrush(hdc, GetStockBrush(NULL_BRUSH));
int YellowInflat = -2;
if (rc.bottom - rc.top < 30)
{
YellowInflat = 2;
}
HPEN hpYellow = CreatePen(PS_SOLID, 3, RGB(255, 255, 32));
hpYellow = SelectPen(hdc, hpYellow);
InflateRect(&rc, YellowInflat, YellowInflat);
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
DeletePen(hpYellow);
SelectBrush(hdc, hBr);
}
Look at the whole file to check all the source

Render a basic Quad to Screen?

I have been trying to accomplish this for quite some time with no success; I've looked at several relevant questions here on StackOverflow with no success; I've also followed 6 different tutorials that ALL followed pretty much the same process:
Build the vertices: -1, -1, 0, -1, 1, 0, 1, 1, 0, and 1, -1, 0.
Build the indices: 0, 1, 2, 0, 2, 3.
Create the Vertex and Index buffers.
Clear the RenderTargetView.
Set the current Vertex and Pixel shaders.
Update the constant buffers if you have any.
Render the quad (see below).
Rinse and repeat 4 - 8.
Now, the reason this is driving me up the wall is because I can render far more advanced objects such as:
Spheres
3D Lines
Fans
My code for creating the quad is pretty much the same as everyone else's:
public class Quad {
private void SetVertices() {
float width = Rescale(Size.Width, 0, Application.Width, -1, 1);
float height = Rescale(Size.Height, 0, Application.Height, -1, 1);
vertices = new Vertex[] {
new Vertex(new Vector3(-width, -height, 0), Vector3.ForwardLH, Color.White),
new Vertex(new Vector3(-width, height, 0), Vector3.ForwardLH, Color.White),
new Vertex(new Vector3(width, height, 0), Vector3.ForwardLH, Color.White),
new Vertex(new Vector3(width, -height, 0), Vector3.ForwardLH, Color.White)
}
indices = new int[] { 0, 1, 2, 0, 2, 3 };
vertexBuffer = Buffer.Create(Device3D, BindFlags.VertexBuffer, vertices);
vertexBinding = new VertexBufferBinding(vertexBuffer, Utilities.SIzeOf<Vertex>(), 0);
indexBuffer = Buffer.Create(Device3D, BindFlags.IndexBuffer, indices);
indexCount = indices.Length;
}
public void Render() {
if (shaderResourceView != null)
context3D.PixelShader.SetShaderResource(0, shaderResourceView);
context3D.PixelShader.SetSampler(0, samplerState);
context3D.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
context3D.InputAssembler.SetVertexBuffers(0, vertexBinding);
context3D.InputAssembler.SetIndexBuffer(indexBuffer, Format.R32_UInt, 0);
context3D.DrawIndexed(totalIndexCount, 0, 0);
}
}
Notes
I am using a right handed coordinate system (for some reason the previous developer hardwired Vector3.ForwardLH into some places that I now cannot get rid of yet); if that helps any and I cannot currently convert to a left handed coordinate system.
Am I missing something here? Why am I unable to render a basic quad?
If you feel more information is needed feel free to let me know and I will add it on request.
When rendering with Direct3D 11, you need to know the all the state. You do not mention what your BlendState, DepthStencilState, or RasterState settings are here which is a likely reason you aren't getting the results you want.
If the DepthStencilState is such set use the Z-Buffer, then the fact that your vertices have a 0 for the Z means they are going to get culled. You can set a depth/stencil state without Z writes or Z tests, and you should definitely turn off Z writes when drawing 2D stuff anyhow. You can also pass something like 0.5 for the Z value for your vertices which is fairly common for 2D drawing with 3D APIs.
If you backface culling enabled in the RasterState, then the winding order of your vertices could result in them being skipped. You can play with different winding orders, or disable culling.
It also really matters what your Vertex Shader and Pixel Shader are here. You don't show the code for setting your shaders or shader constants, and you don't show the HLSL.
You should seriously consider using the SharpDX Toolkit SpriteBatch class for efficient quad rendering or looking at their source for it.
I know you are using SharpDX an C#, but you might find it useful to see the DirectX Tool Kit for DX11 tutorial on drawing 2D shapes.

Object detection using emgu cv CvInvoke.cvHoughCircles

I want to detect objects using cvHoughCircles method in visual c#.If anyone knows how to do this please help me.
Edit Details:
I searched in the Internet there is examples using gray.HoughCircles method.
this is my code.
Image<Bgr, Byte> image = capture.QueryFrame();
MCvScalar hsv_min = new MCvScalar(150, 84, 130, 0);
MCvScalar hsv_max = new MCvScalar(358, 256, 255, 0);
IntPtr hsv_frame = CvInvoke.cvCreateImage(new System.Drawing.Size(640, 480),IPL_DEPTH.IPL_DEPTH_8U, 3);
IntPtr thresholded = CvInvoke.cvCreateImage(new System.Drawing.Size(640, 480), IPL_DEPTH.IPL_DEPTH_8U, 1);
CvInvoke.cvCvtColor(image, hsv_frame, COLOR_CONVERSION.CV_BGR2HSV);
CvInvoke.cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);
IntPtr storage = CvInvoke.cvCreateMemStorage(0);
CvInvoke.cvSmooth(thresholded, thresholded, SMOOTH_TYPE.CV_GAUSSIAN, 9, 9, 0, 0);
IntPtr circles= CvInvoke.cvHoughCircles(thresholded, storage,HOUGH_TYPE.CV_HOUGH_GRADIENT , 2, 4, 100, 50, 10, 400);
In the following link there is code.But it is in pythen.So what I'm doing is trying to convert it into visual c#.
http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision/#comment-847
I want to take all detected circles in to for loop and then draw circle to corresponding objects as in pythen code.
I tried to use foreach loop but there is error,
foreach statement cannot operate on variables of type 'System.IntPtr' because 'System.IntPtr' does not contain a public definition for 'GetEnumerator'.
Is there any method to avoid this error.
Did you try this tutorial?
Shape (Triangle, Rectangle, Circle, Line) Detection in CSharp
This contains good tutorial which may be help you.

Rotate text / Vertical text in itextsharp

I need vertical text or just a way to rotate a ColumnText in ITextSharp.
(It needs to be absolute position)
Until now i have tried a lot of diffrent solution, but with no luck.
Here is a couple of tries:
1.
_cb.SetFontAndSize(BaseFont.CreateFont(), 12f);
_cb.ShowTextAligned(Element.ALIGN_CENTER, "Hello World", 50, 50, 90);
2.
var vt = new VerticalText(_cb);
vt.SetVerticalLayout(50, 50, 400, 8, 30);
vt.AddText(new Chunk("asdasd",_sf.ChildBackPageTextOneFont()));
vt.Go();
3.
System.Drawing.Drawing2D.Matrix foo = new System.Drawing.Drawing2D.Matrix();
foo.Rotate(90);
_cb.ConcatCTM(foo);
I have also tried to draw it with System.Drawing.Graphics, but the quality is VERY poor.
Any solution? Thanks.
I have tried a lot of methods from the web for this rotate issue. But none of them worked. Finally I figured out a simple solution. Maybe we can do it like this. We can draw a table with no borders, and just with one cell. And we add text in the cell, finally rotate the cell.
Every is ok then.
table = new PdfPTable(1);
table.TotalWidth = 72;
paragraph = new Paragraph("123");
cell = new PdfPCell(paragraph);
cell.Rotation = 270;
cell.BorderWidth = 0;
table.AddCell(cell);
table.WriteSelectedRows(0, -1, 72, 72, writer.DirectContent);
Besides, the WriteSelectedRows method can position this cell.
Actually, the easiest way is similar to your first try. You just needed to add a call to BeginText() and EndText() like this
_cb.SetFontAndSize(BaseFont.CreateFont(), 12f);
_cb.BeginText();
_cb.ShowTextAligned(Element.ALIGN_CENTER, "Hello World", 50, 50, 90);
_cb.EndText();
_cb.Stroke();
Found the answer:
Use something like this:
Imports System.Drawing, System.Drawing.Drawing2D
Dim transf as new Matrix
transf.RotateAt(30,New PointF(100,100), MatrixOrder.Append)
writer.DirectContent.Transform(transf)
transf.Invert()
writer.DirectContent.Transform(transf)
Rotate the canvas, write some text, rotate it back.

Categories

Resources