/* $RCSfile: ap203_cc1.cxx,v $ * $Revision: 1.5 $ $Date: 2007/08/29 21:48:35 $ * Auth: Dave Loffredo (loffredo@steptools.com) * * Copyright (c) 1991-2007 by STEP Tools Inc. * All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation is hereby granted, provided that this copyright * notice and license appear on all copies of the software. * * STEP TOOLS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. STEP TOOLS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. */ #include #include #include // The AP203_CC1 sample program creates a data set that contains all of // the configuration management information required for a minimal AP-203 // Conformance Class One file. This is an excellent starting point for // programs based on any of the STEP APs. // This program will create the AP-203 data set and save it as a STEP // Part 21 file called "output_file.stp". This is a text file, so you // can look at it with a text editor or the STEP Part 21 file browser // to see how the information is represented. void generate_cmdata(); int main(int argc, char* argv[]) { /* Force optimizing linkers to bring in all C++ classes */ stp_schema_force_load(); rose_p28_init(); // support xml read/write /* Create a RoseDesign to hold the AP-203 instance data */ const char * output_name = "output_file"; RoseDesign * design = new RoseDesign (output_name); /* Give the design some Part 21 header information */ design-> initialize_header(); design-> header_name()-> originating_system ("AP203 CC1 Demo"); design-> header_description()-> description ()-> add ("AP-203 CC1 Sample File"); /* Set as the current design. Objects created using the "pnew" * macro will go here. If we were working with more than one * design, we could create objects in a specific design using * "pnewIn(design)", but this is less convenient to write. */ ROSE.useDesign(design); /* Populate the design with some AP-203 entities */ generate_cmdata(); // Uncomment the following to write as zip compressed P28 XML // rather than Part 21 ASCII. Change the string "p28-raw" to // write uncompressed XML. The default is "p21". // // design-> format ("p28"); design-> save(); return 0; } /* Generate all of the AP-203 instances required to document a part. */ void generate_cmdata() { /* The pnew operator creates objects in the current design. If you * work with multiple designs, you might consider passing a design * in as a parameter and using pnewIn() to maintain better control * of where objects are created. */ // The first requirement is to specify the AP context using an // application_context and application_protocol_definition. These // entities are frequently referenced by the various subtypes of // application_context_element, so we recommend trying to share them // where possible and appropriate, rather than creating new ones for // each use. application_context specifies the application domain, // which is defined as below for AP-203. // stp_application_context* app_context = pnew stp_application_context(); app_context->application( "configuration controlled 3D designs of mechanical parts and assemblies"); // The application_protocol_definition further specifies the AP. // Status is the status of the AP within the standardization // process. The schema name is the name specified in the EXPRESS // file for the AP. The year is the year that the standard was // released at the specified status. stp_application_protocol_definition* ap_def = pnew stp_application_protocol_definition(); ap_def->status("international standard"); ap_def->application_interpreted_model_schema_name("config_control_design"); ap_def->application_protocol_year(1994); ap_def->application(app_context); //---------------------------------------------------------------------- // Create a product object to represent our part. stp_product* pr = pnew stp_product(); // Fill in the part number, name, and description. pr->id("1234-K789"); pr->name("widget"); pr->description("a fictional product"); // A product is required to have a product_context. For AP-203, the // mechanical_context entity, which specifies that products defined // by AP-203 have a mechanical properties. The discipline_attribute // is restricted to be mechanical. The name field has no standard // mapping. stp_mechanical_context* mech_context = pnew stp_mechanical_context(); mech_context->discipline_type("mechanical"); mech_context->name(""); mech_context->frame_of_reference(app_context); // Now relate the context to the product. Remember to allocate an // object for the SetOfproduct_context. Note that this is a set. // Each AP used to describe a product should have a product_context // in this list and a product_definition from which to relate its AP // specific information. SetOfstp_product_context* contexts = pnew SetOfstp_product_context(); pr->frame_of_reference(contexts); contexts->add(mech_context); /* AP-203 has two rules about product_related_product_category. The * first requires that a product be in a category whose name is one * of assembly, inseparable_assembly, detail, or * customer_furnished_equipment. The second restricts * product_related_product_category.name to be one of the above or * customer_furnished_equipment, cast, coined, drawn, extruded, * forged, formed, machined, molded, rolled, or sheared. To put * your products in more specific categories use product_category * and product_category_relationship. Lowercase is recommended for * category names to make comparison and recognition * easier. Categories should be reused were appropriate. */ // Create the required product_category. There's no standard mapping for // description. stp_product_related_product_category* prp_cat = pnew stp_product_related_product_category(); prp_cat->name("detail"); prp_cat->description(""); prp_cat->products(pnew SetOfstp_product()); prp_cat->products()->add(pr); // An example of a optional special category. It is recommended // that a supertype category called 'part' exist. In addition, a // special category for widgets is created and releated to the // detail category used above. Note the use of the custom // constructor used to initialize all attributes. // stp_product_category* part_cat = pnew stp_product_category("part", ""); stp_product_category* widget_cat = pnew stp_product_category("widget_category", ""); // relate the two optional categories. There are no standard // mappings for name and description. // stp_product_category_relationship* pcr = pnew stp_product_category_relationship(); pcr->name(""); pcr->description(""); pcr->category(part_cat); pcr->sub_category(widget_cat); // make widget_category super-category for detail category. pcr = pnew stp_product_category_relationship("", "", widget_cat, prp_cat); // The product needs an owner. Create a person_and_organization // for this. The person instance below also has middle_names, // prefix_titles, and suffix_titles attributes that are optional. // stp_person* pers = pnew stp_person(); pers->id("099-111-2222"); pers->first_name("Tom"); pers->last_name("Jones"); // The organization. stp_organization* org = pnew stp_organization(); org->name("FBI"); org->description("Foo Bar Inc., a fictional company."); // Relate the person to the organization. stp_person_and_organization* pao = pnew stp_person_and_organization(); pao->the_person(pers); pao->the_organization(org); // Create an assignment object to relate the person to the product. stp_cc_design_person_and_organization_assignment* owner = pnew stp_cc_design_person_and_organization_assignment(); // Set the role of the assignment to be design_owner. The role // and the instances in the items list much match. See function // cc_design_person_and_organization_correlation and rule // restrict_person_organization_role in AP-203 for more // information. stp_person_and_organization_role* paor = pnew stp_person_and_organization_role(); paor->name("design_owner"); // The assignment object points to the role and person organization owner->role(paor); owner->assigned_person_and_organization(pao); // The items of cc_design_person_and_organization_assignment is a // set of item select instances. // SetOfstp_person_organization_item* owner_items = pnew SetOfstp_person_organization_item(); owner->items(owner_items); // The person_organization_item is an EXPRESS select (like a // union) that can hold one of any of the different types of // objects that a person/org can be assigned to. // stp_person_organization_item* poi = pnew stp_person_organization_item(); poi->_product(pr); owner_items->add(poi); //---------------------------------------------------------------------- // The product needs a formation to describe the version. AP-203 // requires the product_definition_formation_with_specified_source // subtype, but other APs just use product_definition_formation. stp_product_definition_formation_with_specified_source* pdf = pnew stp_product_definition_formation_with_specified_source(); // Fill in the revision id, description, and source. Note that // source is restricted to made or bought. pdf-> of_product(pr); pdf-> id ("1.0"); pdf-> description ("first version of our widget"); pdf-> make_or_buy (stp_source_made); // The formation(version) needs a creator. We can reuse the // person and organization information, but we need a new // assignment object so that we can specifiy a role of creator. // Note the use of the custom ROSE constructor to initialize the // role. stp_cc_design_person_and_organization_assignment* creator = pnew stp_cc_design_person_and_organization_assignment(); creator->role(pnew stp_person_and_organization_role("creator")); creator->assigned_person_and_organization(pao); SetOfstp_person_organization_item* creator_items = pnew SetOfstp_person_organization_item(); creator->items(creator_items); // Create an item for formation. poi = pnew stp_person_organization_item; poi->_product_definition_formation(pdf); creator_items->add(poi); // The formation also needs a design_supplier and/or part_supplier. // The design_supplier is the custodian of the master design data // and the part_supplier is the company actually manufacturing the // part. At least one of these needs to be related to each // formation. stp_cc_design_person_and_organization_assignment* design_supplier = pnew stp_cc_design_person_and_organization_assignment(); design_supplier->role(pnew stp_person_and_organization_role("design_supplier")); design_supplier->assigned_person_and_organization(pao); SetOfstp_person_organization_item* des_supp_items = pnew SetOfstp_person_organization_item(); design_supplier->items(des_supp_items); // Create an item for formation. poi = pnew stp_person_organization_item; poi->_product_definition_formation(pdf); des_supp_items->add(poi); // A formation requires a security classification, with a name, // purpose and level. The security_classification_level name must // be unclassified, classified, proprietary, confidential, secret, // or top_secret. If your company uses a classification other the // above, use classified and put the actual classification in // security_classification.name. Otherwise, there are no standard // mappings and you can set name and purpose to be empty. // stp_security_classification* sc = pnew stp_security_classification(); sc->name(""); sc->purpose(""); stp_security_classification_level* scl = pnew stp_security_classification_level(); scl->name("unclassified"); sc->security_level(scl); // Now relate the security classification to the version. stp_cc_design_security_classification* ccd_sc = pnew stp_cc_design_security_classification(); ccd_sc->assigned_security_classification(sc); // Create an items list for the cc_design_security_classification. SetOfstp_classified_item* sc_items = pnew SetOfstp_classified_item(); ccd_sc->items(sc_items); // classified_item is a select that can hold a thing assigned a // classification. Then add it to the items list to complete the // relationship. stp_classified_item* citem = pnew stp_classified_item(); citem->_product_definition_formation(pdf); sc_items->add(citem); // A security classification requires a classification date. // Construct a date and time. First specify time zone in this case // we will use 5 hours 0 minutes behind GMT. stp_coordinated_universal_time_offset* tzone = pnew stp_coordinated_universal_time_offset(); tzone->hour_offset(5); tzone->minute_offset(0); tzone->sense(stp_ahead_or_behind_behind); // Now construct the local time of the security classification. // If this information is unavailable, noon is recommended. stp_local_time* time = pnew stp_local_time(); time->hour_component(12); time->minute_component(0); time->second_component(0); time->zone(tzone); // calendar_date is the recommended way to represent the date. stp_calendar_date* date = pnew stp_calendar_date(); date->year_component(1997); date->month_component(8); date->day_component(19); // Build a date and time object stp_date_and_time* dt = pnew stp_date_and_time(); dt->date_component(date); dt->time_component(time); // Relate the date and time to classification with a role of // classification_date. Note that the name field of date_time_role // is restricted to certain values and that the role restricts the // kinds of objects that can be in the items list. See the // restrict_date_time_role rule and cc_design_date_time_correlation // function in AP-203. stp_cc_design_date_and_time_assignment* class_date = pnew stp_cc_design_date_and_time_assignment(); class_date->assigned_date_and_time(dt); class_date->role(pnew stp_date_time_role("classification_date")); class_date->items(pnew SetOfstp_date_time_item()); // now add the classification stp_date_time_item* dti = pnew stp_date_time_item(); dti->_security_classification(sc); class_date->items()->add(dti); // The security classification also needs a classification_officer. // Create an assignment for this role. Make sure to reuse the person. stp_cc_design_person_and_organization_assignment* cofficer = pnew stp_cc_design_person_and_organization_assignment; cofficer->assigned_person_and_organization(pao); cofficer->role(pnew stp_person_and_organization_role("classification_officer")); SetOfstp_person_organization_item* cofficer_items = pnew SetOfstp_person_organization_item; cofficer->items(cofficer_items); // Create a new person_organization_item to refer to our classification and // add it to the items list. poi = pnew stp_person_organization_item(); poi->_security_classification(sc); cofficer_items->add(poi); // The security classification also needs an approval stp_approval* app = pnew stp_approval(); // Assign an approval level - there's no standard mapping for this // perhaps your organization has different kinds of approvals which // might be specified here. Otherwise, leave it empty. app->level("approved for release"); // assign an approval status - this is restricted to approved, // not_yet_approved, disapproved, or withdrawn by a rule in AP-203. stp_approval_status* app_stat = pnew stp_approval_status(); app_stat->name("approved"); app->status(app_stat); // Create the approval assignment entity. And initialize the items list. stp_cc_design_approval* ccd_app = pnew stp_cc_design_approval(); ccd_app->assigned_approval(app); SetOfstp_approved_item* app_items = pnew SetOfstp_approved_item(); ccd_app->items(app_items); // Create an approval_item to store the value of the select and use // the type specific accessor to populate it with the // classification. Then add the item to the approved items list. stp_approved_item* ai = pnew stp_approved_item(); ai->_security_classification(sc); app_items->add(ai); // Reuse the approval to approve the version itself. Do this by adding // another approved_item to the items list. ai = pnew stp_approved_item(); ai->_product_definition_formation(pdf); app_items->add(ai); // The approval requires an approval_person_organization instance to // identify the person responsible for approving the various items. // Again, we can reuse Tom Jones. Note that // approval_person_organization.person_organization is a select. stp_approval_person_organization* app_po = pnew stp_approval_person_organization(); stp_person_organization_select* po_select = pnew stp_person_organization_select(); po_select->_person_and_organization(pao); app_po->person_organization(po_select); app_po->authorized_approval(app); // The approval_person_organization has a role which can be used to // specify different roles in the approval process. If there is no // special role, approver is recommended. stp_approval_role* app_role = pnew stp_approval_role(); app_role->role("approver"); app_po->role(app_role); // The approval_person_organization should have a // cc_design_date_and_time_assignment to signify when the person // acted in the role specified by the approval_person_organization // on a particular date. Here we're reusing the date with the role // of sign_off_date. stp_cc_design_date_and_time_assignment* sign_off_date = pnew stp_cc_design_date_and_time_assignment(); sign_off_date->role(pnew stp_date_time_role("sign_off_date")); sign_off_date->assigned_date_and_time(dt); sign_off_date->items(pnew SetOfstp_date_time_item()); dti = pnew stp_date_time_item(); dti->_approval_person_organization(app_po); sign_off_date->items()->add(dti); // In addition to dating the approval_person_organization, the // approval itself needs to be dated. This date is the date of the // most recent activity. If there are multiple steps in the // approval process, many approval_person_organizations will exists, // each with its own date. However, this date will record the most // recent change to approval status. Note that date_time is a // select. stp_approval_date_time* app_dt = pnew stp_approval_date_time(); stp_date_time_select* dt_select = pnew stp_date_time_select(); dt_select->_date_and_time(dt); app_dt->date_time(dt_select); app_dt->dated_approval(app); //---------------------------------------------------------------------- // Now that the information for product_definition_formation is complete, // create a product definition. There should be one definition object per // version per AP used to store AP-specific data. All of the AP-203 // representation and assembly information for the part will actually // reference this instance. There is no standard mapping for the id field, // but design, analysis, digital pre-assembly, manufacturing, as built, or as // maintained are recommended. stp_product_definition* pd = pnew stp_product_definition(); pd->id("design"); pd->description("example product_definition"); // The product definition should point to the formation (version). pd->formation(pdf); // Like the product, a product_definition needs a // product_definition_context. For AP-203, the context is // design_context, whose life_cycle_stage attribute is restricted to // design. There is no standard mapping for name. stp_design_context* des_context = pnew stp_design_context(); des_context->life_cycle_stage("design"); des_context->name(""); des_context->frame_of_reference(app_context); // relate it to the product_definition pd->frame_of_reference(des_context); // The definition also needs a creator. Create a // person_organization_item for the definition and add it to the // creator's items list poi = pnew stp_person_organization_item; poi->_product_definition(pd); creator_items->add(poi); // The definition needs a creation date. Reuse the date, but we // need a new assignment entity for role "creation_date" stp_cc_design_date_and_time_assignment* creation_date = pnew stp_cc_design_date_and_time_assignment(); creation_date->role(pnew stp_date_time_role("creation_date")); creation_date->assigned_date_and_time(dt); creation_date->items(pnew SetOfstp_date_time_item()); dti = pnew stp_date_time_item(); dti->_product_definition(pd); creation_date->items()->add(dti); // The definition needs an approval. Resuse the one we have by // adding the definition to the items list. ai = pnew stp_approved_item(); ai->_product_definition(pd); app_items->add(ai); //---------------------------------------------------------------------- // Other things that might be in a 203 file: // o The ARM concept of a product model might be realized with aim entity // product_concept. Different configurations of that model are represented // with configuration_item. product_definition_formations are then // organized into a configuration using configuration design. // o Assemblies are built using subtypes of product_definition_relationship, // such as next_assembly_usage_occurrence. // o Geometry (subtypes of shape_representation) are related to the cm // information using product_definition_shape and // shape_definition_representation. // o Renumbering of vendor parts to correspond to the part number assigned // in-house using supplied_part_relationship // o Assigning specifications (entity document) to product_definition through // cc_design_specification_reference. documents can be constrained using // document_usage_constraint. // o contracts can be assigned to product_definition_formation through // cc_design_contract. Note that contracts require a contractor (person & // org.) and an approval and can have an optional contract_date. // o start/change request/order's are related to product_defintion_formation // using start_request, start_work, change_request, and change. return; }