Monday, March 9, 2009

New installer and code cleanup

NaroCAD has an installer script on SVN. It is based by InnoSetup, it require to you to have preinstalled the following components:
- .NET 3.5 SP1
- Visual C++ 2008 SP1 Redistributable Runtime
- OpenCascade (that may be downloaded from the www.opencascade.org

after you create a new account to your site)

Requirements: Windows XP SP2 or newer, Windows Vista or Windows 7 beta.

Download it from here


This installer may make easier to test in future NaroCAD and is pretty small (4.5 MB).

As the code will need some reorganization, the code is lightly cleanup. The schemas that enforce the data access were moved from function-drivers component to outside so any other component may use the schemas to not access wrong data.

How does a schema work? A schema will set a list of children and attributes. The children are numeric, and the attributes are a string from predefined sets.

So how is defined a schema that defines a line? It is defined as a two-point schema, the first is kept in child 1, the other one in child 2. The code is as following:


public class LineSchema : DescriptionSchema
{
public LineSchema() : base("Line")
{
AddAttributeType(1, "Geometry");
AddAttributeType(2, "Geometry");
}
}

How is used in our OCAF driver that define a line?

public class Line : DriverSimple
{
public Line() : base(2)
{
schema = SchemaFactory.GetSchema("Line");
}

public override OCTopoDS_Shape Execute()
{
// Get the values of dimension and position attributes
OCgp_Pnt firstPoint = schema.Root.Child(1).Geometry;
OCgp_Pnt secondPoint = schema.Root.Child(2).Geometry;

OCTopoDS_Edge aEdge = new OCBRepBuilderAPI_MakeEdge(firstPoint, secondPoint).Edge();
return new OCBRepBuilderAPI_MakeWire(aEdge).Wire();
}

}
This code will clean your code that was accessing your OCAF tree, it also guarantees that you will not read outside of that 2 points (or depending on your schema, the type of geometry you want to access), or reading other attributes that are not defined!

2 comments:

ytjun said...

Hi. I am ytjun

I see your answer
"IGES import is already there"

but I can't find "IGESControl_Writer" and "IGESControld_Reader" class
in the .Net Wrapper.

I want to your help.
I am very sorry. I know you are busy.

ciplogic said...

Hi ytjun,

You have right, there is only STEP import code. I will try to increase priority of making the new wrappers working (one of the advantages, is teh shorter build time). So will be easier at least to add packages and eventually to have IGES support..

Put please in a list which packages you think that you will want to be added as your priority, and I will add it and try to play with them over the weekend. If you will wish also, to create your custom wrappers (based on the same infrastructure!) give to me the email and I will give to you the instructions how to build them right away!

So again, you may email me to ciprian dot mustiata at gmail and I will write to you all instructions to build your custom packages list imported for OCWrappers.dll!

I hope it helps,
CipLogic